:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5d6670;
  --line: #dde1e6;
  /* Leksero's ink (as in the child's app and the icon). The bar is ink in both themes, so it matches the phone's
     status bar (theme-color) and the child's app; buttons and links use a lighter ink in dark mode to stay readable. */
  --bar: #25306a;
  --bar-text: #ffffff;
  --brand: #25306a;
  --brand-text: #ffffff;
  --lock: #a8321e;
  --ok: #2c7a3f;
  --warn: #9a6a00;
  --chip: #eef1f4;
  /* Tappable cards: a shade of ink, so they read as something to tap. */
  --tap: #eef0fa;
  --tap-line: #c5cbea;
  --tap-pressed: #dfe3f5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1c1f24;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --line: #30353c;
    --brand: #aab5f2;
    --brand-text: #10142e;
    --lock: #ef7b63;
    --ok: #6cc785;
    --warn: #e2b44c;
    --chip: #262a30;
    --tap: #232842;
    --tap-line: #3d4675;
    --tap-pressed: #2c3354;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bar); color: var(--bar-text);
}
.bar h1 { flex: 1; margin: 0; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar button { color: inherit; }
/* Beside a phone's name: in touch or not. */
.head-status { flex: none; margin-left: auto; font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: var(--bar-text); white-space: nowrap; }
.head-status.on::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #5fd08a; margin-right: 6px; vertical-align: 1px; }
.head-status.off { opacity: .85; }
.head-status.alert { background: #ffd34d; color: #3a2a00; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
/* An unlinked phone's card with its Link again button straight under it. */
.relink { margin-bottom: 16px; }
.relink .card { margin-bottom: 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 1.05rem; }
/* Folded cards: the heading is the button. */
.card.folding { padding: 0; }
.fold-head {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: none; border-radius: 12px; padding: 16px; text-align: left;
  font-size: 1.05rem; font-weight: 700; color: var(--text, inherit);
}
.fold-head .chev { font-size: 1.4rem; line-height: 1; color: var(--muted); transition: transform .15s; }
.fold-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.fold-body { padding: 0 16px 16px; }
/* Scrolled to from elsewhere: stop below the sticky bar, not under it. */
.fold-head { scroll-margin-top: calc(84px + env(safe-area-inset-top)); }
/* A phone's front page: status and Start study lock, tiles, Settings. */
.status-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0; min-height: 44px;
  background: none; border: none; border-radius: 0; text-align: left; color: var(--text); }
.status-head h2 { margin: 0; flex: 1; }
.status-head .status-more { font-size: .85rem; font-weight: 600; color: var(--brand); }
.status-head .chev { font-size: 1.4rem; color: var(--muted); transition: transform .15s; }
.status-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.watch-list { list-style: none; margin: 0; padding: 0; }
.vpn-note summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: 6px 0; }
.vpn-note p { font-size: .9rem; color: var(--muted); }
.watch { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; text-align: left;
  background: none; border: none; border-radius: 0; border-top: 1px solid var(--line); color: var(--text); }
.watch-list li:first-child .watch { border-top: none; }
.watch .chev { font-size: 1.2rem; color: var(--muted); }
.watch-name { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .95rem; }
.watch-name .muted { font-size: .82rem; }
.state { flex: none; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--chip); }
.state.active { color: var(--ok); }
.state.paused { color: var(--warn); }
.state.off { color: var(--muted); }
.state.check { background: var(--lock); color: #fff; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.status-dot.free { background: var(--ok); }
.status-dot.locked { background: var(--lock); }
.label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 11px; border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap;
  background: var(--card); color: var(--brand); border: 1px solid var(--tap-line); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-text); border-color: transparent; }
