/* Folio — mobile-first reading tracker
   Light/dark follows prefers-color-scheme. Designed at ~390px, scales up. */

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/figtree-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 500 600;
  font-display: swap;
  src: url("../fonts/fraunces-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 500 600;
  font-display: swap;
  src: url("../fonts/fraunces-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("../fonts/fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("../fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;
  --bg: #f4efe6;
  --bg-recessed: #ece5d8;
  --surface: #fffcf6;
  --surface-2: #f8f2e8;
  --ink: #1b1713;
  --ink-muted: #6c6358;
  --ink-faint: #8a8074;
  --line: #e4dccf;
  --line-strong: #d4cbb8;
  --accent: #b84a2a;
  --accent-hover: #9c3c21;
  --accent-soft: #f6e4da;
  --accent-ink: #8a3018;
  --success: #2f6b4a;
  --success-soft: #dcecdc;
  --gold: #b8891f;
  --gold-soft: #f4e8c8;
  --danger: #9b2c2c;
  --danger-soft: #f8e2e0;
  --shadow: 0 1px 2px rgba(28, 22, 16, 0.05), 0 8px 24px rgba(28, 22, 16, 0.06);
  --shadow-sheet: 0 -8px 40px rgba(28, 22, 16, 0.16);
  --font-sans: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;
  --pad: 20px;
  --tabbar-h: 64px;
  --topbar-h: 60px;
  --content: 720px;
  --brand-page: #f4efe6;
  --brand-spine: #e8d9c8;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110e;
    --bg-recessed: #0e0c0a;
    --surface: #1e1a16;
    --surface-2: #26211c;
    --ink: #f3ece3;
    --ink-muted: #b0a59a;
    --ink-faint: #8a8076;
    --line: #322c26;
    --line-strong: #443c34;
    --accent: #e07a55;
    --accent-hover: #f08a66;
    --accent-soft: #3a241c;
    --accent-ink: #f3c2b0;
    --success: #7cb392;
    --success-soft: #1c2e24;
    --gold: #e0c56e;
    --gold-soft: #3a3118;
    --danger: #e08080;
    --danger-soft: #3a1c1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.28);
    --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.45);
    --brand-page: #2a241e;
    --brand-spine: #3a322a;
  }
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
}

html {
  height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img,
svg {
  max-width: 100%;
  display: block;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
  overflow-wrap: break-word;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 80;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  margin: 16px;
  padding: 12px 16px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
}

/* ----- App shell ----- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 8px var(--pad);
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  color: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}

.topbar-actions {
  position: relative;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--ink);
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--surface-2);
}

.icon-btn:focus-visible,
.shelf-tab:focus-visible,
.tabbar-item:focus-visible,
.tabbar-add:focus-visible,
.btn:focus-visible,
.star-btn:focus-visible,
.menu button:focus-visible,
.book-card:focus-visible,
.search-input:focus-visible,
.field-control:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
}

.menu button:hover,
.menu button:focus-visible {
  background: var(--accent-soft);
}

.main {
  flex: 1;
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 var(--pad) calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
}

.view[hidden] {
  display: none;
}

/* ----- Search & shelves ----- */

.search-wrap {
  position: relative;
  margin: 4px 0 16px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px 10px 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 16px;
  appearance: none;
}

.search-input::placeholder {
  color: var(--ink-faint);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  outline: none;
}

.shelves {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--bg-recessed);
  border-radius: 14px;
}

.shelf-tab {
  flex: 1;
  min-height: 40px;
  padding: 8px 6px;
  border-radius: 11px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-muted);
  white-space: nowrap;
  text-align: center;
}

.shelf-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 22, 16, 0.08);
}

/* ----- Book list ----- */

.book-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  min-height: var(--tap);
}

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

.book-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.book-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.book-author {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.chip-example {
  background: var(--gold-soft);
  color: var(--gold);
}

.stars {
  display: inline-flex;
  gap: 1px;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.progress {
  --pct: 0%;
  height: 8px;
  margin-top: 8px;
  background: var(--bg-recessed);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: var(--pct);
  background: var(--accent);
  border-radius: inherit;
}

/* Typographic / image covers */

.cover {
  position: relative;
  width: 72px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(28, 22, 16, 0.18);
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-fallback {
  width: 100%;
  height: 100%;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 7px, transparent 7px),
    var(--cover-bg, #3f2e27);
  color: var(--cover-fg, #f3e6d4);
}

.cover-fallback .cover-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.7rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-fallback .cover-author {
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover.lg,
.cover.lg .cover-fallback {
  width: 112px;
}

.cover.lg .cover-fallback .cover-title {
  font-size: 0.95rem;
}

/* Empty state */

.empty {
  text-align: center;
  padding: 48px 16px 32px;
  color: var(--ink-muted);
}

.empty h2 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 8px;
}

.empty p {
  max-width: 28ch;
  margin: 0 auto 20px;
}

/* ----- Bottom nav ----- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
  min-height: var(--tabbar-h);
  padding: 6px 24px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}

.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tap);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ink-faint);
  border-radius: 12px;
}

.tabbar-item.is-active {
  color: var(--accent);
}

.tabbar-add {
  width: 56px;
  height: 56px;
  margin-top: -18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent);
}

.tabbar-add:hover,
.tabbar-add:focus-visible {
  background: var(--accent-hover);
}

/* ----- Stats ----- */

.stats-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
  padding: 20px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.ring-wrap {
  position: relative;
  width: 132px;
  height: 132px;
}

.ring-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--bg-recessed);
  stroke-width: 10;
}

.ring-value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 0 999;
  transition: stroke-dasharray 0.6s var(--ease);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.ring-label strong {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1;
}

.ring-label span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-top: 2px;
}

.stats-copy h2 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}

