/* Theme.kt (tablet default: Airy) and the screen-specific Compose palettes. */
:root {
  color-scheme:light;
  --app-surface:#fff; --app-surface2:#f0f1f7; --app-bg:#f8f9fc; --app-line:#e7e9f0;
  --app-ink:#1b1e2b; --app-muted:#5f6475; --app-subtle:#9a9fae; --app-accent:#5458dd;
  --app-on-accent:#fff; --app-selected:#e9eafb; --app-paper:#fff;
}

:root:where([data-tone="dark"]) {
    --app-surface:#1c1d26; --app-surface2:#23242e; --app-bg:#15161d; --app-line:#2c2e3a;
    --app-ink:#ecedf3; --app-muted:#a9acba; --app-subtle:#707384; --app-accent:#9396ff;
    --app-on-accent:#14152c; --app-selected:#2b2d48; --app-paper:#f6f7f5;
  }


/* LibraryScreen.kt overlays the shell palette, while SidebarArt.kt supplies separate drawer colors. */
:root[data-section=shelf] {
  color-scheme:light dark;
  --ground:#fcf7ed; --side:#f7eddd; --surface:#fffcf7; --edge:#e8dac4; --strong:#f6e4c7;
  --ink:var(--app-ink); --muted:var(--app-muted); --accent:var(--app-accent);
  --subtle:var(--muted); --on-accent:var(--surface);
  --jacket:var(--surface); --jacket-ink:var(--ink); --hero-body:var(--jacket-ink);
  --hero-button:var(--strong); --hero-button-ink:var(--ink); --hero-button-frame:var(--accent);
  --veil:34%; --compact-veil:78%;
}
:root[data-theme=classic] {
  --subtle:var(--app-subtle); --on-accent:var(--app-on-accent); --hero-body:var(--muted);
  --hero-button:#f3d8ad; --hero-button-ink:#51473d; --hero-button-frame:#916331;
}
.library .hero { isolation:isolate; }
.library .hero[style*="background-image"]::before {
  content:""; position:absolute; inset:0; z-index:-1; border-radius:inherit; pointer-events:none;
  --jacket-veil:color-mix(in srgb,var(--jacket) var(--veil),transparent);
  background:linear-gradient(90deg,var(--jacket-veil) 40%,transparent 72%);
}
@container (max-width:559.98px) {
  .library .hero[style*="background-image"]::before {
    --jacket-veil:color-mix(in srgb,var(--jacket) var(--compact-veil),transparent);
    background:linear-gradient(90deg,var(--jacket-veil) 53%,transparent);
  }
}
.library .hero p,.library .hero [data-hero=motion] { color:var(--hero-body); }
.library .hero .primary {
  color:var(--hero-button-ink); background:var(--hero-button);
  box-shadow:4px 4px var(--surface),5px 5px 0 1px var(--hero-button-frame);
}
.library .hero-controls [aria-pressed=false] { color:var(--muted); }
.library .hero-controls [aria-pressed=true] { color:var(--ink); border-color:var(--strong); }
.library .hide-hero { color:var(--jacket-ink); background:color-mix(in srgb,var(--jacket) 92%,transparent); }
:root[data-theme=classic] .hide-hero { color:var(--subtle); background:transparent; }
.library .tile-info small,.library .shelf-heading-detail small { color:var(--subtle); }
.library .tile-info .book-more { background:transparent; border:0; color:var(--subtle); }
.library .cover-title { background:rgb(255 253 247 / 95%); color:#4d463d; }
.library .text-preview { color:#4c4238; }
.library .cover.locked-preview { color:var(--app-muted); background:var(--app-surface); }
.library :is(.shelf-search input,.shelf-search select,.heading .soft) { color:var(--ink); background:var(--side); }
.library .shelf-search input::placeholder { color:var(--subtle); opacity:1; }
.library .compact-create { background:var(--accent); color:var(--on-accent); }
:root[data-section=shelf] #sheet { background:var(--surface); }
:root[data-section=shelf] :is(#sheet,.library) :is(.soft,.choice,input:not([type=color]),select,textarea) {
  background-color:var(--side); color:var(--ink);
}
:root[data-section=shelf] #sheet .primary { background:var(--accent); color:var(--on-accent); }

:root:where([data-tone="dark"])[data-section=shelf] {
    --ground:#24211d; --side:#383126; --surface:#2e2922; --edge:#564936; --strong:#443a2c;
    --veil:88%; --compact-veil:88%;
  }
:root:where([data-tone="dark"])[data-theme=classic] { --hero-button:#55422d; --hero-button-ink:#f4eadb; --hero-button-frame:#f0c58e; }
:root:where([data-tone="dark"])[data-theme=classic] .classic-shelf-rail {
    --nav-paper:#28251f; --nav-selected:#443a2c; --nav-edge:#69563c; --nav-button:var(--hero-button);
    --nav-ink:var(--hero-button-ink); --nav-muted:#c9bca9; --nav-accent:var(--hero-button-frame);
  }
:root:where([data-tone="dark"])[data-theme=classic] .brand-filter { color:var(--hero-button-ink); }
:where(:root[data-tone="dark"]) .calendar-screen { --cal-paper:var(--surface); --cal-peach:#64503a; }
:where(:root[data-tone="dark"]) .calendar-screen .cal-providers button[aria-expanded=true] { background:var(--cal-peach); color:var(--ink); }


/* DocumentViewport.kt keeps the desk cream in both modes. */
.classic-editor .stage { background-color:#f7ebd9; }
:root[data-section=editor]:has(.classic-editor) {
  color-scheme:light dark; --surface:var(--app-surface); --side:var(--app-surface2); --edge:var(--app-line);
  --ink:var(--app-ink); --muted:var(--app-muted); --strong:var(--app-selected); --accent:var(--app-accent);
}
.classic-editor .note-options,.classic-editor .option-track .opt-chip { background:var(--app-surface); border-color:var(--app-line); }
.classic-editor .option-track button { color:var(--app-ink); }
.classic-editor .option-track .palette-chip,.classic-editor .option-track .preset-star { color:var(--app-muted); }
.classic-editor .main-divider,.classic-editor .opt-sep { background:var(--app-line); }
.classic-editor .size-dot i { background:var(--app-muted); }
.classic-editor .size-dot[aria-pressed=true] { background:var(--app-selected); }
.classic-editor .size-dot[aria-pressed=true] i,.classic-editor .ink-swatch[aria-pressed=true] i { outline-color:var(--app-ink); }
.classic-editor .size-dot[aria-pressed=true] i { background:var(--app-ink); }
:root[data-section=editor]:has(.classic-editor) #writing-options {
  --wp-bg:var(--app-bg); --wp-surface:var(--app-surface); --wp-secondary:var(--app-surface2);
  --wp-selected:var(--app-selected); --wp-ink:var(--app-ink); --wp-muted:var(--app-muted);
  --wp-faint:var(--app-subtle); --wp-line:var(--app-line); --wp-accent:var(--app-accent);
}

:where(:root[data-tone="dark"]) .classic-editor .notebook-tab-band { background:var(--app-surface); }
:where(:root[data-tone="dark"]) .classic-editor .notebook-tab { color:var(--app-muted); border-color:var(--app-line); background:var(--app-bg); }
:where(:root[data-tone="dark"]) .classic-editor .notebook-tab.current { color:var(--app-ink); border-color:#897455; background:var(--app-surface2); }
:where(:root[data-tone="dark"]) .classic-editor .notebook-tab.current::after { background:#e8b97c; }
:where(:root[data-tone="dark"]) .classic-editor .tab-close span { background:color-mix(in srgb,var(--app-selected) 50%,transparent); }
:where(:root[data-tone="dark"]) .classic-editor .current .tab-close span { background:var(--app-selected); }
:where(:root[data-tone="dark"]) .classic-editor .note-nav { background:var(--app-surface); color:var(--app-ink); border-color:var(--app-line); }
:where(:root[data-tone="dark"]) .classic-editor .nav-modes { border-color:var(--app-line); }
:where(:root[data-tone="dark"]) .classic-editor .nav-modes button[aria-pressed=true], :where(:root[data-tone="dark"]) .classic-editor .nav-pages [aria-current=page] { background:var(--app-selected); }
:where(:root[data-tone="dark"]) .classic-editor>.foot { color:#51483e; }
:root:where([data-tone="dark"])[data-section=editor]:has(.classic-editor) #sheet {
    background:var(--app-surface); color:var(--app-ink); border-color:var(--app-line);
  }
:root:where([data-tone="dark"])[data-section=editor]:has(.classic-editor) #sheet :is(input:not([type=color]),textarea,select,.soft,.choice,.plain,.insert-option,.palette-options button) {
    background-color:var(--app-surface2); color:var(--app-ink); border-color:var(--app-line);
  }
:root:where([data-tone="dark"])[data-section=editor]:has(.classic-editor) #sheet .primary {
    background:var(--app-accent); color:var(--app-on-accent);
  }


/* AccountScreen.kt and ReviewLayout.kt have screen-specific paper and action colors. */
:root[data-section=account],:root[data-section=accountData] {
  color-scheme:light dark; --ink:var(--app-ink); --muted:var(--app-muted); --edge:var(--app-line);
  --accent:var(--app-accent); --strong:var(--app-selected); --surface:var(--app-surface);
}
.review-screen { --muted:#756d63; --edge:#e6ded2; --accent:#996236; --review-paper:#fffefc; }
.review-screen .review-source { color:var(--accent); }
.review-screen .review-footer .primary { color:var(--review-paper); }

:where(:root[data-tone="dark"]) .account-screen { --account-paper:#24211d; --account-card:#302b24; --account-accent:#4b3e2d; }
:root:where([data-tone="dark"])[data-section=account] #sheet, :root:where([data-tone="dark"])[data-section=accountData] #sheet {
    color:var(--app-ink); background:var(--app-surface);
  }
:root:where([data-tone="dark"]):is([data-section=account],[data-section=accountData]) #sheet :is(input:not([type=color]),select,textarea) {
    color:var(--app-ink); background:var(--app-surface2);
  }
:where(:root[data-tone="dark"]) .review-screen {
    color-scheme:dark; --muted:#cdc3b6; --edge:#514b42; --accent:#f0c28d; --review-paper:#34312b;
    color:#f5eee3; background:#27241f;
  }
:where(:root[data-tone="dark"]) .review-screen header select { color:var(--muted); }
:where(:root[data-tone="dark"]) .review-screen :is(.review-card,.review-progress,.review-footer,.grade-grid button) { border-color:var(--edge); }
:where(:root[data-tone="dark"]) .review-screen :is(.review-card,.review-progress) { background:var(--review-paper); }
:where(:root[data-tone="dark"]) .review-screen .question, :where(:root[data-tone="dark"]) .review-screen .empty .soft { background:#594630; color:var(--accent); }
:where(:root[data-tone="dark"]) .review-screen .review-answer { background:#344337; }
:where(:root[data-tone="dark"]) .review-screen .review-footer .primary { background:var(--accent); }
:where(:root[data-tone="dark"]) .review-screen .grade-grid button:nth-child(1) { background:#553936; }
:where(:root[data-tone="dark"]) .review-screen .grade-grid button:nth-child(2) { background:#53472f; }
:where(:root[data-tone="dark"]) .review-screen .grade-grid button:nth-child(3) { background:#314754; }
:where(:root[data-tone="dark"]) .review-screen .grade-grid button:nth-child(4) { background:#394b36; }


:root[data-tone=dark][data-section] { color-scheme:dark; }
:root[data-tone=light][data-section] { color-scheme:light; }
