/* เรือนอักษร (Ruen Aksorn) — forest green, ivory and gold; serif display over a clean Thai sans. */
:root {
  --bg: #fbf8f3;
  --hero: #f5ece1;
  --surface: #ffffff;
  --surface-2: #f6f0e7;
  --ink: #1d1d1b;
  --muted: #6c665d;
  --line: #e8dfd1;
  --green: #1f3a2e;
  --green-2: #2b4b3d;
  --on-green: #f1ebdf;
  --on-green-muted: #bfc9bf;
  --gold: #b48a4c;
  --gold-ink: #8a6530;
  --link: #2b5a45;
  --accent: #1f3a2e;
  --accent-ink: #f6f1e6;
  --accent-soft: #e6ece5;
  --ok: #2f6b45;  --ok-soft: #e3efe5;
  --warn: #93600c; --warn-soft: #f8ecd5;
  --bad: #a3271d;  --bad-soft: #f8e2df;
  --shadow: 0 1px 2px rgba(40, 32, 20, .05), 0 6px 22px rgba(40, 32, 20, .07);
  --radius: 6px;
  --display: "Playfair Display", "Noto Serif Thai", Georgia, serif;
  --ui: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  --read-sans: "Sarabun", "IBM Plex Sans Thai", sans-serif;
  --read-serif: "Noto Serif Thai", "Sarabun", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1713; --hero: #142019; --surface: #17231d; --surface-2: #1c2a23; --ink: #eee7da; --muted: #a8a193;
    --line: #2a3a31; --green: #0b130f; --green-2: #16241d; --on-green: #eee7da; --on-green-muted: #a8b3a8;
    --gold: #cda769; --gold-ink: #d9b77e; --link: #d9b77e; --accent: #cda769; --accent-ink: #18120a; --accent-soft: #2a2a1e;
    --ok: #7fc79a; --ok-soft: #1b3326; --warn: #e3ae5a; --warn-soft: #382a12; --bad: #f08c80; --bad-soft: #3c1f1b;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 22px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1713; --hero: #142019; --surface: #17231d; --surface-2: #1c2a23; --ink: #eee7da; --muted: #a8a193;
  --line: #2a3a31; --green: #0b130f; --green-2: #16241d; --on-green: #eee7da; --on-green-muted: #a8b3a8;
  --gold: #cda769; --gold-ink: #d9b77e; --link: #d9b77e; --accent: #cda769; --accent-ink: #18120a; --accent-soft: #2a2a1e;
  --ok: #7fc79a; --ok-soft: #1b3326; --warn: #e3ae5a; --warn-soft: #382a12; --bad: #f08c80; --bad-soft: #3c1f1b;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 22px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.65 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.3; margin: 0 0 .5em; font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
em.g, .display em { font-style: italic; color: var(--green-2); }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .88em; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
svg.i.lg { width: 34px; height: 34px; stroke-width: 1.25; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.wrap { max-width: 1200px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.page { padding-top: 26px; padding-bottom: 72px; }
.eyebrow { font-size: .82rem; letter-spacing: .02em; text-transform: uppercase; color: var(--gold-ink); font-weight: 500; }
.section-title { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: .92rem; font-weight: 600; letter-spacing: .02em; margin: 0 0 22px; font-family: var(--ui); }
.section-title::before, .section-title::after { content: ""; width: 34px; height: 1px; background: var(--ink); opacity: .5; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; flex: 1; font-family: var(--ui); font-size: 1rem; font-weight: 600; letter-spacing: .02em; text-align: center; }
.section-head3 { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 20px; }
.section-head3 h2 { margin: 0; font-family: var(--ui); font-size: 1rem; font-weight: 600; letter-spacing: .02em; }
.section-head3 > :last-child { justify-self: end; }
@media (max-width: 600px) { .section-head3 { grid-template-columns: 1fr auto; } .section-head3 > :first-child { display: none; } }
.hero-art .cover { font-size: 17px; }
.link-more { font-size: .8rem; font-weight: 600; letter-spacing: .04em; color: var(--gold-ink); display: inline-flex; align-items: center; gap: 6px; }

/* top bar + header */
.topbar { background: var(--green); color: var(--on-green); font-size: .8rem; }
.topbar-in { display: flex; align-items: center; gap: 16px; min-height: 36px; }
.tb-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.tb-item svg.i { width: 15px; height: 15px; color: var(--gold); }
.tb-mid { flex: 1; justify-content: center; }
.tb-right button { background: none; border: 0; color: inherit; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; padding: 4px 0; }
@media (max-width: 760px) { .tb-left-hide, #tb-mid { display: none; } .topbar-in { justify-content: space-between; } }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 22px; min-height: 76px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark svg { width: 46px; height: 46px; stroke: var(--ink); stroke-width: 1.2; fill: none; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--display); font-size: 1.45rem; font-weight: 600; letter-spacing: 0; }
.brand-sub { font-size: .66rem; letter-spacing: .22em; color: var(--muted); }
.mainnav { flex: 1; display: flex; gap: 26px; justify-content: center; }
.mainnav a { font-size: .9rem; font-weight: 500; padding: 6px 0; border-bottom: 2px solid transparent; }
.mainnav a:hover { text-decoration: none; border-color: var(--line); }
.mainnav a.on { border-color: var(--green-2); }
.top-actions { display: flex; gap: 4px; }
.icon-btn { position: relative; border: 0; background: transparent; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); }
.badge { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--green); color: var(--on-green); font-size: .68rem; display: grid; place-items: center; padding: 0 5px; font-weight: 600; }
.jobs-btn.active .badge { background: var(--gold); color: #1d1408; }
@media (max-width: 860px) { .mainnav { display: none; } .top-in { justify-content: space-between; min-height: 64px; } .brand-mark svg { width: 38px; height: 38px; } .brand-name { font-size: 1.1rem; } }
.crumbbar { border-bottom: 1px solid var(--line); background: var(--bg); }
.crumb { font-size: .82rem; color: var(--muted); padding: 9px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb a { color: var(--muted); }
.crumb b { color: var(--ink); font-weight: 500; }
main { min-height: 60vh; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--ink); background: transparent; padding: 10px 20px; min-height: 44px; border-radius: 3px; cursor: pointer; white-space: nowrap; text-decoration: none !important; color: var(--ink); font-size: .9rem; font-weight: 500; letter-spacing: .02em; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
:root[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } }
.btn.primary:hover { filter: brightness(1.15); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d1408; }
.btn.ghost { border-color: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 5px 12px; min-height: 34px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg.i { width: 17px; height: 17px; }
input[type=text], input[type=number], input[type=password], input[type=email], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 3px; padding: 10px 12px; width: 100%; min-height: 44px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible, a:focus-visible { outline: 2px solid color-mix(in srgb, var(--gold) 70%, transparent); outline-offset: 2px; }
label.field { display: block; }
label.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 5px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* cards, pills */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }
.pill { display: inline-block; font-size: .74rem; padding: 2px 10px; border-radius: 2px; background: var(--surface-2); color: var(--muted); font-weight: 500; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--green-2); }
:root[data-theme="dark"] .pill.accent { color: var(--gold); }
.bar { height: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green-2); }
.empty { text-align: center; padding: 48px 16px; }
.empty p { color: var(--muted); max-width: 440px; margin: 8px auto 18px; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: .85rem; white-space: nowrap; }
.stars small { color: var(--muted); letter-spacing: 0; margin-left: 4px; }

/* hero */
.hero { background: var(--hero); border-bottom: 1px solid var(--line); overflow: hidden; }
.hero-in { display: flex; flex-wrap: wrap; align-items: center; gap: 40px; padding-top: 56px; padding-bottom: 56px; }
.hero-copy { flex: 1 1 420px; min-width: 0; }
.display { font-family: var(--display); font-weight: 500; font-size: clamp(2.2rem, 4.6vw, 3.6rem); line-height: 1.15; margin: 12px 0 18px; }
.hero-copy p.lead { font-size: 1.02rem; max-width: 30em; margin: 0 0 26px; }
.features { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 34px; }
.feature { display: flex; gap: 10px; align-items: flex-start; max-width: 172px; font-size: .78rem; color: var(--muted); line-height: 1.45; }
.feature b { display: block; color: var(--ink); font-size: .82rem; margin-bottom: 3px; }
.feature svg.i { width: 32px; height: 32px; stroke-width: 1.2; color: var(--ink); }
.hero-art { flex: 1 1 380px; min-height: 360px; position: relative; display: flex; justify-content: center; align-items: center; }
.hero-art .cover { position: absolute; box-shadow: 0 18px 40px rgba(30, 25, 15, .28); }
.hero-art .c1 { width: 210px; transform: rotate(-4deg) translateX(-120px); z-index: 1; }
.hero-art .c2 { width: 240px; transform: translateY(-6px); z-index: 3; }
.hero-art .c3 { width: 200px; transform: rotate(5deg) translateX(130px); z-index: 2; }
.seal { position: absolute; top: 4px; right: 18%; z-index: 4; width: 86px; height: 86px; border-radius: 50%; background: var(--green); color: var(--on-green); display: grid; place-items: center; text-align: center; font-size: .76rem; font-weight: 600; line-height: 1.35; border: 3px solid var(--hero); }
@media (max-width: 760px) { .hero-art { min-height: 300px; } .hero-art .c1 { width: 150px; transform: rotate(-4deg) translateX(-90px); } .hero-art .c2 { width: 170px; } .hero-art .c3 { width: 145px; transform: rotate(5deg) translateX(95px); } .seal { right: 4%; } }

/* book covers */
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 2px 5px 5px 2px; overflow: hidden; color: #f3ead6; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; padding: 1.7em .9em 1.1em; background: var(--cv, #1f3a2e); }
.cover::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(233, 214, 170, .45); pointer-events: none; }
.cover::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7%; background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(0,0,0,0)); }
.cover .cv-genre { font-size: .62em; letter-spacing: .04em; opacity: .8; }
.cover .cv-title { font-family: var(--display); font-weight: 600; font-size: 1.25em; line-height: 1.25; }
.cover .cv-motif svg { width: 2.1em; height: 2.1em; stroke: #e2c98f; stroke-width: 1.1; fill: none; }
.cover .cv-pen { font-size: .66em; letter-spacing: .03em; opacity: .85; }
.ribbon { position: absolute; top: 10px; left: -4px; z-index: 2; background: var(--gold); color: #1d1408; font-size: .72rem; font-weight: 600; padding: 2px 9px; }
.ribbon.dark { background: var(--green); color: var(--on-green); }

/* genre row */
.genres { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.genre { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; background: none; border: 0; cursor: pointer; text-align: center; font-size: .8rem; font-weight: 600; letter-spacing: .02em; color: var(--ink); min-height: 44px; }
.genre + .genre { border-left: 1px solid var(--line); }
.genre svg.i { width: 34px; height: 34px; stroke-width: 1.1; color: var(--gold-ink); }
.genre span { font-weight: 400; color: var(--muted); font-size: .74rem; }
.genre:hover { background: var(--surface-2); }

/* shelf of novel cards */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 20px; }
.book-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); transition: transform .15s, box-shadow .15s; }
.book-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.book-card .cover { font-size: 15px; margin-bottom: 10px; box-shadow: 0 6px 14px rgba(30, 25, 15, .18); }
.book-card .bk-title { font-weight: 600; font-size: .92rem; line-height: 1.35; }
.book-card .bk-meta { font-size: .78rem; color: var(--muted); }
.book-card .bk-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-weight: 600; font-size: .92rem; }
.book-card .bk-foot span.muted { font-weight: 400; font-size: .76rem; }
.book-card.add { align-items: center; justify-content: center; border-style: dashed; box-shadow: none; color: var(--muted); min-height: 300px; cursor: pointer; font: inherit; }
.book-card.add svg.i { width: 36px; height: 36px; stroke-width: 1.1; }

