:root {
  color-scheme: dark;

  --bg: #08090b;
  --bg-elevated: #101216;
  --surface: rgba(126, 138, 156, 0.13);
  --surface-solid: #14171c;
  --surface-hover: rgba(150, 163, 182, 0.2);
  --border: rgba(203, 214, 230, 0.14);
  --border-strong: rgba(214, 226, 242, 0.28);
  --text: #eef1f6;
  --text-secondary: rgba(214, 223, 235, 0.74);
  --muted: rgba(196, 206, 221, 0.52);

  /* Brushed-steel accent: light enough to read as polished metal on dark glass. */
  --primary: #b9c9dc;
  --primary-hover: #d5e1ef;
  --primary-soft: rgba(185, 201, 220, 0.16);
  --steel-light: #e9eff7;
  --steel-mid: #a9b7c8;
  --steel-dark: #7c8a9d;
  --steel-ink: #0d1014;
  --pos: #4fd18b;
  --neg: #ff6b60;
  --warning: #e8c76a;
  --radius: 22px;
  --radius-sm: 16px;
  --max: 1300px;
  --blur: saturate(190%) blur(30px);
  --blur-strong: saturate(200%) blur(44px);

  /* Frosted-glass recipe: a faint sheen across the pane, a specular hairline along the
     top edge, and a soft cast shadow so panes read as floating layers. */
  --sheen: linear-gradient(
    152deg,
    rgba(232, 240, 252, 0.12) 0%,
    rgba(214, 226, 242, 0.04) 38%,
    rgba(255, 255, 255, 0) 68%
  );
  --glass-edge:
    inset 0 1px 0 rgba(232, 240, 252, 0.16),
    inset 0 0 0 1px rgba(203, 214, 230, 0.04);
  --shadow:
    inset 0 1px 0 rgba(232, 240, 252, 0.16),
    inset 0 0 0 1px rgba(203, 214, 230, 0.04),
    0 24px 60px -24px rgba(0, 0, 0, 0.85),
    0 8px 24px -14px rgba(0, 0, 0, 0.7);

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI Variable", Inter, "Segoe UI", system-ui, sans-serif;
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.011em;
}

body {
  /* Overcast light down the facade, cool daylight from the left, plus the faint vertical
     mullions of a curtain wall. */
  background-image:
    linear-gradient(180deg, rgba(164, 180, 202, 0.12), transparent 52%),
    radial-gradient(900px 540px at 14% -12%, rgba(176, 195, 219, 0.16), transparent 70%),
    radial-gradient(780px 470px at 86% -6%, rgba(122, 141, 166, 0.14), transparent 70%),
    radial-gradient(760px 540px at 72% 96%, rgba(96, 112, 134, 0.12), transparent 74%),
    repeating-linear-gradient(90deg, rgba(226, 236, 250, 0.02) 0 1px, transparent 1px 96px);
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, repeat;
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  letter-spacing: -0.022em;
  font-weight: 600;
}

::selection { background: var(--primary-soft); }

*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ─────────────────────────────────────────── */

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(12, 12, 14, 0.5);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04), 0 8px 30px -18px rgba(0, 0, 0, 0.9);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner,
.page,
.disclaimer {
  width: min(var(--max), calc(100% - 2.5rem));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  font-size: 1.02rem;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(160deg, var(--steel-light), var(--steel-dark));
  color: var(--steel-ink);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 4px 14px rgba(160, 180, 205, 0.3);
}

.nav {
  display: flex;
  gap: 0.25rem;
  background: rgba(126, 138, 156, 0.18);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.nav a {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  transition: color 0.2s ease, background 0.2s ease;
}

.nav a:hover { color: var(--text); }

.nav a.active {
  background-color: rgba(118, 118, 124, 0.45);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02));
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.45);
}

.page {
  flex: 1;
  padding: 2.5rem 0 4rem;
}

.disclaimer {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 1.25rem 0 2.5rem;
  border-top: 1px solid var(--border);
}

/* ── Hero / prompt ───────────────────────────────────── */

.hero {
  max-width: 860px;
  margin: 2.5rem auto 0;
  text-align: center;
}

