/* evaluetron web UI — mobile-first, themeable, WCAG-minded. */

:root {
  --bg: #0b0d12;
  --surface: #141821;
  --surface-2: #1b202b;
  --border: #262c3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #5b7cfa;
  --accent-hover: #4a6bf0;
  --accent-contrast: #ffffff;
  --danger: #ff6b6b;
  --focus: #8aa2ff;
  --radius: 14px;
  --maxw: 620px;
}
:root[data-theme='light'] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --border: #e2e6ee;
  --text: #14171f;
  --muted: #5b6472;
  --accent: #4f6bf0;
  --accent-hover: #3f5ae6;
  --danger: #d92d2d;
  --focus: #2a49d6;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f6; --border: #e2e6ee;
    --text: #14171f; --muted: #5b6472; --accent: #4f6bf0; --accent-hover: #3f5ae6;
    --danger: #d92d2d; --focus: #2a49d6;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Accessibility helpers */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 10;
  background: var(--accent); color: var(--accent-contrast);
  padding: 10px 14px; border-radius: 10px; text-decoration: none; font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.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;
}

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; max-width: var(--maxw); width: 100%; margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; }
.brand-name { color: var(--text); font-weight: 650; letter-spacing: -.02em; font-size: 1.1rem; }
.icon-btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font: inherit; font-size: .9rem; cursor: pointer;
  min-height: 40px;
}
.icon-btn:hover { background: var(--surface-2); }

/* Main layout */
.main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 8px 20px 40px; }
.hero { margin: 8px 0 20px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 6vw, 2.1rem); font-weight: 700; letter-spacing: -.03em; }
.lede { margin: 0; color: var(--muted); font-size: 1.05rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.field-label { display: block; font-weight: 600; margin-bottom: 8px; }
.text-input {
  width: 100%; resize: vertical; min-height: 96px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  font: inherit; line-height: 1.5;
}
.text-input::placeholder { color: var(--muted); }
.field-meta { display: flex; justify-content: space-between; gap: 12px; margin: 8px 2px 0; }
.hint, .count { color: var(--muted); font-size: .85rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 20px; border-radius: 12px;
  font: inherit; font-weight: 650; cursor: pointer; border: 1px solid transparent;
  text-decoration: none; width: 100%;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); margin-top: 14px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary[aria-busy='true'] { opacity: .85; cursor: progress; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  display: none; animation: spin .7s linear infinite;
}
.btn-primary[aria-busy='true'] .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: rgba(255,255,255,.9); }
  .skip-link { transition: none; }
}

/* Status + result */
.status { min-height: 1.2em; margin: 14px 2px 0; color: var(--muted); font-size: .95rem; }
.status.error { color: var(--danger); font-weight: 600; }
.result { margin-top: 16px; }
.result-title, .recent-title { margin: 0 0 12px; font-size: 1rem; font-weight: 650; }
.player { width: 100%; }
.result-actions { margin-top: 14px; }

/* Recent */
.recent { margin-top: 24px; }
.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.recent-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.recent-text { margin: 0 0 8px; font-size: .92rem; color: var(--text); overflow-wrap: anywhere; }
.recent-item audio { width: 100%; }

/* Footer */
.site-footer { max-width: var(--maxw); width: 100%; margin: 0 auto; padding: 20px; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: 0; }

/* Larger screens */
@media (min-width: 640px) {
  .btn-primary { width: auto; min-width: 200px; }
}
