:root {
  color-scheme: dark;
  --bg: #07090c;
  --bg-deep: #030506;
  --bg-soft: #0e1518;
  --shell: #111a1f;
  --shell-soft: #18252a;
  --surface: rgba(18, 27, 31, 0.78);
  --surface-strong: rgba(22, 32, 37, 0.94);
  --surface-muted: #1b272d;
  --ink: #f4efe7;
  --ink-inverse: #fffaf0;
  --muted: #9aa6a6;
  --muted-strong: #c3cac6;
  --line: rgba(238, 229, 212, 0.11);
  --line-strong: rgba(238, 229, 212, 0.2);
  --accent: #d97943;
  --accent-strong: #f09a5f;
  --teal: #25c1b3;
  --blue: #8ea3ba;
  --amber: #dfb45c;
  --danger: #f36b78;
  --warn: #e6b45c;
  --ok: #61d49d;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
  --shadow-soft: 0 18px 50px rgba(0, 0, 0, 0.28);
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(3, 5, 6, 0.95), rgba(7, 12, 14, 0.96) 34%, rgba(15, 16, 15, 0.98)),
    repeating-linear-gradient(90deg, rgba(223, 180, 92, 0.035) 0 1px, transparent 1px 86px),
    repeating-linear-gradient(0deg, rgba(37, 193, 179, 0.027) 0 1px, transparent 1px 86px),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  z-index: 0;
  background:
    linear-gradient(118deg, transparent 0 30%, rgba(37, 193, 179, 0.08) 30.2% 30.35%, transparent 31% 100%),
    linear-gradient(62deg, transparent 0 68%, rgba(217, 121, 67, 0.09) 68.2% 68.38%, transparent 69% 100%),
    linear-gradient(180deg, rgba(255, 250, 240, 0.035), transparent 26%);
}

body::after {
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(255, 250, 240, 0.018), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.36)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 7px);
  box-shadow: inset 0 0 180px rgba(0, 0, 0, 0.68);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid rgba(37, 193, 179, 0.72);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 0 calc(42px + env(safe-area-inset-bottom));
}

.auth-view {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 420px);
  gap: 22px;
  align-items: center;
  width: min(1060px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 42px 0;
}

.auth-brand,
.login-panel,
.topbar,
.tabbar,
.panel,
.script-summary,
.reader-view,
.spoiler-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(24px);
}

.auth-brand {
  position: relative;
  min-height: 430px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: 34px;
  color: var(--ink-inverse);
  background:
    linear-gradient(145deg, rgba(217, 121, 67, 0.18), transparent 28%),
    linear-gradient(25deg, rgba(37, 193, 179, 0.16), transparent 56%),
    linear-gradient(180deg, rgba(22, 32, 37, 0.94), rgba(8, 13, 15, 0.96));
  box-shadow: var(--shadow);
}

.auth-brand::before {
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(255, 250, 240, 0.09);
  border-radius: 6px;
  content: "";
}

.auth-brand::after {
  position: absolute;
  inset: auto 26px 26px auto;
  width: 180px;
  height: 118px;
  border-top: 1px solid rgba(223, 180, 92, 0.22);
  border-left: 1px solid rgba(223, 180, 92, 0.16);
  content: "";
  transform: skewX(-12deg);
}

.brand-mark {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  margin-bottom: 26px;
  border: 1px solid rgba(255, 250, 240, 0.18);
  border-radius: 8px;
  color: var(--ink-inverse);
  background: var(--bg-soft);
  font-size: 24px;
  font-weight: 780;
  box-shadow: var(--shadow);
}

.brand-logo {
  position: relative;
  z-index: 1;
  width: 108px;
  height: 108px;
  display: block;
  margin-bottom: 26px;
  border: 1px solid rgba(255, 250, 240, 0.18);
  border-radius: 8px;
  object-fit: cover;
  background: #0f1a20;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.38);
}

.auth-brand h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--ink-inverse);
  font-size: clamp(42px, 7vw, 78px);
  line-height: 0.95;
  letter-spacing: 0;
  font-weight: 860;
}

.auth-brand p {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 18px 0 0;
  color: rgba(255, 250, 240, 0.72);
  font-size: 18px;
  line-height: 1.65;
}

