:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #dce2e8;
  --line-strong: #bdc7d2;
  --text: #17212b;
  --muted: #667587;
  --soft: #8a97a6;
  --accent: #1769e0;
  --accent-soft: #eaf2ff;
  --teal: #078674;
  --teal-soft: #e6f6f2;
  --danger: #c43d33;
  --danger-soft: #fff0ee;
  --warning: #a9660d;
  --warning-soft: #fff6e6;
  --sidebar: #111820;
  --sidebar-2: #1b2530;
  --shadow: 0 8px 24px rgba(18, 29, 43, 0.06);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif; letter-spacing: 0; }
body.is-locked { overflow: hidden; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.62; }
a { color: inherit; }

.auth-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: var(--sidebar); }
.auth-gate.is-hidden { display: none; }
.auth-card { width: min(400px, 100%); padding: 28px; border: 1px solid #34404d; border-radius: 8px; background: #19222c; color: #fff; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand > span, .brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #445363; border-radius: 8px; background: #24303c; font-weight: 800; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand small { margin-top: 3px; color: #aeb9c5; }
.auth-card label { display: block; margin-bottom: 14px; }
.auth-card label span { display: block; margin-bottom: 6px; color: #bdc7d2; font-size: 13px; }
.auth-card input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #42505f; border-radius: 6px; background: #10171f; color: #fff; outline: none; }
.auth-card input:focus { border-color: #6ca6f5; box-shadow: 0 0 0 3px rgba(23,105,224,.22); }
.auth-card .primary-button { width: 100%; margin-top: 4px; }
.auth-error { min-height: 20px; margin: 12px 0 0; color: #ffb2aa; font-size: 13px; }

.operation-bar { position: fixed; top: 14px; left: 50%; z-index: 80; display: flex; align-items: center; gap: 10px; min-height: 42px; max-width: calc(100vw - 32px); padding: 0 16px; transform: translateX(-50%); border: 1px solid #2c3947; border-radius: 8px; background: #17212b; color: #fff; box-shadow: 0 12px 30px rgba(0,0,0,.18); font-size: 13px; }
.toast-region { position: fixed; top: 18px; right: 18px; z-index: 90; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; align-items: start; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 14px 36px rgba(18,29,43,.16); animation: toast-in .18s ease-out; }
.toast::before { content: ""; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--accent); }
.toast.is-success::before { background: var(--teal); }
.toast.is-error::before { background: var(--danger); }
.toast strong, .toast span { display: block; }
.toast span { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.toast button { border: 0; background: transparent; color: var(--soft); font-size: 18px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

.spinner { display: inline-block; width: 16px; height: 16px; flex: 0 0 auto; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
button[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; margin-right: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

.app-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; min-height: 100vh; height: 100vh; padding: 18px 14px; background: var(--sidebar); color: #f6f8fa; overflow-y: auto; }
.brand { display: grid; grid-template-columns: 42px 1fr; gap: 11px; align-items: center; min-height: 46px; margin-bottom: 22px; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #8f9cab; font-size: 11px; }
.nav { display: grid; gap: 4px; }
.nav-item { position: relative; display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: #aeb9c5; text-align: left; }
.nav-item:hover { background: #1b2732; color: #fff; }
.nav-item.is-active { background: #273747; color: #fff; }
.nav-item.is-active::before { content: ""; position: absolute; left: 0; width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: #62a0f5; }
.nav-item em { display: grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: #d94a3f; color: #fff; font-size: 11px; font-style: normal; font-weight: 800; }
.account-panel { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding: 13px 10px; border-top: 1px solid #2b3743; border-bottom: 1px solid #2b3743; }
.account-panel span, .account-panel small { display: block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-panel span { color: #e8edf2; font-size: 13px; font-weight: 700; }
.account-panel small { margin-top: 3px; color: #82909f; font-size: 11px; }
.account-panel > strong { color: #71d7c1; font-size: 13px; }
.worker-status { padding: 13px 10px 0; color: #8f9cab; font-size: 11px; }
.worker-status > div:first-child { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; color: #c6d0da; }
.connection-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d69a3b; }
.connection-dot.is-online { background: #35c78a; }
.connection-dot.is-offline { background: #df5b50; }
.worker-list { display: grid; gap: 3px; margin-top: 8px; }
.worker-list div { display: flex; justify-content: space-between; gap: 8px; }

.main-content { min-width: 0; padding: 22px 28px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 1440px; margin: 0 auto 20px; }
.topbar h1 { margin: 0; font-size: 25px; line-height: 1.2; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 8px; }
.primary-button, .ghost-button, .small-button, .job-action, .download-link { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 6px; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.primary-button { background: var(--accent); color: #fff; font-weight: 750; }
.primary-button:hover:not(:disabled) { background: #0f59c4; }
.ghost-button, .small-button, .job-action { border-color: var(--line); background: #fff; color: var(--text); }
.ghost-button:hover:not(:disabled), .small-button:hover:not(:disabled), .job-action:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.small-button, .job-action { min-height: 34px; padding: 0 11px; font-size: 12px; font-weight: 700; }
.danger-button { color: var(--danger); }
.view { display: none; max-width: 1440px; margin: 0 auto; }
.view.is-visible { display: block; }

.create-layout { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 18px; align-items: start; }
.form-flow { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.reuse-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 16px; border-bottom: 1px solid #b9d3f6; background: #eef6ff; color: #163d6c; }
.reuse-banner[hidden] { display: none; }
.reuse-banner strong, .reuse-banner span { display: block; }
.reuse-banner strong { font-size: 13px; }
.reuse-banner span { margin-top: 3px; font-size: 12px; line-height: 1.45; }
.reuse-banner-actions { display: flex; flex: 0 0 auto; gap: 8px; align-items: center; }
.reuse-banner:focus { outline: 3px solid rgba(20, 103, 216, .24); outline-offset: -3px; }
.flow-section { padding: 24px; border-bottom: 1px solid var(--line); }
.flow-section:last-child { border-bottom: 0; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.step { display: grid; place-items: center; float: left; width: 24px; height: 24px; margin: 0 9px 0 0; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; }
.status-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; border-radius: 6px; background: var(--teal-soft); color: var(--teal); font-size: 12px; font-weight: 800; }

.preflight-options, .mode-control, .creative-mode-control { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.mode-control[hidden] { display: none; }
.creative-mode-control { margin-bottom: 14px; }
.creative-settings { margin-bottom: 14px; }
.choice-button { min-width: 0; min-height: 78px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); text-align: left; }
.choice-button:hover { border-color: #94b9ec; background: #f7faff; }
.choice-button.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-button strong, .choice-button span { display: block; }
.choice-button strong { font-size: 14px; }
.choice-button span { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.upload-card { position: relative; display: grid; place-items: center; min-height: 184px; padding: 16px; overflow: hidden; border: 1px dashed #9eacbb; border-radius: 6px; background: var(--surface-2); text-align: center; cursor: pointer; }
.upload-card:hover { border-color: var(--accent); background: #f4f8ff; }
.upload-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-card img { position: absolute; inset: 0; display: none; width: 100%; height: 100%; object-fit: contain; background: #eef1f4; }
.upload-card.has-image img { display: block; }
.upload-card.has-image::after { content: "更換"; position: absolute; right: 8px; bottom: 8px; padding: 4px 8px; border-radius: 4px; background: rgba(17,24,32,.86); color: #fff; font-size: 11px; }
.upload-card.has-image > :not(input):not(img) { visibility: hidden; }
.upload-symbol { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 8px; border-radius: 50%; background: #e5ebf2; color: var(--accent); font-size: 24px; }
.upload-card strong, .upload-card small, .upload-card em { display: block; }
.upload-card small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.upload-card em { margin-top: 12px; color: var(--accent); font-size: 12px; font-style: normal; font-weight: 700; }
.character-selection { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-top: 14px; padding: 12px; border: 1px solid #bad2f2; border-radius: 6px; background: #f5f9ff; }
.character-selection .small-button { min-height: 40px; }

.field-grid { display: grid; gap: 12px; margin-top: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label > span, .pricing-grid label span, .account-create label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.4; }
select, textarea, .text-input, input[type="number"], .account-create input:not([type="checkbox"]), .pricing-grid input { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); outline: none; }
select, .text-input, input[type="number"], .account-create input:not([type="checkbox"]), .pricing-grid input { min-height: 40px; padding: 0 10px; }
.account-create input[type="checkbox"] { width: auto; min-height: 0; margin: 0; }
textarea { min-height: 88px; padding: 10px; resize: vertical; line-height: 1.5; }
.copy-fields textarea { min-height: 128px; }
.copy-fields .field-hint { min-height: 30px; }
.stacked-fields { display: grid; gap: 12px; align-content: start; }
select:focus, textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23,105,224,.10); }
select:disabled { background: #eef1f4; color: #7c8794; cursor: not-allowed; }
.wide-field { display: block; margin-top: 14px; }
.confirm-row { display: flex; align-items: flex-start; gap: 9px; margin-top: 14px; padding: 11px 12px; border: 1px solid #e7c987; border-radius: 6px; background: var(--warning-soft); color: #6e4c18; font-size: 12px; line-height: 1.5; }
.confirm-row input { flex: 0 0 auto; margin-top: 2px; }
.adult-confirm { border-color: #dcaa5d; }
.adult-confirm > span { display: grid; gap: 3px; }
.adult-confirm strong { color: #52350e; font-size: 13px; }
.adult-confirm small { display: block; color: #6e4c18; }
.adult-confirm .confirmation-state { margin-top: 2px; color: #9a5d00; font-weight: 700; }
.adult-confirm.is-confirmed { border-color: #59b99f; background: #edf9f5; color: #155e50; }
.adult-confirm.is-confirmed strong, .adult-confirm.is-confirmed small, .adult-confirm.is-confirmed .confirmation-state { color: #155e50; }
.adult-confirm.needs-attention { animation: confirmation-attention 0.65s ease-in-out 3; border-color: #df3b30; box-shadow: 0 0 0 3px rgba(223, 59, 48, 0.15); }
@keyframes confirmation-attention { 50% { transform: translateY(-2px); box-shadow: 0 0 0 5px rgba(223, 59, 48, 0.12); } }
.fashion-confirm { border-color: #9ba8b6; background: #f4f7fa; color: var(--text); }
.fashion-confirm span { margin: 0; color: var(--text); }
.fashion-confirm strong, .fashion-confirm small { display: block; }
.fashion-confirm small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.preview-actions { display: grid; grid-template-columns: auto minmax(160px, 1fr) auto minmax(160px, 1fr); gap: 8px; align-items: center; margin-top: 12px; }
.preview-actions audio, .library-player { width: 100%; height: 36px; }
.script-preview-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--accent); background: #f3f7fc; }
.script-preview-panel > div { min-width: 0; }
.script-preview-panel strong, .script-preview-panel span { display: block; }
.script-preview-panel strong { font-size: 13px; }
.script-preview-panel span { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.script-preview-panel .small-button { flex: 0 0 auto; }
.script-preview-result { margin-top: 8px; padding: 12px 14px; border: 1px solid #c9d8ec; border-radius: 6px; background: #fbfdff; }
.script-preview-result > strong { display: block; margin-bottom: 8px; font-size: 13px; }
.script-preview-result ol { display: grid; gap: 6px; margin: 0; padding-left: 24px; }
.script-preview-result li { padding-left: 4px; color: var(--text); font-size: 12px; line-height: 1.55; }
.script-preview-result p { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.advanced-settings { margin-top: 16px; border-top: 1px solid var(--line); }
.advanced-settings summary { padding: 14px 0 0; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 800; }
.advanced-body { padding-top: 2px; }
.toggle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.toggle-grid label { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); font-size: 12px; }
.toggle-grid label span { margin: 0; color: var(--text); }
.scene-list { display: grid; gap: 8px; }
.scene-item { display: grid; grid-template-columns: 58px minmax(0, 1fr) 190px; align-items: center; gap: 12px; min-height: 66px; padding: 9px 10px; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 6px; background: var(--surface-2); }
.scene-item[data-type="kenburns"] { border-left-color: #8c99a8; }
.scene-item[data-type="effect"] { border-left-color: #b98b22; background: #fffaf0; }
.scene-time { color: var(--muted); font-size: 11px; font-weight: 800; }
.scene-item strong, .scene-item span { display: block; }
.scene-item strong { font-size: 13px; }
.scene-item span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.scene-item select { min-height: 36px; font-size: 12px; }
.submit-wide { width: 100%; min-height: 46px; margin-top: 14px; }

.order-summary { position: sticky; top: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.order-summary section { padding: 16px; border-bottom: 1px solid var(--line); }
.order-summary section:last-child { border-bottom: 0; }
.summary-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.order-summary h3 { margin: 0 0 12px; font-size: 16px; }
.order-summary dl { margin: 0; }
.order-summary dl div, .summary-price > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.order-summary dt, .summary-price span { color: var(--muted); font-size: 12px; }
.order-summary dd { margin: 0; max-width: 165px; text-align: right; font-size: 12px; }
.summary-price { background: #f7fbfa; }
.summary-price strong { color: var(--teal); }
.summary-status > div { display: flex; align-items: center; gap: 8px; }
.summary-status p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.queue-list { display: grid; gap: 8px; }
.queue-list article { min-width: 0; padding-left: 9px; border-left: 2px solid var(--line-strong); }
.queue-list strong, .queue-list span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-list strong { font-size: 12px; }
.queue-list span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.page-toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.filter-tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden; }
.filter-tabs button { min-height: 36px; padding: 0 13px; border: 0; border-right: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; }
.filter-tabs button:last-child { border-right: 0; }
.filter-tabs button.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.job-table { display: grid; gap: 10px; }
.job-pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; }
.job-pagination[hidden] { display: none; }
.job-pagination span { min-width: 130px; color: var(--muted); font-size: 12px; text-align: center; }
.job-row { border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.job-line { display: grid; grid-template-columns: minmax(220px, 1.4fr) 102px minmax(160px, .8fr) 150px auto; align-items: center; gap: 12px; padding: 15px 16px; }
.job-main strong, .job-main span { display: block; }
.job-main strong { font-size: 14px; }
.job-main span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.job-status { display: inline-flex; justify-content: center; align-items: center; min-height: 28px; padding: 0 9px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; }
.job-status.is-completed { background: var(--teal-soft); color: var(--teal); }
.job-status.is-failed { background: var(--danger-soft); color: var(--danger); }
.job-status.is-cancelled { background: #eef1f4; color: var(--muted); }
.job-progress { height: 6px; overflow: hidden; border-radius: 3px; background: #e9edf1; }
.job-progress span { display: block; width: var(--progress); height: 100%; background: var(--accent); transition: width .35s ease; }
.job-meta { color: var(--muted); font-size: 11px; line-height: 1.4; }
.job-primary-actions, .job-actions, .voice-card-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; justify-content: flex-end; }
.download-link { min-height: 34px; padding: 0 12px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; }
.download-link.is-draft { background: #7a8794; }
.download-disabled { color: var(--soft); font-size: 11px; }
.job-error, .job-warning { margin: 0 16px 12px; padding: 10px 12px; border-left: 3px solid var(--danger); background: var(--danger-soft); color: #762c26; font-size: 12px; }
.job-warning { border-left-color: #d28a21; background: var(--warning-soft); color: #71501b; }
.job-error div { display: flex; gap: 7px; align-items: center; }
.job-error code { padding: 2px 5px; border-radius: 4px; background: #efd5d2; }
.job-error p { margin: 5px 0 0; line-height: 1.45; }
.job-detail { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.job-detail summary { padding-top: 11px; color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 800; }
.job-media { display: grid; grid-template-columns: repeat(2, 180px); gap: 12px; align-items: start; margin-top: 12px; }
.job-media img, .job-media video, .media-thumb { display: block; width: 180px; height: 320px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #111820; overflow: hidden; }
.media-loading { display: grid; place-items: center; width: 180px; height: 320px; padding: 16px; border-radius: 6px; background: #e9edf1; color: var(--muted); text-align: center; }
.media-loading::before { content: ""; width: 34px; height: 34px; margin-bottom: 10px; border: 3px solid #aab6c3; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.media-loading strong, .media-loading span { display: block; }
.media-loading span { margin-top: 5px; font-size: 11px; line-height: 1.4; }
.job-script { margin-top: 14px; }
.job-scale { display: grid; gap: 4px; margin-top: 14px; padding: 10px 12px; border-left: 3px solid var(--teal); background: var(--teal-soft); color: #155e55; font-size: 12px; }
.job-scale span, .job-scale p { line-height: 1.45; }
.job-scale p { margin: 0; color: var(--muted); }
.job-script ul { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-left: 18px; color: var(--muted); font-size: 11px; }
.job-script-lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.job-script-lines > div { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); }
.job-script-lines span, .job-script-lines p { margin: 0; font-size: 11px; line-height: 1.5; }
.job-script-lines span { color: var(--accent); font-weight: 800; }
.job-script-lines b { display: inline-block; min-width: 34px; color: var(--muted); }
.job-audio-regenerate { display: grid; grid-template-columns: minmax(190px, 240px) auto auto; gap: 7px; align-items: end; width: 100%; }
.job-audio-regenerate label { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.job-scene-repair { display: grid; grid-template-columns: minmax(180px, .75fr) 170px minmax(260px, 1.6fr) auto; gap: 8px; align-items: end; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.job-scene-repair > div strong, .job-scene-repair > div span { display: block; }
.job-scene-repair > div span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.job-scene-repair textarea { min-height: 54px; }

.page-section { padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.batch-drop { display: grid; place-items: center; min-height: 150px; padding: 20px; border: 1px dashed #9eacbb; border-radius: 6px; background: var(--surface-2); text-align: center; cursor: pointer; }
.batch-drop.is-dragging { border-color: var(--blue); background: #edf5ff; }
.batch-drop input, .upload-mini input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.batch-drop strong, .batch-drop span { display: block; }
.batch-drop span { margin-top: 6px; color: var(--muted); font-size: 12px; }
.batch-summary, .metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 14px 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.batch-summary > div, .metric-grid > div { padding: 12px; border-right: 1px solid var(--line); background: var(--surface-2); }
.batch-summary > div:last-child, .metric-grid > div:nth-child(4n) { border-right: 0; }
.batch-summary span, .batch-summary strong, .metric-grid span, .metric-grid strong { display: block; }
.batch-summary span, .metric-grid span { color: var(--muted); font-size: 11px; }
.batch-summary strong, .metric-grid strong { margin-top: 4px; font-size: 13px; }
.batch-list, .voice-list, .asset-list, .account-list, .ledger-list { display: grid; gap: 8px; }
.batch-file, .voice-list article, .asset-list article, .ledger-list article { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 58px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.batch-file { grid-template-columns: 34px minmax(0, 1fr) auto; }
.batch-file strong, .batch-file span, .voice-list strong, .voice-list span, .asset-list strong, .asset-list span { display: block; }
.batch-file span, .voice-list span, .asset-list span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.batch-thumb { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 5px; background: #e7edf4; color: var(--muted); font-size: 11px; }
.batch-state { color: var(--muted); font-size: 11px; font-weight: 800; }
.batch-state.is-已排隊 { color: var(--teal); }
.batch-state.is-失敗 { color: var(--danger); }
.batch-confirm { margin: 0 0 14px; }
.batch-file-error { color: var(--danger) !important; }

.voice-upload-form { display: grid; grid-template-columns: minmax(150px,.7fr) minmax(240px,1.3fr) 180px auto; gap: 12px; align-items: end; margin-bottom: 14px; }
.upload-mini { position: relative; display: grid; place-items: center; min-height: 88px; padding: 10px; border: 1px dashed #9eacbb; border-radius: 6px; background: var(--surface-2); text-align: center; cursor: pointer; }
.upload-mini span { margin: 4px 0 0; }
.library-player { max-width: 520px; margin-bottom: 14px; }
.character-create-form { display: grid; grid-template-columns: minmax(180px,.65fr) minmax(260px,1.35fr) minmax(260px,1fr); gap: 12px; align-items: start; margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.character-create-form textarea { min-height: 88px; }
.character-drop { position: relative; display: grid; place-items: center; min-height: 88px; padding: 10px; border: 1px dashed #9eacbb; border-radius: 6px; background: var(--surface-2); text-align: center; cursor: pointer; }
.character-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.character-drop strong, .character-drop span { display: block; }
.character-drop span { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.character-consent { grid-column: 1 / -1; margin-top: 0; }
.character-create-form > button { grid-column: 1 / -1; justify-self: start; min-width: 150px; }
.character-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.character-card { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; min-height: 112px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.character-card img { display: block; width: 76px; height: 92px; object-fit: cover; border: 1px solid var(--line); border-radius: 5px; background: #e8edf2; }
.character-card-body { display: flex; min-width: 0; flex-direction: column; }
.character-card strong, .character-card span { display: block; }
.character-card span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.character-card p { display: -webkit-box; overflow: hidden; margin: 7px 0; color: var(--text); font-size: 11px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.character-card-actions { display: flex; gap: 6px; margin-top: auto; }

.metric-table { display: grid; gap: 8px; }
.metric-table > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 50px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.metric-table span { color: var(--muted); font-size: 12px; }
.metric-table strong { text-align: right; font-size: 12px; }
.metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid > div:nth-child(3n) { border-right: 0; }

.admin-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-wide { grid-column: 1 / -1; }
.pricing-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.account-create { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.permission-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 0; font-size: 12px; }
.account-create > button { align-self: end; }
.account-card { display: grid; grid-template-columns: minmax(150px, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.account-card strong, .account-card span { display: block; }
.account-card span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.account-permissions { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; }
.account-permissions label { display: flex; gap: 4px; align-items: center; }
.credit-control { display: flex; gap: 6px; align-items: center; }
.credit-control input { width: 90px; min-height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; }
.empty-state { display: grid; place-items: center; min-height: 180px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state .spinner { margin-bottom: 10px; }

@media (max-width: 1180px) {
  .create-layout { grid-template-columns: 1fr; }
  .order-summary { position: static; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .order-summary section { border-right: 1px solid var(--line); }
  .job-line { grid-template-columns: minmax(200px, 1fr) 100px 150px auto; }
  .job-meta { display: none; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: auto; height: auto; padding: 12px 16px; }
  .brand { margin-bottom: 10px; }
  .nav { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .nav-item { flex: 0 0 auto; width: auto; min-height: 38px; }
  .nav-item.is-active::before { display: none; }
  .account-panel { position: absolute; top: 14px; right: 16px; width: 180px; margin: 0; border: 0; }
  .worker-status { display: none; }
  .main-content { padding: 16px; }
  .topbar { align-items: flex-start; }
  .top-actions .ghost-button { display: none; }
  .preflight-options, .mode-control, .creative-mode-control, .field-grid.three { grid-template-columns: 1fr; }
  .choice-button { min-height: 66px; }
  .preview-actions { grid-template-columns: auto 1fr; }
  .voice-upload-form, .character-create-form, .admin-layout { grid-template-columns: 1fr; }
  .admin-wide { grid-column: auto; }
  .job-line { grid-template-columns: 1fr 90px; }
  .job-progress, .job-primary-actions { grid-column: 1 / -1; }
  .job-primary-actions { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .sidebar { padding-top: 10px; }
  .brand { max-width: calc(100% - 180px); }
  .account-panel { width: 170px; }
  .nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; }
  .nav-item { justify-content: center; width: 100%; min-height: 36px; padding: 0 4px; font-size: 12px; text-align: center; }
  .topbar h1 { font-size: 21px; }
  .topbar p, #saveTemplate { display: none; }
  .main-content { padding: 12px; }
  .reuse-banner { align-items: stretch; flex-direction: column; }
  .reuse-banner-actions { width: 100%; }
  .reuse-banner-actions .primary-button { flex: 1; }
  .flow-section, .page-section { padding: 16px; }
  .upload-grid, .field-grid.two, .toggle-grid, .order-summary, .pricing-grid, .account-create, .character-selection { grid-template-columns: 1fr; }
  .upload-card { min-height: 160px; }
  .script-preview-panel { align-items: stretch; flex-direction: column; }
  .script-preview-panel .small-button { width: 100%; }
  .order-summary section { border-right: 0; }
  .scene-item { grid-template-columns: 48px minmax(0,1fr); }
  .scene-item select { grid-column: 1 / -1; }
  .job-media { grid-template-columns: 1fr; }
  .job-media img, .job-media video, .media-thumb, .media-loading { width: 100%; height: auto; aspect-ratio: 9 / 16; }
  .job-script-lines, .job-audio-regenerate, .job-scene-repair { grid-template-columns: 1fr; }
  .batch-summary, .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .batch-summary > div:nth-child(2n), .metric-grid > div:nth-child(2n) { border-right: 0; }
  .account-card { grid-template-columns: 1fr; }
}