.eyebrow {
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
  margin: 0;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.05;
  margin: 0.75rem 0 1rem;
  background: linear-gradient(180deg, #ffffff 18%, rgba(178, 192, 210, 0.66));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  color: var(--text-secondary);
  font-size: 1.08rem;
  line-height: 1.5;
  max-width: 620px;
  margin: 0 auto 2rem;
}

.prompt-card,
.card,
.defaults-card,
.stage-card,
.metric-card {
  background-color: var(--surface);
  background-image: var(--sheen);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.prompt-card {
  text-align: left;
  padding: 1.1rem 1.1rem 0.9rem;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.prompt-card:focus-within {
  border-color: rgba(214, 226, 242, 0.4);
  box-shadow: var(--shadow), 0 0 0 4px rgba(185, 201, 220, 0.14);
}

.prompt-card textarea,
.clarify-block input,
.followup-row input {
  width: 100%;
  border: none;
  outline: none;
  resize: vertical;
  font: inherit;
  color: var(--text);
  background: transparent;
}

.prompt-card textarea {
  min-height: 132px;
  padding: 0.4rem 0.35rem;
  line-height: 1.55;
  font-size: 1.02rem;
}

textarea::placeholder,
input::placeholder { color: var(--muted); }

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.5rem;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn-primary,
.btn-secondary {
  border: none;
  border-radius: 980px;
  padding: 0.7rem 1.35rem;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-primary {
  background-image: linear-gradient(180deg, var(--steel-light), var(--steel-mid));
  color: var(--steel-ink);
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    inset 0 -1px 0 rgba(13, 16, 20, 0.18),
    0 8px 24px -10px rgba(196, 212, 233, 0.55);
}

.btn-primary:hover:not(:disabled) {
  background-image: linear-gradient(180deg, #ffffff, #bcc8d8);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 12px 30px -10px rgba(214, 228, 246, 0.65);
}

.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled) { transform: scale(0.97); }

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background-color: rgba(132, 145, 164, 0.2);
  background-image: linear-gradient(180deg, rgba(232, 240, 252, 0.12), rgba(255, 255, 255, 0));
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  box-shadow: var(--glass-edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.btn-secondary:hover:not(:disabled) {
  background-color: rgba(140, 140, 148, 0.3);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* ── Example chips ───────────────────────────────────── */

.examples {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}

.examples-label {
  width: 100%;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.35rem;
}

.example-chip {
  border: 1px solid var(--border);
  background-color: rgba(52, 52, 58, 0.34);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0));
  box-shadow: var(--glass-edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: 980px;
  padding: 0.6rem 1rem;
  text-align: left;
  cursor: pointer;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9rem;
  max-width: 100%;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.example-chip:hover {
  border-color: var(--border-strong);
  background-color: var(--surface-hover);
  color: var(--text);
  transform: translateY(-1px);
}

.example-chip:active { transform: scale(0.98); }
.example-chip.compact { padding: 0.4rem 0.75rem; font-size: 0.82rem; }

.defaults-card {
  margin-top: 2rem;
  text-align: left;
  padding: 1.25rem 1.4rem;
}

.defaults-card h3 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  color: var(--text);
}

.defaults-card ul,
.plain {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.85;
}

.defaults-card li::marker,
.plain li::marker { color: var(--muted); }

/* ── Workspace / stages ──────────────────────────────── */

.workspace { display: flex; flex-direction: column; gap: 1.1rem; }

.stage-card {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  padding: 1.4rem;
}

.stage-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--primary);
  animation: spin 0.75s linear infinite;
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.stage-list {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.9;
}

.stage-list .active { color: var(--primary); font-weight: 500; }
.stage-list .done { color: var(--pos); }

.card { padding: 1.4rem 1.5rem; }

.card h2, .card h3 {
  margin-top: 0;
  margin-bottom: 0.7rem;
}

.card h3 { font-size: 1rem; }
.card p { line-height: 1.6; color: var(--text-secondary); }

.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.error-card {
  border-color: rgba(255, 107, 96, 0.32);
  background-color: rgba(104, 38, 34, 0.26);
  background-image: linear-gradient(152deg, rgba(255, 140, 130, 0.13), rgba(255, 107, 96, 0.02) 60%);
}

.warning-card {
  border-color: rgba(232, 199, 106, 0.26);
  background-color: rgba(88, 74, 34, 0.22);
  background-image: linear-gradient(152deg, rgba(238, 212, 140, 0.12), rgba(232, 199, 106, 0.02) 60%);
}

.warning-card h3 { color: var(--warning); }

.warning-card ul {
  margin: 0;
  padding-left: 1.15rem;
  color: rgba(240, 216, 150, 0.9);
  font-size: 0.92rem;
  line-height: 1.75;
}

/* ── Results ─────────────────────────────────────────── */

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.25rem 0 0.25rem;
}

.result-header h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.result-header .muted { font-size: 0.92rem; margin: 0; }

.result-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
}

.metric-card {
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.15rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.metric-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 0.45rem;
}

.metric-card strong {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.chart-card .chart-wrap {
  height: 360px;
  position: relative;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.chart-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.chart-toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.two-col {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 1.1rem;
}

.summary {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.93rem;
}

/* ── Tables ──────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.72rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.data-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: rgba(146, 160, 180, 0.1); }
.data-table td:first-child { color: var(--text); }

.table-scroll { overflow-x: auto; }

/* ── Follow-up & clarification ───────────────────────── */

.followup-card {
  border-color: rgba(214, 226, 242, 0.24);
  background-image:
    var(--sheen),
    radial-gradient(120% 140% at 0% 0%, rgba(186, 204, 226, 0.14), transparent 62%);
}

.followup-row {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.followup-row input,
.clarify-block input {
  flex: 1;
  border: 1px solid var(--border);
  background: rgba(126, 138, 156, 0.14);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.followup-row input {
  border-radius: 980px;
  padding: 0.7rem 1.1rem;
}

.clarify-block input {
  border-radius: 12px;
  padding: 0.75rem 0.95rem;
}

.followup-row input:focus,
.clarify-block input:focus {
  border-color: rgba(214, 226, 242, 0.45);
  background: rgba(146, 158, 176, 0.2);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(185, 201, 220, 0.12);
  outline: none;
}

.clarify-block {
  margin: 1.1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.clarify-block label {
  font-weight: 500;
  font-size: 0.95rem;
}

.example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ── History ─────────────────────────────────────────── */

.history-list { display: flex; flex-direction: column; gap: 0.85rem; }

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  align-items: flex-start;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.history-item:hover {
  border-color: var(--border-strong);
  background-color: var(--surface-hover);
  transform: translateY(-2px);
}

.history-item h3 { margin-bottom: 0.25rem; }

.history-prompt {
  color: var(--text-secondary);
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
}

.history-stats {
  display: flex;
  gap: 1.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.history-stats strong { font-size: 1.15rem; }

/* ── Blazor UI overrides ─────────────────────────────── */

#blazor-error-ui {
  background: rgba(20, 23, 28, 0.95);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: var(--text);
  border-top: 1px solid rgba(255, 107, 96, 0.4);
  bottom: 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
  display: none;
  left: 0;
  padding: 0.8rem 1.5rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  font-size: 0.9rem;
}

#blazor-error-ui .reload { color: var(--primary); text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.7rem; }
#blazor-error-ui.show { display: block; }

#components-reconnect-modal {
  background-color: var(--surface-solid) !important;
  color: var(--text);
  border: 1px solid var(--border) !important;
  border-radius: 18px !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7) !important;
}

#components-reconnect-modal::backdrop {
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

#components-reconnect-modal button {
  background-color: var(--primary) !important;
  color: var(--steel-ink);
  border-radius: 980px !important;
  padding: 0.45rem 1.1rem !important;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}

#components-reconnect-modal button:hover { background-color: var(--primary-hover) !important; }
.components-rejoining-animation div { border-color: var(--primary) !important; }

/* ── Glass fallbacks ─────────────────────────────────── */

/* Without backdrop blur the panes would read as flat grey, so make them opaque instead. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .prompt-card,
  .card,
  .defaults-card,
  .stage-card,
  .metric-card,
  .example-chip,
  .btn-secondary,
  .topbar {
    background-color: rgba(23, 26, 32, 0.96);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .prompt-card,
  .card,
  .defaults-card,
  .stage-card,
  .metric-card,
  .topbar {
    background-color: rgba(21, 24, 29, 0.97);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar-inner, .page, .disclaimer { width: calc(100% - 1.5rem); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .history-item { flex-direction: column; }
  .history-stats { text-align: left; }
  .followup-row { flex-direction: column; }
  .result-header { flex-direction: column; }
  .nav a { padding: 0.4rem 0.7rem; }
}