.login-panel {
  padding: 26px;
  background:
    linear-gradient(180deg, rgba(27, 39, 45, 0.96), rgba(13, 20, 23, 0.94)),
    var(--surface-strong);
}

.login-panel h2 {
  margin: 0 0 20px;
  color: var(--ink);
  font-size: 23px;
  font-weight: 820;
}

.login-error {
  margin: -2px 0 14px;
  padding: 11px 12px;
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  color: #ffd6d9;
  background: rgba(243, 107, 120, 0.12);
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding: 12px 14px;
  color: var(--ink-inverse);
  background:
    linear-gradient(135deg, rgba(37, 193, 179, 0.1), transparent 36%),
    linear-gradient(115deg, rgba(217, 121, 67, 0.14), transparent 58%),
    rgba(12, 18, 21, 0.88);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 250, 240, 0.16);
  border-radius: 8px;
  object-fit: cover;
  background: var(--shell-soft);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

.topbar h1 {
  margin: 0;
  color: var(--ink-inverse);
  font-size: 28px;
  line-height: 1;
  font-weight: 840;
  letter-spacing: 0;
}

.topbar p {
  margin: 7px 0 0;
  color: rgba(255, 250, 240, 0.62);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.status-pill,
.user-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 250, 240, 0.14);
  border-radius: 999px;
  padding: 7px 12px;
  color: rgba(255, 250, 240, 0.76);
  background: rgba(255, 250, 240, 0.07);
  backdrop-filter: blur(16px);
}

.user-pill {
  color: #d4fbf6;
  border-color: rgba(37, 193, 179, 0.34);
  background: rgba(37, 193, 179, 0.08);
}

.tabbar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding: 6px;
  background: rgba(10, 15, 18, 0.78);
}

.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.tab-button.active {
  color: #07100f;
  background: linear-gradient(135deg, var(--teal), #cdd8c4);
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(37, 193, 179, 0.18);
}

.tab-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.app-shell.reader-mode {
  width: min(1180px, calc(100vw - 32px));
}

.app-shell.reader-mode .tabbar,
.app-shell.reader-mode .workspace,
.app-shell.reader-mode .library-panel {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel,
.script-summary,
.reader-view,
.spoiler-box {
  background:
    linear-gradient(180deg, rgba(30, 43, 49, 0.92), rgba(13, 20, 23, 0.9)),
    var(--surface-strong);
}

.generator-panel,
.output-panel,
.library-panel {
  padding: 20px;
}

.generator-panel {
  position: sticky;
  top: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
}

.panel-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  font-weight: 820;
}

.panel-head span {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span,
.toggle-row span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid rgba(255, 250, 240, 0.12);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(5, 9, 10, 0.56);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.05);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field select {
  color-scheme: dark;
}

.field input::placeholder {
  color: rgba(154, 166, 166, 0.64);
}

.field input:focus,
.field select:focus {
  border-color: rgba(37, 193, 179, 0.72);
  background: rgba(6, 14, 15, 0.88);
  box-shadow: 0 0 0 4px rgba(37, 193, 179, 0.12), inset 0 1px 0 rgba(255, 250, 240, 0.06);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  border: 1px solid rgba(255, 250, 240, 0.12);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(5, 9, 10, 0.48);
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  min-height: var(--tap);
  display: grid;
  place-items: center;
  color: var(--muted);
  border-right: 1px solid rgba(255, 250, 240, 0.1);
  cursor: pointer;
}

.segmented label:last-child {
  border-right: 0;
}

.segmented input:checked + label {
  color: #07100f;
  background: linear-gradient(135deg, var(--teal), #d8d2ba);
  font-weight: 800;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 18px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.primary-button,
.ghost-button,
.link-button {
  min-height: var(--tap);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 780;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.primary-button {
  width: 100%;
  color: #080d0f;
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.34), transparent 30%),
    linear-gradient(135deg, var(--accent-strong), var(--amber));
  box-shadow: 0 16px 34px rgba(217, 121, 67, 0.22);
}

.primary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 250, 240, 0.28);
  box-shadow: 0 20px 44px rgba(217, 121, 67, 0.28);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.ghost-button:disabled,
.link-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.primary-button.compact,
.ghost-button.compact,
.link-button.compact {
  width: auto;
  min-height: 36px;
  padding: 7px 12px;
}

.ghost-button,
.link-button {
  color: var(--ink);
  background: rgba(255, 250, 240, 0.07);
  border-color: rgba(255, 250, 240, 0.13);
}

.ghost-button:hover,
.link-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 250, 240, 0.24);
  background: rgba(255, 250, 240, 0.12);
}

