:root {
  --bg: #fbf3e8;
  --card: #fffdf9;
  --ink: #2c2730;
  --muted: #8a8294;
  --brand: #543787;
  --brand-dark: #3b2563;
  --accent: #feb737;
  --accent-dark: #e89f14;
  --gold-ink: #8a5e08;
  --good: #1d9e75;
  --bad: #c0512f;
  --line: #ece3d4;
  --radius: 14px;
  --shadow: 0 2px 16px rgba(60,45,100,.07);
  --serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { line-height: 1.2; font-family: var(--serif); font-weight: 600; letter-spacing: .1px; }
h1 { font-size: 1.85rem; margin: 0 0 .2rem; color: var(--brand-dark); }
h2 { font-size: 1.3rem; margin: 0 0 .8rem; }
h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Top bar — light, calm, professional */
header.topbar {
  background: #fffdf9; color: var(--ink); padding: .7rem 1.4rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 8px rgba(60,45,100,.04);
}
header.topbar .brand { display: flex; align-items: center; gap: .6rem;
  font-family: var(--serif); font-weight: 600; font-size: 1.22rem;
  color: var(--brand-dark); }
header.topbar .brand:hover { text-decoration: none; }
header.topbar nav { display: flex; align-items: center; }
header.topbar nav a { color: var(--ink); margin-left: 1.3rem; font-size: .95rem; opacity: .8; }
header.topbar nav a:hover { color: var(--brand-dark); opacity: 1; text-decoration: none; }
header.topbar .who { font-size: .85rem; color: var(--muted); margin-left: 1.3rem; }
.logout-btn { background: #f2ecf9; border: 1px solid var(--line); color: var(--brand-dark);
  padding: .38rem .8rem; border-radius: 8px; cursor: pointer; margin-left: 1rem; font-size: .9rem; }
.logout-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Logo mark */
.logo-mark { width: 34px; height: 34px; display: block; flex: none; }
.logo-mark.big { width: 70px; height: 70px; }

.wrap { max-width: 1040px; margin: 1.4rem auto; padding: 0 1.2rem; }
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px){ .cols-2,.cols-4 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card.tight { padding: .8rem 1rem; }

.stat { text-align: center; }
.stat .num { font-size: 1.9rem; font-weight: 700; color: var(--brand); }
.stat .lbl { color: var(--muted); font-size: .85rem; }

/* Daily strip */
.daily { display: flex; gap: 1rem; flex-wrap: wrap; }
.daily .card { flex: 1; min-width: 240px; }
.daily .tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--gold-ink); font-weight: 700; }