/* dark green band */
.band { background: var(--green); color: var(--on-green); border-radius: var(--radius); padding: 26px 18px; }
.band h2 { font-family: var(--ui); text-align: center; font-size: .95rem; letter-spacing: .02em; font-weight: 600; margin: 0 0 20px; }
.band-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.band-item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 6px 16px; font-size: .8rem; color: var(--on-green-muted); }
.band-item + .band-item { border-left: 1px solid rgba(233, 214, 170, .2); }
.band-item b { color: var(--on-green); font-size: .9rem; }
.band-item svg.i { width: 30px; height: 30px; stroke-width: 1.2; color: var(--gold); }
@media (max-width: 860px) { .band-item + .band-item { border-left: 0; } .band-grid { gap: 18px; } }

/* call-to-action band */
.cta { background: var(--hero); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 26px; align-items: center; padding: 28px 32px; border: 1px solid var(--line); }
.cta-art { flex: none; width: 90px; height: 90px; border-radius: 50%; background: var(--green); display: grid; place-items: center; color: var(--gold); }
.cta-art svg.i { width: 44px; height: 44px; stroke-width: 1.1; }
.cta-copy { flex: 1 1 260px; }
.cta-copy h3 { font-family: var(--display); font-size: 1.8rem; font-weight: 500; margin: 4px 0; line-height: 1.25; }
.cta form { flex: 1 1 340px; display: flex; gap: 0; }
.cta form input { border-radius: 3px 0 0 3px; border-right: 0; }
.cta form .btn { border-radius: 0 3px 3px 0; }