.ghost-button.danger {
  color: #ffd6db;
  border-color: rgba(243, 107, 120, 0.38);
  background: rgba(243, 107, 120, 0.09);
}

.ghost-button.danger:hover {
  border-color: rgba(243, 107, 120, 0.62);
  background: rgba(243, 107, 120, 0.15);
}

.topbar .ghost-button {
  color: var(--ink-inverse);
  border-color: rgba(255, 250, 240, 0.15);
  background: rgba(255, 250, 240, 0.08);
}

.topbar .ghost-button:hover {
  background: rgba(255, 250, 240, 0.14);
}

.job-state {
  min-height: 74px;
}

.lock-note {
  margin-top: 10px;
  color: var(--warn);
  font-size: 13px;
}

.empty-state {
  color: var(--muted);
}

.state-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
}

.state-row strong {
  font-size: 15px;
}

.state-ok {
  color: var(--ok);
}

.state-warn {
  color: var(--warn);
}

.state-danger {
  color: var(--danger);
}

.job-stage-card {
  display: grid;
  gap: 12px;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.job-stage-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.job-stage-head strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.job-stage-head > span {
  max-width: 42%;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.job-eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.stage-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.stage-progress-bar,
.progress-line {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.09);
}

.stage-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--accent-strong));
  transition: width 220ms ease;
}

.progress-line {
  position: relative;
  height: 3px;
  margin-top: 10px;
}

.progress-line span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--accent-strong));
  animation: progressSlide 1.2s ease-in-out infinite;
}

.latest-progress {
  margin: 2px 0 0;
  padding: 11px 12px;
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  color: var(--muted-strong);
  background: rgba(37, 193, 179, 0.09);
  line-height: 1.55;
}

.progress-log {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding: 11px 11px 11px 13px;
  border: 1px solid rgba(255, 250, 240, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(5, 9, 10, 0.68), rgba(11, 17, 20, 0.82)),
    rgba(5, 9, 10, 0.7);
  box-shadow: inset 0 -18px 20px -24px rgba(0, 0, 0, 0.85);
  scrollbar-color: rgba(37, 193, 179, 0.42) transparent;
  scrollbar-width: thin;
}

.progress-log::-webkit-scrollbar {
  width: 8px;
}

.progress-log::-webkit-scrollbar-track {
  background: transparent;
}

.progress-log::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(37, 193, 179, 0.42);
  background-clip: content-box;
}

.progress-log.is-compact {
  max-height: 420px;
}

.progress-log > span {
  color: var(--muted);
  font-size: 12px;
}

.progress-log article {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-top: 1px solid rgba(255, 250, 240, 0.08);
}

.progress-log time {
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
}

.progress-log p {
  margin: 0;
  color: var(--muted);
  line-height: 1.52;
}

.progress-log-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.progress-log-meta strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
}

.progress-log-meta span {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 760;
}

.progress-log article.is-running .progress-log-meta span {
  color: #bceef0;
  background: rgba(37, 193, 179, 0.13);
}

.progress-log article.is-completed .progress-log-meta span {
  color: #c9f7dc;
  background: rgba(97, 212, 157, 0.12);
}

.progress-log article.is-failed .progress-log-meta span {
  color: #ffd6db;
  background: rgba(243, 107, 120, 0.12);
}

.progress-log small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.judge-summary {
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 250, 240, 0.09);
  border-radius: 7px;
  background: rgba(255, 250, 240, 0.045);
}

.judge-summary-row,
.judge-severity-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.judge-summary-row span,
.severity-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.25;
}

.judge-summary-row span {
  color: var(--muted-strong);
  background: rgba(255, 250, 240, 0.08);
}

.judge-review.is-ok {
  color: #c9f7dc;
  background: rgba(97, 212, 157, 0.13);
}

