/* ---------------------------------------------------------------------------
   MVToons
   Two surfaces, one system:
     .reader  — immersive, dark, mobile-first, story is the only thing on screen
     .studio  — editorial workspace, light, dense, information-forward
   --------------------------------------------------------------------------- */

:root {
  --ink:        #16151a;
  --ink-2:      #45424e;
  --ink-3:      #6f6b7a;
  --line:       #e3dfd8;
  --line-2:     #cfc9c0;
  --paper:      #faf8f4;
  --paper-2:    #ffffff;
  --accent:     #b0432f;
  --accent-ink: #8d3524;
  --accent-wash:#fbeeea;
  --good:       #2c6e4b;
  --good-wash:  #e8f3ec;
  --warn:       #8a6516;
  --warn-wash:  #fbf1dc;
  --bad:        #a3312b;
  --bad-wash:   #fbeae9;

  --night:      #111014;
  --night-2:    #1a181f;
  --night-3:    #26232d;
  --night-ink:  #f3f0ea;
  --night-ink-2:#a9a3b4;

  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 1px 2px rgba(22,21,26,.06), 0 8px 24px rgba(22,21,26,.06);
  --shadow-lg:  0 24px 64px rgba(0,0,0,.45);

  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

body.reader { background: var(--night); color: var(--night-ink); }

a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
small { font-size: .82rem; }

/* --- chrome ---------------------------------------------------------------- */

.topbar, .reader-bar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  position: sticky; top: 0; z-index: 40;
}
.reader-bar {
  background: rgba(17,16,20,.86);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--night-3);
  justify-content: space-between;
}

