/* =========================================================================
   Kabisadeck - styles
   Motion rule: only `transform` and `opacity` are ever animated or transitioned.
   ========================================================================= */

@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/vendor/fonts/poppins-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/vendor/fonts/poppins-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/vendor/fonts/poppins-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/vendor/fonts/poppins-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/vendor/fonts/poppins-latin-800-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --teal-900: #073f3e;
  --teal-700: #0b5d5b;
  --teal-600: #0f7773;
  --teal-300: #8fc9c4;
  --teal-100: #dff0ee;
  --teal-50: #eef7f6;

  --accent: #f26b4e;
  --accent-700: #c9472a;
  --accent-100: #fde6df;

  --bg: #f7f3ea;
  --surface: #ffffff;
  --ink: #14201f;
  --muted: #566665;
  --line: #e6e1d6;
  --line-strong: #d3ccbd;

  --good: #17703f;
  --good-bg: #e7f5ec;
  --good-line: #a8d9bb;
  --bad: #b8321f;
  --bad-bg: #fcebe8;
  --bad-line: #f0b9b0;
  --warn: #9a5b00;
  --warn-bg: #fdf3dc;
  --warn-line: #ecd08f;
  --amber: #b86e00;
  --danger: #d12f2f;

  --radius: 8px;
  --radius-lg: 10px;
  --shadow-sm: none;
  --shadow: none;
  --shadow-lg: 0 2px 12px rgba(20, 32, 31, 0.08);
  --ease: cubic-bezier(0.22, 0.8, 0.3, 1);

  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1 { font-size: clamp(1.5rem, 1.15rem + 1.3vw, 2rem); line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; }
h2 { font-size: 1.2rem; line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; }
a { color: var(--teal-700); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
legend { padding: 0; }

:focus-visible {
  outline: 3px solid var(--teal-600);
  outline-offset: 2px;
  border-radius: 6px;
}
h1:focus { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--muted); }
.lead { font-size: 1.05rem; margin-top: 8px; }

/* ---------- Layout shell ---------- */

.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250, 248, 244, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.2) blur(8px);
}
.topbar__inner {
  max-width: 1080px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap;
}
.topbar__logo { text-decoration: none; display: inline-flex; border-radius: 10px; }
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; }
.nav__link {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: 0.95rem; text-decoration: none;
}
.nav__link:hover { background: var(--teal-50); color: var(--teal-700); }
.nav__link.is-active { background: var(--teal-100); color: var(--teal-900); }
.topbar__user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar__name { font-weight: 600; color: var(--muted); font-size: 0.92rem; }

.page { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 16px 72px; }
.view { animation: view-in 0.35s var(--ease) both; }
@keyframes view-in { from { opacity: 0; } to { opacity: 1; } }

.narrow { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.narrow--center { text-align: center; align-items: center; }
.narrow--center > * { max-width: 100%; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  color: var(--muted); font-weight: 600; font-size: 0.92rem; text-decoration: none; min-height: 32px;
}
.back-link:hover { color: var(--teal-700); }

.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: flex-end; margin-top: 4px; }
.actions--center { justify-content: center; }
.actions--wrap { justify-content: flex-start; margin: 24px 0; }