.judge-review.is-danger {
  color: #ffd6db;
  background: rgba(243, 107, 120, 0.13);
}

.judge-review.is-warn {
  color: #ffe7aa;
  background: rgba(229, 184, 97, 0.13);
}

.judge-review.is-muted {
  color: var(--muted);
}

.severity-chip.is-p0 {
  color: #ffd6db;
  background: rgba(243, 107, 120, 0.14);
}

.severity-chip.is-p1 {
  color: #ffe7aa;
  background: rgba(229, 184, 97, 0.14);
}

.severity-chip.is-p2 {
  color: #cbe7ff;
  background: rgba(117, 183, 255, 0.13);
}

.preview {
  margin-top: 16px;
}

.script-summary {
  padding: 16px;
}

.script-summary h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 22px;
}

.script-summary p,
.library-item p,
.reader-section p,
.reader-card p,
.timeline-item p,
.mini-list ul {
  color: var(--muted);
  line-height: 1.64;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.meta-cell,
.metric {
  border: 1px solid rgba(255, 250, 240, 0.1);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.04);
}

.meta-cell span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.role-list li {
  border: 1px solid rgba(37, 193, 179, 0.24);
  border-radius: 999px;
  padding: 5px 10px;
  color: #bff6f0;
  background: rgba(37, 193, 179, 0.09);
  font-weight: 760;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.library-panel {
  margin-top: 16px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.library-item {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 250, 240, 0.11);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(37, 193, 179, 0.08), transparent 36%),
    linear-gradient(180deg, rgba(24, 36, 41, 0.9), rgba(11, 17, 20, 0.88));
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.library-item::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  background: linear-gradient(180deg, var(--teal), var(--amber), var(--accent));
}

.library-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 250, 240, 0.22);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.32);
}

.library-item h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 17px;
}

.library-intro {
  min-height: 3.2em;
  margin: 0;
}

.library-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.library-meta span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 1px solid rgba(255, 250, 240, 0.1);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted-strong);
  background: rgba(255, 250, 240, 0.055);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.library-meta strong {
  color: var(--muted);
  font-weight: 760;
}

.library-item .source {
  margin-top: 10px;
  color: #bff6f0;
  font-size: 12px;
  font-weight: 780;
}

.library-progress-summary {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.library-progress-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 250, 240, 0.1);
}

.production-progress {
  display: grid;
  gap: 10px;
}

.production-progress-head {
  display: grid;
  gap: 4px;
}

.production-progress-head strong {
  color: var(--ink);
  font-size: 13px;
}

.production-progress-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.reader-view {
  margin-top: 16px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(18, 28, 33, 0.98), rgba(8, 13, 15, 0.96)),
    var(--surface-strong);
}

.app-shell.reader-mode .reader-view {
  margin-top: 0;
}

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px;
  color: var(--ink-inverse);
  background:
    linear-gradient(135deg, rgba(37, 193, 179, 0.13), transparent 38%),
    linear-gradient(115deg, rgba(217, 121, 67, 0.15), transparent 60%),
    rgba(6, 10, 12, 0.82);
  border-bottom: 1px solid rgba(255, 250, 240, 0.1);
}

.reader-head h2 {
  margin: 4px 0 0;
  color: var(--ink-inverse);
  font-size: 25px;
  font-weight: 840;
}

.reader-head .ghost-button {
  color: var(--ink-inverse);
  border-color: rgba(255, 250, 240, 0.18);
  background: rgba(255, 250, 240, 0.08);
}

.reader-head .ghost-button:hover {
  background: rgba(255, 250, 240, 0.14);
}

.reader-kicker {
  color: rgba(255, 250, 240, 0.64);
  font-size: 12px;
  letter-spacing: 0;
}

.reader-content {
  padding: 0 18px 22px;
  background: rgba(6, 10, 12, 0.58);
}

.reader-nav {
  position: sticky;
  top: 0;
  z-index: 7;
  display: flex;
  gap: 8px;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 12px 0;
  overflow-x: auto;
  background: rgba(6, 10, 12, 0.86);
  border-bottom: 1px solid rgba(255, 250, 240, 0.1);
  backdrop-filter: blur(18px);
  scrollbar-width: none;
}