.stats-copy p {
  color: var(--ink-muted);
  margin: 4px 0 12px;
  font-size: 0.9rem;
}

.goal-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.goal-edit input {
  width: 64px;
  min-height: 40px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 600;
  font-size: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.stat-card .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-top: 4px;
}

.finished-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finished-list h3 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.finished-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
}

.finished-row .who {
  min-width: 0;
}

.finished-row .who strong,
.finished-row .who span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finished-row .who span {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ----- Buttons & forms ----- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--bg-recessed);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-row .btn {
  flex: 1;
  min-width: 120px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.field .label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.field-control,
textarea.field-control {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
}

textarea.field-control {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
}

.field-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  outline: none;
}

.field-error {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
}

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-recessed);
  border-radius: 12px;
}

.seg label {
  flex: 1;
  min-height: 40px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  border-radius: 9px;
  cursor: pointer;
  padding: 6px 4px;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg label:has(input:checked) {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 22, 16, 0.08);
}

.seg label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ----- Sheet / dialog ----- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.sheet[hidden] {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.45);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(92dvh, 920px);
  overflow: auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 8px var(--pad) calc(20px + env(safe-area-inset-bottom, 0px));
  overscroll-behavior: contain;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 8px auto 12px;
  border-radius: 999px;
  background: var(--line-strong);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-head h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sheet-sub {
  color: var(--ink-muted);
  margin-top: 2px;
}

.detail-layout {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-layout .meta {
  min-width: 0;
  flex: 1;
}

.page-log {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 16px;
}

.page-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.page-log input[type="number"] {
  width: 88px;
  min-height: 44px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 600;
  font-size: 16px;
}

.page-log input[type="range"] {
  width: 100%;
  height: 44px;
  accent-color: var(--accent);
}

.percent {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.1rem;
}

.star-row {
  display: flex;
  gap: 4px;
}

.star-btn {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 1.35rem;
  color: var(--line-strong);
}

.star-btn.is-on {
  color: var(--gold);
}

.star-btn:hover,
.star-btn:focus-visible {
  background: var(--gold-soft);
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.toast[hidden] {
  display: none;
}

/* ----- Desktop / tablet ----- */

@media (min-width: 720px) {
  .book-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .book-card {
    grid-template-columns: 80px 1fr;
  }

  .cover {
    width: 80px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 900px) {
  :root {
    --content: 1080px;
  }

  .app {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    padding: 0;
    min-height: 100dvh;
  }

  .topbar {
    grid-column: 2;
    position: absolute;
    top: 28px;
    right: 32px;
    left: auto;
    z-index: 20;
    min-height: var(--tap);
    padding: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .search-wrap {
    padding-right: 52px;
  }

  .main {
    grid-column: 2;
    max-width: none;
    padding: 8px 32px 40px;
  }

  .tabbar {
    position: relative;
    grid-column: 1;
    grid-row: 1 / span 2;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    height: auto;
    min-height: 100%;
    align-self: stretch;
    width: 220px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 28px 16px 24px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--surface);
    backdrop-filter: none;
  }

  .tabbar::before {
    content: "Folio";
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    padding: 0 12px 4px;
  }

  .tabbar::after {
    content: "Iva's reading tracker";
    font-size: 0.75rem;
    color: var(--ink-muted);
    padding: 0 12px 28px;
  }

  .tabbar::before {
    order: 0;
  }

  .tabbar::after {
    order: 1;
    padding: 0 12px 24px;
  }

  .tabbar-item[data-nav="library"] {
    order: 2;
  }

  .tabbar-item[data-nav="stats"] {
    order: 3;
  }

  .tabbar-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 12px;
    font-size: 0.95rem;
    min-height: 48px;
  }

  .tabbar-add {
    width: auto;
    height: 48px;
    margin: 8px 0 0;
    border-radius: 14px;
    order: 4;
    margin-top: 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .tabbar-add::after {
    content: "Add a book";
    font-size: 0.95rem;
    font-weight: 600;
  }

  .tabbar-add svg {
    width: 18px;
    height: 18px;
  }

  .topbar .brand {
    display: none;
  }

  .sheet-panel {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(480px, calc(100vw - 48px));
    max-height: min(86dvh, 800px);
    transform: translate(-50%, -50%);
    border-radius: 20px;
    padding: 20px 24px 24px;
  }

  .sheet-handle {
    display: none;
  }

  .book-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .book-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 12px 0 0;
}

button,
a,
input,
textarea,
select,
.shelf-tab,
.tabbar-item,
.tabbar-add {
  touch-action: manipulation;
}
