/* Just4Me Education: styles follow Dave's mock-up (custom-learning-demo/just4me-mockup). */
:root {
  --paper: #fbfcf8; --paper-2: #f0f3ea; --line: #d9dfd0;
  --ink: #1c2b3a; --ink-soft: #4a5a68;
  --sun: #f4b52c; --sun-ink: #5a3d00; --sun-soft: #fdf1d3;
  --leaf: #2f7d5b; --leaf-soft: #dcefe4;
  --sky: #2c6fb7; --sky-soft: #e1ecf8;
  --berry: #b8406a; --berry-soft: #f7e2ea;
  --card: #fff;
  --shadow: 0 1px 2px rgba(28, 43, 58, .06), 0 4px 14px rgba(28, 43, 58, .06);
  --radius: 16px;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121a21; --paper-2: #18222b; --line: #2a3743; --ink: #e8eef2; --ink-soft: #a3b1bc;
    --sun: #f6c04d; --sun-ink: #2a1d00; --sun-soft: #3a2e12; --leaf: #5cc495; --leaf-soft: #173527;
    --sky: #7cb2ec; --sky-soft: #172a3f; --berry: #ec84a9; --berry-soft: #3a1a27; --card: #1b2630;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121a21; --paper-2: #18222b; --line: #2a3743; --ink: #e8eef2; --ink-soft: #a3b1bc;
  --sun: #f6c04d; --sun-ink: #2a1d00; --sun-soft: #3a2e12; --leaf: #5cc495; --leaf-soft: #173527;
  --sky: #7cb2ec; --sky-soft: #172a3f; --berry: #ec84a9; --berry-soft: #3a1a27; --card: #1b2630;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.55 var(--body); }
a { color: var(--sky); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; font-weight: 800; margin: 0 0 .35rem; }
h2 { font-size: 1.3rem; font-weight: 700; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.08rem; font-weight: 700; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
code { background: var(--paper-2); padding: 1px 5px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.eyebrow { display: block; text-transform: uppercase; font-size: .78rem; letter-spacing: .09em; font-weight: 700; color: var(--leaf); margin-bottom: .3rem; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }
#view:focus { outline: none; }

/* site head */
.site-head { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-head .inner { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 0 20px; }
.logo { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 800; font-size: 1.2rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.logo b { color: var(--leaf); font-weight: 800; }
.logo-mark { width: 32px; height: 32px; flex: none; }
.site-head .spacer { flex: 1; }
.mock-bar { font-size: .82rem; color: var(--ink-soft); }

/* app shell: sidebar + main */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 63px); }
.side { background: var(--paper-2); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 63px; height: calc(100vh - 63px); overflow-y: auto; }
.side .eyebrow { color: var(--ink-soft); padding: 0 12px; margin: 4px 0 6px; }
.side a { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border-radius: 12px; color: var(--ink);
  text-decoration: none; font-weight: 700; }
.side a svg { width: 18px; height: 18px; flex: none; color: var(--ink-soft); }
.side a:hover { background: color-mix(in srgb, var(--card) 60%, transparent); }
.side a[aria-current="page"] { background: var(--card); box-shadow: var(--shadow); }
.side a[aria-current="page"] svg { color: var(--leaf); }
.side .acct { margin-top: auto; padding: 14px 12px 4px; font-size: .82rem; color: var(--ink-soft); line-height: 1.45; border-top: 1px solid var(--line); }
.side .acct b { color: var(--ink); }
.main { padding: 28px 36px 48px; min-width: 0; max-width: 1120px; }
.main > h1:first-of-type + p { margin-bottom: 1.4rem; }
.footer { color: var(--ink-soft); font-size: .8rem; padding: 18px 20px; border-top: 1px solid var(--line); background: var(--paper-2);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* sign-in */
.signed-out .side, .signed-out .mock-bar { display: none; }
.signed-out .app { grid-template-columns: 1fr; }
.signed-out .main { max-width: none; }
.login-wrap { min-height: calc(100vh - 200px); display: grid; place-items: center; padding: 24px 0;
  background-image: repeating-linear-gradient(transparent 0 31px, color-mix(in srgb, var(--line) 55%, transparent) 31px 32px); }
.card.login { width: 100%; max-width: 420px; padding: 28px; }
.card.login h1 { font-size: 1.6rem; }
.login-go { width: 100%; justify-content: center; padding: .75rem 1rem; margin-top: 4px; }
input[type=password] { width: 100%; padding: 9px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; }
.btn-sm, button.btn-sm { padding: .35rem .85rem; font-size: .85rem; }

/* surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-soft);
  background-image: repeating-linear-gradient(transparent 0 31px, var(--line) 31px 32px); }

/* kid cards */
.kid-top { display: flex; gap: 12px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  font-family: var(--display); font-weight: 800; font-size: 1.15rem; background: var(--sun); color: var(--sun-ink); }
.avatar.av-1 { background: var(--leaf-soft); color: var(--leaf); }
.avatar.av-2 { background: var(--sky-soft); color: var(--sky); }
.avatar.av-3 { background: var(--berry-soft); color: var(--berry); }
.kid dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: .9rem; }
.kid dt { color: var(--ink-soft); }
.kid dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* badges and chips */
.badge, .chip { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; background: var(--paper-2); color: var(--ink-soft); white-space: nowrap; border: 1px solid transparent; }
.badge.ok { background: var(--leaf-soft); color: var(--leaf); }
.badge.warn { background: var(--sun-soft); color: var(--sun-ink); border-color: color-mix(in srgb, var(--sun) 55%, transparent); }
.badge.bad { background: var(--berry-soft); color: var(--berry); }
.chip { background: var(--sky-soft); color: var(--sky); margin: 0; }
.chip.need, .chip-leaf { background: var(--leaf-soft); color: var(--leaf); }
.chip-plain { background: var(--paper-2); color: var(--ink-soft); }
.mode-live { background: var(--sun); color: var(--sun-ink); }

/* forms */
label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: .84rem; }
input[type=text], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 9px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--sky); outline: none; }
textarea { min-height: 90px; resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--leaf); }
input[type=checkbox], input[type=radio] { accent-color: var(--leaf); width: 18px; height: 18px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.cols { display: grid; gap: 0 18px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .cols { grid-template-columns: 1fr 1fr; } }

/* pill buttons */
button, .btn {
  font: inherit; font-weight: 700; font-size: .95rem; border: 0; background: transparent; color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line); padding: .55rem 1.15rem; border-radius: 999px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3;
}
button:hover, .btn:hover { box-shadow: inset 0 0 0 2px var(--ink-soft); }
button.primary, .btn.primary { background: var(--ink); color: var(--paper); box-shadow: none; }
button.primary:hover, .btn.primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--sky)); }
.btn-sun, button.btn-sun { background: var(--sun); color: var(--sun-ink); box-shadow: none; }
.btn-sun:hover { background: color-mix(in srgb, var(--sun) 85%, var(--ink)); box-shadow: none; }
button.danger { color: var(--berry); }
button.danger:hover { box-shadow: inset 0 0 0 2px var(--berry); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* segmented control */
.seg { display: inline-flex; background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; margin-bottom: .6rem; }
.seg button { box-shadow: none; padding: .4rem 1rem; color: var(--ink-soft); }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* messages */
.errors { background: var(--berry-soft); color: var(--berry); border-left: 4px solid var(--berry); border-radius: 10px; padding: 10px 14px; }
.notice { background: var(--sun-soft); color: var(--sun-ink); border-left: 4px solid var(--sun); border-radius: 10px; padding: 10px 14px; }

/* tag picker */
.tag-picker { position: relative; }
.tag-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; border: 2px solid var(--line); border-radius: 10px; background: var(--paper); }
.tag-box:focus-within { border-color: var(--sky); }
.tag-box input[type=text] { flex: 1; min-width: 180px; border: 0; padding: 4px; background: transparent; }
.tag-chips { display: contents; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--leaf-soft); color: var(--leaf); border-radius: 999px;
  padding: 2px 2px 2px 10px; font-size: .85rem; font-weight: 700; }
