/* Spanish study platform: shared styles */
:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --ink: #1a2133;
  --muted: #5f6b80;
  --line: #e4e8ef;
  --brand: #e04a2f;       /* Spanish red-orange */
  --brand-ink: #ffffff;
  --brand-soft: #fdeceb;
  --gold: #ffb020;
  --gold-soft: #fff4d6;
  --good: #139a63;
  --good-soft: #e0f6ec;
  --bad: #d23a36;
  --bad-soft: #fde8e7;
  --info: #2563d9;
  --info-soft: #e5eefd;
  --shadow: 0 1px 2px rgba(26, 33, 51, 0.05), 0 4px 16px rgba(26, 33, 51, 0.05);
  --radius: 16px;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'DM 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-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.8em; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.right { text-align: right; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 16px; }
.grow { flex: 1; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; padding: 0 10px 14px; display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }
.brand small { display: block; font-family: var(--sans); font-weight: 500; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .badge-count { margin-left: auto; }
.side .spacer { flex: 1; }
.me-box { border-top: 1px solid var(--line); padding: 14px 10px 0; font-size: 0.9rem; }
.me-box .name { font-weight: 600; }
.main { padding: 32px clamp(16px, 4vw, 48px) 80px; max-width: 1100px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.crumb { font-size: 0.9rem; margin-bottom: 8px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  .brand small { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .nav a { padding: 8px 12px; white-space: nowrap; }
  .side .spacer { display: none; }
  .me-box { border: 0; padding: 0; margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
  .me-box .name { display: none; }
  .main { padding-top: 22px; }
}

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid > .card + .card { margin-top: 0; }

.tile { padding: 16px 18px; }
.tile .label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.tile .value { font-family: var(--serif); font-size: 2rem; font-weight: 600; line-height: 1.15; margin-top: 4px; }
.tile .hint { font-size: 0.85rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 11px 18px; min-height: 44px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 0.875rem; border-radius: 9px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 4px 6px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.block { width: 100%; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gold { background: var(--gold-soft); color: #9a6a00; }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.progress { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--gold)); transition: width 0.6s ease; }
.progress.thin { height: 8px; }
.progress.good > span { background: var(--good); }
.progress-line { display: flex; align-items: center; gap: 12px; }
.progress-line .progress { flex: 1; }
.progress-line .pct { font-weight: 700; min-width: 3.2ch; text-align: right; }
.hero-progress .big { font-family: var(--serif); font-size: 2.6rem; font-weight: 700; line-height: 1; }

/* forms */
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 1px; border-color: var(--brand); }
.help { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 0; padding: 6px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.pick-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }

/* list rows */
.list > .item { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list > .item:last-child { border-bottom: 0; }
.list > .item.clickable { cursor: pointer; }
.list > .item.clickable:hover .title { color: var(--brand); }
.list > .item > .grow { flex: 1 1 200px; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 0.85rem; color: var(--muted); }
.dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; flex: none; color: var(--muted); }
.dot.done { background: var(--good-soft); color: var(--good); }
.dot.next { background: var(--brand); color: #fff; }

/* bar chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.bars .bar i { display: block; width: 100%; max-width: 38px; border-radius: 8px 8px 3px 3px; background: var(--gold); min-height: 4px; }
.bars .bar.today i { background: var(--brand); }
.bars .bar b { color: var(--ink); font-weight: 600; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(20, 16, 30, 0.55); display: grid; place-items: center; padding: 16px; z-index: 50; overflow: auto; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.modal.wide { width: min(760px, 100%); }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 80; width: min(420px, calc(100% - 24px)); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; }
.toast.error { background: var(--bad); color: #fff; }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.notice.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.copybox { display: flex; gap: 8px; }
.copybox input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.prewrap { white-space: pre-wrap; word-break: break-word; }

/* exercise player */
.player { max-width: 720px; }
.q-card { padding: 26px; }
.q-prompt { font-family: var(--serif); font-size: 1.35rem; margin-bottom: 18px; }
.options { display: grid; gap: 10px; }
.opt { text-align: left; padding: 14px 16px; border: 2px solid var(--line); background: var(--surface); border-radius: 12px; font: inherit; font-weight: 500; cursor: pointer; color: var(--ink); }
.opt:hover:not([disabled]) { border-color: var(--brand); }
.opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { margin-top: 18px; padding: 14px 16px; border-radius: 12px; }
.feedback.good { background: var(--good-soft); color: var(--ink); border: 1px solid var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--ink); border: 1px solid var(--bad); }
.feedback strong { display: block; margin-bottom: 4px; }
.type-input { font-size: 1.1rem; padding: 14px 16px; }
.score-ring { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; font-family: var(--serif); font-size: 2.4rem; font-weight: 700; background: conic-gradient(var(--ring, var(--good)) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; }
.score-ring::before { content: ''; position: absolute; inset: 12px; background: var(--surface); border-radius: 50%; }
.score-ring span { position: relative; }
.vocab-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface-2); border-radius: 10px; padding: 6px 12px; font-size: 0.92rem; }
.chip b { font-weight: 700; }

/* flashcards */
.flash { perspective: 1000px; max-width: 460px; margin: 0 auto; }
.flash-inner { position: relative; height: 240px; transition: transform 0.5s; transform-style: preserve-3d; cursor: pointer; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 18px; display: grid; place-items: center; text-align: center; padding: 24px; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface); }
.flash-face.back { transform: rotateY(180deg); background: var(--brand-soft); }
.flash-face .word { font-family: var(--serif); font-size: 2.2rem; font-weight: 600; }
.flash-face .ex { color: var(--muted); font-style: italic; margin-top: 8px; }

/* login pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(900px 500px at 8% -10%, var(--brand-soft), transparent 60%),
  radial-gradient(700px 500px at 100% 110%, var(--info-soft), transparent 60%), #ffffff; }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { justify-content: center; padding-bottom: 6px; }
.auth-card h1 { text-align: center; font-size: 1.5rem; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.err { color: var(--bad); font-weight: 500; min-height: 1.4em; margin: 6px 0 0; }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.pill-tabs { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.pill-tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.pill-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* codes */
.codes-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; letter-spacing: 0.04em; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; max-height: 260px; overflow: auto; user-select: all; }
.codes-box div + div { margin-top: 6px; }
.code-input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.2rem; letter-spacing: 0.08em; text-transform: uppercase; text-align: center; }
.big-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: clamp(0.95rem, 5vw, 1.5rem); font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; text-align: center; background: var(--surface-2); border: 2px dashed var(--brand); border-radius: 14px; padding: 18px 10px; user-select: all; }

/* ---------- bright student home ---------- */
.hero { padding: 28px; background: linear-gradient(135deg, #ffffff 0%, var(--brand-soft) 140%); border-color: color-mix(in srgb, var(--brand) 18%, var(--line)); }
.hero-kicker { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--brand); margin-bottom: 6px; }
.hero-title { font-family: var(--serif); font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 700; line-height: 1.15; margin-bottom: 6px; }
.hero-bar { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.btn.big { padding: 14px 26px; font-size: 1.05rem; min-height: 52px; border-radius: 14px; }
.goal-dots { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.goal-dots span { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 2px dashed var(--line); }
.goal-dots span.on { background: var(--good); color: #fff; border: 2px solid var(--good); }

/* ---------- pace and groups (teacher) ---------- */
.badge.finished { background: var(--brand-soft); color: var(--brand); }
.group-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--info-soft); color: var(--info); margin: 0 4px 2px 0; white-space: nowrap; }
.pace-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attention-list .item .dot { background: var(--bad-soft); color: var(--bad); }
.pace-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- teaching cards ---------- */
.blk { margin-bottom: 16px; }
.blk h3 { margin-bottom: 8px; }
.blk p { margin: 0 0 0.7em; font-size: 1.05rem; }
.blk ul { margin: 0 0 0.8em; padding-left: 1.3em; }
.blk li { margin-bottom: 4px; font-size: 1.05rem; }
.es { color: var(--brand); font-weight: 600; cursor: pointer; border-bottom: 1px dotted var(--brand); }
.es:hover { background: var(--brand-soft); }
.say-btn { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.say-btn:hover { background: var(--brand-soft); border-color: var(--brand); }
.ex, .dl { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ex:last-child, .dl:last-child { border-bottom: 0; }
.ex-es { font-size: 1.15rem; font-weight: 600; }
.ex-en { color: var(--muted); font-size: 0.95rem; }
.dl .who { flex: none; min-width: 64px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; color: var(--info); padding-top: 8px; }
.tbl { border: 1px solid var(--line); border-radius: 12px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.tbl th { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 12px; font-size: 1rem; }
.tbl tr:nth-child(even) td { background: #fafbfd; }
.blk-tip { background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); border-radius: 14px; padding: 14px 16px; }
.blk-tip p:last-child { margin-bottom: 0; }
.tip-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: #8a5a00; margin-bottom: 4px; }
.blk-check { background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); border-radius: 14px; padding: 16px; }
.blk-check .tip-label { color: var(--info); }
.check-q { font-weight: 600; font-size: 1.1rem; margin-bottom: 10px; }
.learn-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.stage-pills { display: inline-flex; gap: 6px; }
.stage-pills span { padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.stage-pills span.on { background: var(--brand); color: #fff; }
.stage-pills span.done { background: var(--good-soft); color: var(--good); }
.dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0 0; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block; }
.dots i.on { background: var(--brand); }
.dots i.done { background: var(--good); }
.lesson-locked { opacity: 0.6; cursor: not-allowed !important; }
.lesson-locked .dot { background: var(--surface-2); }
.q-list .q-item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.q-list .q-item:last-child { border-bottom: 0; }
.q-num { font-weight: 700; color: var(--brand); margin-right: 6px; }
.q-item .q-text { font-family: var(--serif); font-size: 1.15rem; margin-bottom: 10px; }
.q-item.right { border-left: 4px solid var(--good); padding-left: 12px; }
.q-item.wrong { border-left: 4px solid var(--bad); padding-left: 12px; }
.bar-mini { display: inline-block; width: 70px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.bar-mini i { display: block; height: 100%; background: var(--good); }
