:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-muted: #f2f2f4;
  --surface-raised: #fbfbfc;
  --ink: #19191d;
  --ink-soft: #4d4d57;
  --muted: #74747f;
  --faint: #9b9ba5;
  --line: #e4e4e8;
  --line-strong: #d4d4da;
  --accent: #5d55d6;
  --accent-hover: #4f47c8;
  --accent-soft: #eeedff;
  --accent-ink: #443db0;
  --success: #18835d;
  --success-soft: #e7f6f0;
  --warning: #a6670b;
  --warning-soft: #fff3df;
  --danger: #b63a4a;
  --danger-soft: #fff0f2;
  --shadow-sm: 0 1px 2px rgba(20, 20, 25, .04), 0 5px 15px rgba(20, 20, 25, .04);
  --shadow-lg: 0 24px 80px rgba(23, 23, 30, .16), 0 4px 20px rgba(23, 23, 30, .08);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", SimSun, serif;
}

/* V1.4 stability and story-intelligence controls */
.work-switch-actions,.finding-actions,.memory-item-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.work-switch-actions{padding:0 0 14px}
.finding-actions{margin-top:9px}
.evidence-highlight{background:#fff1b8!important;box-shadow:0 0 0 4px #fff1b8;border-radius:4px;transition:background .2s}
.overview-note{color:var(--muted);font-size:13px;margin:-4px 0 18px}
.relationship-tree{--tree-line:var(--line-strong);display:grid;justify-items:center;min-width:0;gap:0}
.relationship-root{display:grid;justify-items:center;gap:4px;min-width:188px;max-width:min(100%,360px);padding:14px 20px;border:1px solid var(--line-strong);background:var(--surface-raised);border-radius:12px;text-align:center}
.relationship-root strong{font-size:17px}.relationship-root small{color:var(--muted)}
.relationship-node-type{color:var(--accent-ink);font-size:11px;font-weight:700}
.relationship-branches{position:relative;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px;width:100%;padding-top:42px}
.relationship-branches::before{content:"";position:absolute;top:0;left:50%;height:21px;border-left:2px solid var(--tree-line)}
.relationship-branches::after{content:"";position:absolute;top:20px;left:10%;right:10%;border-top:2px solid var(--tree-line)}
.relationship-branch{position:relative;min-width:0;border:1px solid var(--line);border-radius:11px;padding:0;background:var(--surface-raised)}
.relationship-branch::before{content:"";position:absolute;left:50%;top:-22px;height:22px;border-left:2px solid var(--tree-line)}
.relationship-branch>summary{display:flex;align-items:center;justify-content:space-between;gap:5px;min-height:55px;padding:10px;cursor:pointer;list-style:none;color:var(--ink);font-size:12px;font-weight:700}
.relationship-branch>summary::-webkit-details-marker{display:none}
.relationship-branch>summary small{color:var(--muted);font-size:10px;font-weight:500;white-space:nowrap}
.relationship-branch>summary::before{content:"▾";color:var(--accent);font-size:12px}
.relationship-branch:not([open])>summary::before{content:"▸"}
.relationship-leaves{position:relative;display:grid;gap:10px;margin:0 10px 12px;padding:14px 0 0 18px;border-top:1px solid var(--line)}
.relationship-leaves::before{content:"";position:absolute;top:0;bottom:19px;left:6px;border-left:2px solid var(--tree-line)}
.relationship-person{position:relative;display:grid;width:100%;min-width:0;gap:3px;padding:10px;border:1px solid var(--line);border-radius:9px;text-align:left;color:var(--ink);background:#fff;overflow-wrap:anywhere}
.relationship-person:hover{border-color:var(--accent);background:var(--surface-raised)}
.relationship-person::before{content:"";position:absolute;top:20px;left:-13px;width:12px;border-top:2px solid var(--tree-line)}
.relationship-person strong{font-size:12px}.relationship-person span{color:var(--muted);font-size:10px}
.relationship-person em{width:max-content;padding:2px 5px;border-radius:5px;color:#805b19;background:#fff2d8;font-size:10px;font-style:normal}
.relationship-empty{margin:0;color:var(--muted);font-size:11px}
.relationship-sheet-body{display:grid;gap:18px;font-size:13px;line-height:1.6}
.relationship-facts{display:grid;gap:0;margin:0}
.relationship-facts>div{display:grid;grid-template-columns:88px minmax(0,1fr);gap:12px;padding:12px 0;border-bottom:1px solid var(--line)}
.relationship-facts dt{color:var(--muted)}.relationship-facts dd{min-width:0;margin:0;overflow-wrap:anywhere}
.relationship-trust{display:inline-flex;padding:3px 7px;border-radius:6px;font-size:12px}
.relationship-trust.confirmed{color:var(--success);background:var(--success-soft)}
.relationship-trust.pending{color:var(--warning);background:var(--warning-soft)}
.relationship-evidence{padding:14px;border:1px solid var(--line);border-radius:10px;background:var(--surface-raised)}
.relationship-evidence h3{margin:0 0 9px;font-size:13px}.relationship-evidence p{margin:0 0 10px;overflow-wrap:anywhere}
.relationship-evidence small,.relationship-sheet-note{color:var(--muted);font-size:12px}
.relationship-evidence-context{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.9}
.relationship-evidence-context mark{padding:2px 3px;border-radius:3px;background:#fff0ae;color:var(--ink)}
.relationship-add{margin-top:18px}
.candidate-event-card{margin:18px 0;border-color:var(--line);background:var(--surface-raised)}
.candidate-memory-summary{padding:12px;border:1px solid var(--line);border-radius:10px;background:var(--surface-raised)}
.candidate-memory-summary p{margin:0 0 8px;color:var(--ink-soft);font-size:12px}
.memory-history{margin:18px 0;border:1px solid var(--line);border-radius:14px;padding:14px 18px;background:var(--surface)}
.memory-history summary{cursor:pointer;font-weight:700;display:flex;justify-content:space-between}
.memory-history article{display:grid;grid-template-columns:minmax(120px,1fr) 1fr 1fr;gap:12px;padding:10px 0;border-top:1px solid var(--line);font-size:13px}
.memory-history article:first-of-type{margin-top:12px}
.memory-history article span,.memory-history article small{color:var(--muted)}
@media (max-width:1100px){.relationship-branches{grid-template-columns:1fr;max-width:680px;gap:12px;padding-top:26px}.relationship-branches::before{top:0;bottom:0;height:auto}.relationship-branches::after{display:none}.relationship-branch::before{top:-13px;height:13px}}
@media (max-width:720px){.memory-history article{grid-template-columns:1fr}.work-switch-actions{flex-direction:column;align-items:stretch}.relationship-branches{grid-template-columns:1fr;gap:10px;padding:20px 0 0 18px}.relationship-branches::before{left:5px;top:0;bottom:22px;height:auto}.relationship-branches::after{display:none}.relationship-branch::before{left:-14px;top:25px;width:13px;height:0;border-left:0;border-top:2px solid var(--tree-line)}}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; overflow-x: hidden; color: var(--ink); background: var(--bg); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body:has(.modal-layer:not([hidden])) { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [contenteditable]:focus-visible { outline: 3px solid rgba(93, 85, 214, .22); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.prototype-banner { height: 28px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 12px; color: var(--accent-ink); background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 650; letter-spacing: .01em; }
.prototype-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(119, 110, 232, .12); }

.app-shell { min-height: calc(100vh - 28px); display: grid; grid-template: 58px 1fr / 64px minmax(0, 1fr); }
.app-header { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr); align-items: center; gap: 20px; height: 58px; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .9); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 30; }
.brand { justify-self: start; display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand-glyph { width: 28px; height: 30px; display: grid; place-items: center; border-radius: 8px 8px 10px 8px; color: white; background: var(--ink); font-family: Georgia, serif; font-size: 15px; }
.brand-copy { display: grid; gap: 1px; line-height: 1.1; }
.brand-copy strong { font-size: 13px; font-weight: 720; letter-spacing: -.02em; }
.brand-copy strong b { color: var(--muted); font-weight: 620; }
.brand-copy small { color: var(--faint); font-size: 8px; font-weight: 620; letter-spacing: .02em; }
.work-identity { justify-self: center; min-width: 0; display: flex; align-items: center; gap: 9px; }
.work-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 660; }
.sync-state { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.sync-state i { width: 5px; height: 5px; border-radius: 50%; background: var(--success); }
.sync-state.unsaved i { background: var(--warning); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 7px; }
.demo-switcher { height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 7px 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface-raised); }
.demo-switcher span { font-size: 10px; font-weight: 650; white-space: nowrap; }
.demo-switcher select { max-width: 126px; border: 0; outline: 0; color: var(--ink-soft); background: transparent; font-size: 11px; font-weight: 650; }
.icon-button, .avatar, .rail-button { border: 0; color: var(--muted); background: transparent; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; position: relative; border-radius: 8px; }
.icon-button:hover, .rail-button:hover { color: var(--ink); background: var(--surface-muted); }
.notification-dot { position: absolute; top: 7px; right: 7px; width: 5px; height: 5px; border: 1.5px solid white; border-radius: 50%; background: var(--warning); }
.avatar { width: 30px; height: 30px; margin-left: 3px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #383340, #725e82); font-size: 11px; font-weight: 700; }

.navigation-rail { grid-row: 2; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 12px 9px; border-right: 1px solid var(--line); background: #fafafb; position: sticky; top: 58px; height: calc(100vh - 86px); z-index: 15; }
.rail-primary, .rail-secondary { display: grid; gap: 8px; }
.rail-button { width: 42px; height: 42px; display: grid; place-items: center; position: relative; border-radius: 10px; }
.rail-button.active { color: var(--accent-ink); background: var(--accent-soft); }
.rail-button::after { content: attr(data-tooltip); position: absolute; left: 50px; top: 50%; padding: 6px 8px; opacity: 0; transform: translate(-3px, -50%); pointer-events: none; border: 1px solid var(--line); border-radius: 7px; color: white; background: #29292f; box-shadow: var(--shadow-sm); font-size: 10px; white-space: nowrap; transition: .15s ease; }
.rail-button:hover::after { opacity: 1; transform: translate(0, -50%); }
.keycap { width: 21px; height: 19px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; font-size: 11px; }

.main-stage { grid-column: 2; min-width: 0; min-height: calc(100vh - 86px); position: relative; }
.view-shell { min-height: calc(100vh - 86px); }
.document-header { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(247, 247, 248, .94); position: sticky; top: 58px; z-index: 12; }
.document-tabs { display: flex; align-items: center; gap: 4px; }
.document-tab { height: 32px; padding: 0 12px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 650; }
.document-tab:hover { color: var(--ink); background: var(--surface-muted); }
.document-tab.active { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-sm); }
.header-context { display: flex; align-items: center; gap: 8px; }
.version-badge, .status-badge, .operation-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 680; white-space: nowrap; }
.version-badge { color: var(--muted); background: var(--surface-muted); }
.status-badge.success { color: var(--success); background: var(--success-soft); }
.status-badge.warning { color: var(--warning); background: var(--warning-soft); }
.status-badge.danger { color: var(--danger); background: var(--danger-soft); }
.operation-badge { color: var(--accent-ink); background: var(--accent-soft); }
.text-button, .secondary-button, .primary-button, .danger-button { min-height: 36px; border-radius: 8px; font-size: 12px; font-weight: 680; }
.text-button { padding: 0 9px; border: 0; color: var(--muted); background: transparent; }
.text-button:hover { color: var(--ink); background: var(--surface-muted); }
.secondary-button { padding: 0 13px; border: 1px solid var(--line-strong); color: var(--ink-soft); background: var(--surface); }
.secondary-button:hover { border-color: #bdbdc5; background: var(--surface-raised); }
.primary-button { padding: 0 15px; border: 1px solid var(--accent); color: white; background: var(--accent); box-shadow: 0 4px 12px rgba(93, 85, 214, .18); }
.primary-button:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.danger-button { padding: 0 15px; border: 1px solid #e7b4bc; color: var(--danger); background: var(--danger-soft); }
button:disabled { opacity: .46; cursor: not-allowed; box-shadow: none !important; }

.editor-layout { width: min(1120px, 100%); margin: 0 auto; padding: 58px clamp(28px, 6vw, 86px) 218px; }
.document-canvas { width: min(760px, 100%); margin: 0 auto; }
.eyebrow { margin-bottom: 18px; color: var(--accent); font-size: 11px; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
.document-title { width: 100%; margin: 0; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-family: var(--serif); font-size: clamp(32px, 4vw, 46px); font-weight: 760; letter-spacing: -.04em; line-height: 1.22; }
.document-meta { display: flex; align-items: center; gap: 12px; margin: 16px 0 38px; color: var(--muted); font-size: 11px; }
.document-meta .divider { width: 1px; height: 10px; background: var(--line-strong); }
.story-body { min-height: 480px; outline: 0; color: #2e2e35; font-family: var(--serif); font-size: 17px; line-height: 2.05; letter-spacing: .012em; }
.story-body p { margin: 0 0 1.35em; }
.story-body .selected-passage { margin-left: -14px; margin-right: -14px; padding: 3px 14px; border-radius: 8px; background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.selection-hint { width: fit-content; display: flex; align-items: center; gap: 8px; margin: 24px auto 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface); font-size: 10px; box-shadow: var(--shadow-sm); }
.selection-hint kbd { padding: 2px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: #fafafa; font: 9px var(--sans); }

.composer { width: min(820px, calc(100% - 32px)); position: fixed; z-index: 18; left: calc(50% + 32px); bottom: 22px; transform: translateX(-50%); border: 1px solid var(--line-strong); border-radius: 15px; background: rgba(255, 255, 255, .96); box-shadow: 0 18px 50px rgba(32, 31, 44, .12), 0 2px 8px rgba(32, 31, 44, .05); backdrop-filter: blur(18px); }
.composer-main { display: flex; align-items: flex-end; gap: 10px; padding: 12px; }
.composer textarea { flex: 1; min-height: 44px; max-height: 120px; padding: 11px 9px 7px; resize: none; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; line-height: 1.55; }
.composer textarea::placeholder { color: var(--faint); }
.send-button { width: 38px; height: 38px; display: grid; place-items: center; flex: none; border: 0; border-radius: 10px; color: white; background: var(--accent); }
.send-button svg { width: 18px; height: 18px; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 10px; }
.operation-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; margin: 10px 12px 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.operation-summary > span { min-width: 0; padding: 8px 10px; background: var(--surface-raised); }
.operation-summary small, .operation-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operation-summary small { margin-bottom: 3px; color: var(--faint); font-size: 8px; letter-spacing: .06em; }
.operation-summary strong { color: var(--ink-soft); font-size: 10px; }
.operation-summary.needs-selection { border-color: #e2b86f; background: #e2b86f; }
.operation-notice { margin: 0 14px 8px; color: #8a5814; font-size: 10px; line-height: 1.5; }
.operation-picker { display: flex; align-items: center; gap: 3px; }
.operation-picker button { height: 26px; padding: 0 8px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 650; }
.operation-picker button.active { color: var(--accent-ink); background: var(--accent-soft); }
.composer-note { color: var(--faint); font-size: 9px; text-align: right; }

.empty-view { min-height: calc(100vh - 86px); display: grid; place-items: center; padding: 56px 24px 100px; }
.empty-content { width: min(720px, 100%); }
.empty-mark { width: 54px; height: 58px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 16px 16px 20px 16px; color: white; background: var(--ink); font: 28px Georgia, serif; box-shadow: 0 12px 30px rgba(25, 25, 29, .16); }
.empty-content h1 { max-width: 600px; margin: 0; font-family: var(--serif); font-size: clamp(36px, 5vw, 58px); line-height: 1.14; letter-spacing: -.05em; }
.empty-content > p { max-width: 560px; margin: 18px 0 32px; color: var(--muted); font-size: 15px; line-height: 1.75; }
.idea-box { border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.idea-box textarea { width: 100%; min-height: 126px; padding: 18px 19px 10px; resize: vertical; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 15px; line-height: 1.7; }
.idea-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 12px; }
.idea-actions .left { display: flex; gap: 6px; }
.subtle-chip { height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--surface-raised); font-size: 10px; font-weight: 650; }
.sample-prompts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.sample-prompt { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-soft); background: transparent; font-size: 11px; }
.sample-prompt:hover { border-color: #c7c7ce; background: var(--surface); }

.progress-view { min-height: calc(100vh - 86px); display: grid; place-items: center; padding: 40px 24px; }
.progress-card { width: min(600px, 100%); text-align: center; }
.progress-orbit { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 28px; position: relative; }
.progress-orbit::before, .progress-orbit::after { content: ""; position: absolute; inset: 0; border: 1px solid var(--line-strong); border-radius: 50%; }
.progress-orbit::after { inset: 8px; border-color: transparent var(--accent) var(--accent) transparent; animation: spin 1.1s linear infinite; }
.progress-orbit span { width: 34px; height: 38px; display: grid; place-items: center; border-radius: 9px 9px 12px 9px; color: white; background: var(--ink); font: 17px Georgia, serif; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-card h1 { margin: 0; font-family: var(--serif); font-size: 32px; letter-spacing: -.03em; }
.progress-card > p { margin: 10px 0 34px; color: var(--muted); font-size: 13px; }
.progress-list { width: min(420px, 100%); display: grid; gap: 6px; margin: 0 auto; text-align: left; }
.progress-step { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 11px 12px; border-radius: 9px; color: var(--muted); font-size: 12px; }
.progress-step .step-icon { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--faint); font-size: 10px; }
.progress-step.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.progress-step.active .step-icon { border-color: var(--accent); color: white; background: var(--accent); }
.progress-step.done .step-icon { border-color: #b9dfcf; color: var(--success); background: var(--success-soft); }
.progress-step small { color: var(--faint); font-size: 9px; }
.progress-safety { margin-top: 28px !important; color: var(--faint) !important; font-size: 10px !important; }

.candidate-layout { min-height: calc(100vh - 144px); padding: 42px 28px 150px; }
.candidate-document { width: min(820px, 100%); margin: 0 auto; }
.candidate-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 34px; padding: 14px 15px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--accent-ink); background: var(--surface-raised); }
.candidate-banner strong { display: block; font-size: 12px; }
.candidate-banner p { margin: 4px 0 0; color: var(--ink-soft); font-size: 10px; line-height: 1.5; }
.candidate-banner .status-badge { background: white; }
.candidate-banner.blocked { border-color: #edc5ca; color: #872d3a; background: var(--danger-soft); }
.candidate-banner.blocked p { color: #9b515b; }
.candidate-banner.unavailable, .candidate-banner.conflict { border-color: #ead5af; color: #795015; background: var(--warning-soft); }
.candidate-banner.unavailable p, .candidate-banner.conflict p { color: #8e6a34; }
.candidate-banner.adopted { border-color: #bce3d3; color: #176a4a; background: var(--success-soft); }
.candidate-banner.adopted p { color: #397963; }
.candidate-story { padding: 0 28px; }
.candidate-story h1 { margin: 0; font-family: var(--serif); font-size: clamp(34px, 4vw, 46px); letter-spacing: -.04em; }
.candidate-story .document-meta { margin-bottom: 34px; }
.review-actions { width: min(820px, calc(100% - 32px)); min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; position: fixed; z-index: 18; left: calc(50% + 32px); bottom: 22px; transform: translateX(-50%); padding: 10px 12px 10px 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(255, 255, 255, .96); box-shadow: 0 18px 50px rgba(32, 31, 44, .12); backdrop-filter: blur(18px); }
.review-state strong { display: block; font-size: 11px; }
.review-state span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.review-state .adopt-reason { color: var(--muted); font-weight: 650; }
body[data-view="candidate-blocked"] .review-state .adopt-reason { color: var(--danger); }
body[data-view="candidate-unavailable"] .review-state .adopt-reason,
body[data-view="conflict"] .review-state .adopt-reason { color: var(--warning); }
body[data-view="adopted"] .review-state .adopt-reason { color: var(--success); }
.review-buttons { display: flex; gap: 7px; }

.compare-layout { min-height: calc(100vh - 144px); padding: 22px 24px 124px; }
.compare-head { width: min(1240px, 100%); display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 auto 16px; }
.compare-head h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.compare-head p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.compare-toggle { display: none; padding: 3px; border-radius: 8px; background: var(--surface-muted); }
.compare-toggle button { height: 30px; padding: 0 12px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 11px; }
.compare-toggle button.active { color: var(--ink); background: white; box-shadow: var(--shadow-sm); }
.compare-surface { width: min(1240px, 100%); margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.compare-columns-head { display: grid; grid-template-columns: 1fr 1fr; position: sticky; top: 116px; z-index: 4; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.compare-columns-head > div { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; color: var(--muted); font-size: 11px; font-weight: 680; }
.compare-columns-head > div + div { border-left: 1px solid var(--line); }
.compare-body { font-family: var(--serif); font-size: 15px; line-height: 1.95; }
.diff-row { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.diff-row:last-child { border-bottom: 0; }
.diff-cell { min-width: 0; padding: 18px clamp(24px, 3vw, 46px); position: relative; }
.diff-cell + .diff-cell { border-left: 1px solid var(--line); }
.diff-cell p { margin: 0; }
.diff-title { padding-top: 30px; padding-bottom: 24px; }
.diff-title h2 { margin: 0; font-size: 27px; }
.diff-cell.changed, .diff-cell.added { padding-top: 38px; }
.diff-cell.changed::before, .diff-cell.added::before { content: attr(data-change-label); position: absolute; top: 12px; left: clamp(24px, 3vw, 46px); display: inline-flex; align-items: center; gap: 5px; color: var(--ink-soft); font: 9px var(--sans); font-weight: 760; letter-spacing: .04em; }
.diff-cell.changed::after, .diff-cell.added::after { content: ""; width: 7px; height: 7px; position: absolute; top: 15px; left: calc(clamp(24px, 3vw, 46px) - 13px); border-radius: 2px; background: currentColor; }
.diff-cell.changed.original { color: #7d3943; background: repeating-linear-gradient(135deg, #fff5f6, #fff5f6 8px, #fffafb 8px, #fffafb 16px); box-shadow: inset 3px 0 0 #c86674; }
.diff-cell.changed.candidate { color: #176147; background: repeating-linear-gradient(135deg, #eef9f4, #eef9f4 8px, #f8fcfa 8px, #f8fcfa 16px); box-shadow: inset 3px 0 0 #42a47e; }
.diff-cell.added.original { color: var(--faint); background: var(--surface-raised); box-shadow: inset 3px 0 0 var(--line-strong); }
.diff-cell.added.candidate { color: var(--accent-ink); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.diff-cell.unchanged { color: #34343a; background: white; }
.diff-legend { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 9px; }
.diff-legend span { display: inline-flex; align-items: center; gap: 5px; }
.diff-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--line-strong); }
.diff-legend .changed { background: linear-gradient(90deg, #c86674 0 48%, #42a47e 52% 100%); }
.diff-legend .added { background: var(--accent); }
.diff-legend .unchanged { border: 1px solid var(--line-strong); background: white; }

.selection-binding { width: min(760px, calc(100% - 40px)); display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; margin: 18px auto -14px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 11px; color: var(--accent-ink); background: var(--accent-soft); }
.scope-segment { display: flex; gap: 3px; padding: 3px; border-radius: 7px; background: rgba(93, 85, 214, .09); }
.scope-segment button { height: 27px; padding: 0 9px; border: 0; border-radius: 5px; color: var(--ink-soft); background: transparent; font-size: 9px; font-weight: 700; }
.scope-segment button.active { color: var(--accent-ink); background: white; box-shadow: 0 1px 4px rgba(70, 65, 130, .12); }
.binding-details { min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 10px; }
.binding-details strong { color: var(--accent-ink); font-size: 11px; }
.binding-details span { white-space: nowrap; }
.binding-details .binding-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.clear-selection { height: 30px; padding: 0 9px; border: 0; border-radius: 6px; color: var(--accent-ink); background: rgba(255,255,255,.72); font-size: 9px; font-weight: 680; }
.clear-selection:hover { background: white; }
.contextual-panel { width: min(620px, calc(100% - 32px)); margin: 24px auto 120px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.contextual-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.contextual-head h2 { margin: 0; font-size: 14px; }
.contextual-head p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.scope-preview { margin: 16px 18px 0; padding: 13px 14px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; color: var(--ink-soft); background: var(--accent-soft); font-family: var(--serif); font-size: 13px; line-height: 1.8; }
.contextual-form { padding: 16px 18px 18px; }
.contextual-form label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 680; }
.contextual-form textarea { width: 100%; min-height: 96px; padding: 11px 12px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: var(--surface-raised); font-size: 12px; line-height: 1.6; }
.contextual-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.scope-lock { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.scope-lock svg { width: 13px; height: 13px; }
.local-operation-picker { display: flex; gap: 5px; margin: 0 18px 16px; }
.local-operation-picker button { height: 32px; flex: 1; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--surface-raised); font-size: 10px; font-weight: 680; }
.local-operation-picker button.active { border-color: var(--line-strong); color: var(--accent-ink); background: var(--accent-soft); }

.failure-banner { width: min(860px, calc(100% - 36px)); display: flex; align-items: flex-start; gap: 12px; margin: 20px auto -16px; padding: 13px 14px; border: 1px solid #efbdc4; border-radius: 11px; color: #7e2834; background: var(--danger-soft); }
.failure-banner svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.failure-banner strong { display: block; font-size: 12px; }
.failure-banner p { margin: 4px 0 0; color: #9b515b; font-size: 10px; line-height: 1.5; }
.failure-banner .secondary-button { flex: none; margin-left: auto; border-color: #e7b4bc; color: #922f3d; background: white; }

.scrim { position: fixed; z-index: 49; inset: 28px 0 0; background: rgba(24, 24, 29, .24); backdrop-filter: blur(1px); }
.side-sheet { width: min(420px, calc(100vw - 24px)); position: fixed; z-index: 50; top: 40px; right: 12px; bottom: 12px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg); animation: slideIn .2s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 2; padding: 17px 18px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); }
.sheet-header h2 { margin: 0; font-size: 15px; }
.sheet-header p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.sheet-body { padding: 16px 18px 24px; }
.close-button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 7px; color: var(--muted); background: var(--surface-muted); font-size: 18px; }
.sheet-back-button { width: auto; min-width: 72px; height: 36px; flex: none; padding: 0 11px; white-space: nowrap; font-size: 12px; font-weight: 650; }
.check-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.check-metric { padding: 12px; border-radius: 9px; background: var(--surface-muted); }
.check-metric b { display: block; font-size: 20px; }
.check-metric span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.check-group { margin-top: 19px; }
.check-group-title { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 740; text-transform: uppercase; letter-spacing: .08em; }
.check-item { display: grid; grid-template-columns: 22px 1fr; gap: 9px; padding: 11px 0; border-top: 1px solid var(--line); }
.check-item:first-of-type { border-top: 0; }
.check-icon { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; font-size: 10px; }
.check-icon.pass { color: var(--success); background: var(--success-soft); }
.check-icon.warning { color: var(--warning); background: var(--warning-soft); }
.check-icon.block { color: var(--danger); background: var(--danger-soft); }
.check-item strong { display: block; font-size: 11px; }
.check-item p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.check-caveat { margin-top: 18px; padding: 11px 12px; border-radius: 8px; color: var(--muted); background: var(--surface-muted); font-size: 9px; line-height: 1.55; }
.history-view-notice, .compatibility-notice { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: var(--surface-raised); font-size: 9px; line-height: 1.55; }
.history-view-notice strong, .compatibility-notice strong { color: var(--ink); font-size: 10px; }
.compatibility-notice { margin: 12px 0 0; border-color: var(--line-strong); background: var(--surface-raised); }
.version-timeline { position: relative; }
.version-timeline::before { content: ""; position: absolute; top: 16px; bottom: 22px; left: 14px; width: 1px; background: var(--line); }
.version-row { width: 100%; display: grid; grid-template-columns: 29px 1fr auto; gap: 10px; align-items: start; position: relative; padding: 10px 0; border: 0; text-align: left; color: var(--ink); background: transparent; }
.version-node { width: 29px; height: 29px; display: grid; place-items: center; z-index: 1; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--muted); background: white; font-size: 9px; font-weight: 700; }
.version-row.current .version-node { border-color: var(--accent); color: white; background: var(--accent); }
.version-row strong { display: block; font-size: 11px; }
.version-row p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.version-row small { display: block; margin-top: 3px; color: var(--muted-light); font-size: 8px; }
.version-row em { padding: 3px 6px; border-radius: 5px; color: var(--muted); background: var(--surface-muted); font-size: 8px; font-style: normal; }
.version-row:hover strong { color: var(--accent); }
.settings-grid { display: grid; gap: 14px; }
.local-settings-section { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fafafd; }
.local-status { font-size: 12px; font-weight: 700; }
.local-status.ready { color: #247a54; }
.local-status.missing { color: #a33a45; }
.settings-field small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.55; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-result { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.local-path { display: grid; gap: 5px; margin: 0; }
.local-path strong { font-size: 13px; }
.local-path span { overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.danger-text { color: #b33e4a; }
.shutdown-view { min-height: calc(100vh - 80px); display: grid; place-content: center; gap: 10px; text-align: center; padding: 32px; }
.shutdown-view h1, .shutdown-view p { margin: 0; }
.shutdown-view p { color: var(--muted); }
.settings-field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 680; }
.settings-field select, .settings-field input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: var(--surface-raised); font-size: 11px; }

.modal-layer { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; padding: 24px; overflow-y: auto; background: rgba(24, 24, 29, .32); backdrop-filter: blur(2px); }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: var(--shadow-lg); animation: rise .18s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-top { position: relative; padding: 24px 24px 16px; }
.modal-icon { width: 38px; height: 38px; display: grid; place-items: center; margin-bottom: 15px; border-radius: 10px; color: var(--warning); background: var(--warning-soft); }
.modal-top h2 { margin: 0; font-size: 18px; line-height: 1.4; }
.modal-top p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.modal-close { width: 32px; height: 32px; position: absolute; top: 18px; right: 18px; display: grid; place-items: center; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 21px; line-height: 1; }
.modal-close:hover { color: var(--ink); background: var(--surface-muted); }
.modal-form { display: grid; gap: 16px; padding: 0 24px 24px; }
.modal-form .settings-field { display: grid; min-width: 0; gap: 8px; margin: 0; color: var(--ink-soft); font-size: 14px; font-weight: 620; line-height: 1.5; }
.modal-form .settings-field > label { margin: 0; color: inherit; font-size: inherit; font-weight: inherit; }
.modal-form .settings-field > input, .modal-form .settings-field > select { width: 100%; min-width: 0; height: 44px; padding: 0 12px; font-size: 14px; }
.modal-form .settings-field > textarea { width: 100%; min-width: 0; min-height: 104px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: var(--surface-raised); font-size: 14px; line-height: 1.55; resize: vertical; }
.modal-form .settings-field small { margin-top: 0; font-size: 12px; font-weight: 400; }
.modal-error { margin: -4px 0 0; color: var(--danger); font-size: 13px; line-height: 1.5; }
.modal-inline-error{margin:7px 0 0;padding:8px 10px;border-left:3px solid var(--warning);border-radius:4px;color:#785119;background:var(--warning-soft);font-size:13px;line-height:1.5}
.revalidation-consent-group{min-width:0}.revalidation-consent-group:has(.modal-inline-error:not([hidden])) .revalidation-consent{border-color:var(--warning)}
.revalidation-consent input{min-width:18px;min-height:18px}
.version-path { display: flex; align-items: center; gap: 8px; margin: 3px 24px 20px; padding: 12px; border-radius: 9px; background: var(--surface-muted); }
.version-path span { padding: 5px 8px; border-radius: 6px; color: var(--muted); background: white; font-size: 10px; font-weight: 700; }
.version-path span:last-child { color: var(--accent-ink); background: var(--accent-soft); }
.version-path i { flex: 1; height: 1px; position: relative; background: var(--line-strong); }
.version-path i::after { content: ""; width: 6px; height: 6px; position: absolute; right: 0; top: -3px; border-top: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); transform: rotate(45deg); }
.modal-note { margin: 0 24px 20px; padding: 10px 11px; border-left: 3px solid var(--warning); color: #74521d; background: var(--warning-soft); font-size: 12px; line-height: 1.55; }
.modal-form .modal-note { margin: 0; }
.history-authoring-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 24px 16px; }
.history-authoring-summary span { display: flex; min-width: 0; flex-direction: column; gap: 3px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted); }
.history-authoring-summary small { color: var(--muted); font-size: 8px; }
.history-authoring-summary strong { overflow-wrap: anywhere; color: var(--ink); font-size: 10px; }
.modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-raised); }
.modal-actions .right { display: flex; gap: 7px; margin-left: auto; }
.modal-actions button { min-height: 44px; white-space: normal; text-align: center; }

.toast { max-width: min(420px, calc(100vw - 24px)); position: fixed; z-index: 80; left: 50%; bottom: 22px; padding: 10px 13px; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; border-radius: 9px; color: white; background: #29292f; box-shadow: var(--shadow-lg); font-size: 11px; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .operation-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-header { grid-template-columns: auto 1fr auto; }
  .brand-copy { display: none; }
  .work-identity { justify-self: start; }
  .demo-switcher span { display: none; }
  .editor-layout { padding-left: clamp(32px, 8vw, 92px); padding-right: clamp(32px, 8vw, 92px); }
  .candidate-story { padding: 0 18px; }
  .diff-cell { padding-left: 28px; padding-right: 28px; font-size: 14px; }
  .diff-cell.changed::before, .diff-cell.added::before { left: 28px; }
  .diff-cell.changed::after, .diff-cell.added::after { left: 15px; }
}

@media (max-width: 720px) {
  .operation-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prototype-banner { height: 32px; text-align: center; font-size: 9px; }
  .app-shell { min-height: calc(100vh - 32px); display: block; padding-bottom: 58px; }
  .app-header { height: 54px; grid-template-columns: auto 1fr auto; padding: 0 12px; top: 0; }
  .brand-glyph { width: 27px; height: 29px; }
  .work-identity { margin-left: 4px; }
  .work-title { max-width: 110px; font-size: 12px; }
  .sync-state { display: none; }
  .demo-switcher { width: 34px; padding: 0; border: 0; background: transparent; }
  .demo-switcher::before { content: "演"; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--accent-ink); background: var(--accent-soft); font-size: 10px; font-weight: 750; }
  .demo-switcher select { position: absolute; width: 34px; height: 34px; opacity: 0; }
  .header-actions .icon-button { display: none; }
  .avatar { margin: 0; }
  .navigation-rail { height: 58px; width: 100%; display: flex; flex-direction: row; padding: 7px 20px; position: fixed; z-index: 35; left: 0; right: 0; top: auto; bottom: 0; border-top: 1px solid var(--line); border-right: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
  .rail-primary { width: 100%; display: flex; justify-content: space-around; }
  .rail-secondary { display: none; }
  .rail-button { width: 48px; height: 42px; }
  .rail-button::after { display: none; }
  .main-stage { min-height: calc(100vh - 86px); }
  .document-header { height: 52px; padding: 0 12px; top: 54px; }
  .document-tab { padding: 0 9px; font-size: 11px; }
  .header-context .version-badge, .header-context .text-button { display: none; }
  .editor-layout { padding: 40px 22px 260px; }
  .document-title { font-size: 33px; }
  .document-meta { margin-bottom: 28px; }
  .story-body { font-size: 16px; line-height: 1.95; }
  .composer, .review-actions { width: calc(100% - 20px); left: 50%; bottom: calc(68px + env(safe-area-inset-bottom) + var(--keyboard-inset, 0px)); }
  .composer-footer { align-items: flex-end; }
  .operation-picker button { padding: 0 7px; }
  .composer-note { display: none; }
  .empty-view { min-height: calc(100vh - 86px); place-items: start center; padding: 48px 20px 110px; }
  .empty-content h1 { font-size: 38px; }
  .empty-content > p { font-size: 13px; }
  .idea-box textarea { min-height: 138px; font-size: 14px; }
  .sample-prompts { display: grid; grid-template-columns: 1fr; }
  .progress-view { min-height: calc(100vh - 86px); padding: 34px 20px 100px; }
  .progress-card h1 { font-size: 27px; }
  .candidate-layout { padding: 28px 17px 118px; }
  .candidate-banner { align-items: flex-start; }
  .candidate-banner .status-badge { display: none; }
  .candidate-story { padding: 0 6px; }
  .candidate-story h1 { font-size: 34px; }
  .review-actions { min-height: 58px; padding: 7px; border-radius: 12px; }
  .review-state { display: none; }
  .review-buttons { width: 100%; }
  .review-buttons button { min-width: 0; min-height: 42px; padding: 0 10px; }
  .review-buttons .mobile-hide { display: none; }
  .review-buttons .primary-button { flex: 1.25; }
  body[data-view="candidate"] .navigation-rail,
  body[data-view="candidate-blocked"] .navigation-rail,
  body[data-view="candidate-unavailable"] .navigation-rail,
  body[data-view="conflict"] .navigation-rail,
  body[data-view="adopted"] .navigation-rail { display: none; }
  body[data-view="candidate"] .app-shell,
  body[data-view="candidate-blocked"] .app-shell,
  body[data-view="candidate-unavailable"] .app-shell,
  body[data-view="conflict"] .app-shell,
  body[data-view="adopted"] .app-shell { padding-bottom: 0; }
  body[data-view="candidate"] .review-actions,
  body[data-view="candidate-blocked"] .review-actions,
  body[data-view="candidate-unavailable"] .review-actions,
  body[data-view="conflict"] .review-actions,
  body[data-view="adopted"] .review-actions { bottom: max(10px, env(safe-area-inset-bottom)); }
  .compare-layout { padding: 18px 12px 132px; }
  .compare-head { align-items: center; }
  .compare-head p { display: none; }
  .compare-toggle { display: flex; }
  .compare-columns-head { top: 106px; }
  .compare-columns-head > div { display: none; }
  .compare-surface[data-mobile-side="original"] .compare-columns-head .original,
  .compare-surface[data-mobile-side="candidate"] .compare-columns-head .candidate { display: flex; border-left: 0; }
  .diff-row { display: block; }
  .diff-cell { display: none; min-height: 0; padding: 18px 22px; font-size: 15px; }
  .compare-surface[data-mobile-side="original"] .diff-cell.original,
  .compare-surface[data-mobile-side="candidate"] .diff-cell.candidate { display: block; border-left: 0; }
  .diff-cell.changed, .diff-cell.added { padding-top: 40px; }
  .diff-cell.changed::before, .diff-cell.added::before { left: 22px; }
  .diff-cell.changed::after, .diff-cell.added::after { left: 9px; }
  .selection-binding { width: calc(100% - 24px); grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; margin-bottom: -8px; }
  .scope-segment { grid-column: 1 / -1; }
  .scope-segment button { flex: 1; }
  .binding-details { gap: 7px; }
  .binding-details .binding-preview { display: none; }
  .contextual-panel { margin-top: 16px; margin-bottom: 136px; }
  .contextual-actions { align-items: flex-end; }
  .scope-lock { max-width: 180px; }
  .failure-banner { margin-top: 12px; margin-bottom: -18px; }
  .failure-banner .secondary-button { display: none; }
  .side-sheet { top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-height: calc(100vh - 58px); border-radius: 16px 16px 0 0; animation-name: rise; }
  .scrim { inset: 32px 0 0; }
  .modal-layer { align-items: end; padding: 12px 12px calc(68px + env(safe-area-inset-bottom)); }
  .modal { max-height: calc(100dvh - 92px - env(safe-area-inset-bottom)); border-radius: 16px; }
  .modal-form { padding: 0 20px 20px; }
  .modal-top { padding: 20px 20px 16px; }
  .modal-actions { flex-wrap: wrap; padding: 12px 20px; }
  .modal-actions .right { display: flex; flex-wrap: wrap; }
  body.keyboard-open .navigation-rail { display: none; }
  body.keyboard-open .app-shell { padding-bottom: 0; }
  body.keyboard-open .composer { bottom: calc(8px + var(--keyboard-inset, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Production workbench integration overrides. */
:root { --keyboard-inset: 0px; }
html { scroll-padding-top: 122px; }
.app-shell { min-height: 100vh; grid-template-rows: 64px 1fr; }
.app-header {
  height: 64px;
  background: #fff;
  backdrop-filter: none;
  box-shadow: 0 1px 0 var(--line), 0 8px 22px rgba(25,25,29,.035);
}
.navigation-rail { top: 64px; height: calc(100vh - 64px); background: #fbfbfc; }
.main-stage, .view-shell, .empty-view, .progress-view { min-height: calc(100vh - 64px); }
.document-header {
  top: 64px;
  background: #f7f7f8;
  backdrop-filter: none;
  box-shadow: 0 1px 0 rgba(228,228,232,.95), 0 8px 18px rgba(25,25,29,.035);
  isolation: isolate;
}
.header-button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-soft); background: var(--surface); font-size: 10px; font-weight: 680; }
.header-button:hover { border-color: var(--line-strong); background: var(--surface-raised); }
.provider-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-raised); font-size: 9px; white-space: nowrap; }
.provider-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.provider-pill.ready i { background: var(--success); box-shadow: 0 0 0 3px rgba(24,131,93,.1); }
.provider-pill.missing i { background: var(--warning); }
.provider-pill.checking i { animation: breathe 1.1s ease-in-out infinite; }
.work-identity { border: 0; cursor: pointer; text-align: left; }
.work-identity:hover .work-title { color: var(--accent-ink); }
.export-button { color: var(--accent-ink); border-color: var(--line-strong); background: var(--accent-soft); }
.task-model-picker { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--muted); font-size: 11px; }
.task-model-picker select { max-width: 260px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); color: var(--text); padding: 0 28px 0 9px; }
.settings-readonly { margin: 0; min-height: 38px; display: flex; align-items: center; color: var(--muted); }
.provider-disclosure { padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--accent) 5%, var(--surface-raised)); }
.stop-generation-button { margin-top: 18px; min-width: 132px; }
.progress-stop-note { max-width: 540px; margin: 8px auto 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
@keyframes breathe { 50% { opacity: .25; } }
.sync-state.error i { background: var(--danger); }

.story-editor {
  width: 100%;
  min-height: clamp(520px, calc(100vh - 330px), 920px);
  padding: 0 0 90px;
  resize: vertical;
  overflow: hidden;
  border: 0;
  outline: 0;
  color: #2e2e35;
  background: transparent;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 2.05;
  letter-spacing: .012em;
  field-sizing: content;
}
.story-editor::selection { color: var(--ink); background: var(--accent-soft); }
.raw-selection-toolbar { width: fit-content; display: flex; align-items: center; gap: 7px; margin: 14px auto 0; padding: 6px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-sm); }
.raw-selection-toolbar span { padding: 0 7px; color: var(--muted); font-size: 10px; }
.raw-selection-toolbar button { min-height: 32px; padding: 0 10px; border: 0; border-radius: 7px; color: var(--accent-ink); background: var(--accent-soft); font-size: 10px; font-weight: 700; }

.selection-binding { margin-bottom: 4px; padding: 14px 16px; border-color: var(--line-strong); background: var(--accent-soft); }
.binding-details { gap: 15px; color: var(--ink-soft); font-size: 11px; }
.binding-details > div { display: grid; gap: 3px; }
.binding-details span { color: var(--muted); font-size: 9px; font-weight: 650; letter-spacing: .02em; }
.binding-details strong { color: var(--accent-ink); font-size: 11px; line-height: 1.45; }
.binding-details .binding-preview strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clear-selection { border: 1px solid var(--line); background: #fff; }

.composer.busy { opacity: .78; }
.composer-collapse { position: absolute; top: 8px; right: 10px; min-height: 26px; padding: 0 8px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 9px; }
.composer-collapse:hover { color: var(--ink); background: var(--surface-muted); }
.composer-collapsed { display: flex; align-items: center; justify-content: space-between; width: min(540px, calc(100% - 32px)); padding: 8px 10px; }
.composer-expand { min-height: 34px; padding: 0 14px; border: 0; border-radius: 8px; color: white; background: var(--accent); font-weight: 720; }
.composer-collapsed span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.operation-summary.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); padding-right: 54px; }
.task-contract-details { margin: 0 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.task-contract-details summary { padding: 7px 9px; cursor: pointer; color: var(--muted); font-size: 9px; }
.task-contract-details > div { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 9px 9px; }
.task-contract-details span { display: grid; gap: 2px; min-width: 0; }
.task-contract-details small { color: var(--faint); font-size: 8px; }
.task-contract-details strong { overflow: hidden; color: var(--ink-soft); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.ending-intent { display: grid; grid-template-columns: .8fr 1.4fr 1.4fr; gap: 8px; margin: 0 4px 9px; }
.ending-intent label { display: grid; gap: 4px; min-width: 0; }
.ending-intent span { color: var(--muted); font-size: 8px; font-weight: 700; }
.ending-intent input, .ending-intent select { width: 100%; min-width: 0; height: 32px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; background: white; color: var(--ink); font-size: 10px; }
.composer.busy .send-button { cursor: wait; }
.composer-error { margin: 0 12px 10px; padding: 8px 10px; border-radius: 7px; color: var(--danger); background: var(--danger-soft); font-size: 10px; line-height: 1.5; }
.candidate-story .story-body { min-height: 0; }
.candidate-story .story-body p { white-space: pre-wrap; }
.candidate-banner.pending { border-color: var(--line-strong); color: var(--accent-ink); background: var(--surface-raised); }
.candidate-banner.historical { border-color: var(--line-strong); color: var(--ink-soft); background: var(--surface-muted); }
.candidate-banner.historical p { color: var(--muted); }
.segment-title { margin: -10px 0 16px; color: var(--accent-ink); font: 12px var(--sans); }
.consumed-prompt { margin: 18px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); font-family: var(--sans); }
.consumed-prompt summary { cursor: pointer; color: var(--muted); font-size: 10px; }
.consumed-prompt p { margin: 9px 0; color: var(--ink-soft); font-size: 11px; line-height: 1.65; white-space: pre-wrap; }

/* Keep difference encoding but soften the V2.1 diagonal texture. */
.diff-cell.changed.original {
  color: #5d343b;
  background-color: #fffafb;
  background-image: repeating-linear-gradient(135deg, rgba(200,102,116,.035) 0 7px, transparent 7px 22px);
  box-shadow: inset 3px 0 0 rgba(200,102,116,.78);
}
.diff-cell.changed.candidate {
  color: #174f3d;
  background-color: #f9fdfb;
  background-image: repeating-linear-gradient(135deg, rgba(66,164,126,.035) 0 7px, transparent 7px 22px);
  box-shadow: inset 3px 0 0 rgba(66,164,126,.8);
}
.empty-diff { color: var(--faint); font: 10px var(--sans); font-style: italic; }
.diff-cell.unchanged::before { content: "未修改"; display: block; margin-bottom: 8px; color: var(--faint); font: 8px var(--sans); font-weight: 720; letter-spacing: .08em; }
.diff-title.unchanged::before { display: none; }

.check-item.fail { background: var(--danger-soft); }
.check-item.warning, .check-item.unavailable { background: var(--warning-soft); }
.check-item.pass { background: var(--success-soft); }
.check-item .evidence { display: block; margin-top: 5px; color: var(--ink-soft); font-family: var(--serif); font-size: 9px; }
.sheet-empty { padding: 36px 12px; text-align: center; color: var(--muted); font-size: 11px; }
.loading-view { min-height: calc(100vh - 64px); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
body[data-view="candidate"] .toast,
body[data-view="candidate-blocked"] .toast,
body[data-view="candidate-unavailable"] .toast,
body[data-view="conflict"] .toast,
body[data-view="adopted"] .toast,
body[data-view="compare"] .toast,
body[data-view="editor"] .toast,
body[data-view="failure"] .toast { bottom: 102px; }

@media (max-width: 1080px) {
  .provider-pill span { display: none; }
  .provider-pill { width: 30px; justify-content: center; padding: 0; }
}

@media (max-width: 720px) {
  .task-model-picker { width: 100%; justify-content: space-between; }
  .task-model-picker select { max-width: calc(100vw - 150px); }
  html { scroll-padding-top: 108px; }
  .app-shell { min-height: 100vh; grid-template-rows: 54px 1fr; padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .app-header { height: 54px; }
  .header-button { width: auto; min-width: 44px; padding: 0 7px; color: var(--ink-soft); font-size: 11px; }
  .header-button::after { display: none; }
  .rail-button[data-action="new-work"] { display: none; }
  .provider-pill { display: none; }
  .navigation-rail { height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: calc(7px + env(safe-area-inset-bottom)); }
  .main-stage, .view-shell, .empty-view, .progress-view { min-height: calc(100vh - 54px); }
  .document-header { top: 54px; }
  .editor-layout { padding-bottom: 260px; }
  .story-editor { min-height: 520px; font-size: 16px; line-height: 1.95; }
  .composer, .review-actions { bottom: calc(68px + env(safe-area-inset-bottom) + var(--keyboard-inset)); }
  .raw-selection-toolbar { width: 100%; justify-content: center; }
  .selection-binding { grid-template-columns: 1fr auto; }
  .binding-details { display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px 12px; }
  .binding-details .binding-preview { grid-column: 1 / -1; display: grid; }
  .binding-details .binding-preview strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .review-buttons button { min-height: 44px; }
  body[data-view="candidate"] .toast,
  body[data-view="candidate-blocked"] .toast,
  body[data-view="candidate-unavailable"] .toast,
  body[data-view="conflict"] .toast,
  body[data-view="adopted"] .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
  body[data-view="compare"] .toast,
  body[data-view="editor"] .toast,
  body[data-view="failure"] .toast { bottom: calc(142px + env(safe-area-inset-bottom) + var(--keyboard-inset)); }
  body[data-view="candidate"], body[data-view="candidate-blocked"], body[data-view="candidate-unavailable"], body[data-view="conflict"], body[data-view="adopted"] { padding-bottom: env(safe-area-inset-bottom); }
  body.keyboard-open .composer { bottom: calc(8px + var(--keyboard-inset)); }
  body.keyboard-open .document-header { position: static; }
}

/* V1.2 consolidated P1 UX repair. */
.composer { width: min(860px, calc(100% - 32px)); padding: 10px 12px 12px; }
.composer-instruction-row { min-width: 0; }
.instruction-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.composer-instruction-row > small { display: block; font-size: 12px; line-height: 1.6; color: var(--muted); }
.compare-selectors { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: end; gap: 16px; margin-bottom: 24px; }
.compare-selectors label { display: grid; gap: 8px; min-width: 0; font-size: 13px; font-weight: 600; }
.compare-selectors > button { min-height: 44px; }
@media (min-width: 721px) {
  .review-actions { width: min(820px, calc(100% - 96px)); }
  .composer { width: min(860px, calc(100% - 96px)); }
}
.compare-selectors select { width: 100%; min-width: 0; height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; text-overflow: ellipsis; }
.diff-cell.removed { border-left: 3px solid #a87860; background: #faf4f1; }
@media (max-width: 720px) {
  .compare-selectors { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .compare-selectors > button { justify-self: start; min-height: 40px; }
}
.composer-instruction-row textarea { width: 100%; min-height: 46px; padding: 7px 3px 10px; }
.composer-options-row, .composer-model-row, .composer-submit-row,
.idea-config-row, .idea-model-row, .idea-submit-row { display: flex; align-items: center; gap: 10px; }
.composer-options-row { justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--line); }
.composer-quick-settings, .idea-config-row { display: flex; gap: 6px; }
.composer-model-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-top: 8px; }
.composer-model-row .task-model-picker, .idea-model-row .task-model-picker { width: 100%; min-width: 0; }
.composer-model-row .task-model-picker select, .idea-model-row .task-model-picker select { width: 100%; max-width: none; min-width: 0; }
.composer-submit-row { justify-content: space-between; padding-top: 9px; }
.send-button { width: auto; min-width: 154px; height: 40px; padding: 0 18px; font-size: 12px; font-weight: 740; }
.idea-config-row, .idea-model-row, .idea-submit-row { padding: 10px 14px; border-top: 1px solid var(--line); }
.idea-model-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.idea-submit-row { justify-content: space-between; color: var(--muted); font-size: 10px; }

.raw-selection-toolbar { max-width: min(560px, calc(100vw - 20px)); position: fixed; z-index: 45; margin: 0; box-shadow: 0 12px 32px rgba(32,31,44,.18); }
.selection-toolbar-copy { min-width: 0; max-width: 280px; display: grid; gap: 2px; padding: 0 7px; }
.selection-toolbar-copy strong { color: var(--ink); font-size: 10px; }
.selection-toolbar-copy small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.binding-details { color: var(--accent-ink); }
.binding-details span { color: var(--muted); }
.binding-details strong { font-weight: 720; }

.compare-head-actions { display: flex; align-items: center; gap: 8px; }
.compare-mode-toggle { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); }
.compare-mode-toggle button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; }
.compare-mode-toggle button.active { color: var(--accent-ink); background: white; box-shadow: var(--shadow-sm); }
.continuation-focus { width: min(980px, 100%); margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.continuation-retained { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface-muted); }
.continuation-retained strong { color: var(--success); font-size: 12px; }
.continuation-retained span { color: var(--muted); font-size: 11px; }
.continuation-retained small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.continuation-added-list { padding: 10px 0; }
.continuation-added { position: relative; margin: 0; padding: 25px clamp(28px, 6vw, 72px) 20px; border-bottom: 1px solid var(--line); font: 15px/1.95 var(--serif); }
.continuation-added:last-child { border-bottom: 0; }
.continuation-added > span { position: absolute; top: 10px; color: var(--accent); font: 9px var(--sans); font-weight: 760; letter-spacing: .06em; }
.continuation-added p { margin: 0; white-space: pre-wrap; }

.current-validation-card { margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); }
.current-validation-card.passed { border-color: #b9dfcf; background: var(--success-soft); }
.current-validation-card.blocked { border-color: #edc5ca; background: var(--danger-soft); }
.current-validation-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.current-validation-meta span { display: grid; gap: 3px; color: var(--muted); font-size: 9px; }
.current-validation-meta strong { overflow-wrap: anywhere; color: var(--ink-soft); font-size: 10px; }
.adoption-gate { display: grid; gap: 3px; margin-top: 12px; padding: 10px; border-radius: 8px; font-size: 10px; }
.adoption-gate.ready { color: #176147; background: rgba(255,255,255,.7); }
.adoption-gate.locked { color: #872d3a; background: rgba(255,255,255,.7); }
.adoption-gate span { line-height: 1.5; }
.validation-history-item { margin-top: 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); }
.validation-history-item summary { display: grid; grid-template-columns: 22px 1fr; gap: 9px; align-items: start; padding: 11px; cursor: pointer; list-style: none; }
.validation-history-item summary::-webkit-details-marker { display: none; }
.validation-history-item summary strong, .validation-history-item summary small { display: block; }
.validation-history-item summary strong { font-size: 10px; }
.validation-history-item summary small { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.validation-history-details { padding: 0 11px 11px; border-top: 1px solid var(--line); }
.history-warning { padding: 8px; color: #74521d; background: var(--warning-soft); font-size: 9px; }

.provider-card-list { display: grid; gap: 8px; }
.provider-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.provider-card strong { margin-right: 8px; font-size: 12px; }
.provider-card .local-status { display: inline-flex; font-size: 9px; }
.provider-card p, .provider-card small { display: block; margin: 4px 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: 9px; }
.provider-card-actions { display: flex; align-items: center; gap: 4px; }
.provider-editor { display: grid; gap: 13px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 11px; background: #f7f6ff; }
.provider-model-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.revalidation-modal { width: min(520px, 100%); }
.revalidation-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.revalidation-facts > div { display: grid; gap: 4px; min-width: 0; padding: 11px; border-radius: 8px; background: var(--surface-muted); color: var(--muted); font-size: 12px; }
.revalidation-facts strong { overflow-wrap: anywhere; color: var(--ink-soft); font-size: 13px; }
.revalidation-consent { display:flex;align-items:flex-start;gap:9px;width:100%;min-height:48px;padding:11px;border:1px solid #e3c580;border-radius:9px;background:var(--warning-soft);cursor:pointer;line-height:1.5; }
.revalidation-consent input{flex:none;margin:2px 0 0}.revalidation-consent span{min-width:0;overflow-wrap:anywhere}

.overview-canvas { width: min(1160px, calc(100% - 56px)); margin: 0 auto; padding: 52px 0 120px; }
.overview-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.overview-hero h1 { margin: 7px 0 9px; font: 34px/1.2 var(--serif); }
.overview-hero p { max-width: 720px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.story-layer-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.story-layer-legend span { padding: 6px 9px; border-radius: 999px; font-size: 9px; font-weight: 720; }
.story-layer-legend .formal { color: #176147; background: var(--success-soft); }
.story-layer-legend .candidate { color: #872d3a; background: var(--danger-soft); }
.story-layer-legend .planning { color: var(--accent-ink); background: var(--accent-soft); }
.candidate-boundary { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 12px 14px; border: 1px dashed #d3a5ad; border-radius: 10px; color: #7c3641; background: #fffafb; font-size: 10px; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.overview-card, .planning-editor { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: var(--shadow-sm); }
.overview-card.wide { grid-column: 1 / -1; }
.overview-card h2, .planning-editor h2 { margin: 0 0 12px; font-size: 13px; }
.overview-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.overview-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 8px; background: var(--surface-muted); }
.overview-list strong, .overview-list small { display: block; }
.overview-list strong { font-size: 11px; line-height: 1.5; }
.overview-list small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.overview-empty { color: var(--muted); font-size: 10px; line-height: 1.6; }
.evidence-link { flex: 0 0 auto; border: 0; color: var(--accent-ink); background: transparent; font-size: 9px; }
.planning-editor { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.planning-editor > div { grid-column: 1 / -1; }
.planning-editor p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.planning-editor label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; }
.planning-editor textarea { min-height: 108px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 9px; font: 11px/1.6 var(--sans); }
.planning-editor .primary-button { grid-column: 3; justify-self: end; }
.work-search { display: grid; gap: 6px; padding: 14px 18px; color: var(--muted); font-size: 9px; }
.work-search input { height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.work-switch-list { display: grid; gap: 6px; padding: 0 12px 18px; }
.work-switch-item { display: grid; gap: 4px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; text-align: left; background: white; }
.work-switch-item.active { border-color: var(--line-strong); background: var(--accent-soft); }
.work-switch-item small { color: var(--muted); font-size: 9px; }
.work-switch-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; }
.work-switch-row .work-switch-item { min-width: 0; overflow-wrap: anywhere; }
.work-trash-button { font-size: 12px; padding: 10px 4px; }
.work-recycle-row { display: flex; gap: 14px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 15px; }
.work-recycle-row > div { min-width: 0; display: grid; gap: 7px; overflow-wrap: anywhere; }
.work-recycle-row small { color: var(--muted); font-size: 11px; }
.work-recycle-row button { flex-shrink: 0; }
.planner-option { display: flex; gap: 9px; align-items: flex-start; margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--accent-soft); text-align: left; }
.planner-option input { flex-shrink: 0; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); }
.planner-option span { display: grid; gap: 5px; min-width: 0; }
.planner-option strong { font-size: 12px; }
.planner-option small { font-size: 11px; line-height: 1.7; color: var(--muted); }
.private-status-notice { margin: 18px 24px 0; padding: 14px 18px; border: 1px solid #d8bf85; border-radius: 10px; background: #fff8e6; color: #5a471f; font-size: 13px; line-height: 1.7; }
.getting-started { margin: 20px 0 22px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; text-align: left; background: #fff; }
.getting-started > strong { display: block; font-size: 14px; }
.getting-started > p { margin: 8px 0; font-size: 12px; line-height: 1.75; color: var(--muted); }
.getting-started-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.feedback-form .settings-field { margin-bottom: 16px; }
.feedback-form textarea { min-height: 150px; resize: vertical; }
.feedback-form input,.feedback-form select,.feedback-form textarea { font-size: 14px; }
.feedback-privacy { font-size: 12px; line-height: 1.8; color: var(--muted); padding: 12px; border-radius: 9px; background: var(--accent-soft); }
.feedback-counter { display: block; margin: -10px 0 16px; color: var(--muted); text-align: right; }
.feedback-actions { position: sticky; bottom: 0; display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0; background: #fff; }
.modal.feedback-modal { display: flex; flex-direction: column; overflow: hidden; max-height: calc(100dvh - 32px); }
.feedback-modal .modal-top,.feedback-modal .modal-actions { flex: none; }
.feedback-modal .feedback-form { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.feedback-modal .modal-actions { position: static; }
@media (max-width: 720px) { .header-actions .feedback-button { display: inline-flex; padding: 0 9px; min-height: 34px; font-size: 11px; } .getting-started { padding: 14px; } .getting-started-actions { flex-direction: column; } .getting-started-actions button { width: 100%; } .private-status-notice { margin: 14px 12px 0; } .feedback-actions { flex-direction: column; } .feedback-actions button { width: 100%; } }
@media (max-width: 480px) { .work-switch-row { grid-template-columns: minmax(0,1fr); gap: 2px; } .work-trash-button { justify-self: end; } .work-recycle-row { align-items: flex-start; flex-direction: column; } }

@media (max-width: 1024px) {
  .composer { left: calc(50% + 32px); width: min(760px, calc(100% - 96px)); }
  .compare-head { align-items: flex-start; }
  .compare-head-actions { flex-direction: column; align-items: flex-end; }
  .overview-canvas { width: calc(100% - 36px); }
  .planning-editor { grid-template-columns: 1fr 1fr; }
  .planning-editor label:last-of-type { grid-column: 1 / -1; }
  .planning-editor .primary-button { grid-column: 2; }
}

@media (max-width: 720px) {
  .composer { width: calc(100% - 20px); left: 50%; max-height: min(58vh, 430px); overflow-y: auto; padding: 8px 10px 10px; }
  .composer-options-row, .composer-submit-row { align-items: stretch; flex-direction: column; }
  .composer-quick-settings { position: absolute; right: 10px; margin-top: 1px; }
  .operation-picker { padding-right: 104px; }
  .composer-model-row, .idea-model-row { grid-template-columns: 1fr; }
  .composer-submit-row .send-button { width: 100%; }
  .composer-submit-row .composer-note { display: none; }
  .idea-config-row, .idea-submit-row { align-items: stretch; flex-direction: column; }
  .idea-submit-row .primary-button { width: 100%; }
  .raw-selection-toolbar { width: calc(100vw - 20px); justify-content: flex-end; }
  .selection-toolbar-copy { flex: 1; }
  .compare-head { align-items: stretch; flex-direction: column; }
  .compare-head-actions { align-items: stretch; flex-direction: row; justify-content: space-between; }
  .compare-mode-toggle { flex: 1; }
  .compare-mode-toggle button { flex: 1; }
  .continuation-added { padding: 36px 22px 20px; font-size: 15px; }
  .provider-card { grid-template-columns: 1fr; }
  .provider-card-actions { justify-content: flex-end; }
  .provider-model-fields, .current-validation-meta, .revalidation-facts { grid-template-columns: 1fr; }
  .header-button.export-button { display: none; }
  .operation-summary.compact, .task-contract-details > div { grid-template-columns: 1fr 1fr; }
  .ending-intent, .overview-grid, .planning-editor { grid-template-columns: 1fr; }
  .planning-editor label:last-of-type, .planning-editor .primary-button { grid-column: 1; }
  .planning-editor .primary-button { width: 100%; }
  .overview-canvas { width: calc(100% - 20px); padding-top: 28px; }
  .overview-hero { flex-direction: column; }
  .overview-hero h1 { font-size: 28px; }
  .candidate-boundary { flex-direction: column; }
}

@media (max-width: 480px) {
  .operation-picker button { padding: 0 5px; font-size: 9px; }
  .composer-quick-settings .subtle-chip:last-child { display: none; }
  .selection-binding { grid-template-columns: 1fr; }
  .selection-binding .clear-selection { width: 100%; }
  .compare-head-actions { flex-direction: column; }
  .modal-form { padding: 0 16px 16px; }
  .modal-top { padding: 18px 16px 14px; }
  .modal-close { top: 12px; right: 12px; }
  .modal-actions { padding: 10px 16px; }
  .modal-note { margin-left: 16px; margin-right: 16px; }
}

/* The AI-service editor lives in a side sheet but uses the same form controls as dialogs. */
.provider-editor .settings-field > label { font-size: 14px; }
.provider-editor .settings-field > input, .provider-editor .settings-field > select { height: 44px; font-size: 14px; }
.provider-editor .settings-field small { font-size: 12px; }
.provider-editor .check-group-title { font-size: 13px; }
.provider-editor .settings-actions button { min-height: 44px; }

/* V1.4 focused reading/authoring surface; dialog styles above remain untouched. */
.composer { padding: 12px 16px 14px; }
.composer-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; }
.composer-heading > div { display: grid; gap: 3px; min-width: 0; }
.composer-heading strong { color: var(--ink); font-size: 15px; line-height: 1.4; }
.composer-heading small { color: var(--muted); font-size: 10px; }
.composer .composer-collapse { position: static; flex: none; min-height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--accent-ink); background: var(--accent-soft); font-size: 11px; font-weight: 700; }
.composer .composer-collapse:hover { border-color: var(--accent); background: var(--accent-soft); }
.composer .operation-summary.compact { grid-template-columns: repeat(2,minmax(0,1fr)); margin: 0 0 10px; padding-right: 0; }
.composer .operation-summary > span { padding: 7px 10px; }
.composer .operation-summary small { font-size: 10px; }
.composer .operation-summary strong { font-size: 12px; }
.composer .task-contract-details { margin: 8px 0 0; }
.composer .task-contract-details summary { padding: 8px 10px; font-size: 11px; }
.composer .task-model-picker { overflow: hidden; }
.composer .task-model-picker > span { flex: none; font-size: 11px; font-weight: 700; }
.composer .task-model-picker select { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer.composer-collapsed { width: min(390px,calc(100% - 24px)); min-height: 54px; padding: 8px 10px; background: #fff; }
.composer-collapsed span { font-size: 11px; }
.composer-expand { min-height: 38px; flex: none; font-size: 11px; }
body:has(.composer-collapsed) .editor-layout { padding-bottom: 110px; }
@media (max-width:720px) {
  .composer { padding: 10px; }
  .composer.composer-collapsed { width: calc(100% - 20px); max-height: none; overflow: visible; }
  .composer-heading strong { font-size: 14px; }
  .composer .operation-summary.compact { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .composer .task-model-picker select { max-width: min(65vw,340px); }
  body:has(.composer-collapsed) .editor-layout { padding-bottom: 140px; }
}

/* Studio interface. Shared tokens also style the isolated verification pages. */
:root {
  --bg: #f5f6f3;
  --sidebar-width: 208px;
  --header-height: 72px;
  --documentbar-height: 60px;
  --surface-muted: #eef1ec;
  --surface-raised: #fafbf9;
  --ink: #202a25;
  --ink-soft: #526058;
  --muted: #758178;
  --faint: #8b958e;
  --line: #e1e6df;
  --line-strong: #cbd4c9;
  --accent: #31644b;
  --accent-hover: #244d39;
  --accent-soft: #e9f0e8;
  --accent-ink: #315b43;
  --success: #397454;
  --success-soft: #eaf3eb;
  --shadow-sm: 0 2px 6px #22382a05;
  --shadow-lg: 0 24px 80px #2036291a;
}
body { font-size: 14px; }
button { transition: background .15s, border-color .15s, color .15s; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
summary:focus-visible { outline: 3px solid #31644b40; outline-offset: 3px; }
button:disabled { cursor: not-allowed; }
.app-shell { min-height: 100dvh; grid-template: 72px 1fr / 208px minmax(0, 1fr); }
.app-header {
  grid-template-columns: 176px minmax(0, 1fr) auto;
  height: 72px; padding: 0 24px; gap: 24px;
  background: var(--surface); box-shadow: none;
}
.brand { gap: 11px; }
.brand-glyph { width: 34px; height: 36px; border-radius: 10px; background: var(--accent); font-size: 20px; }
.brand-copy strong { font-size: 16px; letter-spacing: -.4px; }
.brand-copy strong b { color: var(--ink); font-weight: 500; }
.brand-copy small { margin-top: 5px; font-size: 10px; font-weight: 400; letter-spacing: 1px; }
.work-identity { justify-self: start; gap: 15px; max-width: 100%; border: 0; background: none; padding: 8px 0; }
.work-title { font-size: 14px; font-weight: 550; }
.sync-state { font-size: 11px; }
.header-actions { gap: 10px; }
.header-actions > [data-action="open-work-switcher"],
.header-actions > [data-action="new-work"] { display: none; }
.provider-pill { min-height: 30px; font-size: 11px; background: var(--surface-raised); border-color: var(--line); }
.header-button, .icon-button { min-height: 38px; border-radius: 8px; font-size: 12px; }
.header-button.export-button { color: var(--ink-soft); background: white; border-color: var(--line); }
.navigation-rail {
  grid-column: 1; grid-row: 2; position: sticky; top: 72px; width: 208px;
  height: calc(100dvh - 72px); padding: 28px 14px 18px;
  align-items: stretch; border-right: 1px solid var(--line); background: var(--surface-raised);
}
.rail-primary, .rail-secondary { align-items: stretch; gap: 6px; }
.rail-section-label { margin: 0 12px 14px; color: var(--faint); font-size: 11px; letter-spacing: 1.5px; }
.rail-button { display: flex; justify-content: flex-start; align-items: center; width: 100%; height: 44px; gap: 12px; padding: 0 13px; border-radius: 8px; }
.rail-button svg { width: 18px; height: 18px; flex: none; stroke-width: 1.6; }
.rail-label { font-size: 13px; font-weight: 500; white-space: nowrap; }
.rail-button.active { color: var(--accent-ink); background: #e7ede3; }
.rail-button:hover { color: var(--ink); background: var(--surface-muted); }
.rail-button::after { display: none; }
.rail-secondary { border-top: 1px solid var(--line); padding-top: 14px; }
.main-stage { min-width: 0; min-height: calc(100dvh - 72px); }

.empty-view { min-height: calc(100dvh - 72px); display: block; padding: 64px 44px 48px; }
.empty-content { width: min(800px, 100%); margin: 0 auto; text-align: left; }
.welcome-eyebrow { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 12px; font-weight: 550; letter-spacing: 1px; }
.welcome-eyebrow > span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.empty-content h1 { margin: 18px 0 16px; color: var(--ink); font: 600 40px/1.35 var(--sans); letter-spacing: -1.6px; }
.empty-content > p { margin: 0 0 30px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.idea-box { margin: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 14px; background: white; box-shadow: 0 5px 24px #2e463608; }
.idea-box:focus-within { border-color: #6b8d75; box-shadow: 0 0 0 3px #31644b09; }
.idea-label { display: block; margin: 22px 24px 10px; color: var(--ink-soft); font-size: 13px; font-weight: 550; }
.idea-box #ideaInput { min-height: 112px; padding: 0 24px 14px; color: var(--ink); font: 15px/1.8 var(--sans); }
.idea-box #ideaInput::placeholder { color: #9aa49c; }
.idea-config-row { padding: 0 24px 14px; border: 0; }
.idea-model-row { display: block; padding: 0 24px; border: 0; }
.idea-submit-row { padding: 18px 24px; border-top: 1px solid var(--line); background: var(--surface-raised); font-size: 11px; }
.idea-submit-row .primary-button { min-height: 42px; gap: 16px; display: inline-flex; align-items: center; font-size: 13px; padding: 0 20px; }
.inspiration-heading { display: flex; justify-content: space-between; margin: 32px 0 14px; color: var(--ink-soft); font-size: 12px; font-weight: 550; }
.inspiration-heading > span { color: var(--faint); font-size: 11px; font-weight: 400; }
.sample-prompts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.sample-prompt { display: grid; gap: 10px; min-width: 0; min-height: 136px; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: #ffffffb3; text-align: left; white-space: normal; }
.sample-prompt:hover { border-color: #a9bca9; background: white; transform: translateY(-2px); }
.sample-prompt small { font-size: 10px; font-weight: 500; letter-spacing: .8px; color: var(--accent); }
.sample-prompt strong { font-size: 14px; color: var(--ink); font-weight: 550; }
.sample-prompt > span { color: var(--muted); font-size: 11px; line-height: 1.7; }

.document-header { top: 72px; min-height: 60px; padding: 0 28px; background: var(--bg); box-shadow: none; }
.document-tabs { gap: 8px; }
.document-tab { min-height: 36px; padding: 0 14px; font-size: 12px; border-radius: 8px; }
.document-tab.active { color: var(--accent-ink); background: white; border-color: var(--line); box-shadow: var(--shadow-sm); }
.header-context { gap: 10px; font-size: 11px; }
.version-badge, .status-badge { font-size: 11px; }
.studio-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; padding: 24px 28px 40px; align-items: start; }
.writing-pane { min-width: 0; }
.editor-view .editor-layout, body:has(.composer-collapsed) .editor-view .editor-layout { padding: 0; }
.editor-view .document-canvas { width: 100%; max-width: none; margin: 0; padding: 36px 40px 24px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: var(--shadow-sm); }
.eyebrow { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 10px; font-weight: 450; letter-spacing: .6px; }
.document-type { padding: 5px 8px; color: var(--accent-ink); border-radius: 4px; background: var(--accent-soft); }
.document-title { margin: 24px 0 16px; color: var(--ink); font: 600 32px/1.5 var(--serif); letter-spacing: -.6px; }
.document-meta { flex-wrap: wrap; gap: 10px; margin-bottom: 28px; font-size: 11px; }
.document-meta .text-button { font-size: 11px; }
.story-editor { color: #344239; font: 16px/2 var(--serif); min-height: 520px; padding-bottom: 32px; resize: none; }
.story-editor::selection { background: #dfeadb; color: var(--ink); }
.selection-binding { margin: 0 0 16px; padding: 14px; border-color: #c3d1bd; border-radius: 10px; background: #eff4eb; }
.binding-details, .binding-details strong { color: var(--accent-ink); font-size: 11px; }
.binding-details span { color: var(--muted); font-size: 10px; }
.raw-selection-toolbar { background: var(--ink); border-color: var(--ink); box-shadow: var(--shadow-lg); }
.raw-selection-toolbar button { color: white; font-size: 12px; border-radius: 6px; }
.raw-selection-toolbar button:hover { background: #ffffff20; }
.raw-selection-toolbar strong, .raw-selection-toolbar small { color: #e8f0e7; }
.composer {
  position: sticky; inset: auto; top: 156px; transform: none; z-index: 2;
  width: 100%; max-height: calc(100dvh - 180px); padding: 20px; overflow: auto;
  border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: var(--shadow-sm);
}
.composer-heading { margin: 0 0 18px; padding: 0; border: 0; }
.composer-heading > div { position: relative; display: grid; gap: 5px; padding-left: 38px; }
.assistant-mark { position: absolute; left: 0; top: 1px; display: grid; place-items: center; width: 29px; height: 32px; color: var(--accent); background: var(--accent-soft); border-radius: 9px; font-size: 20px; }
.composer-heading strong { font-size: 15px; font-weight: 600; }
.composer-heading small { color: var(--muted); font-size: 10px; }
.composer .composer-collapse { top: 17px; right: 12px; min-height: 28px; padding: 0 7px; border: 0; background: transparent; font-size: 11px; }
.composer .composer-collapse:hover { background: var(--surface-muted); }
.composer-options-row { margin: 16px 0; padding: 0; border: 0; }
.operation-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; width: 100%; padding: 4px; border: 0; border-radius: 8px; background: var(--surface-muted); }
.operation-picker button { min-height: 32px; padding: 0 3px; border: 0; border-radius: 6px; color: var(--muted); font-size: 11px; }
.operation-picker button.active { color: var(--accent-ink); background: white; box-shadow: 0 1px 4px #2136280d; }
.instruction-label { margin: 18px 0 10px; color: var(--ink-soft); font-size: 12px; font-weight: 550; }
.composer-instruction-row textarea { min-height: 128px; max-height: 260px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface-raised); font: 13px/1.8 var(--sans); resize: vertical; }
.composer-instruction-row > small { margin-top: 7px; font-size: 10px; }
.composer-quick-settings { position: static; flex-wrap: wrap; margin-top: 0; }
.subtle-chip { min-height: 28px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-soft); background: white; font-size: 11px; font-weight: 450; }
.composer-model-row, .idea-model-row { display: block; }
.model-preferences { width: 100%; border-top: 1px solid var(--line); }
.model-preferences > summary { display: flex; align-items: center; gap: 8px; min-height: 42px; color: var(--ink-soft); font-size: 12px; cursor: pointer; list-style: none; }
.model-preferences > summary::-webkit-details-marker { display: none; }
.model-preferences > summary > small { margin-left: auto; color: var(--faint); font-size: 10px; }
.model-preferences > summary > svg { width: 13px; height: 13px; color: var(--muted); }
.model-preferences[open] > summary > svg { transform: rotate(90deg); }
.model-picker-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px 0 16px; }
.composer .model-picker-grid { grid-template-columns: minmax(0, 1fr); }
.model-picker-grid .task-model-picker { display: grid; gap: 8px; min-width: 0; }
.model-picker-grid .task-model-picker > span { color: var(--muted); font-size: 11px; font-weight: 450; }
.task-model-picker select, .modal-form select, .ending-intent select {
  appearance: none; width: 100%; max-width: 100%; min-height: 40px;
  padding: 8px 32px 8px 11px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); background: var(--surface-raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23758178' stroke-width='1.5'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 12px;
}
.composer-submit-row { position: sticky; bottom: 0; z-index: 3; display: flex; flex-direction: column; align-items: stretch; gap: 9px; padding: 12px 0; background: var(--surface); }
.send-button { width: 100%; min-height: 43px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); font-size: 12px; font-weight: 550; }
.composer-note { font-size: 10px; text-align: center; color: var(--faint); }
.composer .operation-summary.compact { margin-top: 22px; padding: 12px 0 0; border-top: 1px solid var(--line); border-bottom: 0; background: transparent; border-radius: 0; }
.composer .operation-summary > span { padding: 0; background: transparent; border: 0; }
.composer .operation-summary small { font-size: 10px; }
.composer .operation-summary strong { font-size: 12px; font-weight: 500; }
.composer .task-contract-details { margin-top: 12px; border: 0; background: var(--surface-raised); border-radius: 6px; }
.composer .task-contract-details summary { font-size: 10px; color: var(--muted); }
.ending-intent { grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 16px 0; padding: 0; background: transparent; }
.ending-intent select { min-height: 40px; font-size: 12px; }
.ending-intent label > span { font-size: 11px; }
.composer.composer-collapsed { position: sticky; top: 156px; width: 100%; max-height: none; min-height: 0; padding: 16px; display: grid; gap: 12px; }
.composer-expand { min-height: 40px; font-size: 12px; font-weight: 550; }
.composer-collapsed span { white-space: normal; font-size: 11px; line-height: 1.6; }

.primary-button, .secondary-button, .danger-button { min-height: 40px; padding: 0 16px; border-radius: 8px; font-size: 13px; font-weight: 550; }
.primary-button { background: var(--accent); border-color: var(--accent); }
.primary-button:hover, .send-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.text-button { font-size: 12px; }
.modal-layer { padding: 24px; background: #1b29204d; backdrop-filter: blur(5px); }
.modal { border-radius: 16px; box-shadow: 0 24px 100px #16291d30; }
.modal-top { padding: 28px 28px 20px; }
.modal-top h2 { color: var(--ink); font-size: 21px; font-weight: 600; letter-spacing: -.4px; }
.modal-top p { color: var(--muted); font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.modal-form { padding: 0 28px 24px; gap: 18px; }
.modal-form > label { display: grid; gap: 8px; color: var(--ink-soft); font-size: 13px; }
.modal-form input, .modal-form textarea { min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: var(--surface-raised); font-size: 14px; }
.modal-actions { position: sticky; bottom: 0; z-index: 2; gap: 12px; padding: 18px 28px; background: var(--surface-raised); }
.modal-actions .text-button { padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.side-sheet { width: min(420px, 100%); border-color: var(--line); }
.sheet-header h2 { font-size: 19px; }
.sheet-body { font-size: 13px; line-height: 1.7; }
.work-search { font-size: 12px; padding: 18px 22px; }
.work-search input { height: 44px; font-size: 13px; }
.work-switch-item { gap: 7px; padding: 15px; border-radius: 10px; }
.work-switch-item strong { font-size: 14px; }
.work-switch-item small, .work-switch-meta { font-size: 11px; }
.overview-card h2, .planning-editor h2 { font-size: 16px; }
.overview-note, .overview-list, .planning-editor p { font-size: 12px; line-height: 1.8; }
.toast { border-radius: 9px; font-size: 13px; }

/* The same controls and type scale apply to every workflow state. */
.progress-card { width: min(560px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.progress-card h1 { font-size: 25px; line-height: 1.5; }
.progress-card > p { color: var(--muted); font-size: 13px; line-height: 1.8; }
.progress-orbit { width: 58px; height: 58px; margin-bottom: 22px; border-color: var(--line); }
.progress-orbit > span { color: var(--accent); font-size: 22px; }
.progress-list { margin: 24px 0; }
.progress-step { min-height: 58px; gap: 12px; padding: 12px 14px; border-radius: 9px; }
.progress-step strong { font-size: 13px; font-weight: 550; }
.progress-step small { font-size: 12px; }
.progress-step.active { color: var(--accent-ink); background: var(--accent-soft); }
.progress-step .step-icon { font-size: 12px; }
.progress-card .progress-safety, .progress-card .progress-stop-note { font-size: 12px; overflow-wrap: anywhere; }
.candidate-layout { padding: 24px 28px 190px; }
.candidate-document { width: min(880px, 100%); border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); }
.candidate-banner { align-items: flex-start; gap: 18px; padding: 20px 24px; background: var(--success-soft); border-color: var(--line); }
.candidate-banner strong { color: var(--ink); font-size: 15px; line-height: 1.65; }
.candidate-banner p { color: var(--ink-soft); font-size: 12px; line-height: 1.8; }
.candidate-banner.pending, .candidate-banner.historical { background: var(--surface-muted); }
.candidate-banner.blocked { background: var(--danger-soft); }
.candidate-banner.conflict, .candidate-banner.unavailable { background: var(--warning-soft); }
.candidate-story { padding: 34px 40px 48px; }
.candidate-story h1 { margin: 20px 0; color: var(--ink); font: 600 30px/1.5 var(--serif); }
.story-body { color: var(--ink); font-size: 16px; line-height: 2; }
.consumed-prompt { margin: 22px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); font-size: 12px; line-height: 1.8; }
.consumed-prompt summary { cursor: pointer; color: var(--ink-soft); }
.review-actions {
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  bottom: 20px; width: min(920px, calc(100vw - var(--sidebar-width) - 48px));
  gap: 18px; padding: 16px 18px; background: var(--surface);
  border-color: var(--line); box-shadow: var(--shadow-lg);
}
.review-state { min-width: 0; }
.review-state strong { font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.review-state .adopt-reason { max-width: 420px; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.review-buttons { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.review-buttons > button { min-height: 40px; font-size: 12px; }
.compare-layout { padding: 28px 32px 190px; }
.compare-head { margin-bottom: 22px; }
.compare-head h1 { font-size: 24px; line-height: 1.5; }
.compare-head p { font-size: 13px; line-height: 1.8; }
.diff-legend { flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 12px; }
.compare-columns-head { top: calc(var(--header-height) + var(--documentbar-height)); }
.compare-columns-head > div { min-width: 0; height: auto; min-height: 52px; gap: 10px; padding: 12px 18px; font-size: 12px; }
.compare-columns-head strong { overflow-wrap: anywhere; }
.compare-body { font-size: 15px; line-height: 2; }
.compare-surface { overflow: clip; }
.diff-cell::before, .empty-diff { font-size: 11px; }
.diff-cell.added, .continuation-added { background: var(--accent-soft); }
.diff-cell.added { border-left: 3px solid var(--accent); }
.continuation-retained { padding: 18px 22px; background: var(--surface-raised); }
.continuation-retained strong { font-size: 14px; }
.continuation-retained span, .continuation-retained small { font-size: 12px; line-height: 1.7; }
.continuation-added > span { color: var(--accent-ink); font-size: 11px; }
.sheet-header { padding: 20px 22px; background: var(--surface); }
.sheet-header > div { min-width: 0; }
.sheet-header h2 { font-size: 19px; line-height: 1.5; }
.sheet-header p { margin-top: 6px; font-size: 12px; line-height: 1.7; }
.sheet-body { padding: 20px 22px; }
.close-button { flex: none; min-width: 36px; min-height: 36px; }
.check-metric span, .check-group-title { font-size: 12px; letter-spacing: 0; }
.check-item { padding: 15px 0; gap: 12px; }
.check-item strong { font-size: 13px; line-height: 1.65; }
.check-item p, .check-caveat, .validation-history-details, .history-view-notice, .compatibility-notice { font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.history-view-notice strong, .compatibility-notice strong { font-size: 13px; }
.current-validation-meta span { font-size: 11px; line-height: 1.6; }
.current-validation-meta strong { font-size: 12px; }
.validation-history-item summary strong { font-size: 13px; }
.validation-history-item summary small { font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.version-row { padding: 14px 0; gap: 12px; grid-template-columns: 32px minmax(0, 1fr) auto; }
.version-node { width: 32px; height: 32px; font-size: 11px; }
.version-row strong { font-size: 13px; line-height: 1.6; }
.version-row p, .version-row small { color: var(--muted); font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.version-row em { max-width: 90px; padding: 5px 7px; font-size: 10px; text-align: center; }
.overview-canvas { padding-top: 32px; }
.overview-hero p, .overview-note, .overview-empty { font-size: 13px; line-height: 1.8; }
.story-layer-legend span { font-size: 12px; font-weight: 500; }
.story-layer-legend .planning { border: 1px dashed var(--line-strong); color: var(--ink-soft); background: var(--surface-raised); }
.overview-card, .planning-editor { padding: 22px; border-radius: 12px; }
.overview-list strong { font-size: 13px; }
.overview-list small, .evidence-link { font-size: 11px; line-height: 1.7; }
.planning-editor label { font-size: 12px; line-height: 1.6; }
.planning-editor textarea { padding: 12px; font: 13px/1.8 var(--sans); }
.relationship-tree { --tree-line: var(--line-strong); }
.relationship-person strong, .relationship-branch > summary { font-size: 13px; }
.relationship-person span, .relationship-person em, .relationship-empty { font-size: 11px; line-height: 1.7; }
.modal-form .settings-section { display: grid; gap: 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.settings-section-heading { margin: 0; color: var(--ink); font-size: 14px; font-weight: 600; }
.settings-section-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.settings-actions { display: grid; gap: 10px; }
.form-status { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.form-status:not(:empty) { padding: 10px 12px; border-radius: 8px; background: var(--surface-muted); }
.form-status[data-tone="error"] { color: var(--danger); background: var(--danger-soft); }
.form-status[data-tone="success"] { color: var(--success); background: var(--success-soft); }
.consent-summary { display: grid; gap: 12px; color: var(--ink-soft); font-size: 13px; line-height: 1.8; }
.consent-summary p { margin: 0; }
.consent-routes { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.consent-routes > li { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); overflow-wrap: anywhere; }
.consent-routes strong { color: var(--ink); font-size: 12px; }
.consent-routes span, .consent-routes small { color: var(--muted); font-size: 12px; }
.workflow-empty { display: grid; justify-items: start; gap: 10px; padding: 24px 16px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--surface-raised); }
.workflow-empty > strong { font-size: 15px; font-weight: 550; }
.workflow-empty > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.workflow-empty .secondary-button { margin-top: 6px; }
.settings-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-checkbox { display: flex !important; align-items: flex-start; gap: 10px !important; color: var(--ink-soft); font-size: 13px; line-height: 1.8; }
.modal-form .settings-checkbox > input { flex: none; width: 17px; height: 17px; min-height: 0; padding: 0; margin: 3px 0 0; accent-color: var(--accent); }
.settings-storage-note, .form-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.settings-test-tools { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: var(--surface-raised); }
.settings-test-tools > summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.settings-test-tools[open] > summary { margin-bottom: 14px; }
.backup-confirmation { display: grid; gap: 12px; padding: 14px; border: 1px solid #ead9b7; border-radius: 9px; background: var(--warning-soft); }
.backup-confirmation p { margin: 0; font-size: 13px; line-height: 1.8; }
.backup-confirmation > div { display: flex; flex-wrap: wrap; gap: 10px; }
.consent-limit { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); font-size: 13px; }
.consent-limit strong { color: var(--accent-ink); font-size: 20px; }
.form-diagnostics { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.8; overflow-wrap: anywhere; }
.form-diagnostics summary { cursor: pointer; }
.form-diagnostics code { display: block; margin-top: 8px; padding: 10px; border-radius: 6px; background: var(--surface-muted); color: var(--ink-soft); overflow-wrap: anywhere; }
.auth-steps { display: flex; gap: 12px; margin: 0; padding: 0; list-style: none; }
.auth-steps > li { flex: 1; padding-bottom: 10px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 12px; }
.auth-steps > li[aria-current="step"] { color: var(--accent-ink); border-color: var(--accent); font-weight: 550; }
.auth-email-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.auth-email-row > button { min-height: 44px; }
.auth-form input[autocomplete="one-time-code"] { letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.modal-form [aria-invalid="true"] { border-color: var(--danger); }
.verification-page { min-height: 100dvh; padding: 36px 20px; }
.verification-shell { width: min(620px, 100%); margin: 4vh auto; padding: 36px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
.verification-brand { display: grid; place-items: center; width: 38px; height: 40px; margin-bottom: 24px; border-radius: 11px; background: var(--accent); color: white; font: 23px Georgia, serif; }
.verification-heading > p { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.verification-heading > h1 { margin: 0; font-size: 26px; line-height: 1.5; letter-spacing: -.5px; }
.verification-status { display: grid; gap: 8px; margin: 24px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-soft); background: var(--surface-raised); font-size: 13px; line-height: 1.8; }
.verification-status > p { margin: 0; }
.verification-status > strong { font-size: 13px; font-weight: 550; }
.verification-status[data-tone="success"] { color: var(--success); border-color: #c6ddc7; background: var(--success-soft); }
.verification-status[data-tone="warning"] { color: #785419; border-color: #ead9b7; background: var(--warning-soft); }
.verification-status[data-tone="danger"] { color: var(--danger); border-color: #edc5ca; background: var(--danger-soft); }
.verification-steps { display: grid; gap: 10px; margin: 0 0 24px; padding: 0; list-style: none; }
.verification-steps > li { display: flex; align-items: flex-start; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; }
.verification-step-mark { display: grid; place-items: center; flex: none; width: 25px; height: 25px; border-radius: 50%; color: var(--muted); background: var(--surface-muted); font-size: 13px; }
.verification-steps li[data-tone="success"] .verification-step-mark { color: var(--success); background: var(--success-soft); }
.verification-steps li[data-tone="danger"] .verification-step-mark { color: var(--danger); background: var(--danger-soft); }
.verification-steps li[data-tone="warning"] .verification-step-mark { color: #785419; background: var(--warning-soft); }
.verification-steps strong { font-size: 14px; font-weight: 550; }
.verification-steps p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.verification-disclosure { margin: 24px 0; }
.verification-disclosure h2 { margin: 0 0 10px; font-size: 14px; font-weight: 550; }
.verification-disclosure p, .verification-help { color: var(--muted); font-size: 13px; line-height: 1.8; }
.verification-form { display: grid; gap: 10px; margin-top: 24px; }
.verification-form label { color: var(--ink-soft); font-size: 13px; font-weight: 550; }
.verification-form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: var(--surface-raised); font-size: 14px; }
.verification-form small { color: var(--muted); font-size: 12px; }
.verification-form button { margin-top: 8px; min-height: 46px; }
.verification-close { display: flex; justify-content: flex-start; margin: 24px 0 0; }
.verification-footer { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; }

/* Temporary key and verification pages use the same visual language. */
body:not(.verification-page) > main:has(> #status), body:not(.verification-page) > main:has(> form[action^="/__"]) {
  width: min(620px, calc(100% - 40px)); max-width: 620px; margin: 10vh auto;
  padding: 36px; border: 1px solid var(--line); border-radius: 18px;
  background: white; box-shadow: 0 12px 44px #22382a08;
}
body:not(.verification-page) > main:has(> #status)::before, body:not(.verification-page) > main:has(> form[action^="/__"])::before {
  content: "D"; display: grid; place-items: center; width: 38px; height: 40px; margin-bottom: 24px;
  border-radius: 11px; background: var(--accent); color: white; font: 23px Georgia, serif;
}
body:not(.verification-page) > main > h1 { margin: 0 0 14px; font-size: 26px; line-height: 1.4; letter-spacing: -.7px; font-weight: 600; }
body:not(.verification-page) > main > p { margin: 12px 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
body:not(.verification-page) > main > #status { margin: 24px 0 16px; padding: 14px 16px; border: 1px solid #d9e7d7; border-radius: 10px; color: var(--accent-ink); background: #f0f6ed; font-size: 14px; }
body:not(.verification-page) > main > #works { display: grid; gap: 10px; margin: 18px 0 24px; padding: 0; list-style: none; counter-reset: verification; }
body:not(.verification-page) > main > #works > li { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-soft); font-size: 13px; line-height: 1.7; counter-increment: verification; }
body:not(.verification-page) > main > #works > li::before { content: counter(verification, decimal-leading-zero); flex: none; color: var(--muted); font: 12px var(--sans); }
body:not(.verification-page) > main > button, body:not(.verification-page) > main > form button { min-height: 44px; margin: 12px 0 0; padding: 10px 18px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink-soft); background: white; font-size: 13px; font-weight: 550; }
body:not(.verification-page) > main > button:hover { background: var(--surface-muted); }
body:not(.verification-page) > main > form { display: grid; gap: 16px; margin-top: 26px; }
body:not(.verification-page) > main > form label { display: grid; gap: 10px; color: var(--ink-soft); font-size: 13px; }
body:not(.verification-page) > main > form input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: var(--surface-raised); font-size: 14px; }
body:not(.verification-page) > main > form button { margin: 0; color: white; border-color: var(--accent); background: var(--accent); }
body:not(.verification-page) > main > #results { font-size: 12px; }

@media (max-width: 1180px) and (min-width: 721px) {
  :root { --sidebar-width: 72px; }
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .navigation-rail { width: 72px; padding: 22px 10px; }
  .rail-label, .rail-section-label { display: none; }
  .rail-button { justify-content: center; padding: 0; }
  .app-header { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 0 20px; gap: 20px; }
  .brand-copy { display: none; }
  .studio-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; padding: 20px; }
  .editor-view .document-canvas { padding: 30px; }
  .composer { padding: 17px; }
}
@media (max-width: 900px) {
  .studio-layout { display: block; }
  .editor-view .document-canvas { padding: 30px; }
  .composer, .composer.composer-collapsed {
    position: fixed; top: auto; right: 16px; bottom: 16px; left: 88px;
    width: auto; max-height: 60dvh; z-index: 35; box-shadow: var(--shadow-lg);
  }
  .composer-instruction-row textarea { min-height: 90px; }
  .composer.composer-collapsed { display: flex; align-items: center; padding: 10px; gap: 14px; }
  .composer .model-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-view .editor-layout, body:has(.composer-collapsed) .editor-view .editor-layout { padding-bottom: 90px; }
  .header-context .text-button { display: none; }
  .review-actions { flex-direction: column; align-items: stretch; width: calc(100vw - var(--sidebar-width) - 32px); padding: 14px 16px; }
  .review-state .adopt-reason { max-width: none; }
  .candidate-layout { padding-bottom: 240px; }
  .compare-layout { padding-bottom: 240px; }
}
@media (max-width: 720px) {
  :root { --sidebar-width: 0px; --header-height: 64px; --documentbar-height: 54px; }
  .app-shell { display: block; padding: 64px 0 68px; }
  .app-header { position: fixed; inset: 0 0 auto; height: 64px; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; padding: 0 16px; gap: 12px; }
  .brand-copy, .provider-pill, .sync-state { display: none; }
  .work-title { max-width: 160px; font-size: 13px; }
  .header-actions { gap: 6px; }
  .header-actions .icon-button { display: none; }
  .navigation-rail { position: fixed; inset: auto 0 0; display: flex; align-items: center; width: 100%; height: 64px; padding: 5px 6px; z-index: 40; border: 0; border-top: 1px solid var(--line); background: white; }
  .rail-primary { flex: 5; display: flex; flex-direction: row; gap: 0; }
  .rail-primary > [data-action="new-work"] { display: flex; }
  .rail-secondary { flex: 1; display: flex; padding: 0; border: 0; }
  .rail-secondary > [data-action="open-recycle-bin"], .rail-section-label { display: none; }
  .rail-button { flex: 1; flex-direction: column; justify-content: center; gap: 4px; width: 0; min-width: 0; height: 52px; padding: 5px 0; }
  .rail-label { display: block; font-size: 10px; font-weight: 450; }
  .rail-button svg { width: 17px; height: 17px; }
  .empty-view { min-height: calc(100dvh - 132px); padding: 36px 20px; }
  .empty-content h1 { font-size: 29px; letter-spacing: -1px; }
  .empty-content > p { font-size: 13px; margin-bottom: 24px; }
  .idea-label { margin: 18px 18px 10px; }
  .idea-box #ideaInput { padding: 0 18px 12px; min-height: 130px; font-size: 14px; }
  .idea-config-row, .idea-model-row { padding-left: 18px; padding-right: 18px; }
  .idea-submit-row { align-items: stretch; gap: 14px; flex-direction: column; padding: 16px 18px; }
  .idea-submit-row > span { font-size: 11px; }
  .idea-submit-row .primary-button { justify-content: space-between; }
  .sample-prompts { grid-template-columns: 1fr; gap: 10px; }
  .sample-prompt { min-height: 108px; gap: 8px; }
  .inspiration-heading { margin-top: 28px; }
  .model-picker-grid, .composer .model-picker-grid { grid-template-columns: minmax(0, 1fr); }
  .document-header { top: 64px; min-height: 54px; padding: 8px 14px; gap: 6px; }
  .document-tabs { gap: 0; }
  .document-tab { padding: 0 9px; font-size: 11px; }
  .header-context { display: none; }
  .studio-layout { padding: 14px; }
  .editor-view .document-canvas { padding: 25px 22px; border-radius: 10px; }
  .document-title { font-size: 29px; }
  .document-meta { font-size: 10px; gap: 8px; }
  .story-editor { font-size: 16px; line-height: 1.95; }
  .composer, .composer.composer-collapsed { inset: auto 12px 76px; width: auto; padding: 14px; max-height: 62dvh; }
  .composer .operation-picker { padding: 4px; }
  .composer.composer-collapsed { padding: 9px; }
  .composer-collapsed span { font-size: 10px; }
  body.keyboard-open .composer { bottom: calc(10px + var(--keyboard-inset)); }
  .modal-layer { padding: 16px; }
  .modal { max-height: calc(100dvh - 32px); }
  .modal-top { padding: 24px 22px 18px; }
  .modal-form { padding: 0 22px 22px; }
  .modal-actions { padding: 16px 22px; }
  .review-actions { left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 24px); gap: 12px; max-height: 45dvh; overflow-y: auto; }
  body[data-view] .review-actions { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .review-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .review-buttons .primary-button { grid-column: 1 / -1; min-height: 44px; }
  body[data-view] .review-state { display: grid; gap: 5px; }
  body[data-view] .navigation-rail { display: flex; }
  body[data-view] .toast { top: calc(var(--header-height) + var(--documentbar-height) + 12px); bottom: auto; }
  .candidate-layout { padding: 14px 14px 330px; }
  .candidate-banner { padding: 18px; }
  .candidate-banner > .status-badge { display: none; }
  .candidate-story { padding: 24px 22px 32px; }
  .candidate-story h1 { font-size: 27px; }
  .compare-layout { padding: 20px 14px 330px; }
  .compare-head { display: grid; gap: 14px; }
  .compare-head-actions { align-items: stretch; }
  .compare-columns-head { top: calc(var(--header-height) + var(--documentbar-height)); }
  .overview-hero { flex-direction: column; gap: 16px; }
  .overview-hero h1 { font-size: 28px; }
  .overview-canvas { padding-top: 24px; }
  .side-sheet { inset: 12px; width: auto; border-radius: 12px; }
  .sheet-header, .sheet-body { padding: 18px; }
  .version-row { grid-template-columns: 32px minmax(0, 1fr); }
  .version-row > em { grid-column: 2; width: max-content; max-width: 100%; }
  .progress-view { padding: 24px 16px; }
  .progress-card { padding: 26px 22px; }
  .settings-fields-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-email-row { grid-template-columns: minmax(0, 1fr); }
  .auth-email-row > button { justify-self: start; }
  .verification-page { padding: 20px 14px; }
  .verification-shell { margin: 0 auto; padding: 26px 22px; }
  .verification-heading > h1 { font-size: 23px; }
  body:not(.verification-page) > main:has(> #status), body:not(.verification-page) > main:has(> form[action^="/__"]) { margin: 24px auto; padding: 26px 22px; }
  body:not(.verification-page) > main > h1 { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  button, .sample-prompt { transition: none; }
}

/* The home screen reads like a screenplay feature; work-specific tools stay in the workspace. */
.home-nav, .home-works-label { display: none; }
body[data-view="empty"] { background: #f8f7f2; }
body[data-view="empty"] .app-shell { display: flex; flex-direction: column; padding: 0; }
body[data-view="empty"] .app-header {
  position: sticky; inset: 0 0 auto; display: flex; height: 68px; gap: 30px;
  padding: 0 max(24px, calc((100vw - 1200px) / 2)); border-color: #d9dcd2; background: #faf9f5;
}
body[data-view="empty"] .brand-copy { display: block; }
body[data-view="empty"] .brand-copy strong { color: #233d31; font-size: 18px; }
body[data-view="empty"] .brand-copy small { display: none; }
body[data-view="empty"] .home-nav { display: flex; align-items: center; gap: 24px; }
.home-nav a, .lead-actions a { display: inline-flex; align-items: center; min-height: 44px; color: #385144; text-decoration: none; font-weight: 550; }
.home-nav a:hover, .lead-actions a:hover { text-decoration: underline; text-underline-offset: 5px; }
body[data-view="empty"] .work-identity, body[data-view="empty"] .header-actions > :is(.provider-pill,.export-button,.icon-button) { display: none; }
body[data-view="empty"] .header-actions { margin-left: auto; gap: 12px; }
body[data-view="empty"] .header-actions .feedback-button { border-color: transparent; background: transparent; }
body[data-view="empty"][data-account-locked="false"] .work-identity { display: inline-flex; min-height: 44px; margin-left: auto; padding: 0 10px; color: #2e503b; }
body[data-view="empty"] .work-identity > :is(.work-title,.sync-state) { display: none; }
body[data-view="empty"] .home-works-label { display: inline; }
body[data-view="empty"][data-account-locked="false"] .header-actions { margin-left: 0; }
.header-actions .header-login, .studio-primary {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 19px;
  border: 1px solid #284d39; border-radius: 7px; background: #284d39; color: #fff; font-weight: 600;
}
.header-actions .header-login:hover, .studio-primary:hover { background: #193d2a; color: white; }
body[data-view="empty"] .header-login { order: 1; }
body[data-view="empty"] .main-stage { order: 1; }
body[data-view="empty"] .private-status-notice { width: min(calc(100% - 40px),1200px); margin: 20px auto 0; }
@media (min-width:721px) {
  body[data-view="empty"] .navigation-rail {
    order: 2; position: static; display: flex; flex-direction: row; justify-content: space-between;
    width: min(calc(100% - 64px),1200px); height: auto; margin: 0 auto; padding: 14px 0;
    border: 0; border-top: 1px solid #d9dcd2; background: transparent;
  }
  body[data-view="empty"] :is(.rail-primary,.rail-secondary) { display: flex; flex-direction: row; flex-wrap: wrap; padding: 0; border: 0; }
  body[data-view="empty"] .rail-section-label { display: none; }
  body[data-view="empty"] .rail-button { width: auto; gap: 6px; padding: 0 10px; }
  body[data-view="empty"] .rail-label { display: inline; font-size: 12px; }
}
.story-home {
  --paper: #fffef9; --rule: #d6d8cd; --studio-ink: #24372b; --studio-green: #356749;
  width: min(calc(100% - 88px),1200px); margin: 0 auto; color: var(--studio-ink);
}
.story-home :is(h1,h2,h3,p,dl,dd) { margin: 0; }
html:has(body[data-view="empty"]) { scroll-padding-top: 78px; }
.story-lead { display: grid; grid-template-columns: minmax(0,.83fr) minmax(0,1.17fr); align-items: center; gap: clamp(26px,4vw,64px); padding: clamp(34px,4.4vw,68px) 0; }
.home-kicker, .feature-caption small, .screenplay-heading { font-size: 12px; font-weight: 650; letter-spacing: .08em; }
.home-kicker { display: flex; align-items: center; gap: 11px; color: #48664c; }
.home-kicker::before { content: ""; display: block; width: 30px; height: 2px; background: #819675; }
.lead-copy h1 { margin: 14px 0 19px; color: #24372b; font: 650 clamp(44px,4.7vw,70px)/1.14 var(--serif); letter-spacing: -.05em; }
.lead-copy h1 em { color: var(--studio-green); font-style: normal; }
.lead-copy .lead-intro { color: #536355; font-size: 15px; line-height: 1.9; }
.lead-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 19px; margin-top: 24px; font-size: 14px; }
.studio-primary { gap: 20px; }
.studio-primary > span { font-size: 18px; }
.lead-actions a { gap: 8px; }
.feature-still {
  position: relative; display: flex; align-items: end; isolation: isolate; overflow: hidden;
  aspect-ratio: 1.67; width: 100%; min-width: 0; padding: clamp(18px,2.4vw,34px); border-radius: 10px; background: #243b2b; color: #fffdf1; text-decoration: none;
}
.feature-still > img, .feature-still::after { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.feature-still > img { object-fit: cover; object-position: 58% center; }
.feature-still::after { content: ""; background: linear-gradient(0deg,rgba(9,21,13,.76),transparent 62%); }
.feature-caption { display: grid; gap: 6px; padding-right: 35px; text-shadow: 0 1px 4px #08150da8; }
.feature-caption small { font-size: 12px; color: #f0ecda; }
.feature-caption strong { font: 650 clamp(30px,3vw,48px)/1.23 var(--serif); letter-spacing: .01em; }
.feature-caption > span { font-size: 14px; line-height: 1.6; }
.feature-arrow { position: absolute; right: 22px; bottom: 23px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid #fff9; font-size: 21px; }
.feature-still:hover .feature-arrow { background: #f8f7f2; color: #20392a; }
.home-section-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; margin-bottom: 19px; }
.home-section-heading h2 { font: 650 clamp(25px,2.3vw,34px)/1.35 var(--serif); letter-spacing: -.035em; }
.home-section-heading > p { font-size: 14px; line-height: 1.7; color: #59685a; }
.case-library, .idea-desk { padding: 29px 0 clamp(28px,3.3vw,48px); border-top: 1px solid var(--rule); }
.case-spread { display: grid; grid-template-columns: minmax(160px, .62fr) minmax(0,2fr); gap: 24px; align-items: start; }
.case-menu { display: flex; flex-direction: column; gap: 4px; }
.case-menu button {
  position: relative; display: grid; justify-items: start; gap: 5px; min-width: 0; min-height: 64px; padding: 12px 34px 12px 16px;
  background: transparent; border: 1px solid transparent; border-radius: 7px; color: #304334; text-align: left;
}
.case-menu button > span { font-size: 12px; color: #61715f; }
.case-menu button > strong { font-family: var(--serif); font-size: 18px; }
.case-menu button > i { position: absolute; right: 16px; top: calc(50% - 10px); visibility: hidden; font-size: 17px; font-style: normal; }
.case-menu button[aria-selected="true"] { background: #e7ebdf; border-color: #d0d9c9; }
.case-menu button[aria-selected="true"] i { visibility: visible; }
.case-menu button:hover { background: #edf0e7; }
.case-panel { overflow: hidden; min-width: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: 9px; }
.screenplay-page { padding: 21px clamp(19px,3vw,44px); font: 16px/1.76 var(--serif); }
.screenplay-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 15px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); color: #63725f; font-family: var(--sans); font-size: 12px; }
.screenplay-page h3 { margin: 12px 0 6px; font-size: 26px; letter-spacing: -.02em; }
.case-dialogue { padding: 9px 0; }
.case-dialogue > div { display: grid; grid-template-columns: 4em 1fr; align-items: baseline; gap: 8px; }
.case-dialogue dt { font: 600 13px/1.5 var(--sans); color: #506946; }
.case-dialogue dd { font-weight: 600; }
.case-writing { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(19px,3vw,44px); border-top: 1px solid var(--rule); background: #f1f3e9; }
.case-writing p { max-width: 43em; font-size: 13px; color: #4b5f4d; line-height: 1.7; }
.case-writing p strong { display: block; color: #294e35; font-size: 13px; }
.case-use { flex: none; display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 0 13px; border: 1px solid #a8b8a5; border-radius: 6px; background: #fffef9; color: #2e5238; font-size: 13px; font-weight: 600; }
.case-use:hover { background: #e9efdf; }
.desk-columns { display: grid; grid-template-columns: minmax(0,2fr) minmax(200px,.86fr); align-items: start; gap: clamp(20px,3.5vw,52px); }
.desk-columns:has(> :only-child) { grid-template-columns: minmax(0,1fr); }
.idea-desk .idea-box { min-width: 0; border-radius: 9px; border-color: var(--rule); box-shadow: none; }
.idea-desk .idea-box textarea { width: 100%; }
.desk-guide { padding-top: 8px; font-size: 14px; color: #526354; line-height: 1.8; }
.desk-guide h3 { margin-bottom: 8px; color: var(--studio-ink); font-size: 17px; }
.desk-guide .case-use { margin: 13px 0; }
.desk-guide details { border-top: 1px solid var(--rule); }
.desk-guide summary { padding: 12px 0; cursor: pointer; color: #38583e; }
.story-home :focus-visible, .home-nav a:focus-visible { outline: 3px solid #49805a; outline-offset: 2px; }
.case-picker-link { display: inline-flex; justify-self: start; align-items: center; gap: 6px; min-height: 44px; color: #365b40; text-underline-offset: 3px; font-size: 14px; }

.auth-modal { width: min(440px,100%); background: #faf9f5; border-color: #d3d7cb; }
.auth-modal .auth-top { padding: 24px 28px 20px; }
.auth-brand { display: inline-block; margin-bottom: 16px; color: #356749; font: 650 16px/1.35 var(--serif); }
.auth-brand b { font-family: var(--sans); }
.auth-top h2 { font: 650 28px/1.35 var(--serif); }
.auth-top p { color: #536355; }
.auth-modal .auth-form { gap: 0; padding: 0; }
.auth-fields { padding: 0 28px 20px; }
.auth-fields .form-status:empty { display: none; }
.auth-fields .form-status:not(:empty) { margin: 12px 0 0; }
.auth-fields .settings-field > input { min-height: 48px; padding: 11px 13px; background: #fffefa; font-size: 16px; }
.auth-fields input[autocomplete="one-time-code"] { font-size: 20px; letter-spacing: .24em; }
.auth-address, .auth-resend { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: #526354; }
.auth-address { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #d3d7cb; }
.auth-address strong { display: block; color: #263f2f; overflow-wrap: anywhere; }
.auth-resend { margin-top: 6px; }
.auth-modal .text-button { min-height: 44px; flex: none; color: #2f5b40; }
.auth-modal .text-button:disabled { color: #687469; opacity: 1; }
.auth-modal .auth-actions { padding: 14px 28px; background: #f1f3eb; }
.auth-actions .primary-button { min-height: 46px; padding: 0 20px; }
@media (max-width: 900px) {
  .story-home { width: calc(100% - 48px); }
  .lead-intro br { display: none; }
  .case-writing { align-items: flex-start; }
}
@media (max-width: 720px) {
  body[data-view="empty"] .app-shell { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  body[data-view="empty"] .app-header { height: 58px; gap: 12px; padding-inline: max(16px,env(safe-area-inset-left)) max(16px,env(safe-area-inset-right)); }
  body[data-view="empty"] .home-nav { display: none; }
  body[data-view="empty"] .header-actions .feedback-button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; font-size: 12px; }
  body[data-view="empty"] .header-actions { gap: 5px; }
  body[data-view="empty"] .brand-glyph { width: 30px; height: 32px; font-size: 18px; }
  body[data-view="empty"] .brand-copy strong { font-size: 16px; }
  body[data-view="empty"] .header-login { min-height: 44px; padding: 0 10px; white-space: nowrap; }
  body[data-view="empty"] .navigation-rail { height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  body[data-view="empty"][data-account-locked="true"] .rail-primary > :is([data-action="show-overview"],[data-action="open-history"]) { display: none; }
  body[data-view="empty"][data-account-locked="true"] .rail-primary { flex: 3; }
  .story-home { width: auto; margin-inline: max(18px,env(safe-area-inset-left)) max(18px,env(safe-area-inset-right)); }
  html:has(body[data-view="empty"]) { scroll-padding-top: 68px; }
  .story-lead { grid-template-columns: minmax(0,1fr); gap: 18px; padding: 24px 0; }
  .lead-copy h1 { margin: 8px 0; font-size: clamp(32px,7.5vw,45px); letter-spacing: -.045em; line-height: 1.24; }
  .lead-copy h1 br { display: none; }
  .lead-copy .lead-intro { font-size: 14px; line-height: 1.7; }
  .home-kicker { font-size: 11px; }
  .lead-actions { margin-top: 13px; gap: 17px; }
  .feature-still { aspect-ratio: 2.05; min-height: 155px; padding: 16px; }
  .feature-caption { gap: 3px; }
  .feature-caption > span { font-size: 13px; }
  .feature-arrow { width: 30px; height: 30px; right: 16px; bottom: 16px; }
  .case-library, .idea-desk { padding: 20px 0 25px; }
  .home-section-heading { gap: 3px 12px; margin-bottom: 13px; }
  .home-section-heading p { font-size: 12px; }
  .case-spread, .desk-columns { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .case-menu { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
  .case-menu button { min-height: 58px; padding: 7px 5px; gap: 3px; text-align: center; justify-items: center; }
  .case-menu button > span { font-size: 11px; }
  .case-menu button > strong { font-size: 15px; }
  .case-menu button i { display: none; }
  .screenplay-page { padding: 14px 16px; font-size: 15px; }
  .screenplay-page h3 { margin: 10px 0 4px; font-size: 23px; }
  .screenplay-heading { letter-spacing: 0; font-size: 11px; }
  .case-dialogue > div { grid-template-columns: 3em minmax(0,1fr); }
  .case-writing { flex-direction: column; gap: 8px; padding: 12px 16px; }
  .idea-desk .idea-box #ideaInput { font-size: 16px; }
  .modal-form:not(.auth-form) :where(input:not([type="checkbox"]):not([type="radio"]),textarea,select), .side-sheet .settings-field :where(input:not([type="checkbox"]):not([type="radio"]),textarea,select), #composerInput { font-size: 16px; }
  .desk-guide { padding-top: 6px; }
  body.keyboard-open[data-view="empty"] .navigation-rail { visibility: hidden; }
  .modal-layer:has(.auth-modal) { align-items: center; padding: 12px; padding-bottom: max(12px,env(safe-area-inset-bottom)); }
  .auth-modal { max-height: calc(100dvh - var(--keyboard-inset,0px) - 24px); }
  .modal-layer:has(.auth-modal) { bottom: var(--keyboard-inset,0px); }
  .auth-modal .auth-top { padding: 20px 20px 16px; }
  .auth-brand { margin-bottom: 10px; }
  .auth-fields { padding: 0 20px 15px; }
  .auth-modal .auth-actions { padding: 10px 20px; }
}
@media (max-height: 530px) {
  .auth-brand { display: none; }
  .auth-modal .auth-top { padding: 12px 18px 8px; }
  .auth-top h2 { font-size: 21px; }
  .auth-fields { padding: 0 18px 10px; }
  .auth-modal .auth-actions { padding: 8px 18px; }
}

/* Film gallery shown on the empty workbench. Other work views keep the editing palette. */
.story-home.cinema-home {
  --cin-canvas: #151714;
  --cin-cream: #f7f1df;
  --cin-gold: #f4c26c;
  --cin-muted: #b6b6a9;
  --cin-rule: #42443a;
  --cin-serif: "STSong", "华文宋体", "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --cin-width: min(1280px, calc(100% - clamp(40px, 10vw, 168px)));
  width: 100%;
  margin: 0;
  background: var(--cin-canvas);
}
body[data-view="empty"]:has(.cinema-home) .app-header {
  padding-inline: max(5%, calc((100% - 1280px) / 2));
  background: #151714;
  border-color: #393b32;
}
body[data-view="empty"]:has(.cinema-home) .app-header :is(.brand-copy strong, .brand-copy b) { color: #fff8e7; }
body[data-view="empty"]:has(.cinema-home) .app-header .brand-glyph { width: 21px; height: 22px; color: transparent; background: repeating-linear-gradient(to right, #f4c26c 0 4px, transparent 4px 7px); border: 0; border-radius: 0; box-shadow: none; transform: skew(-16deg); }
body[data-view="empty"]:has(.cinema-home) .app-header :is(.home-nav a, .feedback-button, .work-identity) { color: #e4e2d4; }
body[data-view="empty"]:has(.cinema-home) .app-header .header-login { background: #f4c26c; color: #252218; border-color: #f4c26c; border-radius: 3px; }
body[data-view="empty"]:has(.cinema-home) .app-header .header-login:hover { background: #ffda9e; }
body[data-view="empty"]:has(.cinema-home) .app-header :focus-visible { outline: 2px solid #f4c26c; outline-offset: 3px; }

.cinema-home .cin-page-width { width: var(--cin-width); margin-inline: auto; }
.cinema-home .cin-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.cinema-home :is(.cin-feature, .cin-shelf) :focus-visible { outline: 2px solid var(--cin-gold); outline-offset: 4px; }
.cinema-home .cin-feature {
  position: relative; isolation: isolate; overflow: hidden;
  background: #1c211e; color: var(--cin-cream);
}
.cinema-home .cin-feature-still {
  position: absolute; z-index: -3; inset: 0;
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 43%;
}
.cinema-home .cin-feature::before, .cinema-home .cin-feature::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
.cinema-home .cin-feature::before {
  z-index: -2;
  background: linear-gradient(90deg, #0f1511e8 0%, #121712bf 21%, #11161252 44%, #10141105 71%);
}
.cinema-home .cin-feature::after { z-index: -1; background: linear-gradient(0deg, #0d120fca 0%, transparent 35%); }
.cinema-home .cin-feature-layout { position: relative; min-height: clamp(428px, 37vw, 590px); display: flex; align-items: flex-end; }
.cinema-home .cin-feature-copy { padding: 65px 0 clamp(39px, 4.65vw, 70px); max-width: 64%; }
.cinema-home .cin-feature-meta { display: flex; align-items: center; gap: 14px; font: 500 12px/1.3 var(--sans); letter-spacing: .09em; }
.cinema-home .cin-feature-kicker { display: inline-flex; align-items: center; gap: 9px; color: var(--cin-gold); }
.cinema-home .cin-feature-kicker::before { content: ""; width: 22px; height: 2px; background: currentColor; }
.cinema-home .cin-feature-genre { padding-left: 13px; border-left: 1px solid #a8a999; color: #efe7d4; }
.cinema-home .cin-feature h1 {
  margin: 18px 0 20px -.045em;
  color: #fff7df; font: 600 clamp(68px, 7.25vw, 112px)/1.04 var(--cin-serif); letter-spacing: -.065em;
}
.cinema-home .cin-feature-hook {
  color: #f1ecdc; font: 400 clamp(18px, 1.55vw, 24px)/1.58 var(--cin-serif);
  letter-spacing: .025em; text-shadow: 0 1px 8px #10151160;
}
.cinema-home .cin-feature-hook span { display: block; }
.cinema-home .cin-feature-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 25px; margin-top: 27px; }
.cinema-home :is(.cin-primary-action,.cin-text-action) {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 45px; border: 0; font: 600 14px/1.35 var(--sans); text-decoration: none;
}
.cinema-home .cin-primary-action { padding: 0 21px; background: var(--cin-gold); color: #252218; border-radius: 3px; }
.cinema-home .cin-text-action { padding: 0; background: transparent; color: #fff6e4; }
.cinema-home .cin-book-icon { position: relative; display: inline-block; width: 17px; height: 13px; }
.cinema-home .cin-book-icon::before, .cinema-home .cin-book-icon::after {
  content: ""; position: absolute; top: 0; width: 50%; height: 12px; border: 1.4px solid;
}
.cinema-home .cin-book-icon::before { left: 0; transform: skewY(8deg); border-radius: 2px 0 0 1px; }
.cinema-home .cin-book-icon::after { right: 0; transform: skewY(-8deg); border-radius: 0 2px 1px 0; }
.cinema-home :is(.cin-arrow-up,.cin-arrow-right) { display: inline-block; position: relative; flex: none; width: 12px; height: 12px; }
.cinema-home :is(.cin-arrow-up,.cin-arrow-right)::before { content: ""; position: absolute; inset: 5px 0 auto; border-top: 1.5px solid; }
.cinema-home :is(.cin-arrow-up,.cin-arrow-right)::after { content: ""; position: absolute; top: 2px; right: 0; width: 7px; height: 7px; border-top: 1.5px solid; border-right: 1.5px solid; transform: rotate(45deg); }
.cinema-home .cin-arrow-up { transform: rotate(-45deg); }
.cinema-home .cin-reel { position: absolute; right: 0; bottom: clamp(24px, 3.4vw, 56px); display: flex; align-items: center; gap: 8px; color: #fff8e7; }
.cinema-home .cin-reel button { display: grid; place-items: center; width: 44px; height: 44px; color: inherit; border: 1px solid #f2e6cf7d; background: #1b211b70; border-radius: 50%; }
.cinema-home .cin-chevron { width: 8px; height: 8px; border-top: 1.5px solid; border-right: 1.5px solid; transform: translateX(-2px) rotate(45deg); }
.cinema-home .cin-reel button:first-of-type .cin-chevron { transform: translateX(2px) rotate(-135deg); }
.cinema-home .cin-reel-count { min-width: 49px; text-align: center; font: 12px/1.3 Georgia, serif; letter-spacing: .1em; }
.cinema-home .cin-reel-count b { font-size: 16px; font-weight: 400; }

.cinema-home .cin-shelf { padding-block: clamp(30px, 3.3vw, 51px) clamp(32px, 4vw, 65px); color: var(--cin-cream); }
.cinema-home .cin-shelf-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding-bottom: clamp(16px, 1.7vw, 25px); }
.cinema-home .cin-shelf-heading h2 { color: inherit; font: 600 clamp(27px, 2.4vw, 39px)/1.15 var(--cin-serif); letter-spacing: -.045em; }
.cinema-home .cin-shelf-heading p { color: var(--cin-muted); font-size: 13px; }
.cinema-home .cin-films { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2.1vw, 32px); }
.cinema-home .cin-film { position: relative; display: block; width: 100%; padding: 0; text-align: left; border: 0; color: var(--cin-cream); background: transparent; }
.cinema-home .cin-film-image { display: block; overflow: hidden; aspect-ratio: 2.15; background: #31352e; }
.cinema-home .cin-film-image img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .26s ease; }
.cinema-home .cin-film-info { display: grid; gap: 4px; padding: 14px 19px 0 0; }
.cinema-home .cin-film-genre { color: #d4b583; font: 500 11px/1.45 var(--sans); letter-spacing: .075em; }
.cinema-home .cin-film-name { color: inherit; font: 600 clamp(22px, 2vw, 30px)/1.25 var(--cin-serif); letter-spacing: -.025em; }
.cinema-home .cin-film-line { color: var(--cin-muted); font: 13px/1.55 var(--sans); }
.cinema-home .cin-card-arrow { position: absolute; right: 2px; bottom: 33px; color: #c9c7af; }

.cinema-home .idea-desk {
  --desk-type: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --desk-ink: #2a292d;
  --desk-muted: #686365;
  --desk-accent: #a43f43;
  --desk-accent-hover: #843137;
  --desk-hairline: #ddd8d2;
  padding-block: clamp(32px, 4.4vw, 64px) clamp(36px, 5vw, 76px);
  border: 0;
  background: #fbfaf7;
  color: var(--desk-ink);
  font-family: var(--desk-type);
}
.cinema-home .manuscript-layout {
  width: min(716px, var(--cin-width));
  margin-inline: auto;
}
.manuscript-intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 18px;
  padding-bottom: clamp(16px, 2.3vw, 26px);
  margin-bottom: 22px;
  border-bottom: 1px solid var(--desk-hairline);
}
.manuscript-intro h2 {
  color: var(--desk-ink);
  font: 600 clamp(32px, 4.1vw, 52px)/1.24 var(--desk-type);
  letter-spacing: -.035em;
}
.manuscript-intro a, .manuscript-guide .case-use {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--desk-accent);
  text-decoration: none;
  font: 500 14px/1.6 var(--desk-type);
}
.manuscript-intro a:hover, .manuscript-guide .case-use:hover {
  color: var(--desk-accent-hover);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.idea-desk .manuscript-paper {
  min-width: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.manuscript-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.manuscript-paper .idea-label { margin: 0; color: var(--desk-accent); font: 550 15px/1.6 var(--desk-type); }
.manuscript-count { color: var(--desk-muted); font: 13px/1.5 var(--desk-type); font-variant-numeric: tabular-nums; }
.idea-desk .manuscript-paper #ideaInput {
  display: block;
  width: 100%;
  min-height: 148px;
  margin: 0;
  padding: 3px 12px 8px 16px;
  border: 0;
  border-inline-start: 2px solid #d4aca9;
  border-radius: 0;
  background: transparent;
  color: var(--desk-ink);
  font: 400 18px/1.9 var(--desk-type);
  caret-color: var(--desk-accent);
  resize: vertical;
}
.idea-desk .manuscript-paper #ideaInput::placeholder { color: #746d70; opacity: 1; }
.idea-desk .manuscript-paper #ideaInput:focus {
  border-inline-start-color: var(--desk-accent);
  outline: 0;
  box-shadow: inset 2px 0 var(--desk-accent);
}
.idea-desk :is(a, button, summary, select, input):focus-visible { outline: 2px solid var(--desk-accent); outline-offset: 3px; }
.manuscript-paper .idea-model-row { margin-top: 16px; padding: 0; border: 0; border-top: 1px solid var(--desk-hairline); }
.manuscript-options { border: 0; }
.manuscript-options > summary { min-height: 50px; gap: 10px; color: var(--desk-ink); font: 500 14px/1.6 var(--desk-type); }
.manuscript-options > summary > small { color: var(--desk-muted); font-size: 13px; font-weight: 400; text-align: right; }
.manuscript-options > summary > svg { flex: none; width: 15px; height: 15px; color: var(--desk-muted); }
.manuscript-fields { padding: 12px 0 18px; border-top: 1px solid var(--desk-hairline); }
.manuscript-fields .model-picker-grid { padding: 0 0 12px; }
.manuscript-fields .task-model-picker > span { color: var(--desk-muted); font: 500 13px/1.6 var(--desk-type); }
.manuscript-fields select {
  min-height: 44px;
  border: 1px solid var(--desk-hairline);
  border-radius: 6px;
  color: var(--desk-ink);
  background-color: #fff;
  font: 400 14px/1.5 var(--desk-type);
}
.manuscript-fields .planner-option { margin: 2px 0 0; padding: 8px 0 0; border: 0; background: transparent; }
.manuscript-fields .planner-option input { accent-color: var(--desk-accent); }
.manuscript-fields .planner-option strong { color: var(--desk-ink); font-size: 14px; font-weight: 500; }
.manuscript-fields .planner-option small { color: var(--desk-muted); font-size: 12px; }
.manuscript-paper .idea-submit-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0 0;
  border-top: 1px solid var(--desk-hairline);
  background: transparent;
  color: var(--desk-muted);
  font: 400 13px/1.65 var(--desk-type);
}
.manuscript-paper .idea-submit-row .primary-button {
  flex: none;
  width: auto;
  min-height: 46px;
  justify-content: center;
  gap: 12px;
  padding: 0 19px;
  border: 1px solid var(--desk-accent);
  border-radius: 5px;
  color: #fff;
  background: var(--desk-accent);
  font: 550 15px/1.4 var(--desk-type);
  box-shadow: none;
}
.manuscript-paper .idea-submit-row .primary-button:hover { background: var(--desk-accent-hover); border-color: var(--desk-accent-hover); }
.manuscript-guide.desk-guide {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: baseline;
  gap: 0 18px;
  margin-top: clamp(19px, 2.2vw, 28px);
  padding: 0;
  color: var(--desk-muted);
  font: 400 13px/1.7 var(--desk-type);
}
.manuscript-guide .case-use { justify-self: start; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.manuscript-guide details { max-width: 22em; border: 0; }
.manuscript-guide summary { min-height: 44px; padding: 10px 0; color: var(--desk-muted); font-size: 13px; }
.manuscript-guide details p { margin: 0 0 8px; color: var(--desk-muted); }
@media (max-width: 650px) {
  .cinema-home .idea-desk { padding-block: 26px 30px; }
  .manuscript-intro { gap: 2px 10px; padding-bottom: 12px; margin-bottom: 16px; }
  .manuscript-intro h2 { font-size: clamp(26px, 7.2vw, 34px); }
  .manuscript-intro a { gap: 5px; font-size: 13px; }
  .idea-desk .manuscript-paper #ideaInput { min-height: 160px; padding: 2px 8px 8px 12px; font-size: 17px; }
  .manuscript-fields .model-picker-grid { grid-template-columns: minmax(0,1fr); }
  .manuscript-fields select { font-size: 16px; }
  .manuscript-paper .idea-submit-row { align-items: center; gap: 8px; }
  .manuscript-paper .idea-submit-row > span { font-size: 12px; }
  .manuscript-paper .idea-submit-row .primary-button { padding-inline: 13px; font-size: 14px; }
  .manuscript-guide.desk-guide { grid-template-columns: minmax(0,1fr) auto; margin-top: 15px; }
  .manuscript-guide > p { grid-row: 2; grid-column: 1/-1; }
  .manuscript-guide details { grid-row: 1; grid-column: 2; }
  .manuscript-guide:has(details[open]) { display: block; }
}
@media (max-width: 360px) {
  .manuscript-paper .idea-submit-row { flex-wrap: wrap; }
  .manuscript-paper .idea-submit-row .primary-button { margin-left: auto; }
}

body[data-view="empty"] .modal:has(.cin-reader-content) {
  --rule: #cfc6b4;
  width: min(620px, 100%); border: 1px solid #c0b59e; border-radius: 5px;
  background: #f4efe3; color: #28261e; box-shadow: 0 22px 90px #14160f55;
}
body[data-view="empty"] .modal:has(.cin-reader-content) .modal-top {
  padding: 15px 55px 15px 26px; border-bottom: 1px solid #cfc6b4; background: transparent;
}
body[data-view="empty"] .modal:has(.cin-reader-content) .cin-reader-top { position: relative; color: #4e4637; font: 600 14px/1.6 var(--sans); }
body[data-view="empty"] .modal:has(.cin-reader-content) .modal-close { top: 4px; right: 8px; width: 44px; height: 44px; color: #423b2b; }
body[data-view="empty"] .cin-reader-content .screenplay-page { padding: 22px clamp(20px, 4vw, 44px) 27px; line-height: 1.85; }
body[data-view="empty"] .cin-reader-content .screenplay-heading { border-color: #cfc6b4; color: #76521b; }
body[data-view="empty"] .cin-reader-content .screenplay-page h2 { margin: 14px 0 16px; font: 650 clamp(30px, 4vw, 44px)/1.2 var(--serif); color: #29271d; }
body[data-view="empty"] .cin-reader-content .screenplay-page p { margin: 0; color: #484436; font-size: 16px; }
body[data-view="empty"] .cin-reader-content .case-dialogue { display: grid; gap: 10px; margin: 16px 0 16px clamp(10px, 3vw, 32px); padding: 0 0 0 14px; border-left: 2px solid #baa171; }
body[data-view="empty"] .cin-reader-content .case-dialogue dt { color: #71582d; }
body[data-view="empty"] .cin-reader-content .case-dialogue dd { margin: 0; }
body[data-view="empty"] .cin-reader-content .case-writing { padding: 16px clamp(20px, 4vw, 44px); border-color: #cfc6b4; background: #ece5d6; }
body[data-view="empty"] .cin-reader-content .case-writing p { margin: 0; color: #554d3d; }
body[data-view="empty"] .cin-reader-content .case-writing strong { color: #413922; }
body[data-view="empty"] .cin-reader-content .case-use { background: #353022; color: #fff9eb; border-color: #353022; border-radius: 3px; }
body[data-view="empty"] .cin-reader-content .case-use:hover { background: #51442a; }

@media (hover: hover) {
  .cinema-home :is(.cin-text-action:hover, .cin-film:hover .cin-film-name) { color: var(--cin-gold); }
  .cinema-home .cin-primary-action:hover { background: #ffd48a; }
  .cinema-home .cin-reel button:hover { border-color: var(--cin-gold); }
  .cinema-home .cin-film:hover .cin-film-image img { transform: scale(1.035); }
}
@media (min-width: 721px) and (max-width: 920px) {
  .cinema-home .cin-feature-layout { min-height: 420px; }
  .cinema-home .cin-feature-still { object-position: 58% 42%; }
  .cinema-home .cin-feature::before { background: linear-gradient(90deg, #101511e6, #1015119c 38%, transparent 75%); }
}
@media (max-width: 720px) {
  .story-home.cinema-home { --cin-width: calc(100% - max(20px, env(safe-area-inset-left)) - max(20px, env(safe-area-inset-right))); }
  body[data-view="empty"]:has(.cinema-home) .app-header { padding-inline: max(16px,env(safe-area-inset-left)) max(16px,env(safe-area-inset-right)); }
  .cinema-home .cin-feature-layout { display: grid; min-height: 0; }
  .cinema-home .cin-feature { background: #172019; }
  .cinema-home .cin-feature-still { height: clamp(260px, 75vw, 410px); object-position: 69% 35%; }
  .cinema-home .cin-feature-still[data-film="slippers"] { object-position: 55% 55%; }
  .cinema-home .cin-feature-still[data-film="radio"] { object-position: 70% 45%; }
  .cinema-home .cin-feature::before { height: clamp(261px, 75vw + 1px, 411px); background: linear-gradient(0deg, #172019, #1720199c 20%, transparent 57%); }
  .cinema-home .cin-feature::after { background: linear-gradient(0deg, #151714, transparent 36%); }
  .cinema-home .cin-feature-copy { max-width: none; padding: clamp(208px, 57vw, 312px) 0 24px; }
  .cinema-home .cin-feature-meta { font-size: 11px; gap: 10px; }
  .cinema-home .cin-feature-kicker { gap: 7px; }
  .cinema-home .cin-feature-kicker::before { width: 16px; }
  .cinema-home .cin-feature-genre { padding-left: 10px; }
  .cinema-home .cin-feature h1 { font-size: clamp(53px, 14vw, 82px); margin: 10px 0 11px -.045em; }
  .cinema-home .cin-feature-hook { font-size: 17px; line-height: 1.55; }
  .cinema-home .cin-feature-actions { gap: 21px; margin-top: 17px; }
  .cinema-home .cin-primary-action { padding-inline: 16px; }
  .cinema-home .cin-reel { top: 10px; left: -5px; right: auto; bottom: auto; gap: 0; border-radius: 30px; background: #141a16b0; }
  .cinema-home .cin-reel button { border: 0; background: transparent; }
  .cinema-home .cin-reel-count { min-width: 40px; font-size: 10px; }
  .cinema-home .cin-reel-count b { font-size: 13px; }
  .cinema-home .cin-shelf { padding-block: 22px 28px; }
  .cinema-home .cin-shelf-heading { padding-bottom: 15px; }
  .cinema-home .cin-shelf-heading h2 { font-size: 28px; }
  .cinema-home .cin-shelf-heading p { font-size: 12px; }
  .cinema-home .cin-films { grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--cin-rule); }
  .cinema-home .cin-film { display: grid; grid-template-columns: clamp(85px, 27vw, 150px) minmax(0, 1fr) 12px; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--cin-rule); }
  .cinema-home .cin-film-image { aspect-ratio: 1.48; }
  .cinema-home .cin-film-info { padding: 0; gap: 2px; }
  .cinema-home .cin-film-name { font-size: 22px; }
  .cinema-home .cin-film-line { font-size: 12px; }
  .cinema-home .cin-card-arrow { position: relative; inset: auto; width: 10px; }
  body[data-view="empty"] .modal-layer:has(.cin-reader-content) { align-items: center; padding: max(10px,env(safe-area-inset-top)) 10px max(10px,env(safe-area-inset-bottom)); }
  body[data-view="empty"] .modal:has(.cin-reader-content) { max-height: calc(100dvh - max(10px,env(safe-area-inset-top)) - max(10px,env(safe-area-inset-bottom))); }
  body[data-view="empty"] .cin-reader-content .case-writing { align-items: stretch; }
}
@media (max-width: 360px) {
  .story-home.cinema-home { --cin-width: calc(100% - max(15px, env(safe-area-inset-left)) - max(15px, env(safe-area-inset-right))); }
  .cinema-home .cin-film { gap: 9px; }
  .cinema-home .cin-shelf-heading p { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .cinema-home .cin-film-image img { transition: none; }
  .cinema-home .cin-film:hover .cin-film-image img { transform: none; }
}

.site-icp { padding: 6px 12px; text-align: center; font-size: 12px; line-height: 16px; color: var(--ink-soft); }
.site-icp a { color: inherit; }
@media (max-width: 760px) {
  .site-icp { margin-bottom: calc(64px + env(safe-area-inset-bottom)); }
}