#interests-picker .tag-chip { background: var(--sky-soft); color: var(--sky); }
.tag-chip button { box-shadow: none; color: inherit; padding: 0 7px; font-size: 1.05rem; line-height: 1.2; }
.tag-suggestions { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .16); max-height: 320px; overflow-y: auto; }
.tag-suggestions li { padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.tag-suggestions li.active { background: var(--paper-2); }

/* tables */
.table-wrap { overflow-x: auto; padding: 6px 8px; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--ink-soft); font-weight: 700; text-transform: uppercase; font-size: .75rem; letter-spacing: .06em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* progress */
.steps { list-style: none; padding: 8px 20px; margin: 0; }
.steps li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--line); }
.steps .done .dot { background: var(--leaf); }
.steps .warn .dot { background: var(--sun); }
.steps .working .dot { background: var(--sky); box-shadow: 0 0 0 4px var(--sky-soft); }

/* unit viewer */
details.lesson { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin: 12px 0; box-shadow: var(--shadow); }
details.lesson > summary { cursor: pointer; padding: 14px 20px; font-family: var(--display); font-weight: 700; font-size: 1.05rem; list-style: none; }
details.lesson > summary::-webkit-details-marker { display: none; }
details.lesson > summary::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--leaf); transition: transform .15s; }
details.lesson[open] > summary::before { transform: rotate(90deg); }
details.lesson > div { padding: 0 20px 20px; }
.reading { background: var(--paper); border-radius: 12px; padding: 14px 18px; border: 1px solid var(--line);
  background-image: repeating-linear-gradient(transparent 0 31px, color-mix(in srgb, var(--line) 60%, transparent) 31px 32px); line-height: 32px; }
.flag { border-left: 4px solid var(--sun); padding: 8px 14px; background: var(--sun-soft); border-radius: 10px; margin: 8px 0; }
.fix { border-left: 4px solid var(--leaf); padding: 8px 14px; background: var(--leaf-soft); border-radius: 10px; margin: 8px 0; }

/* stats */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.kpi .value { font-family: var(--display); font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .label { color: var(--ink-soft); font-size: .86rem; margin-top: 4px; }

/* responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); gap: 4px; }
  .side { scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .side .eyebrow, .side .acct { display: none; }
  .side a { white-space: nowrap; padding: .5rem .8rem; }
  .main { padding: 22px 20px 40px; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .site-head .inner { padding: 0 16px; }
  .mock-bar { display: none; }
  .logo { font-size: 1.05rem; white-space: nowrap; }
  .logo-mark { width: 28px; height: 28px; }
  .main { padding: 18px 16px 36px; }
  h1 { font-size: 1.55rem; }
  .card { padding: 16px; }
}

@media print {
  .site-head, .side, .footer, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .card, details.lesson { box-shadow: none; }
  details.lesson { break-inside: avoid; }
  details.lesson:not([open]) > div { display: block; }
}