/* A label and its short field on one line: "Ends at [15:30]". */
label.inline-field { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
label.inline-field input { width: auto; min-width: 8.5em; }
.slider-box { display: flex; flex-direction: column; gap: 4px; padding: 4px 2px; }
.slider-box input[type="range"] { width: 100%; accent-color: var(--brand); min-height: 32px; }
.slider-ticks { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); padding: 0 4px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  min-height: 116px; padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--text); }
.tile.news { background: var(--tap); border-color: var(--tap-line); }
.tile strong { font-size: 1rem; }
.tile .tile-line { font-size: .82rem; color: var(--muted); }
.tile .meter { width: 100%; height: 6px; margin-top: auto; }
.tile .badge { position: absolute; top: 10px; right: 10px; min-width: 22px; height: 22px; padding: 0 6px; box-sizing: border-box;
  border-radius: 11px; background: #c62f22; color: #fff; font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.icon-svg { display: inline-flex; color: var(--brand); }
.nav-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; color: var(--text); }
.nav-row .nav-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-row .chev, .fold-head .chev { font-size: 1.4rem; color: var(--muted); }
h3.group { margin: 20px 4px 8px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
h3.group:first-child { margin-top: 0; }
.big-number { font-size: 1.8rem; font-weight: 700; }
/* App use: one row per app, most used first; tap for its time limit. */
.use-item { border-top: 1px solid var(--line); }
.use-item:first-child { border-top: none; }
.use-row { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 12px 0; text-align: left;
  background: none; border: none; border-radius: 0; color: var(--text); }
.use-top { display: flex; align-items: center; gap: 12px; }
.use-name { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.use-time { font-weight: 600; white-space: nowrap; }
.use-row .meter { height: 6px; }
.use-more { padding: 0 0 12px; }
/* The first screen's install offer: a quiet nudge under the main button, not another main thing. */
.card.install { padding: 12px 14px; font-size: .9rem; background: transparent; border-style: dashed; }
.card.install p { margin: 0; color: var(--muted); }
.card h3 { margin: 16px 0 0; font-size: .95rem; }
.muted { color: var(--muted); font-size: .9rem; }
button, .btn {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); padding: 10px 14px; min-height: 44px;
}
button.primary { background: var(--brand); color: var(--brand-text); border-color: transparent; font-weight: 600; }
button.lock { background: var(--lock); color: #fff; border-color: transparent; font-weight: 600; }
button.big { width: 100%; font-size: 1.1rem; padding: 16px; }
button.link, button.icon { background: none; border: none; padding: 8px; min-height: 0; }
button.link { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
button.icon { font-size: 1.3rem; }
button:disabled { opacity: .6; cursor: default; }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: .9rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }
.device { display: block; width: 100%; text-align: left; }
.device .name { font-weight: 600; }
/* Cards you can tap (a child's phone, the set-up choices) look tappable: a shade of ink, an ink border and a ›, so
   they don't read as plain information. */
button.card.device, button.card.choice {
  position: relative; padding-right: 40px; cursor: pointer;
  background: var(--tap); border-color: var(--tap-line);
}
button.card.device::after, button.card.choice::after {
  content: "›"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 1.8rem; line-height: 1; color: var(--brand);
}
button.card.device:active, button.card.choice:active { background: var(--tap-pressed); }
/* A big button straight on the page (Set up a phone) keeps the same gap below it as a card. */
main > button.big { margin-bottom: 16px; }
button.card.device:focus-visible, button.card.choice:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: var(--chip); }
.pill.on { color: var(--ok); }
.pill.off { color: var(--muted); }
.pill.locked { color: var(--lock); font-weight: 600; }
.pill.warn { color: var(--warn); font-weight: 600; }
.app { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.app:first-of-type { border-top: none; }
.app .who { flex: 1 1 180px; min-width: 0; }
.app .who .pkg { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.app select { flex: 1 1 180px; width: auto; }
.choices { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 6px; }
.choices button { padding: 8px 6px; font-size: .9rem; }
.answer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.answer button { padding: 8px 12px; font-size: .9rem; }
textarea { resize: vertical; }
.alert { padding: 10px 0; border-top: 1px solid var(--line); }
.alert:first-of-type { border-top: none; }
.alert.unseen .what { font-weight: 600; }
/* Not seen yet: tinted, with New; a tap marks it seen. */
.alert.unseen { background: var(--tap); margin: 0 -16px; padding: 10px 16px; border-top-color: var(--tap-line); cursor: pointer; }
.alert.unseen + .alert.unseen { border-top-color: var(--tap-line); }
.new-tag { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; background: #c62f22; color: #fff;
  font-size: .72rem; font-weight: 700; vertical-align: 1px; }
.alert.urgent .what { color: var(--lock); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; margin: 0 8px 0 0; }
textarea { font: inherit; resize: vertical; }
details summary { cursor: pointer; }
.code { font-size: 2.2rem; letter-spacing: .3em; font-weight: 700; text-align: center; margin: 12px 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button { flex: 1; min-width: max-content; }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-text); border-color: transparent; }
.error { color: var(--lock); }
#toast {
  position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 600px; margin: 0 auto; padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); text-align: center;
  opacity: 1; transition: opacity 2s ease-in; cursor: pointer;
}
/* Fades out after 3 seconds; tapped, it stays (with a line saying a tap closes it). */
#toast.fading { opacity: 0; }
#toast.kept { transition: none; }
#toast.kept::after { content: "Tap to close"; display: block; margin-top: 6px; font-size: .8rem; opacity: .7; }
.choice { display: block; width: 100%; text-align: left; }
.choice ul, .warnbox ul, details ul { margin: 8px 0 0; padding-left: 20px; }
.choice .name { font-weight: 600; font-size: 1.05rem; }
.steps { padding-left: 22px; margin: 8px 0; }
.steps li { margin: 6px 0; }
.qr { display: block; width: min(380px, 100%); margin: 12px auto; background: #fff; border-radius: 8px; image-rendering: pixelated; }
.code-small { text-align: center; font-weight: 600; overflow-wrap: anywhere; }
.warnbox { border-color: var(--warn); }
.done { border-color: var(--ok); }
.checks { padding-left: 20px; margin: 0; }
details summary { cursor: pointer; font-weight: 600; }
a.btn { display: block; box-sizing: border-box; text-align: center; text-decoration: none; line-height: 1.4; }
a.btn.primary { background: var(--brand); color: var(--brand-text); border-color: transparent; font-weight: 600; }
a.btn.big { width: 100%; font-size: 1.1rem; padding: 16px; }
.radio { display: flex; gap: 10px; align-items: flex-start; font-weight: normal; margin: 8px 0; cursor: pointer; }
.radio input { width: auto; min-height: 0; margin-top: 4px; }
.meter { height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); }
.day-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-weight: normal; margin: 8px 0; }
.day-row > span { flex: 1 1 auto; }
.day-row select { flex: 0 0 auto; width: 9.5em; }
.day-picks { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; font-weight: normal; font-size: .85rem; }
.day-pick input { margin: 0; }
.editbox { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.editbox label.grow { margin: 0; }
