:root {
  color-scheme: light;
  --primary: #4f46a5;
  --primary-dark: #3f378c;
  --primary-soft: #ecebff;
  --background: #f6f2fb;
  --surface: #fff;
  --surface-alt: #f8f6fb;
  --text: #211f26;
  --muted: #6e6874;
  --border: #ddd3e8;
  --error: #a2382f;
  --error-soft: #fff0ed;
  --success: #277457;
  --shadow: 0 18px 50px rgba(51, 43, 120, .08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; background: var(--background); }
body { margin: 0; min-height: 100dvh; color: var(--text); background: radial-gradient(circle at 96% 0, rgba(79,70,165,.09), transparent 31rem), var(--background); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, label.upload-box:focus-within { outline: 3px solid rgba(79,70,165,.28); outline-offset: 2px; }
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; padding: 10px 14px; color: #fff; background: var(--text); border-radius: var(--radius-sm); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.is-hidden { display: none !important; }

.site-header { position: relative; z-index: 10; min-height: 76px; padding: 12px max(24px, calc((100vw - 1370px)/2)); display: flex; align-items: center; justify-content: space-between; gap: 18px; background: rgba(255,255,255,.82); border-bottom: 1px solid var(--border); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; background: var(--primary-soft); border-radius: 14px; box-shadow: 0 7px 18px rgba(79,70,165,.17); }
.brand-mark::before, .brand-mark span { content: ""; display: block; border-radius: 50%; }
.brand-mark::before { width: 25px; height: 25px; border: 6px solid var(--primary); border-right-color: #8c83dc; }
.brand-mark span { position: absolute; width: 7px; height: 7px; background: #fff; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 16px; line-height: 1.2; letter-spacing: .01em; }
.brand-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.connection-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.connection-status i { width: 8px; height: 8px; border-radius: 50%; background: #9389dc; box-shadow: 0 0 0 4px var(--primary-soft); }
.connection-status.is-connected { color: var(--success); }
.connection-status.is-connected i { background: #35a777; box-shadow: 0 0 0 4px #e2f5ec; }
.connection-status.is-offline i { background: #c85e52; box-shadow: 0 0 0 4px var(--error-soft); }
.text-button, .header-link { min-height: 44px; padding: 0 4px; display: inline-flex; align-items: center; color: var(--primary); background: transparent; border: 0; cursor: pointer; font-size: 13px; font-weight: 700; }
.text-button { text-decoration: underline; text-underline-offset: 4px; }
.header-link { text-decoration: none; transition: color .16s ease; }
.header-link:hover { color: #766bd0; }
.header-reconnect { min-height: 36px; padding: 0 12px; color: var(--primary); background: #fff; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 750; }
.header-reconnect:hover { color: #fff; background: var(--primary); border-color: var(--primary); }

.page-shell { width: min(100% - 48px, 1720px); margin: 0 auto; }
.intro { padding: 54px 0 28px; }
.intro h1 { max-width: 780px; margin: 0; font-size: clamp(34px, 4vw, 55px); line-height: 1.14; letter-spacing: -.045em; }
.intro p { margin: 15px 0 0; color: var(--muted); font-size: clamp(16px, 1.7vw, 19px); }
.page-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 336px; grid-template-areas: "form settings" "results settings" "debug settings"; align-items: start; gap: 20px 18px; }
#copyForm { grid-area: form; min-width: 0; }
.settings-panel { grid-area: settings; align-self: start; }
.result-section { grid-area: results; }
.debug-section { grid-area: debug; }
.form-surface, .settings-panel, .result-card, .debug-section { background: rgba(255,255,255,.95); border: 1px solid var(--border); box-shadow: var(--shadow); }
.form-surface { padding: 6px 26px 2px; border-radius: var(--radius-lg); }
.form-section { padding: 25px 0 27px; }
.form-section + .form-section { border-top: 1px solid var(--border); }
.section-heading { margin-bottom: 15px; display: flex; align-items: baseline; gap: 10px; }
.section-heading span { color: var(--primary); font-size: 15px; font-weight: 800; letter-spacing: .04em; }
.section-heading h2 { margin: 0; font-size: 19px; line-height: 1.25; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset + fieldset { margin-top: 24px; }
legend, .field > span:first-child, .upload-label { padding: 0; color: #37323d; font-size: 14px; font-weight: 720; }
.field-help, .field > small { margin: 5px 0 13px; display: block; color: var(--muted); font-size: 12px; }
.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { min-height: 40px; padding: 8px 15px; color: #49434e; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; transition: color .16s ease, border-color .16s ease, background-color .16s ease, transform .08s ease; }
.choice:hover { color: var(--primary); border-color: #a59cda; background: #faf9ff; }
.choice:active { transform: scale(.98); }
.choice.is-selected { position: relative; padding-right: 34px; color: #fff; border-color: var(--primary); background: var(--primary); box-shadow: 0 6px 14px rgba(79,70,165,.19); }
.choice.is-selected::after { content: "✓"; position: absolute; right: 12px; font-weight: 800; }
.custom-field { margin-top: 14px; display: grid; grid-template-columns: 135px minmax(0,1fr); align-items: center; gap: 12px; }
.custom-field.wide { margin-top: 24px; }
.custom-field span { color: #4d4751; font-size: 13px; font-weight: 650; }
em { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 500; }
input, select, textarea { width: 100%; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color .16s ease, box-shadow .16s ease; }
input, select { min-height: 42px; padding: 9px 12px; font-size: 13px; }
textarea { min-height: 120px; padding: 13px 14px; resize: vertical; font-size: 14px; line-height: 1.7; }
input:hover, select:hover, textarea:hover { border-color: #b7afd0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
::placeholder { color: #a29ba9; }
.content-inputs { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(250px, .8fr); gap: 18px; align-items: stretch; }
.text-field { min-width: 0; display: flex; flex-direction: column; }
.text-field textarea { flex: 1; min-height: 170px; }
.counter { margin-top: -28px; padding: 0 12px 9px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; }
.counter b { color: var(--muted); font-size: 11px; font-weight: 500; }
.upload-field { min-width: 0; display: flex; flex-direction: column; }
.upload-field > .field-help { margin: 5px 0 13px; }
.upload-box { min-height: 170px; padding: 18px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1px dashed #afa6cc; border-radius: var(--radius-sm); background: #fbfaff; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.upload-box:hover { background: var(--primary-soft); border-color: var(--primary); }
.upload-box.is-dragging { background: var(--primary-soft); border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,165,.12); transform: translateY(-2px); }
.upload-icon { width: 38px; height: 38px; margin-bottom: 9px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 12px; }
.upload-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.upload-box strong { font-size: 13px; }
.upload-box small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.photo-preview { min-height: 170px; padding: 12px; flex: 1; display: grid; grid-template-columns: 98px 1fr; gap: 12px; align-items: center; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.photo-preview img { width: 98px; height: 118px; object-fit: cover; border-radius: 8px; }
.photo-preview strong, .photo-preview small { display: block; overflow-wrap: anywhere; }
.photo-preview small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.photo-preview button { min-height: 38px; margin-top: 10px; padding: 0; color: var(--primary); background: transparent; border: 0; cursor: pointer; font-size: 12px; text-decoration: underline; }
.material-field { margin-top: 20px; display: block; }
.material-field textarea { margin-top: 10px; }
.field-error { min-height: 18px; margin: 7px 0 0; color: var(--error); font-size: 12px; }
.has-error { border-color: var(--error) !important; box-shadow: 0 0 0 3px var(--error-soft) !important; }

.settings-panel { position: sticky; top: 18px; padding: 25px 24px; border-radius: var(--radius-lg); }
.settings-panel-heading { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-panel h2 { margin: 0; font-size: 20px; }
.clear-button { min-height: 36px; padding: 0; flex: 0 0 auto; display: inline-flex; align-items: center; color: var(--primary); background: transparent; border: 0; cursor: pointer; font-size: 13px; font-weight: 700; text-decoration: none; transition: color .16s ease; }
.clear-button:hover { color: #766bd0; }
.summary-list { margin: 0; }
.summary-list div { padding: 0 0 17px 42px; position: relative; }
.summary-list div::before { content: ""; position: absolute; left: 2px; top: 2px; width: 26px; height: 26px; background: var(--primary-soft); border: 1px solid #d9d3f5; border-radius: 50%; }
.summary-list div::after { content: ""; position: absolute; left: 12px; top: 10px; width: 6px; height: 6px; border: 2px solid var(--primary); border-radius: 50%; }
.summary-list dt { font-size: 13px; font-weight: 750; }
.summary-list dd { margin: 2px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.output-format { padding: 18px 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); }
.output-format span, .output-format strong { display: block; }
.output-format span { color: var(--muted); font-size: 11px; }
.output-format strong { margin-top: 3px; font-size: 13px; }
.privacy-note { margin: 20px 0; display: flex; align-items: flex-start; gap: 10px; color: var(--primary-dark); }
.privacy-note svg { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.privacy-note strong, .privacy-note span { display: block; }
.privacy-note strong { font-size: 12px; }
.privacy-note span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.primary-button, .secondary-button { width: 100%; min-height: 52px; padding: 0 18px; border-radius: var(--radius-sm); cursor: pointer; font-size: 15px; font-weight: 750; transition: transform .08s ease, background-color .16s ease, border-color .16s ease; }
.primary-button { color: #fff; background: var(--primary); border: 1px solid var(--primary); box-shadow: 0 9px 22px rgba(79,70,165,.2); }
.primary-button:hover { background: var(--primary-dark); }
.primary-button:disabled { color: #dedbe7; background: #817aa6; border-color: #817aa6; cursor: wait; box-shadow: none; }
.primary-button:active, .secondary-button:active { transform: scale(.985); }
.secondary-button { margin-top: 10px; color: var(--primary); background: #fff; border: 1px solid var(--border); }
.secondary-button:disabled { color: #aaa4b0; background: #f5f3f7; cursor: not-allowed; box-shadow: none; }
.submit-note { margin: 12px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.form-message { margin-top: 13px; padding: 10px 12px; color: var(--success); background: #edf8f3; border: 1px solid #b9dece; border-radius: var(--radius-sm); font-size: 12px; }
.form-message.is-error { color: var(--error); background: var(--error-soft); border-color: #efc1ba; }
.form-message.is-warning { color: #805b12; background: #fff8df; border-color: #ead28e; }
.main-permission-card { margin-top: 14px; padding: 14px; color: #49434e; background: #fff9e8; border: 1px solid #ead28e; border-radius: var(--radius-sm); }
.main-permission-card strong { display: block; font-size: 13px; }
.main-permission-card p { margin: 5px 0 12px; font-size: 12px; }
.main-permission-card > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.main-permission-card .primary-button, .main-permission-card .secondary-button { min-height: 42px; margin: 0; font-size: 12px; }

.model-settings-shell { width: min(100% - 48px, 920px); margin: 0 auto; padding: 54px 0 80px; }
.settings-intro { margin-bottom: 24px; }
.settings-intro h1 { margin: 0; font-size: clamp(32px, 4vw, 46px); line-height: 1.15; letter-spacing: -.035em; }
.settings-intro p { max-width: 680px; margin: 12px 0 0; color: var(--muted); font-size: 16px; }
.settings-intro .generation-task-notice { width: fit-content; max-width: 100%; margin-top: 16px; padding: 9px 12px; display: flex; align-items: center; gap: 9px; color: var(--muted); background: rgba(255,255,255,.72); border: 1px solid var(--border); border-radius: 10px; font-size: 12px; line-height: 1.5; }
.generation-task-notice i { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #aaa3b4; }
.generation-task-notice.is-working { color: var(--primary); background: var(--primary-soft); border-color: #d8d1f3; }
.generation-task-notice.is-working i { background: var(--primary); animation: task-status-pulse 1.15s ease-in-out infinite; }
.generation-task-notice.is-complete { color: var(--success); background: #edf8f3; border-color: #ccebdd; }
.generation-task-notice.is-complete i { background: var(--success); }
.generation-task-notice.is-error { color: #a13e36; background: var(--error-soft); border-color: #ebc9c5; }
.generation-task-notice.is-error i { background: #c85e52; }
@keyframes task-status-pulse { 50% { opacity: .35; transform: scale(.78); } }
.model-settings-card { padding: 30px; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.settings-form h2 { margin: 0; font-size: 19px; }
.settings-form > p { margin: 6px 0 20px; color: var(--muted); font-size: 13px; }
.agent-selector-field { margin-bottom: 24px; padding: 16px; background: var(--primary-soft); border: 1px solid #d8d1f3; border-radius: var(--radius-sm); }
.agent-settings-panel { padding-top: 24px; border-top: 1px solid var(--border); }
.agent-settings-panel[hidden], .agent-guide[hidden] { display: none; }
.agent-settings-panel > h2 { margin: 0; font-size: 19px; }
.agent-settings-panel > p { margin: 6px 0 20px; color: var(--muted); font-size: 13px; }
.agent-readiness-note { margin: 20px 0 0; padding: 13px 15px; color: var(--muted); background: #fff9e8; border: 1px solid #ead28e; border-radius: var(--radius-sm); font-size: 12px; line-height: 1.6; }
.agent-readiness-note strong { color: var(--text); }
.settings-fields { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; }
.settings-field { display: block; }
.settings-field span { display: block; margin-bottom: 7px; color: #37323d; font-size: 13px; font-weight: 720; }
.settings-field input, .settings-field select { width: 100%; }
.settings-field-wide { margin-top: 2px; }
.settings-field-wide input { width: 100%; }
.settings-connection-actions { display: flex; gap: 10px; margin-top: 16px; }
.settings-connect, .settings-disconnect { width: auto; min-width: 116px; }
.settings-disconnect { margin-top: 0; padding: 12px 20px; }
.settings-model-section, .libtv-settings-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.settings-model-section h3, .libtv-settings-section h3 { margin: 0 0 14px; font-size: 15px; }
.settings-model-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.libtv-settings-row { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-switch-row { min-width: 0; padding: 14px 15px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.settings-switch-copy { min-width: 0; }
.settings-switch-copy strong, .settings-switch-copy small { display: block; }
.settings-switch-copy strong { color: var(--text); font-size: 13px; }
.settings-switch-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.settings-switch-copy a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.settings-switch-copy a:hover { color: var(--primary-dark); }
.libtv-cli-status-panel { min-width: 0; padding: 10px; display: flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.libtv-cli-status { width: 100%; min-width: 0; min-height: 48px; padding: 9px 11px; display: flex; align-items: center; color: var(--muted); background: #fff; border: 1px solid var(--border); border-radius: 8px; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.libtv-cli-status.is-working { color: var(--primary); border-color: rgba(79,70,165,.3); }
.libtv-cli-status.is-success { color: var(--success); border-color: rgba(37,125,91,.3); }
.libtv-cli-status.is-error { color: #a13e36; border-color: #ebc9c5; background: var(--error-soft); }
.libtv-cli-action { width: auto; min-width: 180px; margin-top: 12px; }
.settings-switch-input { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.settings-switch-control { position: relative; width: 42px; height: 24px; flex: 0 0 auto; background: #d7d2df; border-radius: 999px; transition: background .16s ease; }
.settings-switch-control::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(38,31,47,.22); transition: transform .16s ease; }
.settings-switch-input:checked + .settings-switch-control { background: var(--primary); }
.settings-switch-input:checked + .settings-switch-control::after { transform: translateX(18px); }
.settings-switch-input:focus-visible + .settings-switch-control { outline: 3px solid rgba(79,70,165,.28); outline-offset: 2px; }
.settings-address { margin: 16px 0 0; padding: 11px 13px; color: var(--muted); background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; overflow-wrap: anywhere; }
.settings-address strong { color: var(--text); }
.settings-save-row { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border); }
.settings-submit { width: auto; min-width: 180px; margin: 0; }
.cors-guide { margin-top: 20px; padding: 20px 22px; background: rgba(255,255,255,.88); border: 1px solid var(--border); border-radius: var(--radius-md); }

.cors-guide h2 { margin: 0 0 10px; font-size: 17px; }
.cors-guide p { margin: 8px 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.cors-guide strong { color: var(--text); overflow-wrap: anywhere; }
.inline-terminal-command { padding: 3px 7px; display: inline-block; color: #f5f3fa; background: #25222d; border: 1px solid #3b3645; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; line-height: 1.35; white-space: nowrap; }
.platform-switch { width: fit-content; margin-top: 16px; padding: 3px; display: flex; gap: 3px; background: #eeeaf7; border-radius: 10px; }
.platform-option { min-height: 36px; padding: 0 16px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 750; transition: color .16s ease, background-color .16s ease, box-shadow .16s ease; }
.platform-option:hover { color: var(--primary); }
.platform-option.is-active { color: var(--primary); background: #fff; box-shadow: 0 2px 8px rgba(59,48,95,.1); }
.command-actions { margin-top: 10px; display: flex; justify-content: flex-end; }
.command-box { margin-top: 8px; }
.command-box code { width: 100%; min-height: 66px; padding: 15px 17px; display: flex; align-items: center; overflow-x: auto; color: #f5f3fa; background: #25222d; border: 1px solid #3b3645; border-radius: var(--radius-sm); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.command-copy-button { min-height: 36px; padding: 0 15px; color: var(--primary); background: #fff; border: 1px solid #cec7ef; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 750; transition: color .16s ease, background-color .16s ease, border-color .16s ease; }
.command-copy-button:hover { color: #fff; background: var(--primary); border-color: var(--primary); }
.command-copy-status { margin: 8px 0 0 !important; color: var(--success) !important; }
.command-copy-status.is-error { color: var(--error) !important; }
.settings-note { margin-top: 20px; padding: 13px 15px; color: var(--muted); background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; }

.result-section { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 18px; }
.result-card { min-width: 0; padding: 25px 26px 28px; display: flex; flex-direction: column; border-radius: var(--radius-lg); }
.result-heading { min-height: 54px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.result-heading h2 { margin: 0; font-size: 22px; }
.result-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.result-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
.result-generate-button { width: auto; min-height: 36px; margin: 0; padding: 0 13px; border-radius: 8px; box-shadow: 0 6px 14px rgba(79,70,165,.16); font-size: 11px; }
.poster-request-controls { padding: 15px; display: grid; gap: 15px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.poster-request-controls legend, .poster-request-field > span { color: #37323d; font-size: 12px; font-weight: 750; }
.poster-ratio-picker { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.poster-ratio-option { width: auto; min-height: 36px; padding: 7px 14px; color: #49434e; background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 650; line-height: 1.2; }
.poster-ratio-option.is-selected { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 4px 10px rgba(79,70,165,.16); }
.poster-request-field { display: block; }
.poster-request-field textarea { min-height: 76px; margin-top: 8px; resize: vertical; font-size: 12px; }
.poster-request-field > small { margin-top: 5px; display: block; color: var(--muted); font-size: 9px; text-align: right; }
.result-tabs { margin-top: 19px; display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); }
.result-tab { min-height: 48px; color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; cursor: pointer; font-size: 14px; font-weight: 700; }
.result-tab:hover { color: var(--primary); }
.result-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.empty-result { min-height: 0; padding: 22px; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.copy-empty-frame { position: relative; width: 100%; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.empty-result svg { width: 62px; height: 62px; margin-bottom: 13px; fill: none; stroke: #aba4b6; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-result svg .pen { stroke: var(--primary); }
.empty-result strong { font-size: 14px; }
.empty-result span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.result-panels { position: relative; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.result-panel { padding: 22px; }
.result-panel[hidden] { display: none; }
.result-copy-button { min-height: 34px; padding: 0 11px; flex: 0 0 auto; color: var(--primary); background: transparent; border: 1px solid #d7d1e8; border-radius: 8px; cursor: pointer; font-size: 11px; font-weight: 700; transition: color .16s ease, background-color .16s ease, border-color .16s ease; }
.result-copy-button:hover:not(:disabled) { color: #fff; background: var(--primary); border-color: var(--primary); }
.result-copy-button:disabled { color: #aaa4b0; background: transparent; border-color: #e7e3ed; cursor: not-allowed; }
.result-textarea { height: auto; min-height: 0; aspect-ratio: 1; resize: none; font-size: 15px; line-height: 1.85; }
.result-character-count { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.poster-output { margin-top: 19px; padding: 0; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-md); }
.poster-output-heading { height: 48px; padding: 0 22px; display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.poster-output-heading span { min-width: 0; display: block; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.poster-output.is-error .poster-output-heading span { color: var(--error); }
.poster-image-frame { position: relative; margin: 22px; aspect-ratio: 1; overflow: hidden; border: 1px solid #e3deea; border-radius: var(--radius-sm); background: #f1eef5; }
.poster-image-frame.is-portrait { aspect-ratio: 3 / 4; }
.poster-empty-art {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62px;
  height: 62px;
  transform: translate(-50%, -50%);
  fill: none;
  stroke: #aaa3b4;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .72;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.poster-image-frame:has(img[src]) .poster-empty-art,
.poster-output.is-loading .poster-empty-art {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.92);
}
.poster-image-frame img { width: 100%; height: 100%; display: block; object-fit: contain; cursor: zoom-in; -webkit-touch-callout: default; }
.poster-image-frame img:not([src]) { visibility: hidden; }
.poster-image-frame img:focus-visible { outline: 3px solid rgba(79,70,165,.58); outline-offset: -3px; }
.copy-result-card.is-loading .result-panel { position: relative; }
.copy-result-card.is-loading .copy-empty-frame::after,
.copy-result-card.is-loading .result-panels::after,
.poster-output.is-loading .poster-image-frame::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 22px;
  height: 22px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgba(79,70,165,.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  background: rgba(255,255,255,.76);
  box-shadow: 0 0 0 8px rgba(255,255,255,.76);
  animation: result-working .82s linear infinite;
  pointer-events: none;
}
.copy-result-card.is-loading .copy-empty-frame > *,
.copy-result-card.is-loading .result-panel { opacity: .42; }
.copy-result-card.is-loading .copy-empty-frame > * { visibility: hidden; }
@keyframes result-working { to { transform: rotate(360deg); } }
.poster-preview-dialog { width: min(94vw, 1120px); height: min(94dvh, 1040px); max-width: none; max-height: none; margin: auto; padding: 0; overflow: hidden; color: var(--text); background: transparent; border: 0; border-radius: 18px; box-shadow: 0 28px 90px rgba(0,0,0,.42); }
.poster-preview-dialog::backdrop { background: rgba(16,14,20,.82); backdrop-filter: blur(4px); }
.poster-preview-panel { height: 100%; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #17151b; }
.poster-preview-header { min-height: 68px; padding: 12px 16px 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; color: #fff; background: #211e27; border-bottom: 1px solid rgba(255,255,255,.1); }
.poster-preview-header span { display: block; color: #bdb6c7; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.poster-preview-header h2 { margin: 2px 0 0; font-size: 18px; }
.poster-preview-close { min-width: 64px; min-height: 40px; padding: 0 13px; color: #fff; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.18); border-radius: 9px; cursor: pointer; font-weight: 700; }
.poster-preview-close:hover { background: rgba(255,255,255,.16); }
.poster-preview-stage { min-height: 0; padding: 18px; overflow: auto; display: flex; align-items: center; justify-content: center; overscroll-behavior: contain; }
.poster-preview-stage img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 12px 50px rgba(0,0,0,.28); touch-action: pinch-zoom; -webkit-touch-callout: default; }
.poster-preview-footer { padding: 13px 18px calc(13px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 18px; color: #fff; background: #211e27; border-top: 1px solid rgba(255,255,255,.1); }
.poster-preview-footer p { max-width: 560px; margin: 0; color: #c9c3d0; font-size: 12px; line-height: 1.5; }
.poster-preview-actions { display: flex; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
.poster-preview-action { width: auto; min-width: 104px; min-height: 40px; margin-top: 0; padding: 0 14px; font-size: 13px; }
body.has-poster-preview { overflow: hidden; }
.debug-section { padding: 25px 26px 22px; border-radius: var(--radius-lg); }
.debug-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.debug-label { display: inline-block; margin-bottom: 7px; color: var(--primary); font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.debug-heading h2 { margin: 0; font-size: 22px; }
.debug-heading p { max-width: 720px; margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.debug-grid { margin-top: 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.debug-panel { min-width: 0; padding: 16px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-md); }
.debug-panel-heading { min-height: 54px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.debug-panel-heading h3 { margin: 2px 0 0; font-size: 15px; }
.debug-copy-button { min-height: 42px; padding: 0 15px; flex: 0 0 auto; color: var(--primary); background: var(--primary-soft); border: 1px solid #cec7ef; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 750; }
.debug-copy-button:hover { color: #fff; background: var(--primary); border-color: var(--primary); }
.debug-copy-button:disabled { color: #aaa4b0; background: #efedf2; border-color: var(--border); cursor: not-allowed; }
.debug-copy-button:disabled:hover { color: #aaa4b0; background: #efedf2; border-color: var(--border); }
.debug-prompt { height: 420px; min-height: 0; max-height: none; margin: 14px 0 0; padding: 20px; overflow: auto; scrollbar-gutter: stable; color: #d9d6e4; background: #25222d; border: 1px solid #3b3645; border-radius: var(--radius-md); font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", "Microsoft YaHei", monospace; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
.debug-prompt.is-empty { color: #aaa5b1; }
.debug-prompt:focus-visible { outline-color: rgba(79,70,165,.5); }
.debug-footer { margin-top: 11px; display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 11px; }
.debug-footer span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.debug-footer i { width: 7px; height: 7px; border-radius: 50%; background: #d4a349; box-shadow: 0 0 0 3px #fff4dc; }
.site-footer { width: min(100% - 48px, 1720px); margin: 0 auto; padding: 28px 0 38px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: calc(100vw - 32px); padding: 10px 16px; color: #fff; background: rgba(33,31,38,.94); border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s ease, transform .2s ease; font-size: 13px; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .page-workspace { grid-template-columns: 1fr; grid-template-areas: "form" "settings" "results" "debug"; gap: 14px; }
  .settings-panel { position: static; }
  .summary-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .content-inputs { grid-template-columns: 1fr; }
  .upload-box { min-height: 145px; }
  .result-section { grid-template-columns: 1fr; }
  .debug-grid { grid-template-columns: 1fr; }
}

@media (min-width: 981px) and (max-width: 1220px) {
  .debug-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  body { background: var(--background); }
  .site-header { min-height: 64px; padding: 9px 16px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-copy, .connection-status { display: none; }
  .header-actions { gap: 10px; }
  .header-link, .text-button { font-size: 12px; }
  .page-shell { width: min(100% - 24px, 1370px); }
  .model-settings-shell { width: min(100% - 24px, 920px); padding: 34px 0 56px; }
  .model-settings-card { padding: 22px 16px; border-radius: var(--radius-md); box-shadow: none; }
  .settings-fields { grid-template-columns: 1fr; }
  .libtv-settings-row { grid-template-columns: 1fr; }
  .settings-connection-actions { display: grid; grid-template-columns: 1fr; }
  .settings-connect, .settings-disconnect { width: 100%; min-width: 0; }
  .libtv-cli-action { width: 100%; min-width: 0; }
  .settings-submit { width: 100%; min-width: 0; }
  .command-copy-button { min-height: 40px; }
  .intro { padding: 34px 4px 20px; }
  .intro h1 { font-size: 31px; }
  .intro p { margin-top: 11px; font-size: 14px; }
  .form-surface, .settings-panel, .result-card, .debug-section { box-shadow: none; }
  .form-surface { padding: 0 15px; border-radius: var(--radius-md); }
  .form-section { padding: 23px 0; }
  .section-heading h2 { font-size: 18px; }
  .choice-group { gap: 7px; }
  .choice { min-height: 44px; padding: 9px 13px; flex: 1 1 auto; }
  .choice.is-selected { padding-right: 32px; }
  .custom-field { grid-template-columns: 1fr; gap: 7px; }
  input { min-height: 46px; }
  textarea { font-size: 16px; }
  .content-inputs { gap: 20px; }
  .settings-panel { padding: 22px 18px; border-radius: var(--radius-md); }
  .summary-list { grid-template-columns: 1fr; gap: 0; }
  .result-section { gap: 14px; }
  .result-card { padding: 22px 14px; border-radius: var(--radius-md); }
  .result-heading { display: grid; justify-content: stretch; align-items: stretch; gap: 12px; }
  .result-heading p { display: none; }
  .result-heading-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .result-heading-actions button { width: 100%; min-height: 44px; }
  .empty-result { min-height: 0; padding: 13px; }
  .empty-result span { max-width: 270px; }
  .result-panel { padding: 17px 13px; }
  .result-textarea { height: auto; min-height: 0; aspect-ratio: 1; font-size: 16px; }
  .poster-output-heading { padding: 0 13px; }
  .poster-image-frame { margin: 13px; }
  .poster-preview-dialog { width: 100vw; height: 100dvh; margin: 0; border-radius: 0; }
  .poster-preview-header { min-height: 62px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px; }
  .poster-preview-header h2 { font-size: 16px; }
  .poster-preview-stage { padding: 10px; }
  .poster-preview-stage img { width: 100%; height: auto; max-height: 100%; }
  .poster-preview-footer { padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); gap: 10px; }
  .poster-preview-footer p { flex: 1 1 auto; text-align: left; font-size: 10px; line-height: 1.4; }
  .poster-preview-actions { flex: 0 0 auto; }
  .poster-preview-action { min-width: 100px; min-height: 40px; padding: 0 12px; }
  .debug-section { padding: 22px 14px 18px; border-radius: var(--radius-md); }
  .debug-heading { display: grid; gap: 14px; }
  .debug-grid { margin-top: 16px; }
  .debug-panel { padding: 13px; }
  .debug-panel-heading { min-height: 0; display: grid; }
  .debug-copy-button { width: 100%; min-height: 46px; }
  .debug-prompt { height: 320px; margin-top: 13px; padding: 15px; font-size: 12px; }
  .debug-footer { align-items: flex-start; }
  .site-footer { width: calc(100% - 28px); padding: 22px 0 28px; display: grid; gap: 2px; text-align: center; }
  .toast { width: calc(100% - 32px); border-radius: var(--radius-sm); text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