.brand { display: flex; align-items: baseline; gap: 2px; text-decoration: none; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { background: var(--accent); color: #fff; padding: 2px 6px; border-radius: 5px; font-size: .82rem; letter-spacing: .02em; }
.brand-word { font-size: 1.02rem; }

.topnav { display: flex; gap: 18px; flex: 1; }
.topnav a { text-decoration: none; color: var(--ink-2); font-weight: 520; font-size: .92rem; }
.topnav a:hover { color: var(--accent-ink); }

.topbar-end, .reader-bar-end { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.who { font-size: .84rem; color: var(--ink-3); display: flex; flex-direction: column; line-height: 1.25; }
.who em { font-style: normal; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); opacity: .8; }
.inline { display: inline; }

.shell { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
.reader-shell { max-width: 620px; margin: 0 auto; padding: 0 0 96px; }

.footer {
  max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px;
  display: flex; gap: 18px; font-size: .82rem; color: var(--ink-3);
  border-top: 1px solid var(--line);
}
.footer a { color: var(--ink-3); }

/* --- buttons --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius);
  font: inherit; font-weight: 560; font-size: .9rem;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-quiet { background: rgba(255,255,255,.1); color: var(--night-ink); border-color: rgba(255,255,255,.16); }
.btn-danger { background: transparent; border-color: var(--line-2); color: var(--bad); }
.btn-danger:hover { background: var(--bad-wash); border-color: var(--bad); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* --- flashes --------------------------------------------------------------- */

.flashes { max-width: 1180px; margin: 14px auto 0; padding: 0 20px; display: grid; gap: 8px; }
body.reader .flashes { max-width: 620px; }
.flash { padding: 10px 14px; border-radius: var(--radius); font-size: .9rem; border: 1px solid; }
.flash-success { background: var(--good-wash); border-color: #bcdcc8; color: var(--good); }
.flash-error   { background: var(--bad-wash);  border-color: #eec6c4; color: var(--bad); }
.flash-warning { background: var(--warn-wash); border-color: #ebd7a8; color: var(--warn); }
body.reader .flash { background: var(--night-3); border-color: #383343; color: var(--night-ink); }

/* --- forms ----------------------------------------------------------------- */

label { display: block; font-size: .82rem; font-weight: 560; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line-2); border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.field { margin-bottom: 16px; }
.field-hint { font-size: .8rem; color: var(--ink-3); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { margin-left: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 0 6px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.checkline input { width: auto; }

/* --- cards / panels -------------------------------------------------------- */

.card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .row-end { margin-left: auto; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: .82rem; }
.stack { display: grid; gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  background: var(--line); color: var(--ink-2);
}
.pill-good { background: var(--good-wash); color: var(--good); }
.pill-warn { background: var(--warn-wash); color: var(--warn); }
.pill-bad  { background: var(--bad-wash);  color: var(--bad); }
.pill-accent { background: var(--accent-wash); color: var(--accent-ink); }

.stat-row { display: flex; flex-wrap: wrap; gap: 22px; }
.stat { min-width: 84px; }
.stat b { display: block; font-size: 1.4rem; font-weight: 660; letter-spacing: -.02em; }
.stat span { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }

table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }

.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.source-text {
  font-family: var(--serif); font-size: 1.02rem; line-height: 1.75;
  white-space: pre-wrap; background: var(--paper); padding: 16px;
  border-radius: var(--radius); border: 1px solid var(--line);
}

/* --- creator --------------------------------------------------------------- */

.lede { font-size: 1.05rem; color: var(--ink-2); max-width: 62ch; }
.wordcount { font-variant-numeric: tabular-nums; font-weight: 600; }
.wordcount.ok   { color: var(--good); }
.wordcount.warn { color: var(--warn); }
.wordcount.bad  { color: var(--bad); }

.character-card { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--paper-2); }
.character-card > summary {
  padding: 14px 18px; cursor: pointer; display: flex; align-items: center; gap: 12px;
  font-weight: 600; list-style: none;
}
.character-card > summary::-webkit-details-marker { display: none; }
.character-card > summary::before { content: "▸"; color: var(--ink-3); font-size: .8rem; }
.character-card[open] > summary::before { content: "▾"; }
.character-body { padding: 0 18px 18px; border-top: 1px solid var(--line); }

.ref-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.ref-thumb { width: 108px; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.ref-thumb.is-canonical { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
.ref-thumb figcaption { font-size: .7rem; padding: 4px 6px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }

/* --- reader feed ----------------------------------------------------------- */

.feed { display: grid; gap: 14px; padding: 16px; }
.feed-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--night-2); border: 1px solid var(--night-3);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: border-color .15s ease, transform .12s ease;
}
.feed-card:hover { border-color: #423c50; transform: translateY(-2px); }
.feed-cover { aspect-ratio: 3 / 2; background: var(--night-3); overflow: hidden; }
.feed-cover img { width: 100%; height: 100%; object-fit: cover; }
.feed-body { padding: 14px 16px 16px; }
.feed-kicker { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--night-ink-2); margin-bottom: 6px; }
.feed-title { font-size: 1.12rem; font-weight: 640; margin: 0 0 6px; letter-spacing: -.01em; }
.feed-logline { color: var(--night-ink-2); font-size: .92rem; margin: 0 0 12px; }
.feed-meta { display: flex; gap: 14px; font-size: .8rem; color: var(--night-ink-2); }

.reader-hero { padding: 26px 20px 10px; }
.reader-hero h1 { font-size: 1.7rem; letter-spacing: -.02em; }
.byline { color: var(--night-ink-2); font-size: .9rem; }
.byline b { color: var(--night-ink); font-weight: 600; }

/* --- vertical reader ------------------------------------------------------- */

.episode-head { padding: 24px 20px 18px; border-bottom: 1px solid var(--night-3); }
.episode-head h1 { font-size: 1.45rem; margin-bottom: 6px; }

.panels { display: block; }
.panel-frame { position: relative; background: var(--night-2); }
.panel-frame img { width: 100%; height: auto; }
.panel-missing {
  aspect-ratio: 2 / 3; display: grid; place-items: center;
  color: var(--night-ink-2); font-size: .85rem; background: var(--night-3);
}

/* Bubbles are HTML over the artwork — never baked into pixels. */
.bubble {
  position: absolute; transform: translate(-50%, 0);
  background: #fff; color: #16151a;
  padding: 8px 12px; border-radius: 14px;
  font-size: clamp(11px, 3.1vw, 15px); line-height: 1.35; font-weight: 500;
  box-shadow: 0 3px 14px rgba(0,0,0,.35);
  max-width: 92%;
}
.bubble::after {
  content: ""; position: absolute; width: 0; height: 0;
  border: 9px solid transparent; border-top-color: #fff;
}
.bubble.tail-bottom-left::after  { left: 16px;  bottom: -16px; }
.bubble.tail-bottom-right::after { right: 16px; bottom: -16px; }
.bubble.tail-none::after { display: none; }
.bubble.style-thought { border-radius: 20px; font-style: italic; }
.bubble.style-thought::after { border-top-color: transparent; }
.bubble.style-narration {
  background: rgba(17,16,20,.9); color: var(--night-ink);
  border-left: 3px solid var(--accent); border-radius: 4px;
  font-family: var(--serif); font-style: italic;
}
.bubble.style-narration::after { display: none; }
.bubble.style-shout { font-weight: 750; text-transform: uppercase; }

.panel-caption {
  padding: 14px 20px; font-family: var(--serif); font-style: italic;
  color: var(--night-ink-2); background: var(--night);
}

.end-card { padding: 34px 20px 20px; text-align: center; }
.end-card h2 { font-size: 1.25rem; }
.end-card p { color: var(--night-ink-2); }

.engagement {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding: 8px 20px 24px;
}
.eng-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--night-2); border: 1px solid var(--night-3);
  color: var(--night-ink); font: inherit; font-size: .88rem; font-weight: 560;
  cursor: pointer; text-decoration: none;
}
.eng-btn:hover { border-color: #4a4358; }
.eng-btn.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.eng-btn b { font-variant-numeric: tabular-nums; }

.continue-block {
  margin: 10px 20px 26px; padding: 20px; text-align: center;
  border: 1px dashed #423c50; border-radius: var(--radius-lg); background: var(--night-2);
}
.continue-block h3 { font-size: 1.05rem; }
.continue-block p { color: var(--night-ink-2); font-size: .9rem; }
.continue-block textarea {
  background: var(--night-3); border-color: #423c50; color: var(--night-ink);
  margin-bottom: 10px;
}

.comments { padding: 8px 20px 40px; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--night-3); }
.comment b { font-size: .88rem; }
.comment p { margin: 4px 0 0; color: var(--night-ink-2); font-size: .92rem; }
.comment-form { display: grid; gap: 8px; margin-bottom: 18px; }
.comment-form textarea, .comment-form input {
  background: var(--night-2); border-color: var(--night-3); color: var(--night-ink);
}

/* --- editor panel workbench ------------------------------------------------ */

.panel-work {
  display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--paper-2); padding: 18px; margin-bottom: 18px;
}
@media (max-width: 860px) { .panel-work { grid-template-columns: 1fr; } }

.panel-art { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-art img { width: 100%; }
.panel-art .placeholder { aspect-ratio: 2/3; display: grid; place-items: center; color: var(--ink-3); font-size: .84rem; text-align: center; padding: 20px; }

.variant-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.variant { width: 76px; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: none; padding: 0; }
.variant.is-selected { border-color: var(--accent); }
.variant img { width: 100%; }

.bubble-stage { position: relative; }
.bubble-stage .bubble { cursor: grab; user-select: none; }
.bubble-stage .bubble.dragging { cursor: grabbing; opacity: .85; }

.jobs-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }

.blockers { background: var(--warn-wash); border: 1px solid #ebd7a8; color: var(--warn); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: .89rem; }
.blockers ul { margin: 6px 0 0; padding-left: 18px; }

.flag { border-left: 3px solid var(--line-2); padding: 10px 12px; margin-bottom: 8px; background: var(--paper); border-radius: 0 var(--radius) var(--radius) 0; }
.flag.sev-high   { border-left-color: var(--bad); }
.flag.sev-medium { border-left-color: var(--warn); }
.flag.sev-low    { border-left-color: var(--line-2); }
.flag.resolved   { opacity: .55; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
body.reader .empty { color: var(--night-ink-2); }

.notice { background: var(--accent-wash); border: 1px solid #eccdc4; color: var(--accent-ink); padding: 10px 14px; border-radius: var(--radius); font-size: .86rem; margin-bottom: 14px; }

@media (max-width: 640px) {
  .topnav { display: none; }
  .shell { padding: 18px 14px 60px; }
  h1 { font-size: 1.35rem; }
}
