:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --bg-input: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --text-dim: #9aa3b2;
  --accent: #5b9dff;
  --accent-hover: #7eb4ff;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 10px;
  --maxw: 960px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-card: #ffffff;
    --bg-input: #f1f3f7;
    --border: #e2e6ee;
    --text: #1a1d24;
    --text-dim: #5b6470;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
  }
}

/* Manual theme override (set by app.js + the inline FOUC script in index.html).
   These selectors win over the media query thanks to attribute specificity. */
:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-card: #171a21;
  --bg-input: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --text-dim: #9aa3b2;
  --accent: #5b9dff;
  --accent-hover: #7eb4ff;
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-card: #ffffff;
  --bg-input: #f1f3f7;
  --border: #e2e6ee;
  --text: #1a1d24;
  --text-dim: #5b6470;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  padding: 32px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.topbar-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-controls {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.lang-toggle,
.theme-toggle {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.lang-btn,
.theme-btn {
  background: transparent;
  color: var(--text-dim);
  border: 0;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover,
.theme-btn:hover {
  color: var(--text);
}

.lang-btn[aria-pressed="true"],
.theme-btn[aria-pressed="true"] {
  background: var(--accent);
  color: white;
}

.topbar h1 {
  font-size: 28px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.tagline {
  color: var(--text-dim);
  margin: 0;
  font-size: 15px;
}

main {
  padding-bottom: 60px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

@media (max-width: 600px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field[hidden] {
  display: none;
}

.field span {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.field select,
.field input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.field select:focus,
.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.hf-import-field {
  grid-column: 1 / -1;
}

.hf-import-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.hf-import-row input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
  transition: border-color 0.15s;
}

.hf-import-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.hf-import-row .btn {
  flex: 0 0 auto;
}

.hf-hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.45;
}

.hf-hint code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.hf-status {
  margin: 6px 0 0;
  font-size: 13px;
  min-height: 1.4em;
  line-height: 1.4;
}

.hf-status.ok  { color: var(--good); }
.hf-status.err { color: var(--bad); }

.hf-paste {
  margin: 10px 0 0;
  font-size: 13px;
}

.hf-paste summary {
  cursor: pointer;
  color: var(--text-dim);
  user-select: none;
  padding: 4px 0;
}

.hf-paste summary:hover { color: var(--text); }

.hf-paste-hint {
  margin: 8px 0;
  color: var(--text-dim);
  line-height: 1.45;
}

.hf-paste-hint code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.hf-paste textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.45;
  resize: vertical;
  transition: border-color 0.15s;
}

.hf-paste textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.hf-paste-actions {
  margin-top: 8px;
}

.results .result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

@media (max-width: 720px) {
  .results .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .results .result-grid {
    grid-template-columns: 1fr;
  }
}

.metric {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.metric-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 22px;
  font-weight: 600;
  margin: 4px 0 4px;
  font-variant-numeric: tabular-nums;
}

.metric-help {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

.verdict {
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--bg-input);
  border-left: 4px solid var(--accent);
  font-size: 15px;
  line-height: 1.55;
}

.verdict.good {
  border-left-color: var(--good);
}

.verdict.warn {
  border-left-color: var(--warn);
}

.verdict.bad {
  border-left-color: var(--bad);
}

.verdict strong {
  color: var(--text);
}

.actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions-feedback {
  font-size: 13px;
  color: var(--good);
  font-weight: 500;
}

.chart-help {
  color: var(--text-dim);
  font-size: 13.5px;
  margin: 0 0 14px;
  line-height: 1.5;
}

.chart {
  width: 100%;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart .bar.good   { fill: var(--good); }
.chart .bar.warn   { fill: var(--warn); }
.chart .bar.bad    { fill: var(--bad); }
.chart .bar-label  { fill: var(--text-dim); font-size: 11px; font-family: inherit; }
.chart .bar-value  { fill: var(--text); font-size: 11px; font-family: inherit; font-weight: 600; }
.chart .target-line {
  stroke: var(--text-dim);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}
.chart .target-label {
  fill: var(--text-dim);
  font-size: 11px;
  font-family: inherit;
}

.explainer p {
  color: var(--text-dim);
  font-size: 14.5px;
  margin: 0 0 12px;
}

.explainer p:last-child {
  margin-bottom: 0;
}

.explainer strong {
  color: var(--text);
}

.foot {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

.foot p {
  margin: 0 0 6px;
}

.foot p:last-child {
  margin-bottom: 0;
}

.foot .credit {
  font-size: 12px;
}

.foot .credit strong {
  color: var(--text);
  font-weight: 600;
}

.foot a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.foot a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