.fatal { max-width: 460px; margin: 18vh auto 0; padding: 0 20px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 1.5px solid transparent; border-radius: 8px;
  font-weight: 600; font-size: 0.97rem; line-height: 1; text-decoration: none; text-align: center;
  cursor: pointer; background: none;
  transition: transform 0.15s var(--ease), opacity 0.15s linear;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--teal-700); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover:not(:disabled) { background: var(--teal-900); }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover:not(:disabled) { border-color: var(--teal-600); color: var(--teal-700); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #b32424; }
.btn--danger-text { color: var(--bad); }
.btn--danger-text:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
.btn--lg { min-height: 52px; padding: 0 26px; font-size: 1.02rem; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: 0.9rem; border-radius: 8px; }
.btn--block { width: 100%; }
.link { font-weight: 600; font-size: 0.92rem; }

.spinner {
  width: 1em; height: 1em; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 650; font-size: 0.92rem; }
.field__hint { color: var(--muted); font-size: 0.88rem; min-height: 1.3em; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 8px;
}
.input::placeholder { color: #8a9695; }
.input:hover { border-color: var(--teal-300); }
.input:focus-visible { outline: 3px solid rgba(15, 119, 115, 0.35); outline-offset: 0; border-color: var(--teal-600); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input--small { min-height: 38px; padding: 6px 12px; width: auto; font-size: 0.9rem; }
.textarea { resize: vertical; min-height: 96px; }
.form-error { color: var(--bad); font-weight: 600; font-size: 0.92rem; min-height: 1.4em; }
.divider { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.alert {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  padding: 12px 14px; border-radius: 8px; border: 1px solid; font-size: 0.95rem;
}
.alert--error { background: var(--bad-bg); border-color: var(--bad-line); color: #7d2113; }
.alert--warn { background: var(--warn-bg); border-color: var(--warn-line); color: #6e4100; }
.alert--good { background: var(--good-bg); border-color: var(--good-line); color: #0f4f2c; }

/* ---------- Generic bits ---------- */

.card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 22px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel__head--stack { align-items: flex-end; }

.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px;
  background: var(--teal-50); color: var(--teal-700); border: 1px solid var(--teal-100);
  font-size: 0.78rem; font-weight: 600; white-space: nowrap;
}
.tag--you { background: #eef0ff; color: #3b3fa5; border-color: #d9dcfb; }
.tag--right { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.tag--wrong { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 4px;
  font-size: 0.82rem; font-weight: 600; white-space: nowrap; border: 1px solid;
}
.pill--lg { font-size: 0.95rem; padding: 5px 15px; }
.pill--good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.pill--bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }

.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 4px;
  background: var(--accent-700); color: #fff; font-weight: 700; font-size: 0.95rem;
}
.badge--small { padding: 2px 9px; font-size: 0.74rem; }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: 44px 24px; max-width: 520px; margin: 24px auto; color: var(--muted);
}
.empty h2 { color: var(--ink); }
.empty--inline { padding: 24px 12px; margin: 0 auto; }

/* skeletons: the shimmer is a translated overlay (transform only) */
.skeleton {
  position: relative; overflow: hidden; background: #ece7dc; border-radius: 12px; min-height: 16px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton--title { height: 38px; width: 60%; margin-bottom: 20px; }
.skeleton--card { height: 150px; border-radius: var(--radius-lg); }
.skeleton--stat { height: 96px; border-radius: var(--radius); }
.skeleton--line { height: 18px; width: 100%; }
.skeleton--short { width: 62%; }
.skeleton--choice { height: 46px; width: 100%; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 16px; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.results-skeleton { display: grid; gap: 16px; }

/* progress */
.progress-block { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.progress-block__row { display: flex; justify-content: space-between; gap: 12px; align-items: center; font-weight: 600; font-size: 0.92rem; color: var(--muted); }
.progress-block__row > span:first-child { display: inline-flex; gap: 8px; align-items: center; }
.progress { height: 10px; border-radius: 999px; background: var(--teal-100); overflow: hidden; }
.progress__fill {
  width: 100%; height: 100%; border-radius: 999px; background: var(--teal-700);
  transform-origin: left center; transform: scaleX(0); transition: transform 0.45s var(--ease);
}
.progress__pct { font-variant-numeric: tabular-nums; }

/* ---------- Logo ---------- */

.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo__word { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.03em; color: var(--teal-700); line-height: 1; }
.logo__word b { color: var(--accent); font-weight: 800; }
.logo--stacked { flex-direction: column; gap: 10px; }
.logo--stacked .logo__word { font-size: 2rem; }

/* ---------- Login ---------- */

.bare { min-height: 100vh; min-height: 100dvh; }
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 20px; }
.login__card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 36px 32px 32px;
  display: flex; flex-direction: column; gap: 26px; animation: view-in 0.45s var(--ease) both;
}
.login__brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.login__tag { color: var(--muted); font-size: 0.95rem; }
.login__form { display: flex; flex-direction: column; gap: 16px; }
.login__foot { color: var(--muted); font-size: 0.85rem; }

/* ---------- Dashboard ---------- */

.dash { display: flex; flex-direction: column; gap: 24px; }
.dash__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px 24px; flex-wrap: wrap; }
.dash__head .muted { margin-top: 6px; }
.streak {
  display: inline-flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 8px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
}
.streak--idle { color: var(--muted); border-color: var(--line); }
.streak__count { font-weight: 800; line-height: 1.2; }
.streak__sub { font-size: 0.8rem; opacity: 0.85; }

.mode-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mode-card {
  position: relative; display: flex; flex-direction: column; gap: 18px; padding: 28px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--ink);
}
.mode-card:hover { border-color: var(--teal-600); }
.mode-card__body { display: flex; flex-direction: column; gap: 6px; }
.mode-card__title { font-size: 1.4rem; font-weight: 700; }
.mode-card__text { color: var(--muted); }
.mode-card__cta { font-weight: 600; color: var(--teal-700); margin-top: auto; text-decoration: underline; text-underline-offset: 3px; }

.stats { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat__label { font-size: 0.82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat__value { font-size: 2rem; font-weight: 700; color: var(--teal-700); line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: 0.85rem; color: var(--muted); }

.dash__cols { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.dash__cols > * { min-width: 0; }
.mastery__list { display: flex; flex-direction: column; gap: 18px; }
.mastery__head { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; margin-bottom: 8px; }
.mastery__topic { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.mastery__pct { margin-left: auto; font-weight: 700; color: var(--teal-700); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mastery__sub { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.meter { height: 10px; border-radius: 999px; background: var(--teal-100); overflow: hidden; }
.meter__fill { width: 100%; height: 100%; border-radius: 999px; background: var(--teal-700); transform-origin: left center; transform: scaleX(0); }
.meter__fill--done { background: var(--accent); }

.recent { display: flex; flex-direction: column; }
.recent__row {
  display: flex; align-items: center; gap: 12px; padding: 12px 6px; text-decoration: none; color: var(--ink);
  border-top: 1px solid var(--line); border-radius: 0;
}
.recent li:first-child .recent__row { border-top: 0; }
.recent__row:hover { background: var(--teal-50); }
.recent__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.recent__topic { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent__meta { font-size: 0.8rem; color: var(--muted); }
.recent__score { font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.panel--link { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--ink); }
.panel--link:hover { border-color: var(--teal-600); }
.mistakes-teaser__body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.mistakes-teaser__title { font-weight: 750; }
.mistakes-teaser__text { color: var(--muted); font-size: 0.92rem; }

/* ---------- Upload ---------- */

.dropzone {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 48px 24px; min-height: 260px; justify-content: center;
  background: var(--surface); border: 2px dashed var(--teal-300); border-radius: 10px; cursor: pointer;
}
.dropzone:hover { border-color: var(--teal-600); background: var(--teal-50); }
.dropzone.is-over { border-color: var(--teal-700); background: var(--teal-100); }
.dropzone__title { font-size: 1.2rem; font-weight: 700; }
.dropzone__or { color: var(--muted); }
.dropzone__hint { font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
.upload__status { display: flex; flex-direction: column; gap: 16px; }
.file-ready {
  display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.file-ready__body { flex: 1; min-width: 0; text-align: left; }
.file-ready__name { font-weight: 700; overflow-wrap: anywhere; }
.file-ready__meta { color: var(--muted); font-size: 0.9rem; }
.file-ready__note { color: var(--warn); font-size: 0.85rem; margin-top: 4px; }

/* ---------- Topic ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 0.95rem;
  background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--ink); text-align: left;
}
.chip:hover { border-color: var(--teal-600); }
.chip.is-selected { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }

/* ---------- Setup ---------- */

.summary { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.summary__body { display: flex; flex-direction: column; min-width: 0; }
.summary__label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.summary__value { font-weight: 700; overflow-wrap: anywhere; }
.group { border: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.group legend { font-weight: 750; font-size: 1.05rem; margin-bottom: 10px; }
.choice-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-card {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius);
}
.choice-card:hover { border-color: var(--teal-600); }
.choice-card__input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice-card__body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.choice-card__title { font-weight: 750; }
.choice-card__text { color: var(--muted); font-size: 0.9rem; }
.choice-card__check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; margin-top: 2px;
}
.choice-card:has(.choice-card__input:checked) { border-color: var(--teal-700); background: var(--teal-50); box-shadow: 0 0 0 1px var(--teal-700) inset; }
.choice-card:has(.choice-card__input:checked) .choice-card__check { border-color: var(--teal-700); background: radial-gradient(circle, var(--teal-700) 0 5px, transparent 6px); }
.choice-card:has(.choice-card__input:focus-visible) { outline: 3px solid var(--teal-600); outline-offset: 2px; }

.seg { display: inline-flex; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 8px; padding: 3px; gap: 3px; max-width: 100%; flex-wrap: wrap; }
.seg__item { position: relative; cursor: pointer; }
.seg__input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg__item span, .seg__btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 64px; min-height: 42px; padding: 0 16px;
  border-radius: 6px; font-weight: 600; color: var(--muted); border: 0; background: none; cursor: pointer;
}
.seg__item:hover span, .seg__btn:hover { background: var(--teal-50); color: var(--teal-700); }
.seg__item:has(.seg__input:checked) span, .seg__btn.is-on { background: var(--teal-700); color: #fff; }
.seg__item:has(.seg__input:focus-visible) { outline: 3px solid var(--teal-600); outline-offset: 2px; border-radius: 6px; }
.seg--small .seg__btn { min-height: 36px; min-width: 0; font-size: 0.88rem; }

/* ---------- Generating ---------- */

.gen { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8px 0; }
.gen__message { color: var(--muted); font-weight: 600; min-height: 1.6em; }
.gen__note { font-size: 0.88rem; }
.gen__error-text { color: var(--muted); max-width: 520px; }
.steps { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.steps__item { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.steps__dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.steps__item.is-active { color: var(--ink); }
.steps__item.is-active .steps__dot { border-color: var(--teal-700); background: var(--teal-700); animation: pulse 1.2s ease-in-out infinite; }
.steps__item.is-done { color: var(--teal-700); }
.steps__item.is-done .steps__dot { background: var(--teal-700); border-color: var(--teal-700); }
@keyframes pulse { 50% { transform: scale(1.35); opacity: 0.6; } }
.skeleton-deck { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; opacity: 0.8; }

/* ---------- Ready ---------- */

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; }
.facts > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px; }
.facts dt { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.facts dd { font-size: 1.25rem; font-weight: 800; color: var(--teal-700); }
.rules { text-align: left; display: flex; flex-direction: column; gap: 12px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.rules li { color: var(--muted); font-size: 0.95rem; }

/* ---------- Quiz ---------- */

.quiz-loading { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: var(--muted); font-weight: 600; }
.quiz-loading .spinner { width: 28px; height: 28px; color: var(--teal-700); }

.quiz { --tone: var(--teal-700); overflow-x: clip; position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: #fdf8ef; }
.quiz[data-tone="warn"] { --tone: var(--amber); }
.quiz[data-tone="danger"] { --tone: var(--danger); }
.quiz__bar {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px;
  padding: 12px clamp(14px, 3vw, 32px); background: var(--surface);
}
.quiz__brand { display: none; }
.quiz__counter { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.timer { display: inline-flex; align-items: center; color: var(--tone); }
.timer__text { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3.4ch; text-align: right; }
.quiz[data-tone="danger"] .timer { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.55; } }
.timerbar { height: 8px; background: var(--teal-100); overflow: hidden; }
.timerbar__fill { width: 100%; height: 100%; background: var(--tone); transform-origin: left center; will-change: transform; }

.quiz__stage { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: clamp(14px, 3vh, 36px) clamp(14px, 3vw, 24px) 24px; }
.deck { position: relative; }
.flashcard {
  position: relative; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  padding: clamp(20px, 3.5vw, 36px); min-height: 360px;
  display: flex; flex-direction: column; gap: 18px;
}
.flashcard.is-entering { animation: card-in 0.35s var(--ease) both; }
@keyframes card-in { from { opacity: 0; } to { opacity: 1; } }
.flashcard__meta { font-size: 0.9rem; font-weight: 600; color: var(--teal-700); }
.flashcard__stem { font-size: clamp(1.1rem, 1rem + 0.6vw, 1.35rem); line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.choices { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.choice {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  padding: 14px 16px; min-height: 56px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 8px;
}
.choice:hover { border-color: var(--teal-600); background: var(--teal-50); }
.choice__letter {
  width: 30px; height: 30px; border-radius: 6px; flex: none; display: grid; place-items: center;
  background: var(--teal-100); color: var(--teal-700); font-weight: 700; font-size: 0.9rem;
}
.choice__text { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 3px; }
.choice.is-selected { border-color: var(--teal-700); background: var(--teal-50); box-shadow: 0 0 0 1.5px var(--teal-700) inset; }
.choice.is-selected .choice__letter { background: var(--teal-700); color: #fff; }

.watermark { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: inherit; z-index: 3; }
.watermark__grid {
  position: absolute; left: 50%; top: 50%; width: 220%; height: 220%;
  transform: translate(-50%, -50%) rotate(-28deg);
  display: grid; grid-template-columns: repeat(6, 1fr); align-content: space-around; justify-items: center;
}
.watermark__grid span { font-size: 22px; font-weight: 800; letter-spacing: 0.18em; color: rgba(11, 93, 91, 0.07); white-space: nowrap; }

.quiz__actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(14px, 3vw, 32px) calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
}
.quiz__tip { color: var(--muted); font-size: 0.85rem; }
.quiz__buttons { display: flex; gap: 10px; margin-left: auto; }

.quiz.is-locked .flashcard { visibility: hidden; }

.lock {
  position: fixed; inset: 0; z-index: 1000; background: var(--bg);
  display: grid; place-items: center; padding: 20px; animation: fade-in 0.2s linear both;
}
.lock--submit { z-index: 1100; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.lock__panel {
  width: 100%; max-width: 460px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 32px 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.lock__panel > .spinner { width: 34px; height: 34px; color: var(--teal-700); border-width: 3px; }
.lock__text { font-weight: 600; font-size: 1.05rem; }
.lock__count { color: var(--bad); font-weight: 700; }
.lock__note { color: var(--muted); font-size: 0.92rem; min-height: 1.2em; }
.lock__panel .btn { margin-top: 8px; }

body.quiz-active .quiz,
body.quiz-active .quiz * {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none;
}
body.is-printing .quiz { display: none !important; }
@media print { body.quiz-active .quiz { display: none !important; } }

/* ---------- Modal & toast ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 900; background: rgba(7, 63, 62, 0.45); display: grid; place-items: center; padding: 16px;
  opacity: 0; transition: opacity 0.18s linear;
}
.modal-backdrop.is-in { opacity: 1; }
.modal {
  width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 12px; padding: 26px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px;
  transform: translateY(6px); transition: transform 0.2s var(--ease);
}
.modal-backdrop.is-in .modal { transform: none; }
.modal:focus { outline: none; }
.modal__body { display: flex; flex-direction: column; gap: 14px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.modal--danger .modal__title { color: var(--bad); }

.toasts { position: fixed; left: 0; right: 0; bottom: 20px; z-index: 1200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  max-width: 460px; padding: 12px 18px; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 500; font-size: 0.93rem;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); transition: opacity 0.2s linear, transform 0.2s var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast--error { background: #8f2417; }
.toast--success { background: var(--teal-700); }

/* ---------- Results ---------- */

.results { display: flex; flex-direction: column; gap: 18px; }
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: clamp(22px, 4vw, 36px);
  background: var(--teal-700); color: #fff; border-radius: 12px;
}
.hero--fail { background: #3b4a49; }
.hero__main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hero__eyebrow { opacity: 0.85; font-weight: 600; overflow-wrap: anywhere; }
.hero h1 { font-size: clamp(1.3rem, 1rem + 1.2vw, 1.8rem); }
.hero__pct { font-size: clamp(3.4rem, 2.4rem + 5vw, 5.5rem); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.hero__tags { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.hero__meta { opacity: 0.85; font-size: 0.9rem; }
.hero .pill--good { background: #d4f4e1; }
.hero .pill--bad { background: #ffe0da; }
.hero__facts { display: grid; gap: 14px; min-width: 190px; }
.hero__facts > div { background: rgba(255, 255, 255, 0.12); border-radius: 8px; padding: 10px 16px; }
.hero__facts dt { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.8; }
.hero__facts dd { font-weight: 750; }

.qlist { display: flex; flex-direction: column; gap: 18px; margin-top: 16px; }
.qcard { background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 18px 18px 14px; border-left-width: 6px; }
.qcard--correct { border-left-color: var(--good); }
.qcard--wrong, .qcard--unanswered { border-left-color: var(--bad); }
.qcard__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.qcard__num { font-weight: 800; }
.qcard__head .pill { margin-left: auto; }
.qcard__stem { font-weight: 600; font-size: 1.05rem; line-height: 1.5; overflow-wrap: anywhere; margin-bottom: 14px; }
.qcard__stem--small { font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.qcard__note { font-size: 0.9rem; color: var(--muted); margin-top: 12px; }
.qcard__foot { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

.answers { display: flex; flex-direction: column; gap: 8px; }
.answer {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface);
}
.answer__letter { width: 26px; height: 26px; flex: none; border-radius: 6px; display: grid; place-items: center; background: #efebe1; font-weight: 800; font-size: 0.82rem; }
.answer__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.answer__tags { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.answer.is-correct { background: var(--good-bg); border-color: var(--good); color: #0f4f2c; }
.answer.is-correct .answer__letter { background: var(--good); color: #fff; }
.answer.is-wrong { background: var(--bad-bg); border-color: var(--bad); color: #7d2113; }
.answer.is-wrong .answer__letter { background: var(--bad); color: #fff; }
.answers--plain .answer:hover { background: var(--teal-50); }

.whys { display: flex; flex-direction: column; gap: 10px; }
.why { padding: 12px 14px; border-radius: 8px; border: 1.5px solid var(--bad-line); background: #fffafa; }
.why.is-correct { border-color: var(--good); background: var(--good-bg); }
.why__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.why__label { font-weight: 750; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--bad); }
.why.is-correct .why__label { color: var(--good); }
.why .answer__letter { background: var(--bad); color: #fff; }
.why.is-correct .answer__letter { background: var(--good); }
.why__choice { font-weight: 650; margin-top: 6px; overflow-wrap: anywhere; }
.why__text { color: #3c4a49; font-size: 0.95rem; margin-top: 4px; overflow-wrap: anywhere; }

/* flip card: both faces occupy one grid cell so the card keeps one stable height */
.flip { perspective: 1600px; }
.flip__inner { display: grid; transform-style: preserve-3d; transition: transform 0.4s var(--ease); }
.flip__face { grid-area: 1 / 1; min-width: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--surface); border-radius: 14px; }
.flip__face--back { transform: rotateY(180deg); }
.flip.is-flipped .flip__inner { transform: rotateY(180deg); }

/* ---------- History ---------- */

.history { display: flex; flex-direction: column; gap: 10px; }
.history__row {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink);
}
.history__row:hover { border-color: var(--teal-600); }
.history__topic { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.history__name { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.history__meta { font-size: 0.82rem; color: var(--muted); }
.history__score { font-weight: 800; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; font-variant-numeric: tabular-nums; }
.history__pct { font-size: 0.82rem; color: var(--muted); font-weight: 600; }

/* ---------- Mistakes deck ---------- */

.mdeck { display: flex; flex-direction: column; gap: 18px; margin-top: 20px; max-width: 760px; }
.mdeck__tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mdeck__count { font-weight: 700; color: var(--muted); font-size: 0.9rem; }
.mdeck__stack { position: relative; }
.mcard { position: relative; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: clamp(16px, 3vw, 28px); }
.mcard__meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.mdeck__controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .dash__cols { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: 1fr; }
  .hero__facts { grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; }
}

@media (max-width: 720px) {
  .nav { order: 3; flex: 1 0 100%; overflow: hidden; }
  .nav__link { flex: 1; justify-content: center; padding: 0 8px; font-size: 0.85rem; gap: 6px; }
  .topbar__name { display: none; }
  .mode-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
  .page { padding-top: 20px; }
  .mode-card { padding: 22px; }
  .history__row { flex-wrap: wrap; }
  .history__topic { flex-basis: 100%; }
  .history__score { margin-left: auto; align-items: flex-start; }
  .hero__facts { grid-template-columns: 1fr; }
  .file-ready { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .quiz__bar { grid-template-columns: 1fr auto; row-gap: 8px; }
  .quiz__bar .btn { grid-column: 2; grid-row: 1; }
  .quiz__counter { grid-column: 1; grid-row: 1; }
  .timer { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .quiz__tip { display: none; }
  .quiz__buttons { width: 100%; }
  .quiz__buttons .btn { flex: 1; padding: 0 12px; }
  .login__card { padding: 28px 22px; }
  .facts { grid-template-columns: 1fr; }
  .qcard__head .pill { margin-left: 0; }
  .answer { flex-wrap: wrap; }
  .answer__tags { width: 100%; justify-content: flex-start; padding-left: 38px; }
}

@media (min-width: 900px) {
  .quiz__brand { display: block; }
  .quiz__bar { grid-template-columns: auto 1fr auto auto; }
  .quiz__counter { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .skeleton::after { display: none; }
}

/* ---------- Long-text safety ---------- */
.panel__head > * { min-width: 0; }
.mdeck__tools { max-width: 100%; }
.mdeck__tools .input { max-width: 100%; text-overflow: ellipsis; }
.mcard__meta .tag, .qcard__head .tag, .history__name .tag { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.mcard__meta > *, .qcard__head > * { min-width: 0; }
@media (max-width: 720px) {
  .mdeck__tools { width: 100%; }
  .mdeck__tools .input { flex: 1; min-width: 0; }
}
@media (max-width: 420px) {
  .nav { gap: 2px; }
  .nav__link { padding: 0 6px; font-size: 0.8rem; line-height: 1.15; }
  .topbar__inner { padding-left: 12px; padding-right: 12px; }
}

/* Flip card height follows the face that is showing (set at the start of the flip, never animated). */
.flip__inner { display: block; position: relative; }
.flip__face { position: absolute; top: 0; left: 0; width: 100%; }
.flip__face--front { position: relative; }
.flip.is-flipped .flip__face--front { position: absolute; }
.flip.is-flipped .flip__face--back { position: relative; }

/* =========================================================================
   Theme layer: soft cream page, translucent top bar, one big rounded app card,
   bordered pill tabs, stat tiles and a results table.
   ========================================================================= */

:root {
  --card-border: #ece6da;
  --tile-border: #efe9de;
}

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); backdrop-filter: none; }
.topbar__inner { max-width: 1240px; padding: 14px 24px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px 28px; }
.nav { justify-content: center; gap: 6px; }
.nav__link { position: relative; min-height: 44px; padding: 0 18px; font-weight: 500; font-size: 1rem; color: #3d4b4a; border-radius: 8px; }
.nav__link:hover { background: var(--teal-50); color: var(--teal-700); }
.nav__link.is-active { background: var(--teal-100); color: var(--teal-900); font-weight: 600; }
.nav__link.is-active::after {
  content: ""; position: absolute; left: 22px; right: 22px; bottom: 6px; height: 2px; border-radius: 2px; background: currentColor; opacity: 0.8;
}
.topbar__name { color: #3d4b4a; font-weight: 500; }
.btn--accent { background: var(--surface); border-color: var(--line-strong); color: var(--ink); font-weight: 600; padding: 0 18px; }
.btn--accent:hover:not(:disabled) { border-color: var(--accent); }

/* app card */
.page { max-width: 1240px; padding: 28px 24px 80px; }
.appcard {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 12px;
  overflow: hidden;
}
.appcard__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
  padding: 16px 28px; border-bottom: 1px solid #f1ece2;
}
.appcard__date { color: #8a9594; font-weight: 500; font-size: 0.9rem; white-space: pre; }
.view-host { padding: 30px 28px 36px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  color: #5b6968; font-weight: 500; text-decoration: none; font-size: 0.97rem;
}
.tab:hover { color: var(--teal-700); background: var(--teal-50); }
.tab.is-active { background: #fff; border-color: var(--line-strong); color: var(--ink); font-weight: 600; }
.view-host .narrow { padding-top: 6px; }

/* dashboard */
.dash { gap: 28px; }
.dash__head h1 { font-size: clamp(1.4rem, 1.1rem + 1.1vw, 1.9rem); }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { border: 1px solid var(--tile-border); border-radius: 8px; padding: 20px 22px; box-shadow: none; background: #fff; }
.stat__label { font-size: 0.82rem; font-weight: 500; text-transform: none; letter-spacing: 0; color: #5d6b6a; }
.stat__value { font-size: clamp(1.6rem, 1.2rem + 1vw, 2.1rem); font-weight: 700; color: #111c1b; margin-top: 10px; }
.stat__sub { margin-top: 2px; font-size: 0.8rem; }
.mode-card { border-color: var(--tile-border); border-radius: 10px; }
.panel { border-color: var(--tile-border); border-radius: 10px; }
.panel__head h2 { font-size: 1.1rem; }

/* results panel / table */
.rpanel { display: flex; flex-direction: column; gap: 14px; }
.rpanel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.rpanel__title { font-size: 1.25rem; font-weight: 700; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.rpanel__updated { font-size: 0.8rem; font-weight: 400; color: #8a9594; }
.search {
  display: flex; align-items: center; gap: 8px; min-width: min(100%, 300px); padding: 0 14px; min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: #8a9594;
}
.search:focus-within { border-color: var(--teal-600); outline: 3px solid rgba(15, 119, 115, 0.25); }
.search__input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 0.9rem; color: var(--ink); }
.fpills { display: flex; gap: 8px; flex-wrap: wrap; }
.fpill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 8px; cursor: pointer;
  background: #f6f2ea; border: 1px solid transparent; color: #55635f; font-weight: 500; font-size: 0.9rem;
}
.fpill:hover { color: var(--teal-700); }
.fpill.is-on { background: #fff; border-color: var(--line-strong); color: var(--ink); font-weight: 600; }
.fpill__count { background: #ece6da; border-radius: 999px; padding: 0 8px; font-size: 0.78rem; font-weight: 600; line-height: 1.6; }

.rtable { border: 1px solid #f0ebe0; border-radius: 8px; overflow: hidden; background: #fff; }
.rtable__head, .rtable__row {
  display: grid; grid-template-columns: minmax(0, 2.6fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center; gap: 12px; padding: 0 20px;
}
.rtable__head { min-height: 48px; background: #faf6ee; color: #4b5857; font-size: 0.8rem; font-weight: 600; border-bottom: 1px solid #f0ebe0; }
.rtable__row { min-height: 64px; text-decoration: none; color: var(--ink); border-top: 1px solid #f4efe6; font-size: 0.92rem; }
.rtable__body .rtable__row:first-child { border-top: 0; }
.rtable__row:hover { background: #fdfaf4; }
.rtable__cell { min-width: 0; overflow-wrap: anywhere; color: #3e4c4b; }
.rtable__cell--topic { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.rtable__topic { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.rtable__name { font-weight: 600; overflow-wrap: anywhere; }
.rtable__cell--score { font-weight: 700; color: var(--ink); display: flex; flex-direction: column; line-height: 1.25; }
.rtable__cell--score small { font-weight: 400; color: #7c8987; font-size: 0.78rem; }
.rtable__empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.rtable__foot { display: flex; justify-content: flex-end; }
.rtable__foot .link { display: inline-flex; align-items: center; gap: 6px; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 6px; border: 1px solid; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.status--good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.status--bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.status--warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar__inner { grid-template-columns: auto 1fr; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-content: stretch; }
  .nav__link { flex: 1; justify-content: center; }
  .topbar__user { grid-column: 2; grid-row: 1; justify-self: end; }
}
@media (max-width: 760px) {
  .page { padding: 14px 10px 64px; }
  .appcard { border-radius: 10px; }
  .appcard__bar { padding: 12px 14px; }
  .view-host { padding: 20px 14px 28px; }
  .topbar__inner { padding: 10px 14px; }
  .topbar__name { display: none; }
  .nav__link { padding: 0 6px; font-size: 0.85rem; }
  .nav__link.is-active::after { left: 10px; right: 10px; }
  .appcard__date { display: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 0 8px; font-size: 0.88rem; text-align: center; }
  .rtable__head { display: none; }
  .rtable__row { grid-template-columns: 1fr 1fr; padding: 14px 16px; gap: 8px 12px; }
  .rtable__cell--topic { grid-column: 1 / -1; }
  .rtable__cell[data-label]::before { content: attr(data-label); display: block; font-size: 0.7rem; font-weight: 600; color: #8a9594; text-transform: uppercase; letter-spacing: 0.05em; }
}
@media (max-width: 340px) {
  .stats { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .stat { padding: 14px 14px; }
  .stat__value { margin-top: 4px; }
}
