/* =========================================================================
   Amazing Grace Reader - design tokens
   Locked tokens. Every color and font-family below is referenced via var()
   in the rest of the stylesheet. No mid-render improvisation.
   ========================================================================= */

:root {
  /* Color tokens (oklch for stable, perceptually uniform mix) */
  --color-bg:           oklch(97% 0.012 75);     /* warm off-white, paper */
  --color-bg-elev:      oklch(99% 0.008 75);     /* cards, topbar */
  --color-bg-sunk:      oklch(94% 0.018 75);     /* dropped/hover surfaces */
  --color-fg:           oklch(22% 0.018 50);     /* ink */
  --color-fg-muted:     oklch(48% 0.014 60);     /* secondary text */
  --color-fg-subtle:    oklch(62% 0.012 65);     /* labels, hints */
  --color-line:         oklch(89% 0.014 70);     /* hairline borders */
  --color-line-strong:  oklch(82% 0.016 65);     /* focused borders */

  --color-accent:       oklch(48% 0.13 40);      /* rust/terracotta */
  --color-accent-hover: oklch(42% 0.13 40);
  --color-accent-soft:  oklch(94% 0.04 50);      /* accent wash, used for hover bg */
  --color-accent-fg:    oklch(98% 0.005 75);

  --color-ok:           oklch(50% 0.12 145);
  --color-err:          oklch(50% 0.18 25);

  /* Type tokens */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    ui-monospace, "SFMono-Regular", "JetBrains Mono", Consolas, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;

  --leading-tight: 1.2;
  --leading-snug:  1.35;
  --leading-body:  1.55;

  /* Spacing scale (4-pt) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.75rem;
  --space-8: 3.5rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Shadow (subtle, not soft-floating) */
  --shadow-1: 0 1px 0 oklch(0% 0 0 / 0.04);
  --shadow-2: 0 1px 2px oklch(0% 0 0 / 0.04), 0 2px 8px oklch(0% 0 0 / 0.04);
  --shadow-focus: 0 0 0 3px oklch(48% 0.13 40 / 0.25);

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
}

/* =========================================================================
   Reset & base
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

/* The HTML [hidden] attribute relies on `display: none`. Several .btn and
   .field rules set display: inline-flex / block which would otherwise
   override it. Re-assert hidden wins. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  top: -100px; left: var(--space-3);
  background: var(--color-fg);
  color: var(--color-bg-elev);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus { top: var(--space-3); }

/* =========================================================================
   Topbar
   ========================================================================= */

.topbar {
  background: var(--color-bg-elev);
  border-bottom: 1px solid var(--color-line);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-accent-fg);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  font-style: normal;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-1);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xl);
  font-style: normal;
  letter-spacing: -0.01em;
  color: var(--color-fg);
}

.brand-tagline {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
  line-height: 1.3;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-fg-subtle);
  flex: 0 0 auto;
}

.status-pill[data-state="ok"]::before { background: var(--color-ok); }
.status-pill[data-state="err"]::before { background: var(--color-err); }
.status-pill[data-state="busy"]::before {
  background: var(--color-accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* =========================================================================
   Layout
   ========================================================================= */

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-5);
  /* The outer layout is a single-column block; each screen (auth,
     library, reader) manages its own internal grid via .screen-grid. */
  display: block;
}

.col { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }

/* =========================================================================
   Card primitive
   ========================================================================= */

.card {
  background: var(--color-bg-elev);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.card-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xs);
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-fg-subtle);
  margin-bottom: var(--space-4);
}

/* =========================================================================
   Fields (label + control)
   ========================================================================= */

.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field:last-child { margin-bottom: 0; }

.field-hint {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-fg-muted);
}

.field-control {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-bg-elev);
  color: var(--color-fg);
  font: inherit;
  line-height: 1.4;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.field-control:hover:not(:disabled) { border-color: var(--color-line-strong); }

.field-control:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

.field-control:disabled { opacity: 0.5; cursor: not-allowed; }

