:root {
  color-scheme: light;
  --paper: #f7f7f2;
  --surface: #fffefa;
  --ink: #253d37;
  --muted: #647168;
  --line: #dfe4db;
  --accent: #356d60;
  --accent-light: #eaf1eb;
  --radius: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; text-underline-offset: 4px; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }
button:disabled { opacity: .5; }
:focus-visible { outline: 3px solid #548f7b; outline-offset: 3px; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
img { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.page-width { width: min(1380px, calc(100% - 72px)); margin-inline: auto; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 10; padding: 12px 18px; background: var(--surface); }
.skip-link:focus { top: 10px; }
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-size: 21px; font-weight: 650; letter-spacing: -.5px; }
.brand svg { color: var(--accent); }
.brand-section { color: var(--muted); font-size: 13px; font-weight: 400; letter-spacing: 0; margin-left: 9px; }
.back-link { text-decoration: none; font-size: 13px; white-space: nowrap; padding-block: 10px; }
.back-link:hover, .site-footer a:hover { color: var(--accent); text-decoration: underline; }
.page-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 32px 0 17px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .12em; }
h1 { font-size: clamp(27px, 3vw, 35px); letter-spacing: -.035em; line-height: 1.4; margin: 6px 0; }
.page-intro > div > p:not(.eyebrow) { color: var(--muted); }
.preview-note { max-width: 400px; font-size: 12px; text-align: right; }
.preview-note strong { display: inline-block; color: var(--accent); font-weight: 500; padding: 4px 9px; border-radius: 5px; background: var(--accent-light); }
.preview-note p { margin-top: 6px; }
.status-line { min-height: 24px; margin-bottom: 17px; color: var(--accent); font-size: 13px; }
.notice { padding: 13px 17px; border: 1px solid; border-radius: 9px; margin-bottom: 18px; overflow-wrap: anywhere; font-size: 13px; }
.error { color: #903e30; background: #fff1eb; border-color: #eccfc4; }
.warning { color: #75541f; background: #fbf3dc; border-color: #e6d8b4; }
.workspace { display: grid; grid-template-columns: 370px minmax(0, 1fr); gap: 24px; align-items: start; }
.workspace > *, .canvas-panel > *, .output-fields > *, .section-heading > * { min-width: 0; }
.settings-panel, .canvas-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.setting-section, .generate-section { padding: 20px 22px; }
.setting-section { border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.step { color: var(--muted); font-size: 12px; font-weight: 400; margin-right: 10px; }
.text-button { border: 0; padding: 6px 0; background: transparent; color: var(--accent); font-size: 12px; min-height: 36px; text-align: left; text-decoration: underline; text-decoration-color: #b6c9b9; text-underline-offset: 4px; }
.text-button:hover:not(:disabled) { text-decoration-color: var(--accent); }
.drop-zone { position: relative; margin-top: 12px; background: #f7f8f3; border: 1px dashed #b9c7bb; border-radius: 8px; }
.drop-zone:focus-within { outline: 3px solid #548f7b; outline-offset: 3px; }
.drop-zone.drag-over { background: var(--accent-light); border-color: var(--accent); }
.upload-target { padding: 18px 10px; min-height: 123px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; cursor: pointer; }
.upload-target svg { color: var(--accent); margin-bottom: 9px; }
.upload-target strong { font-weight: 500; font-size: 13px; }
.upload-target span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.compact-drop { margin-top: 0; }
.compact-drop .upload-target { min-height: 82px; padding-block: 12px; }
fieldset:disabled .upload-target { opacity: .55; cursor: not-allowed; }
.source-info { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.source-info img { width: 56px; height: 56px; border-radius: 5px; object-fit: contain; background: #f0f1eb; border: 1px solid var(--line); }
.source-info div { min-width: 0; }
.source-info strong { font-size: 12px; font-weight: 500; display: block; overflow-wrap: anywhere; }
.source-info span { display: block; font-size: 12px; color: var(--muted); }
.field-help { font-size: 12px; color: var(--muted); line-height: 1.8; margin-top: 9px; overflow-wrap: anywhere; }
.field-label { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 7px; }
.section-heading .field-label { margin: 0; }
.audio-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin: 14px 0; border: 1px solid var(--line); border-radius: 8px; background: #f1f4ec; }
.audio-modes label { position: relative; }
.audio-modes input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.audio-modes span { display: block; padding: 8px; text-align: center; border-radius: 5px; font-size: 13px; cursor: pointer; }
.audio-modes input:checked + span { color: var(--accent); background: var(--surface); box-shadow: 0 1px 4px #253d3714; }
.audio-modes input:focus-visible + span { outline: 3px solid #548f7b; outline-offset: 2px; }
.audio-modes input:disabled + span { opacity: .5; cursor: not-allowed; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.preset-chip { min-height: 32px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; cursor: pointer; }
.preset-chip:hover:not(:disabled) { color: var(--accent); border-color: #b6c9b9; }
.preset-chip:focus-visible { outline: 3px solid #548f7b; outline-offset: 2px; }
.preset-chip:disabled { opacity: .5; cursor: not-allowed; }
.advanced-settings { margin-top: 0; }
.advanced-settings > summary { font-size: 15px; font-weight: 500; }
textarea, select { width: 100%; min-width: 0; border: 1px solid #cfd8ce; background: var(--surface); border-radius: 7px; padding: 10px; font-size: 14px; }
select { min-height: 44px; }
textarea { display: block; resize: vertical; min-height: 94px; margin-top: 6px; }
textarea::placeholder { color: #738174; }
[aria-invalid="true"] { outline: 2px solid #aa5746; outline-offset: 2px; }
.drop-zone input[aria-invalid="true"] + label { outline: 2px solid #aa5746; border-radius: 7px; }
.field-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 5px; font-size: 12px; color: var(--muted); margin-top: 5px; }
#script-count { font-variant-numeric: tabular-nums; }
.consent-label { display: flex; gap: 9px; align-items: flex-start; font-size: 12px; line-height: 1.8; cursor: pointer; margin-top: 13px; }
.consent-label input, .switches input { width: 17px; height: 17px; margin: 3px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.generate-section .consent-label { margin-top: 0; }
.button { min-height: 44px; padding: 10px 14px; border: 1px solid #c6d3c7; border-radius: 7px; background: var(--surface); font-size: 13px; font-weight: 500; text-align: center; }
.button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-light); }
.button.primary { background: var(--accent); border-color: var(--accent); color: white; }
.button.primary:hover:not(:disabled) { background: #29594d; }
.full-width { width: 100%; margin-top: 14px; }
.audio-preview { background: #f4f6ef; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 18px; min-width: 0; }
audio { width: 100%; min-width: 0; display: block; margin-top: 12px; height: 42px; }
.inline-warning { font-size: 12px; color: #805519; border-left: 3px solid #c29343; padding: 8px 10px; margin-top: 12px; background: #fff5de; }
.output-fields { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 10px; }
.switches { display: grid; gap: 12px; margin: 17px 0; }
.switches label { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; cursor: pointer; }
.range-heading { font-size: 12px; gap: 8px; }
.range-heading output { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
input[type="range"] { display: block; width: 100%; margin: 6px 0 0; min-height: 36px; accent-color: var(--accent); }
.generation-footnote { margin-top: 9px; text-align: center; font-size: 12px; color: var(--muted); }
.canvas-panel { position: sticky; top: 20px; overflow: hidden; }
.canvas-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.canvas-toolbar h2 { margin-top: 3px; font-size: 17px; }
.state-label { display: inline-block; padding: 3px 8px; border-radius: 5px; font-size: 12px; color: var(--accent); background: var(--accent-light); }
.waiting-panel { padding: 15px 22px; background: var(--accent-light); border-bottom: 1px solid #d4e2d5; font-size: 12px; color: var(--accent); }
.waiting-panel strong { font-size: 14px; font-weight: 500; }
.waiting-panel p:last-child { color: #526b5a; }
#elapsed-time { font-size: 18px; margin: 5px 0; font-variant-numeric: tabular-nums; }
.image-stage { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 14px; padding: 20px; }
.media-figure { min-width: 0; }
.media-figure figcaption { margin-bottom: 9px; font-size: 12px; }
.media-well { display: flex; align-items: center; justify-content: center; height: clamp(320px, 34vw, 490px); border: 1px solid #e3e7dc; background: #edf0e7; border-radius: 8px; overflow: hidden; }
.media-well > img, .media-well > video { width: 100%; height: 100%; min-width: 0; object-fit: contain; }
.video-well { background: #f1f3eb; }
.video-well:has(video:not([hidden])) { background: #182823; }
.empty-state { text-align: center; padding: 22px 15px; width: 100%; }
.empty-state svg { color: #809b85; margin-bottom: 16px; }
.empty-state h3 { font-size: 15px; font-weight: 500; }
.empty-state p { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.9; }
.empty-wordmark { display: block; font-size: 12px; letter-spacing: .2em; color: #688572; margin-bottom: 22px; }
.canvas-note { padding: 0 20px 18px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.result-details { padding: 18px 20px; border-top: 1px solid var(--line); }
.result-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 17px; }
.result-metadata { display: grid; gap: 7px; font-size: 12px; }
.result-metadata > div { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 10px; }
.result-metadata dt { color: var(--muted); }
.result-metadata dd { overflow-wrap: anywhere; }
details { font-size: 12px; margin-top: 12px; }
summary { padding-block: 7px; cursor: pointer; color: var(--accent); }
details p { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 7px; }
#save-state.unsaved { color: #805519; }
.recovery-panel { padding: 18px 20px; background: #fbf3dc; border-top: 1px solid #e6d8b4; color: #75541f; }
.recovery-panel p { font-size: 12px; margin: 7px 0 12px; }
.history-section { margin-top: 35px; }
.history-heading { margin-bottom: 18px; }
.history-heading .section-heading { justify-content: flex-start; flex-wrap: wrap; }
.history-heading h2 { font-size: 18px; }
.local-badge { color: var(--muted); font-size: 12px; }
.history-heading p { color: var(--muted); font-size: 12px; margin-top: 8px; max-width: 880px; }
.history-empty { padding: 30px 16px; border-block: 1px solid var(--line); text-align: center; font-size: 13px; color: var(--muted); }
.history-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.history-list li { min-width: 0; }
.history-card { width: 100%; height: 100%; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; text-align: left; }
.history-card[aria-current="true"], .history-card:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.history-card img { width: 100%; height: 160px; object-fit: contain; background: #eaece3; }
.history-card span { display: block; padding: 11px 12px; }
.history-card strong { display: block; font-size: 13px; font-weight: 500; }
.history-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 25px 0; margin-top: 35px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.site-footer a { text-decoration: none; }

@media (max-width: 1150px) {
  .page-width { width: calc(100% - 40px); }
  .workspace { grid-template-columns: 335px minmax(0, 1fr); gap: 18px; }
  .setting-section, .generate-section { padding-inline: 18px; }
  .image-stage { padding: 16px; gap: 10px; }
  .canvas-toolbar { padding-inline: 18px; }
  .media-well { height: 360px; }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .canvas-panel { position: static; }
  .page-intro { align-items: flex-start; }
  .preview-note { max-width: 290px; }
  .media-well { height: 420px; }
}
@media (max-width: 560px) {
  .page-width { width: calc(100% - 28px); }
  .topbar { min-height: 62px; gap: 12px; }
  .brand { font-size: 19px; gap: 7px; }
  .brand-section { display: none; }
  .back-link { font-size: 12px; }
  .page-intro { display: block; padding-top: 24px; }
  .preview-note { text-align: left; margin-top: 12px; max-width: none; }
  .settings-panel, .canvas-panel { border-radius: 12px; }
  .setting-section, .generate-section { padding: 18px 16px; }
  textarea, select { font-size: 16px; }
  .output-fields { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .section-heading { flex-wrap: wrap; gap: 5px 12px; }
  .image-stage { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .media-well { height: min(112vw, 420px); }
  .canvas-toolbar, .result-details, .recovery-panel { padding: 16px; }
  .canvas-note { padding-inline: 16px; }
  .waiting-panel { padding: 14px 16px; }
  .history-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .history-card img { height: 145px; }
  .history-card span { padding: 10px; }
  .result-metadata > div { grid-template-columns: 73px minmax(0, 1fr); gap: 7px; }
  .history-section { margin-top: 28px; }
}
@media (max-height: 900px) and (min-width: 901px) { .canvas-panel { position: static; } }
