:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-top: #f8fbff;
  --panel: #ffffff;
  --panel-soft: #fbfdff;
  --panel-strong: #ffffff;
  --text: #162033;
  --muted: #5b6780;
  --border: #dbe3f0;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent-soft: #e8f0ff;
  --control-bg: #eef4ff;
  --shadow: 0 18px 48px rgba(20, 32, 62, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1020;
    --bg-top: #0f172a;
    --panel: #121931;
    --panel-soft: #151e38;
    --panel-strong: #1a2447;
    --text: #e8ecf3;
    --muted: #b7c0d1;
    --border: rgba(138,180,255,0.18);
    --primary: #8ab4ff;
    --primary-strong: #6aa1ff;
    --accent-soft: #1b2548;
    --control-bg: #0f1b35;
    --shadow: 0 12px 40px rgba(0,0,0,0.22);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-top: #0f172a;
  --panel: #121931;
  --panel-soft: #151e38;
  --panel-strong: #1a2447;
  --text: #e8ecf3;
  --muted: #b7c0d1;
  --border: rgba(138,180,255,0.18);
  --primary: #8ab4ff;
  --primary-strong: #6aa1ff;
  --accent-soft: #1b2548;
  --control-bg: #0f1b35;
  --shadow: 0 12px 40px rgba(0,0,0,0.22);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 100%);
  color: var(--text);
}
.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 260px;
  padding-top: 24px;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-start;
}
.hero-copy {
  max-width: 780px;
}
.eyebrow {
  display: inline-block;
  color: var(--primary);
  background: var(--accent-soft);
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 12px;
  padding: 6px 12px;
}
.hero h1, .section-head h2, .block-head h3, .result-panel h3 { margin: 0 0 10px; }
.hero-text, .section-head p, .block-head p, .hint {
  color: var(--muted);
  line-height: 1.6;
}
.hero-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.badge {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}
.theme-toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.theme-label {
  color: var(--primary);
  font-weight: 700;
}
.theme-toggle {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--control-bg);
  gap: 4px;
}
.theme-option {
  min-width: 68px;
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}
.theme-option.is-selected {
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.10);
}
.hero-actions {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  min-width: min(100%, 520px);
}
.stack-form { display: flex; flex-direction: column; gap: 20px; }
.form-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: var(--panel-soft);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.field-group { display: flex; flex-direction: column; gap: 8px; }
.full-span { width: 100%; }
label { font-weight: 700; }
input, textarea, select, button {
  font: inherit;
}
input, textarea, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  padding: 12px 14px;
}
textarea {
  resize: vertical;
  min-height: 260px;
  font-family: "JetBrains Mono", "Consolas", monospace;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
  color: white;
}
.btn-secondary {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn:disabled { opacity: 0.6; cursor: wait; }
.status-card {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.hidden { display: none; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.result-panel {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.section-gap { margin-top: 16px; }
pre.report-box, pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  overflow: auto;
  color: var(--text);
}
@media (max-width: 768px) {
  .page-shell { padding: 16px; }
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .hero-actions {
    align-items: flex-start;
    min-width: 0;
  }
  .theme-toolbar { align-items: flex-start; }
  .hero-badges { justify-content: flex-start; }
}
