:root {
  color-scheme: dark;
  --bg: #11151b;
  --panel: #1a2029;
  --panel2: #202833;
  --line: #35404e;
  --text: #edf0f4;
  --muted: #aab5c4;
  --gold: #edc987;
  --goldink: #201b12;
  --green: #91d6b5;
  --red: #ffb6ac;
  --radius: 18px;
  font-family: 'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html { overflow-wrap: anywhere; }
body { margin: 0; min-height: 100vh; min-height: 100svh; background: var(--bg); color: var(--text); }
a { color: var(--gold); text-decoration: none; }
button, input, textarea, select { font: inherit; max-width: 100%; }
button, a, input, textarea, select { touch-action: manipulation; }
button { padding: 12px 20px; min-height: 48px; border: 1px solid transparent; border-radius: 10px; background: var(--gold); color: var(--goldink); font-weight: 650; cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
button.secondary { background: var(--panel2); color: var(--text); border-color: var(--line); }
button.text-button { padding: 10px 0; color: var(--gold); background: transparent; font-weight: 400; text-align: left; }
input, textarea, select { width: 100%; min-width: 0; background: #10161e; border: 1px solid var(--line); color: var(--text); padding: 13px 14px; border-radius: 10px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
textarea { resize: vertical; min-height: 120px; }
label { display: block; color: var(--muted); margin-bottom: 8px; }
p { margin: 0 0 18px; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 20px; }
h2 { font-size: 25px; }
h3 { font-size: 19px; }
small, .small { font-size: 14px; color: var(--muted); }
[hidden] { display: none !important; }
main, section, aside, form, .inline, .status-line, .topbar > *, .workspace > *, .owner-shell > * { min-width: 0; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: calc(20px + env(safe-area-inset-top, 0px)) max(5vw, env(safe-area-inset-right, 0px)) 20px max(5vw, env(safe-area-inset-left, 0px)); border-bottom: 1px solid #2c3541; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-size: 20px; letter-spacing: 2px; }
.brand small { display: block; font-size: 12px; letter-spacing: 1px; }
.seal { flex: 0 0 46px; width: 46px; border: 1px solid #b39460; border-radius: 4px; color: var(--gold); font: 29px/1.6 serif; text-align: center; }
.top-actions { display: flex; gap: 16px; align-items: center; flex-shrink: 0; font-size: 14px; }
.local-tag, .pill { border: 1px solid var(--line); padding: 4px 10px; border-radius: 20px; color: var(--muted); font-size: 13px; }
#shareEntry { padding: 9px 14px; min-height: 44px; color: var(--gold); background: transparent; border-color: #62533c; white-space: nowrap; }

.entry { width: calc(100% - 48px); max-width: 620px; margin: 48px auto 24px; padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); }
.entry-welcome { border-top-color: #8f7851; box-shadow: 0 18px 60px #0002; }
.eyebrow { color: var(--gold); letter-spacing: 1px; font-size: 13px; }
.entry h1 { font-family: 'STSong', 'SimSun', serif; font-weight: 500; font-size: clamp(32px, 4vw, 40px); line-height: 1.45; letter-spacing: .5px; }
.lead { color: var(--muted); margin-bottom: 18px; }
.entry-hint { display: inline-block; padding: 5px 11px; margin-bottom: 30px; border: 1px solid #554a38; border-radius: 8px; color: #e1cba4; font-size: 13px; }
#startForm > label:first-child { color: var(--text); }
.inline { display: flex; gap: 12px; align-items: center; }
.inline input { flex: 1; }
.inline button { white-space: nowrap; }
#startForm .check-label { margin: 18px 0 12px; font-size: 13px; line-height: 1.8; }
#resumeButton { display: block; margin-top: 10px; }
.entry-footer { border-top: 1px solid var(--line); padding-top: 22px; margin: 26px 0 0; color: var(--gold); font-size: 14px; }
.entry-footer span { display: inline-block; margin-top: 5px; font-size: 13px; color: var(--muted); }
.entry .resume-card { font-size: 14px; }
.site-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; padding: 4px max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); color: #738195; font-size: 12px; }
.site-footer a { display: inline-flex; min-height: 44px; align-items: center; color: var(--muted); }
.client-mode #ownerLink { color: #97a3b3; }

.workspace { max-width: 1280px; margin: 30px auto 20px; padding: 0 max(28px, env(safe-area-inset-right, 0px)) 0 max(28px, env(safe-area-inset-left, 0px)); display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; }
.journey { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.journey .active { color: var(--gold); }
.main-panel, .dossier, .card { min-width: 0; padding: 26px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); }
.main-panel { min-height: 530px; }
.dossier { align-self: start; position: sticky; top: 20px; }
.dossier h2 { font-size: 21px; }
.dossier dl { margin: 0; }
.dossier dt { color: var(--muted); font-size: 14px; margin-top: 18px; }
.dossier dd { margin: 4px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.dossier dd button { display: block; padding: 4px 0; min-height: 44px; font-size: 14px; }
.dossier .identity { font: 30px serif; color: var(--gold); margin-bottom: 8px; }
.question { font-size: 24px; line-height: 1.65; margin: 24px 0; white-space: pre-wrap; }
.answer-preview { border-left: 2px solid var(--gold); padding: 10px 16px; background: var(--panel2); white-space: pre-wrap; margin: 12px 0 24px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.notes { font-size: 14px; color: var(--muted); margin: 14px 0; }
.error { color: var(--red); }
.good { color: var(--green); }
.card { margin-bottom: 18px; padding: 22px; }
.card .label { font-size: 14px; color: var(--gold); margin-bottom: 8px; }
.card p { white-space: pre-wrap; overflow-wrap: anywhere; }
.card p:last-child { margin-bottom: 0; }
.divider { height: 1px; background: var(--line); margin: 26px 0; }
.history { margin: 28px 0 0; color: var(--muted); font-size: 14px; }
.history summary { cursor: pointer; padding: 10px 0; min-height: 44px; }
.history .turn { padding: 12px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; }
.history b { color: var(--gold); }
.result-title { color: var(--gold); }
.preview-frame { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #0b1117; margin: 20px 0; }
.preview-frame img { display: block; width: 100%; height: auto; }
.watermark { position: absolute; bottom: 0; left: 0; right: 0; padding: 12px; background: #111c; color: #fff; text-align: center; font-size: 14px; }
.preview-empty { padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; margin: 20px 0; }
.status-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.status-line > * { min-width: 0; }
.source-badge { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
#refreshCase { flex-shrink: 0; }
.owner-shell { max-width: 1360px; margin: 30px auto; padding: 0 28px; display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 24px; }
.owner-nav { align-self: start; }
.owner-nav button { display: block; width: 100%; text-align: left; margin: 10px 0; background: var(--panel); color: var(--text); border: 1px solid var(--line); overflow-wrap: anywhere; }
.owner-nav button.selected { border-color: var(--gold); }
.owner-nav button small { display: block; }
.owner-form .two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.owner-form label { margin-top: 20px; }
.check-label { display: block; position: relative; padding-left: 30px; min-height: 26px; line-height: 1.8; }
.check-label input[type="checkbox"] { position: absolute; left: 0; top: 3px; width: 20px; height: 20px; padding: 0; margin: 0; accent-color: var(--gold); }
.check-label a { text-decoration: underline; text-underline-offset: 3px; }
.access-code { font: 16px monospace; word-break: break-all; color: var(--gold); }
.resume-card { background: var(--panel); border: 1px solid var(--line); padding: 16px; border-radius: 10px; margin-top: 10px; }
.resume-card button { margin-top: 10px; }
.busy { opacity: .7; pointer-events: none; }
footer { padding-top: 20px; color: var(--muted); font-size: 14px; }

#notice { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(calc(100% - 32px), 700px); max-height: 50vh; overflow-y: auto; background: #313d4d; border: 1px solid var(--gold); padding: 14px 18px; border-radius: 10px; z-index: 50; display: none; white-space: pre-wrap; }
#notice.visible { display: block; }
dialog { max-width: min(620px, calc(100% - 24px)); width: 100%; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); overflow-y: auto; overscroll-behavior: contain; padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: #000b; }
dialog:not([open]) { display: none; }
body.modal-open { overflow: hidden; }
body.modal-open #app, body.modal-open .topbar, body.modal-open .site-footer { pointer-events: none; }
dialog.dialog-fallback[open] { display: block; position: fixed; inset: 50% auto auto 50%; transform: translate(-50%, -50%); margin: 0; z-index: 90; width: calc(100% - 24px); max-height: 85vh; max-height: 85dvh; overflow-y: auto; box-shadow: 0 0 0 100vmax #000b; }
dialog h2 { font-size: 24px; }
dialog form { margin-bottom: 20px; }
dialog .toolbar { margin-bottom: 0; }
#workState { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); background: #243245; border: 1px solid var(--gold); padding: 10px 20px; border-radius: 12px; z-index: 100; color: var(--text); font-size: 14px; max-width: calc(100% - 32px); }

@media (max-width: 860px) {
  .workspace, .owner-shell { grid-template-columns: minmax(0, 1fr); padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
  .dossier { position: static; order: 2; }
  .owner-nav { display: flex; overflow-x: auto; gap: 10px; align-items: stretch; }
  .owner-nav > h2 { display: none; }
  .owner-nav button { flex: 0 0 210px; min-width: 210px; }
  .owner-form .two-col { grid-template-columns: minmax(0, 1fr); }
  .owner-shell h1 { font-size: 28px; }
  .owner-shell .status-line { flex-wrap: wrap; justify-content: flex-start; }
  .owner-shell .status-line h1 { flex-basis: 100%; }
  .main-panel, .dossier { padding: 22px; }
  .question { font-size: 22px; }
  .toolbar button { flex: 1 1 120px; }
}

@media (max-width: 600px) {
  .topbar { gap: 10px; padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 14px max(16px, env(safe-area-inset-left, 0px)); }
  .brand { gap: 9px; font-size: 18px; letter-spacing: 0; }
  .brand small { font-size: 11px; letter-spacing: 0; }
  .seal { flex-basis: 38px; width: 38px; font-size: 25px; }
  .top-actions { gap: 8px; font-size: 13px; }
  .local-tag { display: none; }
  #shareEntry { padding: 9px 11px; }
  .entry { width: calc(100% - 32px); margin: 24px auto 12px; padding: 26px 22px; border-radius: 18px; }
  .entry h1 { font-size: 32px; }
  .eyebrow { font-size: 12px; letter-spacing: .5px; }
  .lead { font-size: 15px; }
  .entry-hint { margin-bottom: 24px; }
  .inline { flex-wrap: wrap; }
  .inline input { flex-basis: 100%; }
  .inline button { width: 100%; min-height: 52px; }
  .entry-footer { font-size: 13px; }
  #resumeButton { font-size: 14px; }
  .workspace { margin-top: 22px; gap: 18px; }
  .journey { gap: 8px; font-size: 12px; margin-bottom: 16px; }
  .main-panel, .dossier, .card { padding: 18px; }
  .main-panel { min-height: 0; }
  .question { font-size: 21px; }
  .status-line { gap: 10px; }
  dialog { padding: 22px 18px; }
  dialog h2 { font-size: 22px; }
}

@media (max-width: 360px) {
  .entry { padding: 24px 18px; }
  .entry h1 { letter-spacing: 0; }
  .entry-hint { padding-right: 9px; padding-left: 9px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
.voice-controls { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0 0 22px; background: #151c25; }
.voice-caption { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.voice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.voice-actions button { min-height: 44px; font-size: 14px; }
.voice-actions button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.voice-choice { font-size: 13px; margin: 10px 0 0; }
.voice-choice select { display: block; margin-top: 5px; min-height: 44px; font-size: 16px; }
.voice-controls .notes, #voiceNote { font-size: 13px; line-height: 1.65; margin: 10px 0 0; overflow-wrap: anywhere; }
.voice-controls summary { cursor: pointer; min-height: 44px; font-size: 13px; color: var(--muted); }
.narration-panel { margin: 26px 0; padding: 18px; border: 1px solid var(--gold); border-radius: 14px; overflow-wrap: anywhere; }
.narration-panel audio, .narration-panel video { display: block; width: 100%; max-width: 100%; margin: 14px 0; border-radius: 10px; background: #080d13; }
.narration-panel [hidden] { display: none; }
.narration-panel video { max-height: 65vh; object-fit: contain; }
.narration-panel button, .narration-panel summary { min-height: 44px; }
.narration-panel button { white-space: normal; max-width: 100%; }
.narration-panel textarea { width: 100%; min-width: 0; font-size: 16px; }
.narration-panel .check-label { align-items: flex-start; font-size: 13px; }
@media (max-width: 480px) { .narration-panel { padding: 12px; } .narration-panel button { width: 100%; } }
@media (max-width: 360px) { .voice-controls { padding: 10px; } .voice-actions { gap: 4px 10px; } .voice-actions button { padding-left: 6px; padding-right: 6px; } }
.plan-view { margin: 24px 0; overflow-wrap: anywhere; }
.plan-view .eyebrow { margin-top: 22px; }
.plan-map { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) auto minmax(0,1fr); gap: 12px; align-items: start; margin: 24px 0 12px; }
.plan-map > div { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #151c25; min-width: 0; }
.plan-map p { margin: 10px 0 0; font-size: 15px; white-space: pre-wrap; }
.plan-label { font-size: 12px; color: var(--gold); }
.plan-arrow { padding-top: 30px; color: var(--gold); }
.plan-steps { list-style: none; padding: 0; counter-reset: none; }
.plan-steps li { border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; overflow: hidden; }
.plan-steps summary { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 16px; cursor: pointer; }
.plan-steps summary::after { content: '+'; margin-left: auto; color: var(--gold); }
.plan-steps details[open] summary::after { content: '−'; }
.plan-steps details[open] summary { border-bottom: 1px solid var(--line); }
.plan-step-number { color: var(--gold); font-size: 14px; }
.plan-step-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.plan-steps .plan-step-text { padding: 0 16px; margin: 16px 0; }
.plan-original summary, .plan-intake summary { min-height: 44px; padding: 10px 0; cursor: pointer; color: var(--muted); font-size: 14px; }
@media (max-width: 1100px) {
  .plan-map { grid-template-columns: minmax(0,1fr); gap: 6px; }
  .plan-map > div { padding: 14px 16px; }
  .plan-arrow { padding: 0; justify-self: center; transform: rotate(90deg); }
}
.question-audio-panel { margin: 20px 0; padding: 20px; border: 1px solid #9a8156; border-radius: 14px; background: linear-gradient(140deg,#28271f,#17222c); }
.question-audio-panel h3 { margin-bottom: 10px; color: var(--gold); }
.question-audio-panel audio { display: block; width: 100%; margin-top: 14px; }
.question-audio-panel button { white-space: normal; }
.question-audio-panel .notes { font-size: 13px; }
.question-audio-panel.question-audio-compact { margin: 12px 0 18px; padding: 0; border: 0; border-radius: 0; background: none; }
.question-audio-compact .question-audio-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.question-audio-compact .question-audio-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.question-audio-compact button { min-height: 44px; }
.question-audio-compact .notes { margin: 8px 0 0; }
.question-audio-compact .question-audio-consent { margin: 4px 0 8px; font-size: 12px; }
.question-audio-compact audio { margin-top: 8px; }
.consultation-wait, .project-gate { padding: 20px; margin: 24px 0; border: 1px solid var(--line); border-radius: 14px; background: #151c25; }
.project-gate .pill { display: inline-block; margin-bottom: 14px; }
.manual-draft { margin: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; }
.manual-draft summary { cursor: pointer; min-height: 44px; color: var(--gold); }
.consultation-visual { border: 1px solid #5b644f; border-radius: 14px; margin: 24px 0; padding: 20px; background: radial-gradient(ellipse at top left,#293328,#131b24 70%); overflow: hidden; }
.consultation-visual .status-line { flex-wrap: wrap; }
.consultation-visual h3 { margin: 0; }
.structure-stage { perspective: 850px; padding: 16px 0; }
.structure-modules { list-style: none; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 0; margin: 0; transform-origin: center; transition: transform .35s ease; }
.structure-modules li { min-width: 0; position: relative; }
.structure-module { display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 92px; text-align: left; color: var(--text); background: #202c33; border: 1px solid #56685c; box-shadow: 0 8px 0 #0c131aaa; font-weight: 400; white-space: pre-wrap; }
.structure-module.selected { border-color: var(--gold); background: #30352b; }
.structure-module .plan-step-number { flex-shrink: 0; }
.perspective-view .structure-modules { transform: rotateX(14deg) rotateY(-6deg); }
.structure-focus { border-left: 2px solid var(--gold); padding: 12px 14px; margin: 14px 0 0; color: var(--gold); white-space: pre-wrap; }
@media (max-width: 600px) {
  .consultation-visual,.question-audio-panel,.consultation-wait,.project-gate { padding: 14px; }
  .structure-modules { grid-template-columns: minmax(0,1fr); }
  .structure-module { min-height: 76px; }
  .question-audio-panel button { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .structure-modules { transition: none; } }