.reader-nav::-webkit-scrollbar {
  display: none;
}

.reader-nav a {
  flex: 0 0 auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 250, 240, 0.11);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.055);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

.reader-nav a:hover {
  color: #07100f;
  border-color: rgba(37, 193, 179, 0.64);
  background: linear-gradient(135deg, var(--teal), #d4d6c4);
}

.reader-section {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 22px 0;
  border-bottom: 1px solid rgba(255, 250, 240, 0.08);
  scroll-margin-top: 68px;
}

.reader-section:last-child {
  border-bottom: 0;
}

.reader-section h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 18px;
}

.reader-section p {
  margin: 0 0 10px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title-row h3 {
  margin: 0;
}

.section-title-row > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.hero-reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  gap: 18px;
  align-items: start;
  padding-top: 22px;
}

.hero-reader h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 30px;
}

.reader-metrics,
.inline-facts,
.truth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.reader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.reader-card {
  position: relative;
  border: 1px solid rgba(255, 250, 240, 0.1);
  border-radius: 8px;
  padding: 15px;
  background:
    linear-gradient(180deg, rgba(26, 38, 43, 0.88), rgba(12, 18, 21, 0.82));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
}

.reader-card h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 16px;
}

.reader-card details {
  margin-top: 10px;
}

.truth-recap {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: rgba(217, 121, 67, 0.1);
}

.truth-recap p {
  margin: 0 0 8px;
}

.truth-recap p:last-child {
  margin-bottom: 0;
}

.reader-card summary,
.spoiler-box summary {
  cursor: pointer;
  color: #bff6f0;
  font-weight: 760;
}

.chapter-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 250, 240, 0.1);
}

.chapter-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.chapter-title-row span {
  flex: 0 0 auto;
  border: 1px solid rgba(37, 193, 179, 0.24);
  border-radius: 999px;
  padding: 3px 7px;
  color: #bff6f0;
  background: rgba(37, 193, 179, 0.09);
  font-size: 12px;
}

.mini-list {
  margin-top: 10px;
}

.mini-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.mini-list ul {
  margin: 0;
  padding-left: 18px;
}

.stage-group-stack,
.evidence-rounds,
.evidence-stack,
.timeline-list {
  display: grid;
  gap: 10px;
}

.stage-group {
  border: 1px solid rgba(255, 250, 240, 0.1);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 15px;
  background:
    linear-gradient(135deg, rgba(142, 163, 186, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(24, 36, 41, 0.9), rgba(10, 16, 18, 0.84));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
}

.reading-group {
  border-left-color: var(--teal);
}

.evidence-round {
  border-left-color: var(--accent);
}

.unassigned-round {
  border-left-color: var(--amber);
}

.stage-group-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.stage-group-head h4 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 17px;
}

.stage-group-head p {
  margin: 0;
}

.stage-group-head > strong {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.stage-chip {
  min-width: 46px;
  border: 1px solid rgba(255, 250, 240, 0.1);
  border-radius: 999px;
  padding: 5px 9px;
  color: #07100f;
  background: linear-gradient(135deg, var(--teal), #cfd8c7);
  font-size: 12px;
  font-weight: 820;
  text-align: center;
}

.dispatch-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.dispatch-notes span {
  border: 1px solid rgba(37, 193, 179, 0.2);
  border-radius: 999px;
  padding: 4px 8px;
  color: #bff6f0;
  background: rgba(37, 193, 179, 0.08);
  font-size: 12px;
}

.chapter-dispatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.chapter-dispatch-grid article {
  border: 1px solid rgba(255, 250, 240, 0.1);
  border-radius: 6px;
  padding: 10px;
  background: rgba(255, 250, 240, 0.055);
}

.chapter-dispatch-grid span,
.chapter-dispatch-grid p {
  color: var(--muted);
  font-size: 12px;
}

.chapter-dispatch-grid strong {
  display: block;
  margin: 4px 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.empty-stage-note {
  margin: 0;
  color: var(--muted);
}

.card-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.card-title-row span {
  flex: 0 0 auto;
  border: 1px solid rgba(217, 121, 67, 0.25);
  border-radius: 999px;
  padding: 3px 8px;
  color: #ffd0ad;
  background: rgba(217, 121, 67, 0.1);
  font-size: 12px;
}

.evidence-card {
  background:
    linear-gradient(135deg, rgba(217, 121, 67, 0.08), transparent 35%),
    linear-gradient(180deg, rgba(30, 40, 43, 0.92), rgba(12, 18, 21, 0.86));
}

.timeline-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 250, 240, 0.09);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item > span {
  color: #bff6f0;
  font-weight: 780;
}

.timeline-item p {
  margin: 4px 0 0;
}

.spoiler-box {
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(243, 107, 120, 0.08), transparent 35%),
    linear-gradient(180deg, rgba(26, 38, 43, 0.9), rgba(11, 17, 20, 0.84));
}

@keyframes progressSlide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(280%);
  }
}