/* footer */
.foot { background: var(--green); color: var(--on-green-muted); margin-top: 64px; font-size: .84rem; }
.foot-in { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 28px; padding-top: 40px; padding-bottom: 26px; }
.foot h4 { font-family: var(--ui); color: var(--on-green); font-size: .86rem; letter-spacing: .02em; margin: 0 0 12px; }
.foot a { display: block; color: var(--on-green-muted); padding: 3px 0; }
.foot a:hover { color: var(--on-green); }
.foot .brand-name { color: var(--on-green); }
.foot .brand-mark svg { stroke: var(--on-green); width: 40px; height: 40px; }
.foot-bottom { border-top: 1px solid rgba(233, 214, 170, .18); padding-top: 14px; padding-bottom: 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .76rem; }
@media (max-width: 760px) { .foot-in { grid-template-columns: 1fr 1fr; } .foot-in > :first-child { grid-column: 1 / -1; } }

/* novel header */
.book-head { background: var(--hero); border-bottom: 1px solid var(--line); }
.book-head-in { display: flex; gap: 28px; align-items: flex-end; flex-wrap: wrap; padding-top: 28px; padding-bottom: 0; }
.book-head .cover { width: 128px; font-size: 12px; flex: none; margin-bottom: -26px; box-shadow: 0 12px 28px rgba(30, 25, 15, .25); }
.book-head .bh-copy { flex: 1 1 320px; min-width: 0; padding-bottom: 18px; }
.book-head h1 { font-family: var(--display); font-weight: 500; font-size: clamp(1.7rem, 3.4vw, 2.5rem); margin: 4px 0 6px; }
.book-head .bh-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .86rem; align-items: center; }
.tabs { display: flex; gap: 24px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 24px; scrollbar-width: none; padding-left: 156px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 14px 0 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: .88rem; font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--green-2); }
:root[data-theme="dark"] .tabs a.on { border-bottom-color: var(--gold); }
@media (max-width: 700px) { .book-head .cover { width: 92px; margin-bottom: 0; } .book-head-in { align-items: center; padding-bottom: 14px; } .book-head .bh-copy { padding-bottom: 0; } .tabs { padding-left: 0; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 2px; color: var(--muted); font-size: .86rem; cursor: pointer; }
.chip.on { background: var(--green); color: var(--on-green); border-color: var(--green); }
.chip:hover { text-decoration: none; border-color: var(--muted); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; flex: 1; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat { padding: 16px 20px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { display: block; font-family: var(--display); font-size: 1.9rem; font-weight: 600; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr 1fr; } .stat:nth-child(3) { border-left: 0; } .stat:nth-child(n+3) { border-top: 1px solid var(--line); } }
.notice { border-radius: var(--radius); padding: 10px 14px; background: var(--warn-soft); color: var(--warn); margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice.info { background: var(--accent-soft); color: var(--green-2); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }

/* rendered markdown */
.md { overflow-wrap: anywhere; }
.md h1 { font-size: 1.5rem; } .md h2 { font-size: 1.25rem; margin-top: 1.4em; } .md h3 { font-size: 1.08rem; margin-top: 1.2em; }
.md table { margin: 10px 0; }
.md td, .md th { border: 1px solid var(--line); }
.md blockquote { margin: 10px 0; padding: 8px 16px; background: var(--surface-2); color: var(--muted); border-radius: var(--radius); }
.md ul, .md ol { padding-left: 1.3em; }

/* reader */
.reader-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 3px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 16px; min-height: 40px; cursor: pointer; color: var(--ink); }
.seg button.on { background: var(--green); color: var(--on-green); }
.reader { max-width: 40em; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); padding: 48px clamp(20px, 6vw, 64px); box-shadow: var(--shadow); font-family: var(--read-sans); font-size: var(--read-size, 19px); line-height: 1.95; }
.reader.serif { font-family: var(--read-serif); }
.reader h1 { text-align: center; font-family: var(--read-serif); font-size: 1.35em; margin: 0 0 1.4em; font-weight: 600; }
.reader p { margin: 0 0 .9em; text-indent: 2em; }
.reader hr { border: 0; text-align: center; margin: 1.6em 0; }
.reader hr::after { content: "❦"; color: var(--gold); font-size: 1.1em; }
.reader-nav { display: flex; justify-content: space-between; gap: 8px; max-width: 40em; margin: 28px auto 0; }
.ai-bar { position: sticky; bottom: 14px; max-width: 46em; margin: 26px auto 0; display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
.ai-bar input { border: 0; background: transparent; }
.ai-bar input:focus { outline: none; }

/* editor */
.editor { display: flex; flex-direction: column; gap: 8px; }
.editor-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: sticky; top: 76px; z-index: 5; background: var(--bg); padding: 8px 0; }
.editor textarea { min-height: 70vh; font-family: var(--read-sans); font-size: 17px; line-height: 1.85; padding: 20px; resize: vertical; }
.editor textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 14px; line-height: 1.6; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 16px; max-width: 840px; margin: 0 auto; }
.msg { max-width: 92%; padding: 12px 16px; border-radius: var(--radius); }
.msg.user { align-self: flex-end; background: var(--green); color: var(--on-green); white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.msg.ai .md p:last-child { margin-bottom: 0; }
.chat-input { position: sticky; bottom: 14px; display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
.chat-input textarea { border: 0; resize: none; min-height: 44px; max-height: 200px; background: transparent; }
.chat-input textarea:focus { outline: none; }

/* job log */
.log { font-size: .88rem; display: flex; flex-direction: column; gap: 6px; }
.ev { display: flex; gap: 8px; align-items: baseline; }
.ev .tag { flex: none; font-size: .7rem; padding: 0 7px; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.ev.tool .tag { background: var(--accent-soft); color: var(--green-2); border-color: transparent; }
.ev.sub { padding-left: 18px; opacity: .75; }
.ev.err { color: var(--bad); }
.ev.text { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.ev.result { display: block; background: var(--ok-soft); border-radius: var(--radius); padding: 10px 12px; }
.ev.result.bad { background: var(--bad-soft); }
.ev.log { color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: .78rem; overflow-wrap: anywhere; }
.job-row { display: flex; gap: 10px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.job-row:hover { background: var(--surface-2); }
.job-row .t { flex: 1; min-width: 0; }
.job-row .t div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* drawer, modal, toast */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 40; background: var(--bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.14); }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--green); color: var(--on-green); }
.drawer-head .icon-btn { color: var(--on-green); }
.drawer-head .icon-btn:hover { background: var(--green-2); }
.drawer-head h2 { flex: 1; margin: 0; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px; }
.scrim { position: fixed; inset: 0; background: rgba(15, 20, 16, .35); z-index: 35; }
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 16, .4); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: var(--bg); border-radius: var(--radius); padding: 26px; width: min(660px, 100%); box-shadow: var(--shadow); border-top: 4px solid var(--green); }
.modal h2 { margin-bottom: 16px; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--green); color: var(--on-green); padding: 10px 18px; border-radius: 3px; box-shadow: var(--shadow); font-size: .9rem; }
.toast.bad { background: var(--bad); color: #fff; }

/* login */
.login-wrap { min-height: 72vh; display: flex; flex-wrap: wrap; align-items: center; gap: 48px; padding-top: 40px; padding-bottom: 40px; }
.login-copy { flex: 1 1 380px; }
.login { flex: 1 1 320px; max-width: 400px; }

/* audio & drama */
.cast td { min-width: 120px; }
.cast input[type=number] { width: 84px; }
audio { height: 36px; max-width: 100%; }
.shots { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.shot { display: flex; flex-direction: column; gap: 8px; }
.shot .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.shot .no { font-family: var(--display); font-weight: 600; font-size: 1.3rem; }
.prompt { background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; padding: 8px 10px; font-size: .8rem; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.prompt .copy { float: right; margin: -2px -4px 4px 8px; }
.dialogue { font-family: var(--read-sans); }
.dialogue b { color: var(--gold-ink); font-weight: 600; }

@media (max-width: 600px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .reader { font-size: var(--read-size, 18px); padding: 28px 18px; }
  .cta { padding: 22px 18px; }
}
