/* Learning Studio — clean, modern, calm, gender-neutral. Mobile-first.
   Neutral base (soft off-white / light slate), crisp dark-slate text, WCAG AA.
   The ACCENT is per-user (--accent set from the user's chosen color via JS).
   NO pink anywhere in the default palette or options. */
:root {
  --bg: #f6f7f9;          /* soft off-white / light slate */
  --bg-2: #eef1f5;
  --card: #ffffff;
  --ink: #1e293b;         /* slate-800, strong AA on white */
  --ink-soft: #334155;    /* slate-700 */
  --muted: #64748b;       /* slate-500 */
  --line: #e2e8f0;        /* slate-200 */
  --accent: #0f766e;      /* DEFAULT deep teal (overridden per-user) */
  --accent-soft: #0f766e1a;
  --accent-ink: #0b5852;
  --good: #15803d;
  --good-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(30, 41, 59, 0.07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  line-height: 1.5;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: #b91c1c; font-weight: 700; }
.centered { text-align: center; max-width: 440px; margin-left: auto; margin-right: auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 14px 0;
}

h1 { font-size: 1.6rem; line-height: 1.2; margin: 6px 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 0; letter-spacing: -0.01em; }

.badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

/* sticky app header (persistent across all views) */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 14px 6px 10px;
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.appbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { font-size: 1.15rem; line-height: 1; color: var(--accent); }
.brand-name { font-weight: 800; font-size: 1.22rem; color: var(--ink); letter-spacing: -0.015em; }
.appbar .ghost { padding: 8px 13px; font-size: 0.9rem; }

/* answer-format guidance */
.answer-hint { margin-top: 9px; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

/* buttons */
button {
  font-family: inherit;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
}
button:active { transform: translateY(1px) scale(0.99); }
button:disabled { opacity: 0.6; cursor: default; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { filter: brightness(1.07); }
.primary.big { width: 100%; padding: 15px; font-size: 1.05rem; margin-top: 8px; }
.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
  padding: 9px 14px;
}
.ghost:hover { background: var(--bg-2); }

/* inputs */
input[type="text"], input[type="password"] {
  font-family: inherit;
  font-size: 1.1rem;
  padding: 13px 15px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  outline: none;
  width: 100%;
  background: #fbfcfd;
  color: var(--ink);
  margin-bottom: 4px;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.answer-row { display: flex; gap: 10px; margin-top: 16px; align-items: stretch; }
.answer-row input { flex: 1; min-width: 0; margin-bottom: 0; }
.answer-row button { white-space: nowrap; }
@media (max-width: 430px) {
  .answer-row { flex-direction: column; }
  .answer-row button { width: 100%; }
}

.action-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* hero (home / parent) */
.hero { padding: 8px 4px 4px; }
.hero h1 { font-size: 1.8rem; }
.glance-line { font-size: 0.98rem; margin-top: 2px; }

/* launcher tiles */
.tile-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 10px; }
@media (min-width: 560px) { .tile-grid { grid-template-columns: 1fr 1fr; } }
.tile {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
  width: 100%;
  border-left: 4px solid var(--accent);
}
.tile:hover { filter: none; transform: translateY(-1px); }
.tile-name { font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.tile-blurb { color: var(--muted); font-size: 0.92rem; }
.tile .go { color: var(--accent-ink); font-weight: 700; font-size: 0.92rem; margin-top: 4px; }
.tile-soon { opacity: 0.75; cursor: default; border-left-color: var(--line); }
.soon-pill {
  display: inline-block; align-self: flex-start;
  background: var(--bg-2); color: var(--muted);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px; margin-top: 4px;
}

/* color picker swatches */
.palette { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 16px; }
.swatch {
  width: 54px; height: 54px; border-radius: 14px; border: 3px solid transparent;
  box-shadow: var(--shadow); padding: 0;
}
.swatch:hover { transform: scale(1.06); }
.swatch.sel { border-color: var(--ink); }

/* tutor bubble */
.bubble {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  line-height: 1.55;
}
.tutor-msg { font-size: 1.05rem; color: var(--ink); }
.self-explain {
  margin-top: 10px; font-style: italic; color: var(--accent-ink); font-size: 0.96rem;
  border-top: 1px dashed var(--line); padding-top: 8px;
}

/* problem */
.problem-box { margin-top: 18px; }
.skill-name { font-weight: 700; color: var(--accent-ink); font-size: 0.92rem; margin-bottom: 6px; }
.problem { font-size: 1.12rem; line-height: 1.45; color: var(--ink); }
.problem-box .problem { font-weight: 600; }
.math { margin: 12px 0 4px; font-size: 1.5rem; text-align: center; overflow-x: auto; }

/* hints */
.hint-dots { color: var(--accent); font-weight: 800; letter-spacing: 2px; }

/* placement */
.strand-tag { font-weight: 700; color: var(--accent-ink); text-transform: capitalize; margin: 8px 0 4px; }
.progress-line { margin-top: 16px; color: var(--muted); font-size: 0.9rem; }

/* feedback states */
.after { margin-top: 18px; }
.flash-correct { animation: pop 0.4s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.015); } 100% { transform: scale(1); } }

/* modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
@media (min-width: 600px) { .modal { align-items: center; } }
.modal-card {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 640px;
  max-height: 82vh; overflow-y: auto;
  padding: 22px;
}
@media (min-width: 600px) { .modal-card { border-radius: 20px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* skill rows (progress) */
.skill-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.skill-row .name { font-weight: 700; color: var(--ink); }
.skill-row .strand { font-size: 0.8rem; color: var(--muted); }

/* status pills (shared kid + parent) */
.status-pill {
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.s-locked { background: #eef1f5; color: #64748b; }
.s-unlocked { background: var(--info-soft); color: var(--info); }
.s-practicing { background: var(--warn-soft); color: var(--warn); }
.s-proficient { background: var(--good-soft); color: var(--good); }
.s-mastered { background: #ccfbf1; color: #0f766e; }
.due-star { color: var(--accent); font-weight: 800; margin-left: 6px; font-size: 0.8rem; }

.bar { height: 7px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin-top: 5px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* parent dashboard */
.kid-card { padding: 20px; }
.kid-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.count-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.count-chip {
  font-size: 0.78rem; font-weight: 700; padding: 5px 11px; border-radius: 999px;
}
.app-block { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.app-block-head {
  font-weight: 800; color: var(--ink); margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.app-soon { opacity: 0.7; }
.p-strand { margin: 8px 0 12px; }
.p-strand-head {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); margin-bottom: 6px;
}
.p-skill {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--bg-2);
}
.p-name { font-size: 0.95rem; color: var(--ink-soft); }

/* center the login + pick-your-color cards in the viewport (not stuck at top) */
#login:not(.hidden), #colorPick:not(.hidden) {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  margin: 0;
}

/* rendered markdown inside the tutor bubble */
.tutor-msg p { margin: 0 0 10px; }
.tutor-msg p:last-child { margin-bottom: 0; }
.tutor-msg strong { font-weight: 800; color: var(--ink); }
.tutor-msg em { font-style: italic; }
.tutor-msg code, .self-explain code {
  background: var(--bg-2); padding: 1px 6px; border-radius: 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.92em;
}
.self-explain p { margin: 0; }

/* hint modal + loading spinner */
.hint-loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 14px 2px; }
.spinner {
  width: 22px; height: 22px; flex: none;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hint-body { line-height: 1.55; color: var(--ink); }
.hint-body p { margin: 0 0 10px; }
.hint-body p:last-child { margin-bottom: 0; }
.hint-body strong { font-weight: 800; }
.hint-body em { font-style: italic; }
