:root {
  --bg: #0b0f14;
  --panel: #11171f;
  --panel-2: #151d27;
  --line: #26313d;
  --text: #f4f7fb;
  --muted: #8e9aaa;
  --accent: #24d3b0;
  --accent-2: #ffb86b;
  --danger: #ff6f77;
  --shadow: 0 18px 45px rgba(0, 0, 0, .25);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: #0d1218; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: #071411; background: var(--accent); border-radius: 8px; font-weight: 800; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.brand-sub { color: var(--muted); margin-left: 8px; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-chip, .mode-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(36, 211, 176, .12); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; }
.icon-btn:hover { color: var(--text); border-color: #3c4c5d; }
.mini-icon-btn { width: 28px; height: 28px; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; }
.mini-icon-btn:hover { color: var(--danger); border-color: rgba(255, 111, 119, .55); }
.workspace { flex: 1; display: grid; grid-template-columns: 255px minmax(420px, 1fr) 355px; gap: 0; min-height: 0; }
.sidebar, .inspector { background: #0e141b; }
.sidebar { border-right: 1px solid var(--line); padding: 22px 16px; }
.inspector { border-left: 1px solid var(--line); padding: 22px 20px; overflow-y: auto; }
.section-label { color: #6e7c8d; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin: 4px 10px 12px; }
.nav-list { display: grid; gap: 5px; margin-bottom: 28px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); text-align: left; }
.nav-item:hover, .nav-item.active { color: var(--text); background: #18212c; }
.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.nav-item .count { margin-left: auto; color: #6e7c8d; font-size: 11px; }
.usage { margin-top: auto; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.usage-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.usage strong { color: var(--text); font-size: 18px; }
.progress { height: 5px; margin: 12px 0 8px; overflow: hidden; background: #202b35; border-radius: 99px; }
.progress > span { display: block; height: 100%; width: 38%; background: var(--accent); border-radius: inherit; }
.usage-note { color: #687687; font-size: 11px; }
.main { min-width: 0; padding: 26px 30px 30px; overflow-y: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
h1 { margin: 7px 0 0; font-size: 26px; letter-spacing: -.03em; }
.page-head p { margin: 8px 0 0; color: var(--muted); }
.main-grid { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(260px, .78fr); gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.panel-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-title { font-weight: 700; }
.panel-meta { color: var(--muted); font-size: 12px; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 14px; gap: 8px; border-bottom: 1px solid var(--line); }
.mode-tab { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 11px; border: 1px solid transparent; border-radius: 6px; background: #151c24; color: var(--muted); text-align: left; }
.mode-tab.active { border-color: rgba(36, 211, 176, .6); background: rgba(36, 211, 176, .08); color: var(--text); }
.mode-tab small { display: block; color: #6e7c8d; font-size: 10px; margin-top: 2px; }
.mode-tab.active small { color: #92e9d9; }
.form-body { padding: 18px; }
.field { margin-bottom: 17px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: #c2ccd8; font-size: 12px; font-weight: 600; }
.hint { color: #687687; font-weight: 400; }
textarea, input, select { width: 100%; border: 1px solid var(--line); border-radius: 6px; outline: none; background: #0d131a; color: var(--text); }
textarea { min-height: 152px; resize: vertical; padding: 13px; line-height: 1.6; }
input, select { height: 38px; padding: 0 11px; }
textarea:focus, input:focus, select:focus { border-color: rgba(36, 211, 176, .75); box-shadow: 0 0 0 3px rgba(36, 211, 176, .1); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prompt-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; color: #687687; font-size: 11px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); }
.upload-zone { min-height: 108px; display: grid; place-items: center; padding: 16px; border: 1px dashed #3a4a59; border-radius: 7px; background: #0d131a; color: var(--muted); text-align: center; }
.upload-zone.dragover { border-color: var(--accent); background: rgba(36, 211, 176, .08); }
.upload-zone strong { display: block; margin-top: 8px; color: #dce3eb; font-size: 12px; }
.upload-zone span { display: block; margin-top: 4px; font-size: 11px; }
.thumb { width: 70px; height: 48px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); }
.primary-btn { width: 100%; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 6px; background: var(--accent); color: #06130f; font-weight: 800; }
.primary-btn:hover { background: #58e3ca; }
.primary-btn:disabled { opacity: .5; cursor: wait; }
.secondary-btn { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: #151c24; color: #cbd4df; }
.secondary-btn:hover { border-color: #4c5f70; }
.preview { min-height: 450px; display: flex; flex-direction: column; }
.preview-canvas { flex: 1; min-height: 375px; margin: 18px; display: grid; place-items: center; position: relative; overflow: hidden; border: 1px solid #2b3845; border-radius: 6px; background: #0a0e13; }
.preview-canvas img, .preview-canvas video { width: 100%; height: 100%; object-fit: cover; }
.preview-empty { padding: 30px; color: #617082; text-align: center; }
.preview-empty .empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 14px; border: 1px solid #2b3845; border-radius: 50%; color: #8493a5; }
.preview-caption { display: flex; align-items: center; justify-content: space-between; padding: 0 18px 18px; color: var(--muted); font-size: 12px; }
.preview-caption strong { color: var(--text); }
.history { margin-top: 18px; }
.history-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px; }
.history-item { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #0d131a; cursor: pointer; }
.history-item:hover { border-color: #4b5d6d; }
.history-media { aspect-ratio: 16 / 10; background: #151c24; }
.history-media img, .history-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.history-info { padding: 9px; }
.history-title { overflow: hidden; color: #dfe6ee; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.history-time { margin-top: 5px; color: #687687; font-size: 10px; }
.tag { display: inline-flex; align-items: center; padding: 3px 6px; border-radius: 4px; background: #1d2934; color: #9fabb9; font-size: 10px; }
.tag.success { color: #8ce6d5; background: rgba(36, 211, 176, .1); }
.tag.failed { color: #ff9ca1; background: rgba(255, 111, 119, .12); }
.inspector-section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.inspector-section:last-child { border-bottom: 0; }
.inspector-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-weight: 700; }
.inspector-title svg { color: var(--accent); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stat { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.stat-value { font-size: 21px; font-weight: 800; }
.stat-label { margin-top: 5px; color: var(--muted); font-size: 11px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; color: var(--muted); font-size: 12px; }
.setting-row strong { color: var(--text); font-weight: 600; }
.toggle { position: relative; width: 35px; height: 20px; border: 0; border-radius: 99px; background: #2a3642; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #8291a2; transition: transform .18s; }
.toggle.on { background: rgba(36, 211, 176, .35); }
.toggle.on::after { transform: translateX(15px); background: var(--accent); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: 320px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: #18222d; color: #e4ebf2; box-shadow: var(--shadow); }
.toast.error { border-color: rgba(255, 111, 119, .55); }
.modal-mask { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .68); }
.modal { width: min(520px, 100%); border: 1px solid var(--line); border-radius: 8px; background: #11171f; box-shadow: var(--shadow); }
.modal-body { padding: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 0 18px 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .inspector { display: none; }
}
@media (max-width: 820px) {
  .topbar { padding: 0 16px; }
  .brand-sub, .status-chip { display: none; }
  .workspace { display: block; }
  .sidebar { display: none; }
  .main { padding: 20px 14px; }
  .main-grid { grid-template-columns: 1fr; }
  .history-list { grid-template-columns: repeat(2, 1fr); }
  .page-head { align-items: flex-start; flex-direction: column; }
}
#app { display: none; }
#app[data-ready="true"] { display: flex; flex-direction: column; }
.hidden { display: none !important; }
.app-fallback { min-height: 100vh; display: grid; place-content: center; gap: 8px; padding: 24px; background: #071018; color: var(--text); font-size: 15px; text-align: center; }
.app-fallback span { color: var(--muted); font-size: 12px; }
.usage-name { margin-top: 8px; color: var(--text); font-size: 18px; font-weight: 700; }
.form-hint { margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.mode-icon { width: 22px; text-align: center; color: var(--accent); font-size: 18px; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; }
.history-loading { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.preview-sub { margin-top: 8px; color: #617082; font-size: 12px; }
.error-text { color: #ff9ca1; line-height: 1.6; }
.modal-label { display: block; margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.modal-label input { display: block; margin-top: 7px; }
.modal-primary { width: auto; min-width: 112px; padding: 0 18px; }
.auth-tabs { grid-template-columns: 1fr 1fr; padding: 0 0 14px; border-bottom: 0; }
.chat-panel { margin-top: 18px; }
.chat-messages { min-height: 180px; padding: 18px; display: grid; gap: 12px; }
.message { max-width: 82%; }
.message.user { margin-left: auto; }
@media (max-width: 720px) { .top-actions { gap: 6px; } .top-actions .status-chip { display: none; } .message { max-width: 94%; } }
