/* Brimz Learning HQ — mobile-first styles.
   Brand: teal #20BDB3, near-black #14201E. Teal is used as a fill with dark
   text on it (8:1 contrast); text links use a deeper teal for legibility. */

:root {
  --teal: #20bdb3;
  --teal-ink: #0b7a73;      /* teal dark enough for text on white */
  --teal-soft: #e3f6f4;
  --ink: #14201e;
  --ink-2: #3b4a47;
  --muted: #5b6b68;
  --line: #dde7e5;
  --bg: #f3f7f6;
  --card: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a5b00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 32, 30, 0.06), 0 2px 10px rgba(20, 32, 30, 0.04);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
h1:focus, h2:focus { outline: none; }
h1, h2 { scroll-margin-top: 72px; }
p { margin: 0 0 10px; }
a { color: var(--teal-ink); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; margin-top: 14px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.warn { color: var(--warn); font-weight: 600; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; }
.brand-mark { display: block; width: 32px; height: 32px; flex: none; }
.auth-brand .brand-mark { width: 44px; height: 44px; }
.brand-name b { color: var(--teal); font-weight: 800; }
.topbar .avatar { background: #2a3a37; color: #fff; text-decoration: none; }

.tabs { display: flex; gap: 4px; background: var(--ink); padding: 0 12px; overflow-x: auto; }
.tabs a {
  color: #b9c8c5; text-decoration: none; padding: 10px 12px 12px; font-size: 0.95rem;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a.on { color: #fff; border-color: var(--teal); }

.demo-bar {
  background: #fff4d6; color: #5c4400; font-size: 0.85rem; text-align: center; padding: 6px 12px;
}
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; font-weight: 700; cursor: pointer; }

.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-size: 0.95rem; }
.page-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.page-head p { margin: 0; }
.section-h { margin: 26px 0 10px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card.empty { text-align: center; padding: 28px 18px; }
.card.danger { border-color: #f3c5c0; background: #fffafa; }

.latest { border-top: 4px solid var(--teal); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 6px 0 10px; font-size: 0.92rem; }
.subject {
  display: inline-block; background: var(--teal-soft); color: #075e58; font-weight: 700;
  font-size: 0.8rem; padding: 3px 10px; border-radius: 99px;
}
.note { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }

.rating { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 4px 0 8px; }
.score b { font-size: 1.6rem; font-weight: 800; }
.score { color: var(--ink-2); }
.conf { display: inline-flex; align-items: center; gap: 4px; }
.conf i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); display: inline-block; }
.conf i.on { background: var(--teal); }
.conf .small { margin-left: 4px; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 6px 0; }
.chips li { border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: 0.85rem; background: #fff; }

.next { background: var(--ink); color: #fff; border-color: var(--ink); }
.next h2 { color: var(--teal); }
.next .muted { color: #b9c8c5; }
.next-date { margin-bottom: 8px; }
.next-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.next-list li { border-top: 1px solid #2c3c39; padding-top: 10px; }
.next-list p { margin: 6px 0 0; }
.next .subject { background: var(--teal); color: var(--ink); }

.chart-card h3 { margin: 0; }
.trend { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin: 2px 0 8px; }
.trend.up { color: var(--teal-ink); }
.trend.down { color: var(--warn); }
.chart-box { position: relative; height: 210px; }

/* ---------- History ---------- */
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.history details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.history summary {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; list-style: none;
  min-height: 56px;
}
.history summary::-webkit-details-marker { display: none; }
.history .date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 44px; flex: none; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; line-height: 1.1;
}
.history .date b { font-size: 1.2rem; color: var(--ink); }
.history .subject { align-self: flex-start; margin-bottom: 2px; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex: none; font-weight: 800; font-size: 0.95rem; color: var(--ink); }
.history .detail { padding: 2px 14px 12px 68px; }
.history details[open] summary { border-bottom: 1px solid var(--line); }
.history details[open] .detail { padding-top: 10px; }
.filter select { padding: 6px 30px 6px 10px; font-size: 0.9rem; min-height: 36px; }

/* ---------- Lists ---------- */
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 64px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); text-decoration: none; font-weight: 400;
}
a.row:active { background: var(--teal-soft); }
.row b { font-weight: 700; }
.row .small { display: block; }
.chev { font-size: 1.5rem; color: var(--muted); }
.row-wrap { display: flex; align-items: center; gap: 8px; }
.row-wrap .row { flex: 1; min-width: 0; }

.avatar {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--teal-soft); color: #075e58; font-weight: 800; font-size: 0.9rem;
}
.avatar.lg { width: 56px; height: 56px; font-size: 1.1rem; }
.who { display: flex; gap: 14px; align-items: center; }
.pill { display: inline-block; font-size: 0.75rem; font-weight: 700; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; color: var(--ink-2); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; min-height: 46px;
  font: 16px/1.4 var(--font); color: var(--ink); background: #fff;
  border: 1.5px solid #c9d6d3; border-radius: 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(32, 189, 179, 0.25); }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }
.grid2 { display: grid; gap: 0 12px; }
.label { font-weight: 600; font-size: 0.95rem; display: block; margin-bottom: 6px; }

.suffix { display: flex; align-items: center; gap: 8px; max-width: 160px; }
.suffix input { margin-top: 6px; }
.suffix span { margin-top: 6px; font-weight: 700; }
.conf-pick { margin-bottom: 14px; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: grid; place-items: center; min-height: 46px; border: 1.5px solid #c9d6d3; border-radius: 10px;
  font-weight: 800; font-size: 1.05rem; cursor: pointer; background: #fff;
}
.seg input:checked + span { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(32, 189, 179, 0.35); }

.checks { display: grid; gap: 6px; margin-bottom: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.check input { width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; flex: none; accent-color: var(--teal-ink); }
.check span { display: flex; flex-direction: column; }
.card.danger .check { border: 0; padding: 0; margin-bottom: 14px; }
.sub { font-size: 0.9rem; margin: 14px 0 8px; color: var(--ink-2); }

.roles { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 12px; }
.radio { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; border: 1.5px solid #c9d6d3; border-radius: 99px; padding: 6px 12px 6px 8px; }
.radio input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--teal-ink); }
.radio:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.search input { margin: 0 0 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 10px; border: 1.5px solid var(--teal);
  background: var(--teal); color: var(--ink); font: 700 1rem var(--font); text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.96); }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: #fff; border-color: #c9d6d3; color: var(--ink); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 0.88rem; }
.danger-text { color: var(--danger) !important; }
.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger-link { background: none; border: 0; color: var(--danger); padding: 0; margin-top: 16px; min-height: 0; font-weight: 600; text-decoration: underline; }

/* ---------- Sign-in ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 16px 40px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; font-size: 1.15rem; }
.auth-brand .brand-name { font-weight: 600; }
.auth-brand .brand-name b { color: var(--teal-ink); }
.auth-card { padding: 22px 18px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 16px; }
.alert { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 0.92rem; }
.demo-pick { display: grid; gap: 8px; margin: 14px 0 6px; }
.demo-pick .btn { justify-content: space-between; font-weight: 600; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Feedback ---------- */
.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#app[aria-busy="true"] { cursor: progress; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transition: opacity 0.4s, transform 0.4s;
}
.toast-error { background: var(--danger); }
.toast-out { opacity: 0; transform: translate(-50%, 8px); }

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  .wrap { padding-top: 28px; }
  h1 { font-size: 1.8rem; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .card { padding: 20px; }
  .chart-box { height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}