.input-with-action {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.input-with-action .field-control { flex: 1 1 auto; min-width: 0; }
.input-with-action .select-wrap-grow { flex: 1 1 auto; }

/* Custom select wrap - keeps arrow consistent across browsers */
.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--space-3);
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--color-fg-subtle);
  border-bottom: 1.5px solid var(--color-fg-subtle);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-6);
  cursor: pointer;
}

/* Speed slider */
.field-slider {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}

.field-slider input[type="range"] {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--color-line);
  border-radius: var(--radius-pill);
  outline: none;
}

.field-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-bg-elev);
  box-shadow: 0 0 0 1px var(--color-line-strong);
  transition: transform var(--dur-fast) var(--ease-out);
}
.field-slider input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
.field-slider input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--shadow-focus); }

.field-slider input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-bg-elev);
  box-shadow: 0 0 0 1px var(--color-line-strong);
}

.speed-readout {
  min-width: 56px;
  text-align: right;
}

.speed-value {
  font-family: var(--font-display);
  font-feature-settings: "tnum" 1;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-fg);
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-bg-elev);
  color: var(--color-fg);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.btn:hover:not(:disabled) {
  background: var(--color-bg-sunk);
  border-color: var(--color-line-strong);
}

.btn:active:not(:disabled) { transform: translateY(0.5px); }

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--color-accent);
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--color-fg-muted);
}

.btn-icon {
  padding: var(--space-2) var(--space-3);
  min-width: 38px;
}

.btn-play {
  background: var(--color-accent);
  color: var(--color-accent-fg);
  border-color: var(--color-accent);
  padding-left: var(--space-4);
  padding-right: var(--space-5);
  min-width: 110px;
}
.btn-play:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Link-style button (inside drop zone) */
.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font: inherit;
}
.link:hover { color: var(--color-accent-hover); }
.link:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 2px; }

/* =========================================================================
   Drop zone
   ========================================================================= */

.drop {
  border: 1.5px dashed var(--color-line-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-sunk);
  padding: var(--space-7) var(--space-5);
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
  text-align: center;
}

.drop:hover, .drop:focus-visible, .drop.dragover {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  outline: none;
}

.drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-fg-muted);
  margin-bottom: var(--space-3);
}

.drop:hover .drop-icon, .drop.dragover .drop-icon, .drop:focus-visible .drop-icon {
  color: var(--color-accent);
}

.drop-headline {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  font-style: normal;
  color: var(--color-fg);
  margin-bottom: var(--space-2);
}

.drop-sub {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
}

.drop-sub .dot { margin: 0 var(--space-2); color: var(--color-fg-subtle); }

/* =========================================================================
   Now reading
   ========================================================================= */

.now-reading {
  padding: var(--space-5) 0 var(--space-4);
  border-top: 1px solid var(--color-line);
  border-bottom: 1px solid var(--color-line);
}

.nr-eyebrow {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-fg-subtle);
  margin-bottom: var(--space-2);
}

.nr-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-2xl);
  font-style: normal;
  line-height: var(--leading-tight);
  color: var(--color-fg);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-3);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.nr-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
}

.nr-chapter {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
}

.nr-chapter-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-xs);
  color: var(--color-fg-subtle);
}

.nr-chapter-input {
  width: 3.5rem;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-bg-elev);
  color: var(--color-fg);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.nr-chapter-input:hover:not(:disabled) { border-color: var(--color-line-strong); }
.nr-chapter-input:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}
.nr-chapter-input:disabled { opacity: 0.4; }

.nr-chapter-sep, .nr-chapter-total {
  color: var(--color-fg-subtle);
  font-variant-numeric: tabular-nums;
}

/* Print-page badge - a proper badge, not a tiny pill */
.nr-print {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border: 1px solid oklch(48% 0.13 40 / 0.18);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.nr-print::before {
  content: "";
  width: 4px; height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  flex: 0 0 auto;
}

/* =========================================================================
   Transport
   ========================================================================= */

.transport {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: center;
  padding: var(--space-2) 0;
}

.btn-transport {
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--color-fg);
}