@media (max-width: 820px) {
  .auth-view {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 220px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .generator-panel {
    position: static;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-reader {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  :root {
    --tap: 50px;
  }

  body {
    background:
      linear-gradient(180deg, rgba(3, 5, 6, 0.96), rgba(7, 12, 14, 0.98) 38%, rgba(15, 16, 15, 0.98)),
      repeating-linear-gradient(90deg, rgba(223, 180, 92, 0.03) 0 1px, transparent 1px 64px),
      repeating-linear-gradient(0deg, rgba(37, 193, 179, 0.025) 0 1px, transparent 1px 64px),
      var(--bg);
  }

  .app-shell {
    width: 100%;
    padding: calc(10px + env(safe-area-inset-top)) 12px calc(86px + env(safe-area-inset-bottom));
  }

  .app-shell.reader-mode {
    width: 100%;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .auth-view {
    width: 100%;
    min-height: 100dvh;
    padding: calc(18px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  }

  .auth-brand {
    min-height: auto;
    padding: 22px;
  }

  .auth-brand::before {
    inset: 12px;
  }

  .brand-mark,
  .brand-logo {
    width: 68px;
    height: 68px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-soft);
  }

  .auth-brand h1 {
    font-size: 42px;
  }

  .auth-brand p {
    font-size: 15px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 8;
    margin: -10px -12px 12px;
    padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
    border-radius: 0 0 8px 8px;
    border-inline: 0;
    border-top: 0;
    background:
      linear-gradient(135deg, rgba(37, 193, 179, 0.1), transparent 36%),
      linear-gradient(115deg, rgba(217, 121, 67, 0.14), transparent 58%),
      rgba(8, 13, 15, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.36);
  }

  .topbar h1 {
    font-size: 24px;
  }

  .topbar-logo {
    width: 42px;
    height: 42px;
  }

  .topbar p {
    margin-top: 4px;
    font-size: 13px;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
  }

  .status-pill,
  .user-pill {
    min-width: 0;
    overflow: hidden;
    justify-content: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 9px 10px;
  }

  .tabbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 20;
    margin: 0;
    padding: 6px;
    border-color: rgba(255, 250, 240, 0.14);
    border-radius: 8px;
    background: rgba(8, 13, 15, 0.88);
    backdrop-filter: blur(20px);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  }

  .tab-button {
    flex: 1;
    border-radius: 6px;
    padding: 8px 6px;
    color: var(--muted);
    font-size: 13px;
  }

  .tab-button.active {
    color: #07100f;
    background: linear-gradient(135deg, var(--teal), #d8d2ba);
  }

  .field-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .reader-head {
    align-items: stretch;
    flex-direction: column;
  }

  .generator-panel,
  .output-panel,
  .library-panel,
  .reader-content {
    padding: 16px;
  }

  .app-shell.reader-mode .reader-content {
    padding: 0 12px 18px;
  }

  .reader-nav {
    position: static;
    width: 100%;
  }

  .panel-head,
  .section-title-row {
    align-items: start;
  }

  .section-title-row {
    flex-direction: column;
  }

  .segmented {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .segmented label {
    font-size: 14px;
  }

  .job-stage-head,
  .state-row,
  .card-title-row,
  .stage-group-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .job-stage-head > span {
    max-width: none;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .reader-grid,
  .library-grid,
  .chapter-dispatch-grid {
    grid-template-columns: 1fr;
  }
}
