:root {
  --ink: #181b19;
  --paper: #f4f4ef;
  --surface: #fffefa;
  --muted: #717872;
  --line: #d6d8d1;
  --line-dark: #393f3b;
  --mint: #5ed6a2;
  --mint-soft: #e4f7ef;
  --mint-dark: #176e50;
  --coral: #ff6b4a;
  --coral-soft: #ffe7e0;
  --yellow: #f3c94b;
  --red: #b63d2a;
  --sidebar: 220px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 15px;
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 15px;
  font-weight: 900;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--mint);
  color: var(--ink);
  font-size: 11px;
}

.nav {
  margin-top: 30px;
  display: grid;
  gap: 5px;
}

.nav a {
  padding: 12px;
  border-radius: 4px;
  color: #afb6b0;
  text-decoration: none;
  font-size: 13px;
  font-weight: 760;
}

.nav a span {
  display: inline-grid;
  width: 24px;
  color: var(--mint);
  font-weight: 900;
}

.nav a:hover,
.nav a.active {
  background: #2d322f;
  color: #fff;
}

.sidebar-status {
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--line-dark);
  display: grid;
  gap: 5px;
  color: #939b95;
  font-size: 10px;
  line-height: 1.4;
}

.sidebar-status strong {
  color: #f3f5f3;
  font-size: 11px;
}

.main { min-width: 0; }
.mobile-header { display: none; }
.view { min-height: 100vh; }