.btn-transport svg { display: block; }

/* =========================================================================
   Extracted text
   ========================================================================= */

.text details {
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-bg-elev);
  overflow: hidden;
}

.text details > summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-fg-muted);
  user-select: none;
}
.text details > summary::-webkit-details-marker { display: none; }
.text details > summary::after {
  content: "+";
  float: right;
  font-family: var(--font-display);
  color: var(--color-fg-subtle);
  font-size: var(--text-lg);
  line-height: 1;
}
.text details[open] > summary::after { content: "\2212"; }

.text pre {
  margin: 0;
  padding: var(--space-4);
  background: var(--color-bg-sunk);
  border-top: 1px solid var(--color-line);
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--color-fg);
}

/* =========================================================================
   Footer
   ========================================================================= */

.foot {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) var(--space-7);
  color: var(--color-fg-subtle);
  font-size: var(--text-sm);
  text-align: center;
}

.foot a { color: var(--color-fg-muted); text-decoration: underline; text-underline-offset: 2px; }
.foot a:hover { color: var(--color-accent); }

/* =========================================================================
   Responsive - verified at 320 / 375 / 414 / 768
   ========================================================================= */

@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .col-settings { order: 2; }
  .col-main { order: 1; }
}

@media (max-width: 600px) {
  .topbar-inner {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-3);
  }
  .brand-tagline { display: none; }
  .status-pill { max-width: 100%; }
  .layout { padding: var(--space-4); gap: var(--space-4); }
  .col { gap: var(--space-4); }
  .card { padding: var(--space-4); }
  .drop { padding: var(--space-6) var(--space-4); }
  .drop-headline { font-size: var(--text-lg); }
  .nr-title { font-size: var(--text-xl); }
  .foot { padding: var(--space-4) var(--space-4) var(--space-6); }
}

@media (max-width: 360px) {
  .brand-mark { width: 32px; height: 32px; font-size: 1.1rem; }
  .brand-name { font-size: var(--text-lg); }
  .btn-play { min-width: 96px; }
  .btn-transport { width: 38px; height: 38px; }
}

/* =========================================================================
   Screens - one visible at a time (auth | library | reader)
   ========================================================================= */

.screen { width: 100%; }
.screen[hidden] { display: none !important; }
.screen-grid { display: grid; grid-template-columns: 280px 1fr; gap: var(--space-5); }

/* =========================================================================
   Auth screen
   ========================================================================= */

.auth-card {
  max-width: 420px;
  margin: var(--space-6) auto var(--space-7);
  padding: var(--space-6);
  background: var(--color-bg-elev);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.auth-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-2xl);
  font-style: normal;
  color: var(--color-fg);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-2);
}

.auth-sub {
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.auth-tabs {
  display: inline-flex;
  background: var(--color-bg-sunk);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-5);
}

.auth-tab {
  background: transparent;
  border: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-fg-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.auth-tab:hover { color: var(--color-fg); }
.auth-tab-active {
  background: var(--color-bg-elev);
  color: var(--color-fg);
  box-shadow: var(--shadow-1);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.auth-error {
  background: oklch(94% 0.04 25);
  border: 1px solid oklch(85% 0.06 25);
  color: var(--color-err);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  font-size: var(--text-base);
}

.auth-hint {
  font-size: var(--text-xs);
  color: var(--color-fg-subtle);
  margin-top: var(--space-4);
  text-align: center;
  line-height: 1.5;
}

.auth-hint code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 1px 5px;
  background: var(--color-bg-sunk);
  border-radius: 3px;
}

/* =========================================================================
   Library screen
   ========================================================================= */

.library-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.library-eyebrow {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-fg-subtle);
  margin-bottom: var(--space-2);
}

