:root {
  color-scheme: dark;
  --black: #160d0a;
  --panel: #281a16;
  --muted: #b8aaa3;
  --accent: #c97b4d;
  --paper: #fff8ef;
  --ink: #3f2e23;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: #f7f7f7; background: var(--black); font-family: "Trebuchet MS", "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
h1, h2, h3, h4, p { margin-top: 0; }

.app-shell { min-height: 100vh; padding-bottom: 7.6rem; }
.sidebar { display: none; }
.main-stage { width: min(760px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 1rem; }
.spotify-topbar { display: flex; justify-content: space-between; align-items: center; padding: max(1rem, env(safe-area-inset-top)) 0 0.85rem; }
.brand-mark { width: 3.6rem; height: 3.6rem; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #2b130b; font-size: 2rem; font-weight: 700; }
.spotify-home { display: grid; gap: 1.4rem; }
.category-tabs { display: flex; gap: 0.75rem; overflow-x: auto; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 0.72rem 1.35rem; background: #3a2722; color: #f5f5f5; font-size: 1.05rem; }
.category-tab.active { background: var(--accent); color: #2b130b; }
.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.quick-link { min-width: 0; display: flex; align-items: center; gap: 0.7rem; padding: 0; overflow: hidden; border: 0; border-radius: 0.5rem; background: #30201c; color: #f7f7f7; text-align: left; }
.quick-link strong { font-size: clamp(0.82rem, 3.9vw, 1.1rem); }
.quick-art { width: 4.2rem; height: 4.2rem; flex: 0 0 4.2rem; display: grid; place-items: center; font-size: 2.2rem; }
.heart-art { background: linear-gradient(135deg, #5b2636, #d18c5b); }
.ask-bar { width: 100%; display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.9rem; border: 0; border-radius: 999px; background: #352420; color: var(--muted); font-size: 1.05rem; text-align: left; }
.ask-orb { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 50%; background: #9b593a; color: #f6d4a9; font-size: 1.65rem; }
.ask-bar b { margin-left: auto; padding: 0.2rem 0.35rem; border-radius: 0.18rem; background: #c9c9c9; color: #111; font-size: 0.78rem; }
.mic-icon { color: #c5c5c5; font-size: 1.65rem; }
.home-section h1, .section-heading-row h2 { margin-bottom: 0; font-size: clamp(1.65rem, 7.2vw, 2.2rem); letter-spacing: -0.03em; }
.section-kicker { margin: 0.3rem 0 0.75rem; color: var(--muted); font-size: 0.95rem; }
.section-kicker span { margin-left: 0.3rem; }
.featured-book { position: relative; display: grid; grid-template-columns: 42% 1fr; min-height: 16rem; overflow: hidden; border-radius: 0.75rem; background: var(--panel); }
.featured-cover { min-width: 0; padding: 0.65rem; }
.featured-copy { padding: 1rem 0.75rem; }
.featured-copy h2 { margin: 0 1.2rem 0 0; font-size: 1.2rem; line-height: 1.15; }
.featured-copy p { margin: 0.45rem 0; color: #b1afb1; font-size: 0.95rem; }
.add-circle, .play-circle, .more-btn { border: 0; }
.add-circle { position: absolute; bottom: 1rem; left: calc(42% + 0.8rem); width: 2.7rem; height: 2.7rem; border: 2px solid #aaa; border-radius: 50%; background: transparent; color: #eee; font-size: 1.8rem; }
.play-circle { position: absolute; right: 1rem; bottom: 1rem; width: 3.5rem; height: 3.5rem; border-radius: 50%; background: #fff; color: #111; font-size: 1.25rem; }
.more-btn { position: absolute; top: 0.8rem; right: 0.7rem; background: transparent; color: #ddd; font-size: 1.8rem; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.text-btn { border: 0; background: transparent; color: var(--muted); font-weight: 700; }
.recommended-shelves { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.75rem; }
.recommendation-card { position: relative; aspect-ratio: 1; overflow: hidden; padding: 0.8rem; border: 0; border-radius: 0.55rem; color: #111; text-align: left; }
.lavender-card { background: #ce91f4; }
.coral-card { background: #ff9a73; }
.recommendation-label { position: absolute; top: 0.75rem; right: 0.75rem; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.18em; }
.recommendation-orbit { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(4rem, 18vw, 7rem); line-height: 1; }
.recommendation-card strong { position: absolute; bottom: 0.8rem; left: 0.8rem; font-size: clamp(1.5rem, 7vw, 2.3rem); line-height: 0.95; }
.book-list { margin-top: 1.25rem; }
.preview-shelf { display: grid; gap: 0.6rem; }
.preview-shelf-header { display: flex; justify-content: space-between; color: var(--muted); }
.preview-shelf-header h4 { margin: 0; color: #fff; }
.preview-scroll-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.book-cover-card { min-width: 0; cursor: pointer; }
.book-cover-art { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 0.72; overflow: hidden; border-radius: 0.55rem; background: linear-gradient(145deg, #684630, #291a14); color: #fff3e8; box-shadow: 0 5px 14px rgba(0,0,0,.2); }
.book-cover-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-cover-placeholder { max-width: 85%; padding: 0.6rem; font: 600 clamp(0.75rem, 2vw, 1rem)/1.2 Georgia, serif; text-align: center; }
.book-cover-art.has-cover .book-cover-placeholder { display: none; }
.book-cover-title { display: block; margin-top: 0.45rem; color: #fff8ef; font-size: 0.9rem; line-height: 1.2; }
.book-cover-author { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.8rem; line-height: 1.25; }
.featured-cover .book-cover-art { height: 100%; }
.featured-cover .book-cover-placeholder { font-size: clamp(1rem, 2.2vw, 1.5rem); }
.legacy-panel, .overview-stats { display: none; }
.now-reading { position: fixed; z-index: 5; right: max(0.95rem, calc((100vw - 760px) / 2 + 0.95rem)); bottom: 4.75rem; left: max(0.95rem, calc((100vw - 760px) / 2 + 0.95rem)); display: grid; grid-template-columns: 2.7rem 1fr auto auto auto; gap: 0.7rem; align-items: center; padding: 0.55rem; border-radius: 0.75rem; background: #7d2807; box-shadow: 0 8px 18px rgba(0,0,0,.35); }
.mini-cover { width: 2.7rem; height: 2.7rem; overflow: hidden; border-radius: 0.3rem; }
.mini-cover .book-cover-art { height: 100%; border-radius: 0.3rem; }
.mini-cover .book-cover-placeholder { padding: 0.1rem; font-size: 0.45rem; }
.now-reading strong, .now-reading span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-reading strong { font-size: 0.98rem; }
.now-reading span { margin-top: 0.15rem; color: #d6bcb2; font-size: 0.85rem; }
.now-reading button { border: 0; background: transparent; color: #fff; font-size: 1.4rem; }
.mobile-nav { position: fixed; z-index: 4; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: 0.6rem 0 max(0.7rem, env(safe-area-inset-bottom)); background: rgba(22,11,8,.98); }
.mobile-nav-item { display: grid; gap: 0.2rem; justify-items: center; border: 0; background: transparent; color: var(--muted); font-size: 0.75rem; }
.mobile-nav-item span { font-size: 1.8rem; line-height: 1; }
.mobile-nav-item.active { color: #fff; }

.dialog-overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 1rem; background: rgba(24,12,8,.72); }
.drawer-overlay { justify-content: end; align-items: stretch; padding: 0; }
.dialog-card { width: min(560px, 100%); max-height: 95vh; overflow: auto; padding: 1rem; border-radius: 1rem; background: var(--paper); color: var(--ink); }
.drawer-card { height: 100%; border-radius: 1rem 0 0 1rem; }
.dialog-head, .panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.dialog-head { margin-bottom: 0.75rem; }
.icon-btn { border: 0; border-radius: 999px; padding: 0.55rem 0.8rem; background: rgba(139,94,60,.1); }
.book-form { display: grid; gap: 0.75rem; }
.book-form label { display: grid; gap: 0.35rem; }
.book-form input, .book-form textarea, .book-form select { padding: 0.78rem 0.9rem; border: 1px solid rgba(139,94,60,.18); border-radius: 0.75rem; background: #fff; color: var(--ink); }
.field-hint { color: rgba(63,46,35,.74); font-size: 0.85rem; }
.form-actions { display: flex; justify-content: end; margin-top: 0.25rem; }
.action-btn, .secondary-btn { padding: 0.75rem 1rem; border: 0; border-radius: 999px; }
.action-btn { background: #7a4a2d; color: #fff; }
.secondary-btn { background: #eadcc8; color: var(--ink); }
.google-auth-options { display: grid; gap: 0.65rem; margin: 0.75rem 0; }
.google-auth-btn { width: 100%; padding: 0.75rem 1rem; border: 1px solid rgba(63,46,35,.2); border-radius: 0.65rem; background: #fff; color: var(--ink); font: inherit; font-weight: 600; }
.google-auth-btn:disabled { opacity: 0.65; }
.auth-divider { display: flex; align-items: center; gap: 0.65rem; margin: 0; color: var(--muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { flex: 1; height: 1px; background: rgba(63,46,35,.16); content: ""; }
.scan-zone { padding: 0.8rem; border: 1px solid rgba(139,94,60,.16); border-radius: 1rem; }
.lookup-panel { display: grid; gap: 0.6rem; margin-top: 0.65rem; }
.book-dialog-card { width: min(960px, 100%); }
.lookup-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; max-height: 54vh; overflow-y: auto; padding: 0.1rem; }
.lookup-result { min-width: 0; display: grid; grid-template-rows: auto 1fr; gap: 0.5rem; padding: 0.55rem; border: 1px solid rgba(139,94,60,.18); border-radius: 0.7rem; background: #fff; color: var(--ink); text-align: left; }
.lookup-result[aria-pressed="true"] { border-color: #7a4a2d; box-shadow: 0 0 0 2px rgba(122,74,45,.2); }
.lookup-results .book-cover-art { aspect-ratio: 0.72; }
.lookup-result-copy { min-width: 0; display: grid; align-content: start; gap: 0.25rem; }
.lookup-result-copy strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 0.95rem; line-height: 1.2; }
.lookup-result-copy span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: rgba(63,46,35,.74); font-size: 0.78rem; line-height: 1.25; }
.selected-book-confirmation { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 0.8rem; align-items: center; padding: 0.75rem; border: 1px solid rgba(139,94,60,.25); border-radius: 0.75rem; background: #fff; }
.selected-book-confirmation > .book-cover-art { grid-row: span 2; width: 4.5rem; }
.selected-book-confirmation p { margin: 0; color: rgba(63,46,35,.74); font-size: 0.85rem; }
.selected-book-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.book-profile-layout { display: grid; grid-template-columns: minmax(6rem, 0.7fr) minmax(0, 1.3fr); gap: 1rem; align-items: start; }
.profile-book-cover { position: sticky; top: 0; }
.book-profile-details { display: grid; gap: 0.7rem; }
.profile-field { display: grid; gap: 0.15rem; }
.profile-field strong { font-size: 0.8rem; }
.profile-field span { overflow-wrap: anywhere; }
.scan-actions { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
#scannerVideo { width: 100%; margin-top: 0.75rem; border-radius: 0.75rem; background: #1f130d; }
.scan-status { margin: 0.6rem 0 0; color: rgba(63,46,35,.74); }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 20; padding: 0.7rem 0.95rem; border-radius: 999px; background: #30251f; color: #fff; }
@media (max-width: 380px) { .featured-book { min-height: 14rem; } .featured-copy h2 { font-size: 1.05rem; } .now-reading { gap: 0.35rem; } .now-reading button { font-size: 1.15rem; } }

@media (min-width: 620px) {
  .lookup-results { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
}

@media (min-width: 900px) {
  body {
    background: radial-gradient(circle at 78% 0%, #5a3324 0%, #291712 34%, #160d0a 76%);
  }

  .app-shell {
    display: grid;
    grid-template-columns: minmax(220px, 17vw) minmax(0, 1fr);
    gap: 0.3rem;
    padding: 0.3rem;
  }

  .sidebar {
    display: flex;
    min-height: calc(100vh - 0.6rem);
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid rgba(245, 221, 201, 0.12);
    border-radius: 0.65rem;
    background: rgba(31, 17, 13, 0.82);
    box-shadow: 0 24px 60px rgba(12, 5, 3, 0.28);
  }

  .sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(245, 221, 201, 0.1);
  }

  .sidebar .brand-mark { width: 2.9rem; height: 2.9rem; font-size: 1.6rem; }
  .sidebar .eyebrow { margin: 0 0 0.15rem; color: #c29b82; font-size: 0.65rem; letter-spacing: 0.16em; }
  .sidebar h2 { font-size: 1.4rem; }
  .sidebar-nav { display: grid; gap: 0.35rem; }
  .nav-pill { padding: 0.8rem 0.9rem; border: 0; border-radius: 0.6rem; background: transparent; color: #bca9a0; text-align: left; }
  .nav-pill:hover, .nav-pill.active { background: #43271e; color: #fff; }
  .sidebar-card { margin-top: auto; padding: 1rem; border-radius: 0.85rem; background: linear-gradient(145deg, #6d3820, #3c2018); }
  .sidebar-card p { margin-bottom: 0.8rem; color: #f4dfd1; line-height: 1.45; }
  .sidebar-card .action-btn { width: 100%; background: #d48b59; color: #25120d; }

  .main-stage { width: 100%; min-width: 0; margin: 0; padding: 0 clamp(1.25rem, 4vw, 3.5rem); }
  .spotify-topbar { padding: 1rem 0 1.25rem; }
  .compact-mark { display: none; }
  .spotify-topbar::before { content: "Your library"; color: #f8ede6; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
  .spotify-home { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.75rem 1.25rem; align-items: start; }
  .category-tabs, .quick-links, .ask-bar { grid-column: 1 / -1; }
  .category-tabs { gap: 0.55rem; }
  .category-tab { padding: 0.62rem 1.15rem; font-size: 0.92rem; background: #402a23; }
  .quick-links { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .quick-link { min-height: 4.4rem; }
  .quick-art { width: 4.4rem; height: 4.4rem; flex-basis: 4.4rem; }
  .ask-bar { width: 100%; justify-self: start; padding: 0.85rem 1rem; }
  .buzz-section { grid-column: 1 / span 7; }
  .recommendation-section { grid-column: 8 / -1; }
  .home-section h1, .section-heading-row h2 { font-size: 1.8rem; }
  .featured-book { min-height: 17rem; grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr); }
  .featured-cover { font-size: 1.5rem; }
  .featured-copy { padding: 1.35rem 1rem; }
  .featured-copy h2 { font-size: 1.45rem; }
  .recommended-shelves { grid-template-columns: repeat(auto-fill, minmax(8rem, 10rem)); gap: 0.75rem; }
  .recommendation-card strong { font-size: 1.5rem; }
  .book-list { padding-top: 0.5rem; }
  .preview-scroll-row { grid-auto-columns: 8rem; grid-auto-flow: column; grid-template-columns: none; gap: 0.75rem; overflow-x: auto; padding-bottom: 0.35rem; scrollbar-width: thin; }
  .legacy-panel { display: block; grid-column: 1 / -1; padding: 1.25rem; border: 1px solid rgba(245,221,201,.1); border-radius: 1rem; background: rgba(42,24,18,.8); }
  .legacy-panel .panel-heading { margin-bottom: 1rem; color: #f7e6dc; }
  .shelf-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
  .shelf-item { padding: 0.85rem; border-radius: 0.7rem; background: #39241d; color: #f5e3d8; }
  .shelf-item span { color: #bca69b; }
  .now-reading, .mobile-nav { display: none; }
}