.page-header {
  min-height: 82px;
  padding: 18px clamp(22px, 3.4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(23px, 2.4vw, 34px);
  line-height: 1.12;
}

.page-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.button,
.icon-button {
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid #c8cbc4;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
}

.button:hover,
.icon-button:hover { border-color: var(--ink); }

.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.button.approve {
  border-color: var(--mint-dark);
  background: var(--mint);
  color: #0d3d2d;
}

.button.danger {
  border-color: #d9b2aa;
  color: var(--red);
}

.button.wide { width: 100%; }

.save-state {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.page-body {
  padding: clamp(22px, 3.4vw, 48px);
}

.section-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.workspace {
  min-height: calc(100vh - 82px);
  display: grid;
  grid-template-columns: 214px minmax(420px, 1fr) 330px;
  background: var(--surface);
}

.stage-panel,
.feedback-panel {
  min-width: 0;
  padding: 28px 22px;
  background: var(--paper);
}

.stage-panel { border-right: 1px solid var(--line); }
.feedback-panel { border-left: 1px solid var(--line); }

.stage-rail {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
}

.stage-rail li {
  position: relative;
  min-height: 82px;
  padding-left: 42px;
  color: #9a9f9a;
}

.stage-rail li::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 30px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.stage-rail li:last-child::after { display: none; }

.stage-marker {
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  width: 29px;
  height: 29px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
}

.stage-rail li.active { color: var(--ink); }
.stage-rail li.active .stage-marker {
  border-color: var(--coral);
  background: var(--coral);
  color: #fff;
}

.stage-rail li.done { color: var(--ink); }
.stage-rail li.done .stage-marker {
  border-color: var(--mint-dark);
  background: var(--mint);
  color: var(--mint-dark);
}

.stage-rail strong,
.stage-rail small { display: block; }
.stage-rail strong { padding-top: 5px; font-size: 12px; }
.stage-rail small { margin-top: 6px; font-size: 9px; line-height: 1.45; }

.memory-applied {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.memory-applied p {
  margin: 11px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--mint);
  color: #5f665f;
  font-size: 9px;
  line-height: 1.55;
}

.editor-panel {
  min-width: 0;
  padding: 26px clamp(26px, 3vw, 44px) 38px;
  background: var(--surface);
}

.work-fields {
  display: grid;
  grid-template-columns: minmax(190px, .75fr) minmax(260px, 1.25fr);
  gap: 16px;
}

.work-fields label,
.document-editor,
.feedback-input {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}

input { height: 42px; padding: 0 12px; }
textarea { padding: 12px; resize: vertical; line-height: 1.6; }
select { height: 42px; padding: 0 12px; }

input:focus,
textarea:focus,
select:focus {
  border-color: var(--mint-dark);
  box-shadow: 0 0 0 2px rgba(94, 214, 162, .16);
}

.editor-toolbar {
  margin-top: 24px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
}

.segmented button {
  min-width: 65px;
  min-height: 31px;
  padding: 6px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 850;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(20, 23, 21, .1);
}

.editor-actions {
  display: flex;
  gap: 7px;
}

.document-editor { margin-top: 18px; }

.document-editor textarea {
  min-height: 480px;
  padding: 28px clamp(22px, 3vw, 40px);
  border-color: #e0e1dc;
  background: #fbfbf8;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.9;
}

.compare-editor {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.compare-editor label {
  min-width: 0;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.read-document {
  min-height: 480px;
  padding: 28px;
  border: 1px solid #e0e1dc;
  background: #fbfbf8;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.85;
}

.read-document.revision {
  border-top: 3px solid var(--mint);
  background: #f8fcfa;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2 {
  margin: 6px 0 0;
  font-size: 20px;
}

.feedback-count {
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.panel-help {
  margin: 16px 0 20px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.feedback-input textarea {
  min-height: 115px;
  background: var(--surface);
}

.feedback-panel > .button { margin-top: 10px; }

.quiet-empty {
  margin-top: 24px;
  padding: 30px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: #929893;
  text-align: center;
  font-size: 10px;
  line-height: 1.65;
}

.feedback-history {
  margin-top: 26px;
  display: grid;
  gap: 10px;
}

.feedback-history blockquote {
  margin: 0;
  padding: 12px;
  border-left: 3px solid var(--coral);
  background: var(--surface);
  font-size: 10px;
  line-height: 1.55;
}

.feedback-history footer {
  margin-top: 8px;
  color: var(--coral);
  font-size: 9px;
  font-weight: 850;
}

.learning-proposal {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid #e3c0b7;
  border-top: 4px solid var(--coral);
  background: var(--surface);
}

.learning-proposal.approved {
  border-color: #9fd6bd;
  border-top-color: var(--mint);
}

.proposal-label {
  margin-bottom: 10px;
  color: var(--coral);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.learning-proposal.approved .proposal-label { color: var(--mint-dark); }

.learning-proposal > strong {
  display: block;
  font-size: 12px;
  line-height: 1.55;
}

.learning-proposal dl {
  margin: 16px 0;
  display: grid;
  gap: 9px;
}

.learning-proposal dl div {
  padding-top: 9px;
  border-top: 1px solid #e5e6e0;
}

.learning-proposal dt {
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
}

.learning-proposal dd {
  margin: 4px 0 0;
  font-size: 9px;
  line-height: 1.5;
}

.proposal-actions {
  display: grid;
  grid-template-columns: .6fr 1.4fr;
  gap: 7px;
}

.empty-state {
  min-height: 60vh;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-state h2 { margin: 0; }
.empty-state p { color: var(--muted); font-size: 12px; }

.history-list {
  display: grid;
  gap: 0;
}

.history-row {
  width: 100%;
  min-height: 94px;
  padding: 18px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  grid-template-columns: 120px 1fr 140px 34px;
  align-items: center;
  gap: 20px;
  text-align: left;
}

.history-row:hover { background: rgba(255, 255, 255, .55); }

.history-stage {
  color: var(--coral);
  font-size: 10px;
  font-weight: 900;
}

.history-main strong,
.history-main small { display: block; }
.history-main strong { font-size: 15px; }
.history-main small {
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-stats {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.row-arrow { font-size: 18px; }

.memory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: clamp(30px, 5vw, 74px);
}

.memory-header {
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: end;
  justify-content: space-between;
}

.memory-header h2 { margin: 7px 0 0; font-size: 24px; }
.memory-header > strong { font-size: 42px; line-height: 1; }

.memory-list { display: grid; }

.memory-row {
  min-height: 96px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 42px 1fr 38px;
  align-items: center;
  gap: 15px;
}

.memory-index {
  color: var(--mint-dark);
  font-size: 10px;
  font-weight: 900;
}

.memory-row strong,
.memory-row small { display: block; }
.memory-row strong { font-size: 13px; line-height: 1.5; }
.memory-row small { margin-top: 6px; color: var(--muted); font-size: 9px; }
.memory-row .icon-button { min-width: 34px; padding: 6px; font-size: 17px; }

.memory-guide {
  padding: 26px;
  border-left: 4px solid var(--mint);
  background: var(--surface);
  align-self: start;
}

.memory-guide h3 { margin: 12px 0; font-size: 20px; }
.memory-guide p { color: var(--muted); font-size: 11px; line-height: 1.7; }
.memory-guide dl { margin: 24px 0 0; }

.memory-guide dl div {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 10px;
}

.memory-guide dt { color: var(--muted); }
.memory-guide dd { margin: 0; font-weight: 850; }

.settings-layout {
  max-width: 1000px;
  display: grid;
}

.settings-section {
  min-height: 126px;
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 34px;
}

.settings-section h2 { margin: 0; font-size: 17px; }
.settings-section p { max-width: 600px; margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.settings-actions { display: flex; gap: 8px; }
.file-button { position: relative; display: inline-flex; align-items: center; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.privacy-state { color: var(--mint-dark); font-size: 11px; font-weight: 900; }
.danger-zone { border-bottom-color: #d9b2aa; }

.github-sync-section {
  padding-block: 32px;
  grid-template-columns: minmax(220px, .72fr) minmax(420px, 1.28fr);
  align-items: start;
}

.github-section-copy h2 { margin-top: 8px; }

.github-form {
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  gap: 14px;
}

.github-form label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.github-form input {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
}

.github-form input:focus {
  outline: 2px solid var(--mint);
  outline-offset: 1px;
}

.github-form-row {
  display: grid;
  grid-template-columns: minmax(100px, .45fr) minmax(220px, 1fr);
  gap: 12px;
}

.token-help,
.sync-meta {
  margin: -3px 0 0 !important;
  font-size: 9px !important;
}

.github-status {
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #f6f6f1;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a1a7a2;
  flex: 0 0 auto;
}

.github-status.connected {
  border-color: #9bcdb9;
  background: var(--mint-soft);
  color: var(--mint-dark);
}

.github-status.connected .status-dot { background: var(--mint-dark); }

.github-status.error {
  border-color: #deb1a6;
  background: var(--coral-soft);
  color: var(--red);
}

.github-status.error .status-dot { background: var(--red); }

.github-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.github-actions .danger-link {
  margin-left: auto;
  border-color: transparent;
  color: var(--red);
}

.github-actions button:disabled {
  cursor: wait;
  opacity: .55;
}

.import-preview {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--mint-dark);
  background: var(--mint-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  font-size: 11px;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  padding: 28px;
  background: rgba(17, 20, 18, .68);
  display: grid;
  place-items: center;
}

.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 56px);
  padding: 26px;
  overflow: auto;
  border: 1px solid #343a36;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .28);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.modal-head h2 {
  margin: 7px 0 0;
  font-size: 22px;
}

.modal-head .icon-button {
  min-width: 36px;
  padding: 6px;
  font-size: 18px;
}

.modal-help {
  margin: 18px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.modal > label,
#handoff-link-area label {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.handoff-summary {
  margin-top: 16px;
  padding: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

#handoff-link-area .button { margin-top: 8px; }

.link-warning {
  margin: 8px 0 0;
  color: var(--red);
  font-size: 9px;
}

.modal-actions {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.agent-brief {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 58px);
  display: grid;
  gap: 18px;
}

.agent-mission {
  padding: clamp(26px, 4vw, 48px);
  background: var(--ink);
  color: #fff;
}

.agent-mission .section-label { color: var(--mint); }
.agent-mission h2 { margin: 12px 0 0; font-size: clamp(30px, 4vw, 52px); }
.agent-mission p { max-width: 800px; margin: 18px 0 0; color: #c6cdc7; font-size: 14px; line-height: 1.7; }

.brief-section {
  padding: 26px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.brief-section h3 { margin: 10px 0 0; font-size: 18px; line-height: 1.45; }
.brief-section > p { color: var(--muted); font-size: 11px; line-height: 1.7; }

.brief-meta { margin: 20px 0 0; }
.brief-meta div { padding: 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 110px 1fr; gap: 18px; }
.brief-meta dt { color: var(--muted); font-size: 10px; font-weight: 800; }
.brief-meta dd { margin: 0; font-size: 11px; line-height: 1.55; }

.brief-documents {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.brief-document {
  min-height: 260px;
  margin-top: 14px;
  padding: 22px;
  border-top: 2px solid var(--ink);
  background: #f7f7f3;
  font-size: 13px;
  line-height: 1.8;
}

.brief-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.brief-list blockquote {
  margin: 0;
  padding: 14px;
  border-left: 3px solid var(--coral);
  background: #f8f8f4;
  font-size: 11px;
  line-height: 1.6;
}

.brief-list footer { margin-top: 8px; color: var(--coral); font-size: 9px; font-weight: 850; }

.memory-brief { border-top: 4px solid var(--mint); }
.memory-brief ol { margin: 16px 0 0; padding-left: 22px; }
.memory-brief li { padding: 10px 0; font-size: 12px; line-height: 1.55; }
.memory-brief small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }

.rule-list { margin: 16px 0 0; padding-left: 20px; color: var(--muted); font-size: 11px; line-height: 1.75; }

.return-contract {
  padding: 26px;
  border: 2px solid var(--ink);
  background: var(--surface);
}

.return-contract h3 { margin: 10px 0 18px; font-size: 17px; }
.return-contract pre {
  margin: 0;
  padding: 20px;
  overflow: auto;
  background: var(--ink);
  color: #dce3de;
  font: 10px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 750;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .18s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* Comic workspace */
.comic-shell {
  min-height: calc(100vh - 82px);
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--surface);
}

.comic-sidebar {
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.comic-sidebar select { width: 100%; margin-top: 8px; }
.episode-switcher { display: grid; gap: 6px; margin-top: 14px; }
.episode-chip {
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.episode-chip strong, .episode-chip span { display: block; }
.episode-chip strong { font-size: 10px; }
.episode-chip span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.episode-chip.active { border-color: var(--line); background: var(--surface); }
.stage-label { display: block; margin-top: 28px; }
.comic-stage-rail li { padding-left: 0; }
.comic-stage-rail .stage-link {
  position: relative;
  width: 100%;
  min-height: 68px;
  padding: 0 0 0 42px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.comic-stage-rail .stage-link > span:last-child { display: grid; }
.comic-stage-rail .stage-marker { pointer-events: none; }
.comic-stage-rail small { margin-top: 4px; }

.comic-main { min-width: 0; padding: 28px clamp(22px, 3.4vw, 48px) 60px; }
.next-action-band {
  min-height: 112px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 2px solid var(--ink);
  background: var(--mint-soft);
}
.next-action-band h2 { margin: 5px 0; font-size: 21px; }
.next-action-band p { margin: 0; color: var(--muted); font-size: 11px; }
.comic-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}
.comic-stats div { padding: 18px 0; }
.comic-stats strong, .comic-stats span { display: block; }
.comic-stats strong { font-size: 22px; }
.comic-stats span { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 800; }
.comic-stage-content { padding-top: 30px; }
.stage-heading, .section-head, .review-card-head, .panel-qa-box > div:first-child {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.stage-heading h2, .section-head h3 { margin: 5px 0 0; }
.section-head > span { font-weight: 900; }
.comic-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.comic-form-grid .full { grid-column: 1 / -1; }
.artifact-section { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.bible-snapshot-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr); gap: 24px; margin-top: 22px; padding: 20px; border: 1px solid var(--line); background: var(--mint-soft); }
.bible-snapshot-card h3 { margin: 5px 0; }
.bible-snapshot-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.bible-snapshot-card ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.bible-snapshot-card li { padding-bottom: 8px; border-bottom: 1px solid #c9dfd4; }
.bible-snapshot-card li:last-child { padding-bottom: 0; border: 0; }
.bible-snapshot-card strong, .bible-snapshot-card small { display: block; }
.bible-snapshot-card small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.character-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 16px; }
.character-tile { display: grid; grid-template-columns: 116px 1fr; gap: 14px; align-items: start; }
.character-tile img { width: 116px; aspect-ratio: 2 / 3; object-fit: cover; border: 1px solid var(--line); }
.character-tile strong, .character-tile small { display: block; }
.character-tile small { margin-top: 4px; color: var(--coral); font-size: 9px; font-weight: 850; }
.character-tile p { color: var(--muted); font-size: 10px; line-height: 1.6; }
.asset-placeholder { min-height: 110px; display: grid; place-items: center; background: #e9eae4; color: var(--muted); font-size: 10px; }
.storyboard-list { margin-top: 14px; border-top: 1px solid var(--line); }
.storyboard-list article { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.storyboard-list article > span { color: var(--coral); font-weight: 900; }
.storyboard-list small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.production-reference-strip { display: flex; gap: 10px; margin-top: 20px; overflow-x: auto; }
.production-reference-strip > div { width: 76px; flex: 0 0 auto; }
.production-reference-strip img { width: 76px; height: 76px; object-fit: cover; border: 1px solid var(--line); }
.production-reference-strip span { display: block; margin-top: 4px; font-size: 9px; }
.panel-production-list { margin-top: 22px; border-top: 1px solid var(--line); }
.production-panel-row { display: grid; grid-template-columns: 42px 100px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.panel-order { color: var(--coral); font-weight: 900; }
.production-thumb img { display: block; width: 100px; height: 120px; object-fit: cover; }
.production-panel-row p, .production-panel-row small { color: var(--muted); font-size: 9px; }
.compact-empty { margin-top: 22px; padding: 40px 20px; }
.review-rule { color: var(--mint-dark); font-size: 10px; font-weight: 900; }
.comic-review-card { padding: 30px 0; border-bottom: 1px solid var(--line); }
.review-card-head h3 { margin: 5px 0 0; font-size: 16px; }
.review-status { padding: 5px 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 9px; }
.review-status.approved, .review-status.selected { border-color: var(--mint-dark); color: var(--mint-dark); }
.review-status.regenerate { border-color: var(--red); color: var(--red); }
.candidate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.candidate { position: relative; margin: 0; border: 2px solid transparent; background: var(--paper); }
.candidate.selected { border-color: var(--mint-dark); }
.candidate img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center; }
.candidate-label { position: absolute; top: 9px; left: 9px; padding: 5px 8px; background: var(--ink); color: #fff; font-size: 9px; font-weight: 900; }
.candidate figcaption { min-height: 46px; padding: 10px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.review-reason { width: 100%; margin-top: 12px; }
.candidate-actions, .qa-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.panel-qa-box { margin-top: 18px; padding: 18px; border-left: 4px solid var(--yellow); background: #faf9f1; }
.panel-qa-box > div:first-child strong { color: var(--mint-dark); }
.qa-check-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.qa-check-grid label { font-size: 9px; }
.single-panel-preview img { width: min(420px, 100%); margin-top: 18px; }
.publish-gate { margin-top: 20px; padding: 22px; display: flex; justify-content: space-between; gap: 20px; border: 2px solid var(--line-dark); }
.publish-gate.ready { border-color: var(--mint-dark); background: var(--mint-soft); }
.publish-gate.blocked { border-color: #d9b2aa; background: var(--coral-soft); }
.publish-gate h3 { margin: 5px 0; }
.publish-gate p { margin: 0; color: var(--muted); font-size: 10px; }
.publish-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.comic-reader { width: min(720px, 100%); margin: 30px auto 0; background: #111; }
.comic-reader figure { position: relative; margin: 0; }
.comic-reader img { display: block; width: 100%; height: auto; }
.comic-reader figcaption { position: absolute; left: 50%; bottom: 5%; max-width: 80%; transform: translateX(-50%); padding: 8px 12px; border: 2px solid #111; border-radius: 50%; background: #fff; font-size: 12px; }
.reader-page { min-height: 100vh; background: #111; color: #fff; }
.reader-page > header { height: 54px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #333; }
.reader-page > header a { color: var(--mint); text-decoration: none; font-weight: 900; }
.reader-title { width: min(720px, calc(100% - 36px)); margin: 0 auto; padding: 48px 0 30px; }
.reader-title span { color: var(--mint); font-size: 10px; font-weight: 900; }
.reader-title h1 { margin: 8px 0; font-size: 34px; }
.reader-title p { color: #aeb4b0; }
.reader-page footer { padding: 46px 20px; color: #777; text-align: center; font-size: 9px; }
.brief-asset { padding: 12px 0; border-bottom: 1px solid var(--line); }
.brief-asset code { color: var(--mint-dark); font-size: 9px; overflow-wrap: anywhere; }
.wide-modal { width: min(820px, calc(100vw - 32px)); }
.generation-card-form { margin-top: 18px; padding: 18px; border-left: 4px solid var(--mint-dark); background: var(--mint-soft); }
.generation-card-form > p { margin: 7px 0 14px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.generation-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.generation-card-grid textarea { min-height: 74px; }
.generation-brief dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; margin: 14px 0 0; }
.generation-brief dl div { display: contents; }
.generation-brief dt { color: var(--coral); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.generation-brief dd { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

@media (max-width: 1180px) {
  :root { --sidebar: 190px; }
  .workspace { grid-template-columns: 180px minmax(390px, 1fr) 280px; }
  .stage-panel, .feedback-panel { padding: 24px 16px; }
  .editor-panel { padding-inline: 24px; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 170px minmax(0, 1fr); }
  .feedback-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .feedback-panel {
    display: grid;
    grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr);
    gap: 20px;
  }
  .feedback-panel .panel-heading,
  .feedback-panel .panel-help,
  .feedback-panel .feedback-input,
  .feedback-panel > .button { grid-column: 1; }
  .feedback-panel .quiet-empty,
  .feedback-panel .feedback-history,
  .feedback-panel .learning-proposal { grid-column: 2; grid-row: 1 / span 5; margin-top: 0; }
  .memory-layout { grid-template-columns: 1fr; }
  .comic-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .qa-check-grid { grid-template-columns: 1fr 1fr; }
  .generation-card-grid { grid-template-columns: 1fr; }
  .bible-snapshot-card { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 50;
    left: 0;
    width: min(82vw, 290px);
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-header {
    position: sticky;
    z-index: 40;
    top: 0;
    height: 62px;
    padding: 0 18px;
    background: var(--ink);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .mobile-header .icon-button {
    min-width: 38px;
    padding: 7px;
    border-color: #424944;
    background: transparent;
    color: #fff;
  }
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .actions { width: 100%; flex-wrap: wrap; }
  .workspace { display: block; }
  .stage-panel {
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .stage-rail {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .stage-rail li {
    min-height: 74px;
    padding: 36px 0 0;
  }
  .stage-rail li::after {
    left: 29px;
    right: -8px;
    top: 14px;
    bottom: auto;
    width: auto;
    height: 1px;
  }
  .stage-rail strong { font-size: 9px; }
  .stage-rail small,
  .memory-applied { display: none; }
  .editor-panel { padding: 20px 18px 30px; }
  .work-fields,
  .compare-editor,
  .feedback-panel,
  .settings-section { grid-template-columns: 1fr; }
  .editor-toolbar { align-items: stretch; flex-direction: column; }
  .editor-actions .button { flex: 1; }
  .document-editor textarea,
  .read-document { min-height: 360px; }
  .feedback-panel { display: block; padding: 24px 18px; }
  .feedback-panel .quiet-empty,
  .feedback-panel .feedback-history,
  .feedback-panel .learning-proposal { margin-top: 22px; }
  .history-row {
    grid-template-columns: 1fr 28px;
    gap: 8px;
  }
  .history-stage,
  .history-stats { grid-column: 1; }
  .history-main { grid-column: 1; }
  .row-arrow { grid-column: 2; grid-row: 1 / span 3; }
  .settings-section { align-items: start; }
  .settings-actions { flex-wrap: wrap; }
  .github-sync-section,
  .github-form-row { grid-template-columns: 1fr; }
  .github-actions .danger-link { margin-left: 0; }
  .modal-backdrop { padding: 12px; }
  .modal { max-height: calc(100vh - 24px); padding: 20px; }
  .brief-documents { grid-template-columns: 1fr; }
  .brief-document { min-height: 180px; }
  .agent-brief { padding: 18px; }
  .comic-shell { display: block; }
  .comic-sidebar { padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .episode-switcher { display: flex; overflow-x: auto; }
  .episode-chip { min-width: 140px; }
  .comic-stage-rail { grid-template-columns: repeat(4, 1fr); }
  .comic-stage-rail .stage-link { min-height: 72px; padding: 38px 0 0; text-align: center; }
  .comic-main { padding: 18px 18px 40px; }
  .next-action-band, .stage-heading, .publish-gate { align-items: stretch; flex-direction: column; }
  .comic-stats { grid-template-columns: repeat(2, 1fr); }
  .comic-form-grid, .publish-form, .candidate-grid { grid-template-columns: 1fr; }
  .production-panel-row { grid-template-columns: 34px 82px minmax(0, 1fr); gap: 10px; }
  .production-panel-row > .button { grid-column: 2 / -1; }
  .production-thumb img { width: 82px; height: 100px; }
  .qa-check-grid { grid-template-columns: 1fr 1fr; }
  .candidate-actions .button { flex: 1 1 42%; }
  .character-tile { grid-template-columns: 92px 1fr; }
  .character-tile img { width: 92px; }
}
