/* App themes for the library. Classic (dark walnut and brass) is the base in
   library-home.css; each theme below restyles the room, the bookcase and the
   chrome around it. Books keep their own bindings in every theme.
   Selected with <html data-app-theme="...">. */

:root {
  --dust-color: #ffe1ae;
  --dust-alpha: 1;
}

/* ====================================================================== Modern
   Light oak shelves on a gallery-white wall: flat planes, crisp shadows,
   black label tags and sans-serif lettering. */

html[data-app-theme="modern"] {
  --text: #23201c;
  --muted: #6b655c;
  --dim: #9b948a;
  --side-w: 16px;
  --board-h: 34px;
  --edge-h: 18px;
  --dust-alpha: 0;
  --grain-h: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='96'><filter id='f' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='0.002 0.32' numOctaves='2' seed='5' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.3  0 0 0 0 0.15  0 0 0 -0.9 0.5'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  --grain-v: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='96' height='900'><filter id='f' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='0.32 0.002' numOctaves='2' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.3  0 0 0 0 0.15  0 0 0 -0.9 0.5'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  color-scheme: light;

  & body { background: #e9e7e2; }

  & #app {
    background:
      radial-gradient(ellipse 70% 50% at 50% -10%, rgba(255, 255, 255, .9), transparent 70%),
      linear-gradient(180deg, #f1efeb, #e2dfd9 60%, #d6d3cc);
  }
  & #glow { background: radial-gradient(ellipse 120% 90% at 50% 40%, transparent 62%, rgba(60, 50, 40, .12)); }

  & #topbar {
    background: rgba(252, 251, 248, .86);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    backdrop-filter: blur(14px) saturate(1.2);
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 6px 20px rgba(40, 30, 20, .06);
  }
  & .brand-mark { background: #1f1d1a; color: #f4f1ea; box-shadow: none; border-radius: 10px; }
  & .brand h1 { color: #1d1b18; font: 700 19px/1.1 var(--sans); letter-spacing: -.2px; }
  & #stats { color: var(--muted); }
  & #search {
    background: #fff;
    border-color: rgba(0, 0, 0, .1);
    box-shadow: none;
    color: var(--text);
  }
  & #search:focus { border-color: #1f1d1a; box-shadow: 0 0 0 3px rgba(31, 29, 26, .1); }
  & .seg { background: rgba(0, 0, 0, .05); border-color: transparent; box-shadow: none; }
  & .seg button:hover { background: rgba(0, 0, 0, .05); color: var(--text); }
  & .seg button.on { background: #1f1d1a; color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
  & .select select {
    background-color: #fff;
    border-color: rgba(0, 0, 0, .1);
    color: var(--text);
  }
  & .select option { background: #fff; color: var(--text); }
  & .btn {
    background: #fff;
    border-color: rgba(0, 0, 0, .12);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  }
  & .btn:hover { border-color: rgba(0, 0, 0, .3); filter: none; }
  & .btn.primary { background: #1f1d1a; border-color: #1f1d1a; color: #fff; text-shadow: none; }

  /* the case: thin oak frame, no mouldings */
  & #case::before,
  & #case::after {
    background:
      var(--grain-v),
      linear-gradient(90deg, #b8936a, #dcbd93 35%, #d3b288 70%, #ad8960);
    opacity: .9;
  }
  & #case::before { box-shadow: 8px 0 14px -8px rgba(60, 40, 20, .35); }
  & #case::after { box-shadow: -8px 0 14px -8px rgba(60, 40, 20, .35); }
  & .crown {
    height: 16px;
    margin: 0 calc(-1 * var(--side-w));
    border-radius: 3px 3px 0 0;
    background: var(--grain-h), linear-gradient(180deg, #e6caa2, #cfae84);
    box-shadow: 0 8px 16px -8px rgba(60, 40, 20, .35);
  }
  & .plinth {
    height: 22px;
    margin: 0 calc(-1 * var(--side-w));
    border-radius: 0 0 3px 3px;
    background: linear-gradient(180deg, #2a2724, #1d1b19);
    box-shadow: 0 24px 40px -10px rgba(40, 30, 20, .35);
  }
  & .board {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .55) 0 1px, transparent 1px calc(100% - 2px), rgba(80, 50, 20, .2) calc(100% - 2px)),
      var(--grain-h),
      linear-gradient(180deg, #e8cda6, #d6b78d);
    box-shadow: 0 8px 14px -6px rgba(60, 40, 20, .3);
  }
  & .plate {
    height: 24px;
    padding: 0 11px;
    border-radius: 6px;
    background: #1f1d1a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  }
  & .plate::before,
  & .plate::after { display: none; }
  & .plate-card { height: auto; padding: 0; background: none; box-shadow: none; }
  & .plate-name,
  & .plate-input { color: #fff; font: 600 11px/1 var(--sans); letter-spacing: 1.3px; }
  & .plate-count { color: rgba(255, 255, 255, .55); text-shadow: none; font-weight: 500; }
  & .plate-btn { background: rgba(255, 255, 255, .7); border-color: rgba(0, 0, 0, .08); color: #3a352f; }
  & .plate-btn:hover { background: #fff; border-color: rgba(0, 0, 0, .25); color: #000; }
  & .shelf.drop-target .plate { box-shadow: 0 0 0 3px rgba(31, 29, 26, .18), 0 6px 18px rgba(0, 0, 0, .2); }

  & .row {
    background:
      linear-gradient(180deg, rgba(60, 40, 20, .2), rgba(60, 40, 20, .05) 34px, transparent 70px),
      linear-gradient(90deg, rgba(60, 40, 20, .1), transparent 50px, transparent calc(100% - 50px), rgba(60, 40, 20, .1)),
      linear-gradient(180deg, #f3f1ec, #e6e2da);
  }
  & .floor {
    background:
      linear-gradient(0deg, rgba(255, 255, 255, .35), transparent 25%, rgba(60, 40, 20, .25)),
      var(--grain-h),
      linear-gradient(0deg, #e2c69e, #c8a67b);
  }
  & .edge {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .7) 0 1px, transparent 1px calc(100% - 2px), rgba(80, 50, 20, .25) calc(100% - 2px)),
      var(--grain-h),
      linear-gradient(180deg, #e9cfa8, #d3b388);
  }
  & .be-box > .spine { border-radius: 3px; background: linear-gradient(90deg, #2a2724, #3a3632 45%, #1d1b19); box-shadow: none; }
  & .be-box > .front,
  & .be-box > .back { background: #24211e; }
  & .be-box > .top { background: #34302c; }
  & .slot::before { opacity: .55; }

  & .shelf-hint .hint-text { color: rgba(40, 34, 28, .42); }
  & .shelf-hint.welcome .hint-title { color: #1d1b18; font-family: var(--sans); }
  & .shelf-hint.welcome .hint-text { color: rgba(40, 34, 28, .62); }
  & .add-shelf .plate-card { background: rgba(255, 255, 255, .5); border-color: rgba(0, 0, 0, .25); }
  & .add-shelf .plate-name { color: #3a352f; font-family: var(--sans); }
  & .add-shelf .plate:hover .plate-card { background: #fff; border-color: rgba(0, 0, 0, .5); }
  & .add-hint,
  & .nm-card { color: rgba(40, 34, 28, .4); }

  & .menu { background: #fff; border-color: rgba(0, 0, 0, .1); color: var(--text); box-shadow: 0 16px 40px rgba(40, 30, 20, .18); }
  & .menu-item:hover,
  & .menu-item:focus,
  & .menu-item.open { background: rgba(0, 0, 0, .05); }
  & .mi-icon { color: #6b655c; }
  & .menu-item.danger { color: #b3392a; }
  & .menu-sep { background: rgba(0, 0, 0, .08); }
  & .dialog { background: #fff; }
  & #toast { background: #1f1d1a; border-color: transparent; color: #f4f1ea; }
  & #theater .veil {
    background: rgba(236, 234, 229, .78);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
  }
  & ::-webkit-scrollbar-thumb { background-color: rgba(0, 0, 0, .18); }
}

/* ==================================================================== Midnight
   Matte charcoal shelves lit by cool LED strips, glass labels, steel bookends. */

html[data-app-theme="midnight"] {
  --text: #e6eaf3;
  --muted: #9aa4b8;
  --dim: #69728a;
  --brass-hi: #a9c1ff;
  --brass: #7b9cf5;
  --side-w: 20px;
  --dust-color: #cfe0ff;
  --dust-alpha: .7;

  & body { background: #07090c; }
  & #app {
    background:
      radial-gradient(ellipse 70% 55% at 50% -8%, rgba(110, 150, 255, .14), transparent 70%),
      linear-gradient(180deg, #11151c, #0a0c11 55%, #050608);
  }
  & #glow {
    background:
      radial-gradient(ellipse 42% 60% at 50% -6%, rgba(120, 160, 255, .08), transparent 72%),
      radial-gradient(ellipse 110% 85% at 50% 42%, transparent 56%, rgba(0, 0, 0, .55));
  }
  & #topbar {
    background: rgba(14, 17, 23, .88);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(140, 170, 255, .14);
    box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
  }
  & .brand-mark { background: linear-gradient(135deg, #8fb0ff, #5b7fe8); color: #0b1020; }
  & .brand h1 { color: #eef2fb; font: 700 19px/1.1 var(--sans); }
  & #search,
  & .select select { background-color: rgba(255, 255, 255, .05); border-color: rgba(140, 170, 255, .16); box-shadow: none; color: var(--text); }
  & #search:focus { border-color: rgba(143, 176, 255, .7); box-shadow: 0 0 0 3px rgba(123, 156, 245, .18); }
  & .select option { background: #141821; }
  & .seg { background: rgba(255, 255, 255, .04); border-color: rgba(140, 170, 255, .12); box-shadow: none; }
  & .seg button.on { background: linear-gradient(180deg, #a3bcff, #7395f2); color: #0b1020; }
  & .btn { background: rgba(255, 255, 255, .05); border-color: rgba(140, 170, 255, .18); color: var(--text); box-shadow: none; }
  & .btn:hover { border-color: rgba(143, 176, 255, .55); }
  & .btn.primary { background: linear-gradient(180deg, #a3bcff, #6f91ef); border-color: transparent; color: #0b1020; text-shadow: none; }

  & #case::before,
  & #case::after { background: linear-gradient(90deg, #0c0e12, #20242b 40%, #1a1d23 70%, #0b0d10); }
  & #case::before { box-shadow: 10px 0 18px -8px rgba(0, 0, 0, .8); }
  & #case::after { box-shadow: -10px 0 18px -8px rgba(0, 0, 0, .8); }
  & .crown {
    height: 22px;
    margin: 0 calc(-1 * var(--side-w) - 4px);
    background: linear-gradient(180deg, #2a2f38, #15181d);
    box-shadow: 0 10px 20px -8px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(170, 200, 255, .15);
  }
  & .plinth {
    height: 28px;
    margin: 0 calc(-1 * var(--side-w) - 4px);
    background: linear-gradient(180deg, #1a1d23, #0c0e11);
    box-shadow: 0 30px 50px rgba(0, 0, 0, .7);
  }
  /* A glowing LED strip runs under the front of every shelf. */
  & .board {
    background:
      linear-gradient(180deg, rgba(170, 200, 255, .16) 0 1px, transparent 1px calc(100% - 3px), rgba(150, 185, 255, .85) calc(100% - 3px) calc(100% - 1px), transparent calc(100% - 1px)),
      linear-gradient(180deg, #252a32, #1a1e24);
    box-shadow: 0 10px 22px -4px rgba(110, 150, 255, .28);
  }
  & .plate {
    border-radius: 6px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(143, 176, 255, .35);
    box-shadow: 0 0 14px rgba(110, 150, 255, .18);
  }
  & .plate::before,
  & .plate::after { display: none; }
  & .plate-card { background: none; box-shadow: none; }
  & .plate-name,
  & .plate-input { color: #d6e1ff; font: 600 11px/1 var(--sans); letter-spacing: 1.6px; }
  & .plate-count { color: rgba(200, 215, 255, .6); text-shadow: none; }
  & .plate-btn { background: rgba(255, 255, 255, .06); border-color: rgba(140, 170, 255, .2); color: #c5d2f5; }
  & .shelf.drop-target .plate { box-shadow: 0 0 0 2px rgba(143, 176, 255, .8), 0 0 26px rgba(110, 150, 255, .55); }
  & .shelf.drop-target .row::after { background: radial-gradient(ellipse 60% 80% at 50% 60%, rgba(120, 160, 255, .12), transparent 72%); }

  & .row {
    background:
      linear-gradient(180deg, rgba(120, 160, 255, .2), rgba(120, 160, 255, .05) 46px, transparent 110px),
      linear-gradient(90deg, rgba(0, 0, 0, .55), transparent 70px, transparent calc(100% - 70px), rgba(0, 0, 0, .55)),
      linear-gradient(180deg, #161a20, #0c0e12);
  }
  & .floor { background: linear-gradient(0deg, rgba(170, 200, 255, .1), transparent 25%, rgba(0, 0, 0, .6)), linear-gradient(0deg, #262b33, #14171c); }
  & .edge {
    background:
      linear-gradient(180deg, rgba(180, 205, 255, .28) 0 1px, transparent 1px calc(100% - 2px), rgba(0, 0, 0, .6) calc(100% - 2px)),
      linear-gradient(180deg, #2b3039, #1b1e24);
  }
  & .be-box > .spine {
    border-radius: 4px;
    background: linear-gradient(90deg, #4b5260, #b9c2d3 42%, #e6ebf5 52%, #8b93a4 75%, #3c424e);
    box-shadow: none;
  }
  & .be-box > .front,
  & .be-box > .back { background: linear-gradient(180deg, #7d8597, #3f4552); }
  & .be-box > .top { background: linear-gradient(90deg, #dfe5f1, #7f8899); }

  & .shelf-hint .hint-text,
  & .add-hint,
  & .nm-card { color: rgba(190, 205, 240, .4); }
  & .shelf-hint.welcome .hint-title { color: #eef2fb; font-family: var(--sans); }
  & .shelf-hint.welcome .hint-text { color: rgba(200, 215, 245, .62); }
  & .add-shelf .plate-card { background: rgba(255, 255, 255, .03); border-color: rgba(143, 176, 255, .4); }
  & .add-shelf .plate-name { color: #b9c9f5; font-family: var(--sans); }

  & .menu { background: linear-gradient(180deg, #181c24, #12151b); border-color: rgba(140, 170, 255, .2); }
  & .menu-item:hover,
  & .menu-item:focus,
  & .menu-item.open { background: rgba(123, 156, 245, .16); }
  & .mi-icon { color: #8fb0ff; }
  & .menu-sep { background: rgba(140, 170, 255, .14); }
  & .dialog { background: #171b23; color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .7), inset 0 0 0 1px rgba(140, 170, 255, .15); }
  & .dialog p { color: var(--muted); }
  & .dialog input { background: rgba(255, 255, 255, .05); border-color: rgba(140, 170, 255, .25); color: var(--text); }
  & .dialog .btn { background: rgba(255, 255, 255, .06); border-color: rgba(140, 170, 255, .2); color: var(--text); }
  & .dialog .btn.primary { background: linear-gradient(180deg, #a3bcff, #6f91ef); color: #0b1020; }
  & #toast { background: rgba(20, 24, 32, .97); border-color: rgba(140, 170, 255, .25); }
  & .toast-btn { color: #a9c1ff; border-color: rgba(143, 176, 255, .45); }
  & #fileHint { background: linear-gradient(180deg, #a3bcff, #6f91ef); color: #0b1020; }
  & #theater .veil { background: radial-gradient(ellipse at 50% 45%, rgba(5, 8, 14, .55), rgba(2, 3, 6, .92)); }
  & ::-webkit-scrollbar-thumb { background-color: rgba(143, 176, 255, .22); }
}

/* ==================================================================== Mahogany
   A gentlemen's-club reading room: red-brown mahogany, green felt behind the
   books, brass plates and a green leather top bar. */

html[data-app-theme="mahogany"] {
  --text: #f1e6d2;
  --muted: #c2b08e;
  --dim: #8d7b5c;
  --dust-color: #ffe6b8;

  & body { background: #0b120e; }
  & #app {
    background:
      radial-gradient(ellipse 70% 55% at 50% -8%, rgba(255, 210, 140, .16), transparent 70%),
      var(--noise),
      linear-gradient(180deg, #1d2a22, #121b16 50%, #0a100c);
  }
  & #topbar {
    background:
      linear-gradient(180deg, rgba(30, 50, 39, .97), rgba(20, 35, 27, .97)),
      var(--noise);
    border-bottom: 1px solid rgba(214, 178, 100, .4);
  }
  & .brand h1 { color: #f6ead1; }
  & #search,
  & .select select { background-color: rgba(5, 12, 8, .5); border-color: rgba(214, 178, 100, .25); }
  & .seg { background: rgba(5, 12, 8, .45); border-color: rgba(214, 178, 100, .2); }
  & .btn:not(.primary) { background: linear-gradient(180deg, rgba(45, 70, 55, .95), rgba(28, 46, 36, .95)); border-color: rgba(214, 178, 100, .32); }

  & #case::before,
  & #case::after {
    background:
      var(--grain-v),
      linear-gradient(90deg, #2c0d09, #6a2418 28%, #85301f 55%, #5a1d13 82%, #240a07);
  }
  & .crown {
    background:
      linear-gradient(180deg,
        rgba(255, 210, 170, .3) 0 1px, transparent 1px 7px,
        rgba(0, 0, 0, .4) 7px 9px, rgba(255, 200, 160, .2) 9px 10px, transparent 10px 25px,
        rgba(214, 178, 100, .55) 25px 26px, rgba(0, 0, 0, .45) 26px 28px, transparent 28px 100%),
      var(--grain-h),
      linear-gradient(180deg, #8a3322, #6a2418 40%, #45150e);
  }
  & .plinth {
    background:
      linear-gradient(180deg, rgba(255, 210, 170, .25) 0 1px, transparent 1px 12px, rgba(214, 178, 100, .45) 12px 13px, rgba(0, 0, 0, .4) 13px 15px, transparent 15px 100%),
      var(--grain-h),
      linear-gradient(180deg, #6a2418, #45150e 70%, #2d0d08);
  }
  & .board {
    background:
      linear-gradient(180deg, rgba(255, 215, 175, .28) 0 1px, rgba(255, 200, 160, .07) 1px 3px,
        transparent 3px calc(100% - 4px), rgba(0, 0, 0, .5) calc(100% - 4px)),
      var(--grain-h),
      linear-gradient(180deg, #7e2d1e, #622215 50%, #4a180f);
  }
  /* green baize lining the back of each compartment */
  & .row {
    background:
      linear-gradient(180deg, rgba(0, 0, 0, .62), rgba(0, 0, 0, .2) 40px, transparent 86px),
      linear-gradient(90deg, rgba(0, 0, 0, .5), transparent 76px, transparent calc(100% - 76px), rgba(0, 0, 0, .5)),
      radial-gradient(ellipse 70% 100% at 50% 0%, rgba(255, 210, 140, .08), transparent 76%),
      var(--noise),
      linear-gradient(180deg, #1f3a2b, #10221a);
  }
  & .floor {
    background:
      linear-gradient(0deg, rgba(255, 215, 175, .14), transparent 22%, rgba(0, 0, 0, .62)),
      var(--grain-h),
      linear-gradient(0deg, #7a2a1b, #44150e);
  }
  & .edge {
    background:
      linear-gradient(180deg, rgba(255, 220, 180, .42) 0 1px, rgba(255, 200, 160, .1) 1px 3px,
        transparent 3px calc(100% - 3px), rgba(0, 0, 0, .5) calc(100% - 3px)),
      var(--grain-h),
      linear-gradient(180deg, #842f1f, #632216 60%, #521b11);
  }
  & .shelf-hint .hint-text,
  & .add-hint,
  & .nm-card { color: rgba(240, 225, 190, .36); }
  & .menu { background: linear-gradient(180deg, #1f3328, #15251c); border-color: rgba(214, 178, 100, .35); }
  & #toast { background: rgba(24, 40, 31, .97); }
}

/* ============================================================ theme switching */

/* Switching themes reveals the new room in a widening circle from the card
   that was clicked (View Transitions). */
html[data-vt="theme"]::view-transition-old(root),
html[data-vt="theme"]::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html[data-vt="theme"]::view-transition-new(root) { animation: theme-reveal .7s cubic-bezier(.45, 0, .2, 1); }
/* Moving between home and the bookcase: a short cross-fade with a slight lift. */
html[data-vt="route"]::view-transition-old(root) { animation: route-out .22s ease-in both; }
html[data-vt="route"]::view-transition-new(root) { animation: route-in .38s cubic-bezier(.2, .85, .25, 1) both; }
@keyframes route-out { to { opacity: 0; } }
@keyframes route-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--reveal-x, 50%) var(--reveal-y, 50%)); }
  to { clip-path: circle(var(--reveal-r, 150vmax) at var(--reveal-x, 50%) var(--reveal-y, 50%)); }
}

/* ============================================================ settings window */

.settings {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px 24px 20px;
  border-radius: 14px;
  color: #2c2117;
  background: var(--noise), #f5ecd6;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .5);
  animation: dialog-in .22s var(--ease-out);
}
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.settings h2 { margin: 0; font: 700 21px/1.2 var(--serif); }
.settings h3 {
  margin: 20px 0 10px;
  color: #8a7358;
  font: 700 11px/1 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.settings-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6d5843;
  cursor: pointer;
  font-size: 20px;
}
.settings-close:hover { background: rgba(60, 40, 20, .08); }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; }
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch; /* buttons default to flex-start */
  gap: 8px;
  padding: 8px 8px 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, .55);
  color: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(60, 40, 20, .12);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.theme-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(60, 40, 20, .18); }
.theme-card.on { border-color: #b8893a; box-shadow: 0 0 0 3px rgba(184, 137, 58, .2), 0 8px 20px rgba(60, 40, 20, .16); }
.theme-card.on::after {
  content: '\2713';
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #b8893a;
  color: #fff;
  font: 700 12px/1 var(--sans);
  box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
}
.theme-card b { font: 700 14px/1.2 var(--serif); padding: 0 4px; }
.theme-card small { padding: 0 4px; color: #7a6650; font: 12px/1.35 var(--sans); }

/* A tiny bookcase drawn in each theme's materials. */
.tp {
  position: relative;
  height: 96px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--tp-room);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
}
.tp-case {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 9px;
  bottom: 0;
  padding: 0 5px;
  border-radius: 3px 3px 0 0;
  background: var(--tp-frame);
}
.tp-shelf {
  position: relative;
  height: 39px;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  padding: 0 6px;
  background: var(--tp-wall);
  border-bottom: 5px solid var(--tp-edge);
  box-shadow: inset 0 6px 8px -4px rgba(0, 0, 0, .35);
}
.tp-shelf + .tp-shelf { margin-top: 0; }
.tp-shelf:first-child { margin-top: 5px; }
.tp-book { flex: none; border-radius: 1px 1px 0 0; box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25), inset 1px 0 0 rgba(255, 255, 255, .15); }
.tp-tag {
  position: absolute;
  left: 7px;
  top: -6px;
  width: 22px;
  height: 5px;
  border-radius: 1px;
  background: var(--tp-tag);
}

.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-top: 1px solid rgba(90, 60, 30, .12);
  cursor: pointer;
}
.set-row:first-of-type { border-top: 0; }
.set-row > span:first-child { flex: 1; font: 14px/1.4 var(--sans); }
.set-row small { display: block; color: #7a6650; font-size: 12px; }
.switch { position: relative; flex: none; width: 40px; height: 24px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(90, 60, 30, .25);
  transition: background .2s ease;
  pointer-events: none;
}
.switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s var(--ease-out);
}
.switch input:checked + i { background: #b8893a; }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid #b8893a; outline-offset: 2px; }

html[data-app-theme="midnight"] .settings {
  background: #161a22;
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .7), inset 0 0 0 1px rgba(140, 170, 255, .15);
}
html[data-app-theme="midnight"] .settings h3,
html[data-app-theme="midnight"] .theme-card small,
html[data-app-theme="midnight"] .set-row small { color: var(--muted); }
html[data-app-theme="midnight"] .theme-card { background: rgba(255, 255, 255, .04); }
html[data-app-theme="midnight"] .settings-close { color: var(--muted); }
html[data-app-theme="modern"] .settings { background: #fff; }
html[data-app-theme="modern"] .settings h2,
html[data-app-theme="modern"] .theme-card b { font-family: var(--sans); }

/* ---- the Continue reading nook in each theme */
html[data-app-theme="modern"] :is(#hero, #dash, #crumbs) {
  --hero-bg: linear-gradient(180deg, #ffffff, #f6f4f0);
  --hero-line: rgba(0, 0, 0, .08);
  --hero-desk: linear-gradient(180deg, #e8cda6, #d1b086);
  --hero-accent: #8a6a2e;
}
html[data-app-theme="modern"] .hero-inner { box-shadow: 0 18px 40px rgba(60, 45, 30, .12); }
html[data-app-theme="modern"] .hero-lamp { background: radial-gradient(ellipse 55% 60% at 50% 30%, rgba(255, 236, 200, .5), transparent 70%); }
html[data-app-theme="modern"] .hero-title,
html[data-app-theme="modern"] .hero-other-text b { font-family: var(--sans); }
html[data-app-theme="modern"] .hero-progress,
html[data-app-theme="modern"] .hero-other-bar { background: rgba(0, 0, 0, .08); }
html[data-app-theme="modern"] .hero-other { background: rgba(0, 0, 0, .03); }
html[data-app-theme="modern"] .hero-other:hover { background: rgba(0, 0, 0, .05); }

html[data-app-theme="midnight"] :is(#hero, #dash, #crumbs) {
  --hero-bg:
    radial-gradient(ellipse 45% 90% at 16% 0%, rgba(120, 160, 255, .2), transparent 70%),
    linear-gradient(180deg, rgba(24, 29, 39, .92), rgba(12, 14, 19, .92));
  --hero-line: rgba(140, 170, 255, .2);
  --hero-desk: linear-gradient(180deg, #2c313a, #15181d);
  --hero-accent: #a9c1ff;
}
html[data-app-theme="midnight"] .hero-lamp { background: radial-gradient(ellipse 55% 60% at 50% 30%, rgba(140, 175, 255, .22), transparent 70%); }
html[data-app-theme="midnight"] .hero-title { font-family: var(--sans); }

html[data-app-theme="mahogany"] :is(#hero, #dash, #crumbs) {
  --hero-bg:
    radial-gradient(ellipse 45% 90% at 16% 0%, rgba(255, 210, 140, .18), transparent 70%),
    var(--noise),
    linear-gradient(180deg, rgba(31, 58, 43, .95), rgba(16, 34, 26, .95));
  --hero-line: rgba(214, 178, 100, .32);
  --hero-desk: linear-gradient(180deg, #8a3322, #5a1d13 50%, #3d120b);
}

.account-row { cursor: default; }
.account-row .btn { height: 32px; }

/* ---- the per-shelf view switch in each theme */
html[data-app-theme="modern"] .shelf-view { background: rgba(255, 255, 255, .55); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
html[data-app-theme="modern"] .shelf-view-btn { color: #5d564d; }
html[data-app-theme="modern"] .shelf-view-btn:hover { color: #000; }
html[data-app-theme="modern"] .shelf-view-btn.on { background: #1f1d1a; color: #fff; }
html[data-app-theme="midnight"] .shelf-view { background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px rgba(140, 170, 255, .15); }
html[data-app-theme="midnight"] .shelf-view-btn { color: #9aa4b8; }
html[data-app-theme="midnight"] .shelf-view-btn.on { background: linear-gradient(180deg, #a3bcff, #7395f2); color: #0b1020; }

/* ---- account and people forms in Settings */
.account-row .btn,
.person .btn { height: 30px; padding: 0 11px; font-size: 12.5px; }
.person { cursor: default; }
.btn.danger-text { color: #a3312a; }
.set-form {
  display: grid;
  gap: 10px;
  margin: 4px 0 10px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(90, 60, 30, .07);
}
.set-field span { display: block; margin-bottom: 4px; font: 600 12px var(--sans); opacity: .75; }
.set-field input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid #c9b38c;
  background: #fffaf0;
  color: #2c2117;
  font: 14px var(--sans);
  outline: none;
}
.set-field input:focus { border-color: #b0802f; box-shadow: 0 0 0 3px rgba(176, 128, 47, .2); }
.set-check { display: flex; align-items: center; gap: 6px; font: 13px var(--sans); }
.set-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.set-msg { flex: 1; color: #a3312a; font: 12.5px var(--sans); }
.people-add { margin-top: 8px; height: 32px; }
html[data-app-theme="midnight"] .set-form { background: rgba(255, 255, 255, .04); }
html[data-app-theme="midnight"] .set-field input { background: rgba(255, 255, 255, .05); border-color: rgba(140, 170, 255, .25); color: var(--text); }
html[data-app-theme="modern"] .set-field input { background: #fff; border-color: rgba(0, 0, 0, .15); }

/* home cards per theme (the cards themselves: ui/src/home) */
html[data-app-theme="modern"] :is(#dash, #crumbs) {
  --dash-card: #fff;
  --dash-plank: linear-gradient(180deg, #e2c69c, #c9a674);
  --dash-back: linear-gradient(180deg, #ecebe7, #f5f4f1);
}
html[data-app-theme="modern"] #dash :is(.dash-card, .dash-stat) { box-shadow: 0 10px 26px rgba(60, 45, 30, .1); }
html[data-app-theme="modern"] #dash .dash-card:hover { box-shadow: 0 18px 36px rgba(60, 45, 30, .16); }
html[data-app-theme="modern"] #dash .dash-add { box-shadow: none; }
html[data-app-theme="modern"] :is(#dash, #crumbs) :is(.dash-card-name, .dash-head h2, .crumb-name, .dash-stat b) { font-family: var(--sans); }
html[data-app-theme="modern"] #dash .dash-card-bar { background: rgba(0, 0, 0, .08); }
html[data-app-theme="modern"] #dash .dash-mini { box-shadow: inset 0 6px 10px rgba(0, 0, 0, .06); }
html[data-app-theme="midnight"] :is(#dash, #crumbs) {
  --dash-card: linear-gradient(180deg, rgba(26, 31, 42, .9), rgba(14, 16, 22, .9));
  --dash-plank: linear-gradient(180deg, #3a404c, #20242c);
  --dash-back: linear-gradient(180deg, rgba(4, 6, 10, .6), rgba(20, 24, 32, .4));
}
html[data-app-theme="midnight"] :is(#dash, #crumbs) :is(.dash-card-name, .dash-head h2, .crumb-name) { font-family: var(--sans); }
html[data-app-theme="mahogany"] :is(#dash, #crumbs) {
  --dash-card: linear-gradient(180deg, rgba(31, 58, 43, .92), rgba(16, 34, 26, .92));
  --dash-plank: linear-gradient(180deg, #8a3322, #5a1d13 60%, #3d120b);
}