/* Buttons & forms */
.btn { display: inline-block; background: var(--brand); color: #fff; border: none;
  padding: .5rem .9rem; border-radius: 9px; cursor: pointer; font-size: .92rem; font-family: inherit; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #f2ecf9; color: var(--brand-dark); }
.btn.ghost:hover { background: #e7ddf6; }
.btn.accent { background: var(--accent); color: var(--brand-dark); }
.btn.accent:hover { background: var(--accent-dark); }
.btn.warn { background: var(--bad); color: #fff; }
.btn.small { padding: .3rem .6rem; font-size: .8rem; }

input, select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .2rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }
.inline { display: flex; align-items: center; gap: .5rem; }
.inline input[type=checkbox] { width: auto; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.flash.ok { background: #efe9f7; color: var(--brand-dark); border: 1px solid #ddd4ee; }
.flash.error { background: #f8e6e0; color: #9d3f2c; border: 1px solid #f0d2c9; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line);
  vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .03em; }

/* Pills / badges */
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; }
.pill.brand { background: #efe9f7; color: var(--brand-dark); }
.pill.adult { background: #fbeccb; color: var(--gold-ink); }
.pill.ai { background: #efe9f7; color: var(--brand-dark); }
.pill.off { background: #efece4; color: var(--muted); }

/* Collapsible / details */
details.box { border: 1px solid var(--line); border-radius: 11px; padding: .3rem .8rem;
  margin-bottom: .7rem; background: #fff; }
details.box > summary { cursor: pointer; font-weight: 600; padding: .5rem 0; }
.preformat { white-space: pre-wrap; font-size: .92rem; }

.section-nav { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.section-nav a { background: #f2ecf9; color: var(--brand-dark); padding: .35rem .8rem;
  border-radius: 999px; font-size: .85rem; border: 1px solid #e2dbf2; }
.section-nav a:hover { background: var(--brand); color: #fff; text-decoration: none; }

/* Tabs (student page) */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1.1rem 0 1.2rem;
  border-bottom: 2px solid var(--line); padding-bottom: .6rem; }
.tab-btn { background: #f2ecf9; color: var(--brand-dark); padding: .45rem .85rem;
  border-radius: 999px; font-size: .88rem; border: 1px solid #e2dbf2; cursor: pointer; font-family: inherit; }
.tab-btn:hover { background: #e7ddf6; text-decoration: none; }
.tab-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
/* Only hide panels once JS has taken over, so it degrades to one long page. */
body.js-tabs .tab-panel { display: none; }
body.js-tabs .tab-panel.active { display: block; margin-top: 0; }

hr.soft { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(150deg, #6a4ba3 0%, #543787 55%, #3b2563 100%); }
.login-card { background: #fffdf9; padding: 2.2rem 2rem; border-radius: 20px; width: 350px;
  box-shadow: 0 18px 50px rgba(40,25,80,.30); text-align: center; }
.login-card h1 { color: var(--brand-dark); margin-top: .6rem; }
.login-card form { text-align: left; }
.login-card label:first-of-type { margin-top: .4rem; }

.empty { color: var(--muted); font-style: italic; padding: .6rem 0; }
.attn-dots { letter-spacing: 2px; color: var(--accent-dark); }

/* Vocabulary */
.vocab-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .8rem; padding-left: 0; }
.vocab-item { display: flex; align-items: center; gap: .6rem; list-style: none;
  padding: .45rem .6rem; background: #fffdf9; border: 1px solid var(--line); border-radius: 10px; }
.vocab-item form { margin: 0; }
.vocab-word { flex: 1; font-weight: 600; color: var(--ink); }

/* U/P toggle switch (admin) */
.switch { display: inline-flex; padding: 0; border: 1px solid #e2dbf2;
  border-radius: 999px; overflow: hidden; cursor: pointer; background: #f2ecf9; }
.switch .seg { padding: .28rem .7rem; font-size: .82rem; font-weight: 700;
  color: var(--muted); transition: background .15s, color .15s; }
.switch.is-u .seg.u { background: var(--brand); color: #fff; }
.switch.is-p .seg.p { background: var(--accent); color: var(--brand-dark); }

/* Read-only U/P badge (parent / learner view) */
.vocab-item .seg { display: inline-block; padding: .2rem .65rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; }
.vocab-item .seg.u { background: #efe9f7; color: var(--brand-dark); }
.vocab-item .seg.p { background: #fbeccb; color: var(--gold-ink); }

/* Vocabulary sub-tabs (Words / Understood / Produced) */
.vocab-subtabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0 .3rem; }
.vsub { background: #f2ecf9; color: var(--brand-dark); border: 1px solid #e2dbf2;
  border-radius: 999px; padding: .32rem .75rem; font-size: .82rem; cursor: pointer;
  font-family: inherit; display: inline-flex; align-items: center; gap: .4rem; }
.vsub:hover { background: #e7ddf6; }
.vsub.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.vsub-n { font-size: .72rem; font-weight: 600; opacity: .8; }

/* Suggested words from the questionnaire */
.suggest-box { margin-top: 1rem; padding: .8rem; border: 1px dashed var(--brand);
  border-radius: 12px; background: #f4f0fb; }
.suggest-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.suggest-head form { margin: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.chip-row form { margin: 0; }
.chip { background: #fff; color: var(--brand-dark); border: 1px solid #e2dbf2;
  padding: .3rem .7rem; border-radius: 999px; font-size: .85rem; font-weight: 600; cursor: pointer;
  font-family: inherit; }
.chip:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* AI "summarize the session" helper */
.ai-fill { padding: .8rem; margin-bottom: 1rem; border: 1px dashed var(--brand);
  border-radius: 12px; background: #f4f0fb; }
.ai-fill textarea { min-height: 4.5rem; }
.ai-fill ~ .row textarea, #progress textarea[name="notes"],
#progress textarea[name="what_worked"], #progress textarea[name="what_didnt"] { min-height: 5rem; }

/* Preserve line breaks in rich session notes */
.pre-line { white-space: pre-line; margin: .1rem 0 .6rem; }
