:root {
  color-scheme: light;
  --bg: #f2f7f4;
  --panel: rgba(255, 255, 255, .94);
  --line: #dce8e2;
  --text: #20372f;
  --muted: #7a9187;
  --brand: #47846f;
  --brand-dark: #326753;
  --brand-soft: #e4f1eb;
  --shadow: 0 14px 40px rgba(36, 79, 62, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 1px 1px, rgba(71,132,111,.08) 1px, transparent 1px) 0 0/18px 18px,
    var(--bg);
  font: 14px/1.5 Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; width: fit-content; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; background: var(--brand); display: grid; place-items: center; box-shadow: 0 8px 20px rgba(71,132,111,.24); }
.brand-mark img { width: 31px; height: 31px; filter: brightness(0) invert(1); }
.brand b { display: block; font-size: 17px; letter-spacing: .01em; }
.brand small { display: block; color: var(--muted); letter-spacing: .18em; font-size: 9px; }
.mode-switch { display: flex; padding: 4px; background: #edf4f0; border: 1px solid var(--line); border-radius: 999px; }
.mode-button { min-width: 86px; padding: 8px 20px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; }
.mode-button.active { color: white; background: var(--brand); box-shadow: 0 4px 14px rgba(71,132,111,.22); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.status-pill, .ghost-button, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: white; text-decoration: none;
}
.status-pill { padding: 0 12px; color: var(--muted); }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: #e1a854; }
.status-pill.online i { background: #45a978; box-shadow: 0 0 0 4px #e7f7ef; }
.status-pill.offline i { background: #d65d5d; }
.ghost-button { padding: 7px 13px; cursor: pointer; }
.icon-button { width: 36px; cursor: pointer; }
.workspace { display: grid; grid-template-columns: 280px minmax(420px, 1fr) minmax(440px, 1.12fr); min-height: calc(100vh - 68px); }
.sidebar { background: rgba(255,255,255,.78); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; min-height: 0; }
.sidebar-heading, .panel-heading, .preview-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sidebar-heading > div { display: flex; align-items: center; gap: 8px; }
.sidebar-heading span { color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--brand); cursor: pointer; }
.history-list { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; overflow: auto; flex: 1; }
.empty-hint { color: var(--muted); text-align: center; padding: 50px 12px; }
.history-card { display: grid; grid-template-columns: 55px 1fr; gap: 10px; padding: 9px; background: white; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; }
.history-card:hover { border-color: var(--brand); }
.history-thumb { width: 55px; height: 55px; border-radius: 8px; object-fit: cover; background: var(--brand-soft); }
.history-thumb.video { display: grid; place-items: center; font-size: 23px; }
.history-meta { min-width: 0; }
.history-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta span { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.sidebar-footer { display: grid; gap: 4px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.composer { padding: 22px; display: flex; flex-direction: column; gap: 16px; overflow: auto; }
.panel, .preview-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.panel { padding: 18px; }
.panel h2, .preview-panel h2 { margin: 0; font-size: 16px; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.panel-heading > span { color: var(--muted); font-size: 12px; }
.dropzone { min-height: 150px; margin-top: 14px; border: 1.5px dashed #b8cec4; border-radius: 13px; background: #f8fbf9; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: .2s ease; }
.dropzone:hover, .dropzone.dragging { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input { display: none; }
.drop-icon { font-size: 26px; width: 38px; height: 38px; border: 1px solid #bad1c6; border-radius: 50%; display: grid; place-items: center; color: var(--brand); margin-bottom: 9px; }
.dropzone small { color: var(--muted); margin-top: 3px; }
.file-strip { display: flex; gap: 9px; overflow-x: auto; margin-top: 12px; }
.file-chip { position: relative; flex: 0 0 78px; height: 78px; }
.file-chip img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.file-chip button { position: absolute; top: -5px; right: -5px; width: 21px; height: 21px; border-radius: 50%; border: 0; background: #263c34; color: white; cursor: pointer; }
.prompt-panel textarea { width: 100%; min-height: 155px; resize: vertical; margin-top: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #fbfdfc; outline: none; }
.prompt-panel textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(71,132,111,.1); }
.prompt-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.run-button { border: 0; border-radius: 11px; padding: 10px 20px; color: white; background: var(--brand); cursor: pointer; font-weight: 650; min-width: 128px; }
.run-button:hover { background: var(--brand-dark); }
.run-button:disabled { opacity: .58; cursor: wait; }
.run-spinner { display: none; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
.run-button.loading .run-spinner { display: inline-block; }
.run-button.loading { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.setting-row { display: grid; grid-template-columns: 100px 1fr; align-items: center; margin-top: 14px; }
.setting-label { color: #49655a; font-weight: 600; }
.model-summary { padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 650; }
.model-select { width: 100%; padding: 10px 36px 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: white; outline: none; cursor: pointer; }
.model-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(71,132,111,.1); }
.setting-block { margin-top: 16px; }
.choice-grid { display: grid; gap: 7px; margin-top: 8px; }
.ratios { grid-template-columns: repeat(5, 1fr); }
.resolutions { grid-template-columns: repeat(2, 1fr); }
.counts { grid-template-columns: repeat(4, 1fr); }
.durations { grid-template-columns: repeat(4, 1fr); }
.choice-grid button { border: 1px solid var(--line); background: white; padding: 8px; border-radius: 9px; cursor: pointer; }
.choice-grid button.active { color: white; border-color: var(--brand); background: var(--brand); }
.choice-grid button:disabled { display: none; }
.notice { display: flex; flex-direction: column; gap: 3px; padding: 12px; margin-top: 17px; border-radius: 11px; background: #f3f7f5; color: var(--muted); font-size: 12px; }
.notice strong { color: var(--text); }
.preview-panel { margin: 22px 22px 22px 0; padding: 18px; display: flex; flex-direction: column; min-height: calc(100vh - 112px); }
.preview-heading { align-items: center; }
.preview-heading > div { display: flex; align-items: center; gap: 10px; }
#elapsed { color: var(--muted); font-size: 12px; }
.results { flex: 1; min-height: 0; display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; margin-top: 14px; overflow: auto; }
.preview-empty { grid-column: 1/-1; min-height: 440px; border: 1px dashed #c6d8d0; border-radius: 14px; background: linear-gradient(145deg,#f9fcfa,#eef6f2); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 20px; }
.preview-empty strong { color: var(--text); margin-top: 9px; font-size: 16px; }
.preview-orb { width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center; font-size: 28px; color: white; background: linear-gradient(135deg,var(--brand),#79aa98); box-shadow: 0 16px 40px rgba(71,132,111,.25); }
.result-card { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: #f7faf8; }
.result-media { aspect-ratio: 1/1; width: 100%; object-fit: contain; background: #eaf1ed; display: block; }
.result-card.wide .result-media { aspect-ratio: 16/9; }
.result-card.tall .result-media { aspect-ratio: 9/16; max-height: 620px; }
.result-actions { display: flex; justify-content: space-between; align-items: center; padding: 9px; gap: 7px; }
.result-actions span { color: var(--muted); font-size: 12px; }
.result-actions div { display: flex; gap: 6px; }
.result-actions a, .result-actions button { border: 1px solid var(--line); background: white; padding: 6px 9px; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; }
dialog { border: 0; border-radius: 15px; padding: 0; box-shadow: 0 30px 80px rgba(20,45,35,.25); }
dialog::backdrop { background: rgba(18,38,31,.45); backdrop-filter: blur(3px); }
.access-card { width: min(390px, 90vw); padding: 24px; }
.access-card h2 { margin: 0; }
.access-card p { color: var(--muted); }
.access-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 17px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%,18px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 10px; color: white; background: #294b3e; transition: .2s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 230px minmax(380px, 1fr); }
  .preview-panel { grid-column: 2; margin-top: 0; }
  .sidebar { grid-row: 1 / span 2; }
}
@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; height: auto; padding: 10px 14px; }
  .mode-switch { grid-column: 1/-1; grid-row: 2; justify-self: stretch; }
  .mode-button { flex: 1; }
  .status-pill, .top-actions .ghost-button { display: none; }
  .workspace { display: block; }
  .sidebar { display: none; }
  .composer { padding: 12px; }
  .preview-panel { margin: 0 12px 12px; min-height: 520px; }
  .results { grid-template-columns: 1fr; }
  .ratios { grid-template-columns: repeat(3, 1fr); }
}
