/* Converse — design system
   Calm rehearsal studio: navy ink, teal action, per-track accents, warm canvas. */
:root {
  --ink: #17324D;
  --ink-2: #33506e;
  --muted: #5b7186;
  --teal: #147D78;
  --teal-700: #0f635f;
  --blue: #2E74B5;
  --violet: #7567C7;
  --amber: #D9912B;
  --amber-700: #a96d1c;
  --canvas: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --line: #dbe4ee;
  --line-strong: #c2d0df;
  --good: #147D78;
  --good-bg: #e5f2f1;
  --warn: #a96d1c;
  --warn-bg: #fbf1de;
  --danger: #b03a3a;
  --danger-bg: #f7e7e7;
  --safety: #8a4a1f;
  --safety-bg: #f7eae0;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(23,50,77,.06), 0 1px 3px rgba(23,50,77,.05);
  --shadow: 0 6px 20px rgba(23,50,77,.09), 0 2px 6px rgba(23,50,77,.06);
  --shadow-lg: 0 18px 48px rgba(23,50,77,.16);
  --focus: 0 0 0 3px rgba(20,125,120,.45);
  --maxw: 1120px;
  --readw: 720px;
  --t: 160ms cubic-bezier(.2,.7,.3,1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --accent: var(--teal);
  --accent-bg: var(--good-bg);
}
[data-track="CAS"] { --accent: var(--teal); --accent-bg: #e5f2f1; }
[data-track="BUS"] { --accent: var(--blue); --accent-bg: #e6eff8; }
[data-track="OPP"] { --accent: var(--violet); --accent-bg: #eeecf8; }
[data-track="KID"] { --accent: var(--amber); --accent-bg: #fbf1de; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--canvas);
  font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; margin: 0 0 .4em; font-weight: 680; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 1.05rem + .8vw, 1.6rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--teal-700); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .82rem; }

/* Accessibility */
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip-link {
  position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { left: 8px; }
.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;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
[data-motion="reduced"] * { transition: none !important; animation: none !important; }

/* Layout */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font: inherit; font-weight: 620; cursor: pointer; border: 1px solid transparent;
  padding: 11px 18px; border-radius: 11px; background: var(--accent); color: #fff;
  transition: transform var(--t), background var(--t), box-shadow var(--t); box-shadow: var(--shadow-sm);
  min-height: 44px;
}
.btn:hover { background: var(--teal-700); text-decoration: none; }
[data-track="BUS"] .btn:hover, .btn.bus:hover { background: #245c91; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8f2d2d; }
.btn.sm { padding: 7px 12px; min-height: 36px; font-size: .9rem; }
.btn.block { width: 100%; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.card.pad-lg { padding: 28px; }
.card.link { transition: box-shadow var(--t), transform var(--t), border-color var(--t); cursor: pointer; display: block; color: inherit; }
.card.link:hover { box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; border-color: var(--line-strong); }

/* Forms */
label.field { display: block; font-weight: 600; margin-bottom: 14px; color: var(--ink-2); }
label.field small { display: block; font-weight: 400; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 11px 13px; margin-top: 6px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; transition: border var(--t), box-shadow var(--t);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus); }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.checkbox input { width: auto; margin-top: 4px; }

/* Chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); font-size: .8rem; font-weight: 600; border: 1px solid var(--line);
}
.chip.accent { background: var(--accent-bg); color: var(--ink); border-color: transparent; }
.chip.safety { background: var(--warn-bg); color: var(--safety); border-color: transparent; }
.chip.adult { background: #eeecf8; color: #4b3fa0; border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* Top nav */
.appbar {
  position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.9); backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}
.appbar .wrap { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; color: var(--ink); letter-spacing: -.02em; font-size: 1.12rem; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { padding: 8px 13px; border-radius: 9px; color: var(--ink-2); font-weight: 600; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-bg); color: var(--ink); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }

/* Landing */
.hero-land { min-height: 100dvh; display: grid; place-items: center; background:
  radial-gradient(1200px 500px at 80% -10%, #e9eef6, transparent),
  radial-gradient(900px 500px at -10% 110%, #e7f2f1, transparent), var(--canvas); }
.hero-card { max-width: 460px; width: 100%; }
.orbit { width: 66px; height: 66px; margin-bottom: 8px; }

/* Track / scenario cards */
.track-card { position: relative; overflow: hidden; }
.track-card .accentbar { position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent); }
.track-card .mark { width: 40px; height: 40px; margin-bottom: 6px; color: var(--accent); }
.meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.meta b { color: var(--ink-2); font-weight: 650; }

/* Session player */
.player { max-width: var(--readw); margin: 0 auto; }
.progressbar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progressbar > i { display: block; height: 100%; background: var(--accent); transition: width var(--t); }
.context-card { background: var(--accent-bg); border: 1px solid transparent; border-radius: var(--radius); padding: 16px 18px; }
.context-card summary { cursor: pointer; font-weight: 650; }
.choice {
  display: block; width: 100%; text-align: left; padding: 15px 16px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line-strong); font: inherit; color: var(--ink);
  transition: border var(--t), background var(--t), box-shadow var(--t); margin: 0;
}
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-bg); box-shadow: var(--focus); }
.choice.correct { border-color: var(--good); background: var(--good-bg); }
.choice.incorrect { border-color: var(--danger); background: var(--danger-bg); }
.choice .tag { float: right; font-size: .78rem; font-weight: 700; }
.choice.correct .tag { color: var(--good); }
.choice.incorrect .tag { color: var(--danger); }

.feedback { border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--line); margin-top: 16px; }
.feedback.good { background: var(--good-bg); border-color: #bfe0dd; }
.feedback.improvable { background: var(--warn-bg); border-color: #ecd9b0; }
.feedback.safety { background: var(--warn-bg); border-color: #e6c59a; }
.feedback h3 { display: flex; align-items: center; gap: 8px; }
.feedback .line + .line { margin-top: 10px; }
.feedback .k { font-weight: 700; color: var(--ink); }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tile .big { font-size: 1.7rem; font-weight: 750; color: var(--ink); letter-spacing: -.02em; }
.tile .lbl { color: var(--muted); font-size: .85rem; font-weight: 600; }

/* Bars for mastery */
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.good > i { background: var(--good); }
.bar.mid > i { background: var(--amber); }
.bar.low > i { background: var(--danger); }

/* Tables (admin) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--surface-2); font-weight: 650; color: var(--ink-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tbody tr:hover, tr.link:hover { background: var(--surface-2); cursor: pointer; }
td.wrap-cell { white-space: normal; min-width: 220px; }

/* Admin shell */
.admin-shell { display: grid; grid-template-columns: 232px 1fr; gap: 26px; align-items: start; }
.side { position: sticky; top: 78px; }
.side a { display: block; padding: 9px 13px; border-radius: 9px; color: var(--ink-2); font-weight: 600; }
.side a:hover { background: var(--surface-2); text-decoration: none; }
.side a.active { background: var(--ink); color: #fff; }
.side .grp { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; padding: 0 13px; }

/* Toast */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 90; max-width: 360px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 11px; box-shadow: var(--shadow-lg); animation: slidein var(--t); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--teal-700); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Skeletons + states */
.skeleton { background: linear-gradient(90deg, var(--surface-2), #f4f7fb, var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .orbit { margin: 0 auto 10px; opacity: .7; }

.page { padding: 26px 0 80px; }
.section + .section { margin-top: 30px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 20px 0; border: none; }

.banner { padding: 12px 16px; border-radius: 11px; background: var(--warn-bg); color: var(--safety); border: 1px solid #ecd9b0; font-weight: 550; }
.banner.info { background: #e6eff8; color: #245c91; border-color: #c6ddf1; }

/* Responsive */
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side { position: static; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
  .side .grp { display: none; }
  .side a { white-space: nowrap; }
  .nav .label { display: none; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .card { padding: 18px; }
  .nav a { padding: 8px 10px; }
}

.loading { color: var(--muted); padding: 40px; text-align: center; }
code.inline { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .86em; }
.kbd { border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font-size: .8em; background: var(--surface); }