.library-greeting {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-2xl);
  font-style: normal;
  color: var(--color-fg);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.library-actions { display: flex; gap: var(--space-2); }

.drop-library {
  padding: var(--space-6) var(--space-5);
}

.book-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
}

.book-card {
  display: grid;
  grid-template-columns: 1fr auto;
  background: var(--color-bg-elev);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.book-card:hover {
  border-color: var(--color-line-strong);
  background: var(--color-bg-elev);
}

.book-card-open {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  min-width: 0;
}

.book-card-open:focus-visible {
  outline: none;
  background: var(--color-accent-soft);
}

.book-card-mark {
  display: grid;
  place-items: center;
  width: 44px; height: 56px;
  background: var(--color-accent);
  color: var(--color-accent-fg);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  font-style: normal;
  letter-spacing: 0.05em;
}

.book-card-body { min-width: 0; padding: var(--space-1) 0; }
.book-card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-base);
  font-style: normal;
  color: var(--color-fg);
  line-height: 1.3;
  margin: 0 0 var(--space-1);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.book-card-author {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
  margin: 0 0 var(--space-1);
}
.book-card-meta {
  font-size: var(--text-xs);
  color: var(--color-fg-subtle);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.book-card-del {
  border: 0;
  background: transparent;
  color: var(--color-fg-subtle);
  cursor: pointer;
  padding: var(--space-3);
  transition: color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
.book-card-del:hover { color: var(--color-err); background: oklch(94% 0.04 25); }
.book-card-del:focus-visible { outline: none; color: var(--color-err); }

/* ----- Visibility toggle on each book card ----- */
.book-card-share {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-fg-muted);
  border-radius: 999px;
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  white-space: nowrap;
}
.book-card-share:hover {
  color: var(--color-fg);
  border-color: var(--color-border-strong, var(--color-fg-muted));
}
.book-card-share:focus-visible {
  outline: none;
  border-color: var(--color-fg);
  color: var(--color-fg);
}
/* Public state: warm gold accent that matches the brand */
.book-card-share[aria-pressed="true"] {
  color: var(--color-accent, #b07a2a);
  border-color: var(--color-accent, #b07a2a);
  background: oklch(96% 0.04 75);
}
.book-card-share[aria-pressed="true"]:hover {
  background: oklch(92% 0.06 75);
}
/* Swap which lock icon is shown */
.book-card-share .book-card-share-icon-public { display: none; }
.book-card-share[aria-pressed="true"] .book-card-share-icon-private { display: none; }
.book-card-share[aria-pressed="true"] .book-card-share-icon-public { display: inline-block; }

/* ----- Public-library meta line ("shared by @username") ----- */
.book-card-sharedby {
  font-weight: 600;
  color: var(--color-fg);
}

/* ----- Library footer (Browse public library link) ----- */
.library-foot {
  margin-top: var(--space-5);
  display: flex;
  justify-content: center;
}

.library-empty {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--color-fg-muted);
}
.library-empty p { margin: 0; }
.library-empty p + p { margin-top: var(--space-2); }
.library-empty .muted { color: var(--color-fg-subtle); font-size: var(--text-sm); }

.btn-small { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }

.btn-back {
  margin-top: var(--space-3);
  align-self: flex-start;
}

/* Library on the auth screen uses the same hidden attribute */
#authScreen[hidden],
#libraryScreen[hidden],
#readerScreen[hidden] { display: none !important; }

@media (max-width: 880px) {
  .screen-grid {
    grid-template-columns: 1fr;
  }
  .screen-grid .col-settings { order: 2; }
  .screen-grid .col-main { order: 1; }
}

@media (max-width: 600px) {
  .auth-card {
    margin: var(--space-4) auto;
    padding: var(--space-5);
  }
  .library-head { flex-direction: column; align-items: stretch; }
  .library-actions { justify-content: flex-end; }
  .book-grid { grid-template-columns: 1fr; }
  .drop-library { padding: var(--space-5) var(--space-4); }
}
