:root {
  --screen-color: #5B7FE8;
  --screen-bg: #E8EEFF;
  --reading-color: #F0578F;
  --reading-bg: #FFE5EF;
  --owed-color: #F2921E;
  --credit-color: #2FBE86;
  --success-color: #2FBE86;
  --even-color: #9C8FC7;

  --bg-grad-start: #FFE8D6;
  --bg-grad-mid: #FFDCEC;
  --bg-grad-end: #EDE0FA;

  --card-bg: #FFFFFF;
  --ink: #392F4D;
  --text: var(--ink);
  --text-muted: #7B7096;
  --border: #F0E6F5;

  --accent-purple: #8B5CF6;
  --accent-pink: #EC4899;
  --gradient-primary: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);

  --radius-card: 22px;
  --radius-pill: 999px;

  --font-heading: 'Baloo 2', 'Nunito', sans-serif;
  --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --bg: #FBF7FC;
}

* { box-sizing: border-box; }

.ic {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.18em;
  display: inline-block;
}
/* icon that sits alone in a round button */
.icon-btn .ic { width: 1em; height: 1em; vertical-align: 0; }

/* värviline kategooria-emoji (lugemine / ekraan) — inline Fluent Emoji */
.emo {
  width: 1.2em;
  height: 1.2em;
  flex: none;
  vertical-align: -0.22em;
  display: inline-block;
}
/* emoji üksinda ümmarguses mullis — täida rohkem ruumi */
.pt-k .emo { width: 17px; height: 17px; vertical-align: 0; }
.reward-icon .emo { width: 26px; height: 26px; vertical-align: 0; }
.wk-l .emo { width: 15px; height: 15px; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg-grad-start) 0%, var(--bg-grad-mid) 45%, var(--bg-grad-end) 100%);
  background-repeat: no-repeat;
  /* app-like: kill the double-tap-to-zoom gesture and its 300ms delay */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.wrap.narrow { max-width: 480px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.greeting {
  font-family: var(--font-heading);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
  margin: -8px 0 16px;
}

h1, h2, h3 { font-family: var(--font-heading); color: var(--ink); font-weight: 700; }
h1 { font-size: 23px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 16px; }

.app-logo {
  display: flex;
  align-items: center;
  gap: 9px;
}
.app-logo img { display: block; border-radius: 8px; }

.brand-logo-full {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.brand-logo-full img { display: block; max-width: 100%; height: auto; }

.link-muted {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.link-muted:hover { color: var(--accent-purple); }

.login-home-link {
  display: block;
  text-align: center;
  margin-top: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 10px;
}
/* Text actions in the topbar (Admin / Logi välja) match the round icon button */
.header-actions .link-muted {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--card-bg);
  color: var(--accent-purple);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 12px -6px rgba(57, 47, 77, 0.2);
  transition: transform 0.1s ease;
}
.header-actions .link-muted:hover { color: var(--accent-pink); }
.header-actions .link-muted:active { transform: scale(0.96); }
.header-actions .link-muted.current {
  background: var(--gradient-primary);
  color: #fff;
}
.header-actions .link-muted.current:hover { color: #fff; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--card-bg);
  color: var(--accent-purple);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 4px 12px -6px rgba(57, 47, 77, 0.2);
}
.icon-btn:hover { transform: rotate(20deg); }
.icon-btn:active { transform: scale(0.94); }

.card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius-card);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 14px 34px -18px rgba(139, 92, 246, 0.32), 0 3px 10px -6px rgba(236, 72, 153, 0.18);
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.balance-card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius-card);
  padding: 24px 22px 20px;
  margin-bottom: 20px;
  box-shadow: 0 14px 34px -18px rgba(139, 92, 246, 0.32), 0 3px 10px -6px rgba(236, 72, 153, 0.18);
  position: relative;
  overflow: hidden;
}
.balance-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: var(--even-color);
}
.balance-card.owed::before { background: linear-gradient(90deg, var(--owed-color), var(--reading-color)); }
.balance-card.credit::before { background: linear-gradient(90deg, var(--success-color), var(--screen-color)); }
.balance-card.even::before { background: var(--even-color); }

.balance-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 6px;
}
.balance-value { font-family: var(--font-heading); font-size: 25px; font-weight: 700; color: var(--ink); }

.stat-card {
  background: var(--card-bg);
  border: none;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 24px -16px rgba(57, 47, 77, 0.22);
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-family: var(--font-heading); font-size: 19px; font-weight: 700; color: var(--ink); }

/* Earned screen-time (reward conversion) */
.reward-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--screen-bg);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
}
.reward-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex: none;
}
.reward-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #5069C9;
  margin-bottom: 2px;
}
.reward-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 22px;
  color: #3A4FA0;
  font-variant-numeric: tabular-nums;
}
.reward-sub {
  font-size: 12px;
  color: #5069C9;
  font-weight: 700;
  margin-top: 2px;
}

.goal-form-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Reading goal — ring + progress */
.goal-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card-bg);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 10px 24px -16px rgba(57, 47, 77, 0.22);
}
.goal-ring {
  position: relative;
  width: 84px;
  height: 84px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(
    var(--goal-color, #F0578F) calc(var(--pct, 0) * 1%),
    rgba(57, 47, 77, 0.12) calc(var(--pct, 0) * 1%)
  );
}
.goal-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--card-bg);
}
.goal-ring-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.goal-card.done .goal-ring { --goal-color: #2FBE86; }
.goal-card.done .goal-ring-num { color: #2FBE86; }
.goal-body { min-width: 0; }
.goal-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.goal-card.done .goal-label {
  color: #2FBE86;
  text-transform: none;
  font-size: 13px;
}
.goal-value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.goal-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 2px;
}

/* children.php — set a child's goal */
.goal-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.goal-form-head {
  margin: 0 0 6px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.goal-form-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.goal-form-row > div { flex: 1; min-width: 0; }
.goal-form-row .btn {
  flex: none;
  margin-top: 0;
  padding: 11px 22px;
  font-size: 14px;
  min-height: 46px;
}

/* Statistika — one tile per period (Täna / See nädal / See kuu / Kokku) */
.period-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.period-tile {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 24px -16px rgba(57, 47, 77, 0.22);
  min-width: 0; /* let the grid track shrink below the tile's content width */
}
.pt-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.pt-row {
  /* Text size/weight/font here matches .chal-dates / .chal-prog / .chal-pages
     (the Väljakutse card's meta lines) so the two cards read consistently. */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px; /* tight row-gap between the label and the value under it, normal column-gap between icon and label */
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
}
.pt-row + .pt-row { margin-top: 10px; }
.pt-t {
  color: var(--text-muted);
  font-size: 12px;
}
.pt-k {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.pt-row.pt-reading .pt-k { background: var(--reading-bg); }
.pt-row.pt-screen .pt-k  { background: var(--screen-bg); }
.pt-v {
  /* Always its own line under the icon + label, indented to line up with
     the label text, so a long lifetime total ("1 päev 3 h 31 min") gets
     the tile's full width to wrap into instead of squeezing next to the
     icon: the label stays "up", the count sits "under it". */
  flex-basis: 100%;
  margin-left: 34px;
  text-align: left;
  font-size: 12px;
  /* No white-space: nowrap here. format_duration() already keeps each
     "number unit" pair unbreakable via U+00A0, but a lifetime total like
     "1 päev 3 h 31 min" is long enough that forcing the whole string onto
     one line blew out the grid tile (and the page) on narrow phones. Let
     it wrap between parts instead. */
  font-variant-numeric: tabular-nums;
}
.pt-row.pt-reading .pt-v { color: #C93E68; }
.pt-row.pt-screen .pt-v  { color: #5069C9; }
.period-tile.pt-total {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.13), rgba(236, 72, 153, 0.13));
  box-shadow: 0 12px 26px -14px rgba(139, 92, 246, 0.4);
}

.actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

/* Tactile press feedback across tappable controls */
.btn:active,
.btn-delete-full:active,
.toggle-btn:active,
.quick-add-btn:active,
.tab:active { transform: scale(0.97); }
.btn-delete-full, .toggle-btn, .quick-add-btn, .tab { transition: transform 0.1s ease; }

.btn {
  flex: 1;
  display: block;
  text-align: center;
  padding: 15px 18px;
  border-radius: 16px;
  color: white;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 22px -8px rgba(139, 92, 246, 0.55);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-screen { background: var(--gradient-primary); }
.btn-reading { background: var(--gradient-primary); }
.btn-add { background: var(--gradient-primary); }
.full-width { width: 100%; margin-top: 8px; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-header h2 { margin: 0; }
.ov-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  color: #C9691E;
}
.ov-streak svg { width: 15px; height: 15px; }

.entries-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.entries-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.entries-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}

.empty {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 26px 16px;
  background: rgba(139, 92, 246, 0.05);
  border-radius: 14px;
}

/* Grouped entries list — "Viimased kanded" / "Kõik kanded".
   Stacked day cards instead of a fixed-width table, so the comment text
   wraps and any length fits a phone screen without sideways scrolling. */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.day-group {
  border-radius: 16px;
  padding: 10px 14px 12px;
}
.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 4px;
}
.day-date {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.day-rows {
  display: flex;
  flex-direction: column;
}
.entry-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(57, 47, 77, 0.10);
}
.entry-row:first-child { border-top: none; }
.entry-row .tag {
  flex: none;
  white-space: nowrap;
  margin-top: 1px;
  min-width: 92px;
  text-align: center;
}
.entry-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.entry-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}
.day-blue   { background: #DCE6FF; }
.day-green  { background: #D7F5E6; }
.day-peach  { background: #FFE3C4; }
.day-purple { background: #F0DEFF; }

.btn-edit-day {
  color: var(--accent-purple);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
  white-space: nowrap;
}
.btn-edit-day:hover { opacity: 1; }

@media (min-width: 560px) {
  .entry-row { align-items: center; }
  .entry-row .tag { min-width: 104px; }
}

/* Standalone "Kokku" tile at the top of "Kõik kanded" */
.hist-total { margin-bottom: 16px; }
.pt-row.pt-balance {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(57, 47, 77, 0.12);
}
.pt-row.pt-balance .pt-k { background: rgba(57, 47, 77, 0.06); }
.pt-balance.bal-owed  .pt-v { color: var(--owed-color); }
.pt-balance.bal-bonus .pt-v { color: var(--screen-color); }
.pt-balance.bal-even  .pt-v { color: var(--even-color); }

form { display: flex; flex-direction: column; gap: 6px; }
label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 8px;
}
label.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}
label.check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  flex: none;
  accent-color: var(--brand, #8B5CF6);
  cursor: pointer;
}
.check-hint {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
}
.poem-star {
  color: #F5B301;
  font-size: 13px;
  vertical-align: 1px;
}
input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="email"] {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 15px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  font-family: var(--font-body);
  background: #FFFDFE;
  color: var(--text);
}

/* iOS Safari gives date inputs an intrinsic width that ignores width:100%
   until the native appearance is stripped. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
}
input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  min-width: 0;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  margin-left: auto;
}

/* Add / edit entry — one entry is either a book or a screen record */
.type-fields[hidden] { display: none; }
input:focus { outline: 2px solid var(--accent-purple); border-color: transparent; }

select {
  padding: 11px 38px 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 15px;
  width: 100%;
  min-height: 46px;
  background-color: #FFFDFE;
  color: var(--text);
  font-family: var(--font-body);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239B7BF0'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.19l3.71-3.96a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
select:focus { outline: 2px solid var(--accent-purple); border-color: transparent; }

.field-stack { display: flex; flex-direction: column; gap: 6px; }

.toggle-group { display: flex; gap: 8px; margin-bottom: 8px; }
.toggle-btn {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  text-decoration: none;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  background: #FFFDFE;
}
.toggle-btn.active { background: var(--gradient-primary); color: white; border-color: transparent; }

.error {
  background: #FFEBEF;
  color: #C2436A;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.btn-delete {
  background: none;
  border: none;
  color: #E0577E;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.btn-edit {
  color: var(--accent-purple);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 6px;
}

.day-edit-title {
  margin: 8px 0 16px;
}
.day-entry-card {
  margin-bottom: 12px;
}
.day-entry-actions {
  margin-top: 12px;
}
.day-entry-delete-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.btn-delete-full {
  width: 100%;
  background: #FFF1F4;
  border: none;
  color: #E0577E;
  border-radius: 14px;
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-heading);
  cursor: pointer;
}
.btn-delete-full:hover {
  background: #FFE3EA;
}

.child-link-note {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}
.child-link-note a { color: var(--accent-purple); font-weight: 700; }

.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-family: var(--font-heading);
  font-weight: 700;
}
.tag-screen { background: var(--screen-bg); color: #5069C9; }
.tag-reading { background: var(--reading-bg); color: #C93E68; }
.tag-unread { background: #F2EEFA; color: #8B7FB0; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--card-bg);
  border: none;
  border-radius: 18px;
  padding: 5px;
  box-shadow: 0 8px 22px -16px rgba(57, 47, 77, 0.26);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  text-align: center;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 13px;
  white-space: nowrap;
}
.tab:hover {
  color: var(--accent-purple);
}
.tab.active {
  color: white;
  background: var(--gradient-primary);
  box-shadow: 0 6px 14px -6px rgba(139, 92, 246, 0.55);
}
.child-switcher { margin-top: -6px; margin-bottom: 20px; background: var(--screen-bg); }

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 14px;
}
.page-link {
  color: var(--accent-purple);
  text-decoration: none;
  font-weight: 700;
  padding: 6px 10px;
}
.page-link.disabled {
  color: var(--border);
  pointer-events: none;
}
.page-status { color: var(--text-muted); font-size: 13px; }

/* Book list — grouped by status (Loeb praegu / Lugemata / Loetud) */
.books-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.bl-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bl-group-head {
  margin: 0 0 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bl-group-head.bl-reading { color: #5069C9; }
.bl-group-head.bl-unread  { color: #8B7FB0; }
.bl-group-head.bl-done    { color: #C93E68; }
.bl-count {
  min-width: 20px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: rgba(57, 47, 77, 0.07);
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}
.bl-item {
  position: relative;
  border-radius: 14px;
  padding: 12px 14px 12px 16px;
  border-left: 4px solid transparent;
}
.bl-item.bl-reading { background: #EEF3FF; border-left-color: #5B7FE8; }
.bl-item.bl-unread  { background: #F7F4FC; border-left-color: #C9BEE4; }
.bl-item.bl-done    { background: #FFF3F8; border-left-color: #F0578F; }
.bl-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 26px;
}
.bl-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.bl-author {
  font-size: 13px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.bl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
}
.bl-mins { color: #C93E68; }
.bl-pages { color: var(--text-muted); }
.bl-pct {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  color: #C93E68;
}
.bl-date { color: var(--text-muted); }
.bl-progress {
  height: 7px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(57, 47, 77, 0.12);
  overflow: hidden;
}
.bl-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: #F0578F;
  transition: width 0.3s ease;
}
.bl-progress-label {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.bl-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 7px;
  color: var(--accent-purple);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  opacity: 0.75;
}
.bl-edit:hover { opacity: 1; }

/* The whole book card is clickable: stretch the title link over it. The
   pencil sits above the stretched layer so it keeps its own target. */
.bl-link { color: inherit; text-decoration: none; }
.bl-link::after { content: ''; position: absolute; inset: 0; border-radius: 14px; }
.bl-item:hover { filter: brightness(0.985); }
.bl-edit { z-index: 2; }

/* Book detail page (book.php / child_book.php) */
.trash-type { flex: none; min-width: 92px; text-align: center; justify-content: center; align-self: flex-start; margin-top: 2px; }
/* Archived books: collapsed list at the bottom of the book list */
.bl-archive { margin-top: 6px; }
.bl-archive > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.bl-archive > summary::-webkit-details-marker { display: none; }
.bl-archive > summary::before { content: '›'; display: inline-block; font-size: 18px; line-height: 1; width: 10px; text-align: center; transition: transform 0.15s ease; }
.bl-archive[open] > summary::before { transform: rotate(90deg); }
.bl-group-head.bl-archived { color: var(--text-muted); }
.bl-archive .bl-item { opacity: 0.85; margin-top: 8px; }
.bd-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.bd-badges .bd-status { margin-bottom: 0; }
.bd-status.bd-archived { background: rgba(57, 47, 77, 0.08); color: var(--text-muted); }
.bd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 12px; }
.bd-actions .bd-edit { margin-top: 0; }
.bd-archive-form { margin: 0; display: inline; }
.bd-archive-btn { background: none; border: none; padding: 0; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.bd-data { margin: 0; }
.bd-data > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.bd-data > div:first-child { border-top: none; padding-top: 0; }
.bd-data dt { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.bd-data dd { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); text-align: right; overflow-wrap: anywhere; }
.bd-owner { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.bd-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.bd-status {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 6px;
}
.bd-status.bl-reading { background: #EEF3FF; color: #4A5FB5; }
.bd-status.bl-unread  { background: #F2EEFA; color: #7B6BA8; }
.bd-status.bl-done    { background: #FFF3F8; color: #C93E68; }
.bd-title { margin: 0; overflow-wrap: anywhere; }
.bd-author { font-size: 14px; color: var(--text-muted); margin: 0 0 6px; }
.bd-card .bl-progress, .bd-card .bl-progress-label { align-self: stretch; }
.bd-note {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}
.bd-edit { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; }
.bd-stats { margin-bottom: 20px; }
.bd-stat-v {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}
.bd-stat-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.bd-sessions { list-style: none; margin: 0; padding: 0; }
.bd-sessions li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.bd-sessions li:first-child { border-top: none; padding-top: 0; }
.bd-s-date { font-size: 13px; font-weight: 700; color: var(--text-muted); min-width: 84px; }
.bd-s-min { font-family: var(--font-heading); font-weight: 700; color: #C93E68; }
.bd-s-page { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.bd-s-note { flex-basis: 100%; font-size: 13px; color: var(--text-muted); }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll table { min-width: 480px; }

/* Balance bar */
.balance-bar {
  display: flex;
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
  margin: 12px 0 8px;
}
.balance-bar-fill.raamat { background: var(--reading-color); }
.balance-bar-fill.ekraan { background: var(--screen-color); }
.balance-bar-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.dot-reading { background: var(--reading-color); }
.dot-screen { background: var(--screen-color); }

/* Streak badge */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(90deg, #FFC98A, #FFA8CB);
  color: #93450A;
  font-size: 13px;
  font-family: var(--font-heading);
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}

/* Milestone banner */
.milestone-banner {
  background: linear-gradient(90deg, #FFDE70, #FFAAD4);
  color: #7A4E00;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 16px;
  margin-bottom: 20px;
  text-align: center;
  max-height: 100px;
  overflow: hidden;
  animation: banner-in 0.28s ease-out, banner-out 0.45s ease-in 3.2s forwards;
}
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-10px); }
}
@keyframes banner-out {
  to {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .milestone-banner { animation: banner-out 0.3s ease 4s forwards; }
}

/* Achievement banner — like the milestone toast, but it STAYS (shown for a day). */
.achievement-banner {
  background: linear-gradient(90deg, #FFDE70, #FFAAD4);
  color: #7A4E00;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 20px;
  text-align: center;
  animation: banner-in 0.28s ease-out;
}

/* Milestones / achievements list */
.ms-list { list-style: none; margin: 0; padding: 0; }
.ms-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 2px;
  border-bottom: 1.5px solid var(--border);
}
.ms-row:last-child { border-bottom: none; }
.ms-icon { font-size: 20px; line-height: 1; flex: none; }
.ms-text {
  flex: 1;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink, var(--text));
}
.ms-date {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.ms-edit {
  flex: none;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  margin-left: 2px;
}
.ms-edit svg { width: 16px; height: 16px; }
.ms-edit:active { transform: scale(0.9); }
.ms-new-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.ms-new-row > input[type="text"]:last-child { flex: 1; }
.ms-emoji-input {
  width: 60px;
  flex: none;
  text-align: center;
}
.mc-group { border-top: 1.5px solid var(--border); }
.mc-group:last-child { border-bottom: 1.5px solid var(--border); }
.mc-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 22px 12px 2px;
  position: relative;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-heading);
}
.mc-title::-webkit-details-marker { display: none; }
.mc-title::after {
  content: "›";
  position: absolute;
  right: 4px;
  top: 50%;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-muted);
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.18s ease;
}
.mc-group[open] > .mc-title::after { transform: translateY(-50%) rotate(90deg); }
.mc-name {
  flex: 1;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.mc-meta {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
}
.mc-now { color: var(--accent-purple); }
.mc-group[open] > .ms-list { padding-bottom: 8px; }
.ms-row.mc-locked { opacity: 0.5; }
.ms-row.mc-locked .ms-date { color: var(--accent-purple); }

/* Heatmap */
.heatmap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 8px 0;
}
.hm-cell {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}
.hm-good { background: var(--success-color); }
.hm-bonus { background: var(--screen-color); }
.hm-debt { background: var(--owed-color); }
.hm-empty { background: var(--border); }
.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.heatmap-legend .hm-cell { width: 10px; height: 10px; margin-right: 4px; vertical-align: middle; }

/* Weekly recap */
.wk-banner {
  display: block;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(236, 72, 153, 0.12));
  color: var(--accent-purple);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  padding: 12px;
  border-radius: 14px;
  margin-bottom: 16px;
}
.wk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.wk-stat {
  background: rgba(139, 92, 246, 0.06);
  border-radius: 14px;
  padding: 14px;
}
.wk-l { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.wk-n {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  margin: 2px 0;
  font-variant-numeric: tabular-nums;
}
.wk-d { font-size: 12px; font-weight: 700; }
.wk-good { color: #2FBE86; }
.wk-bad { color: var(--owed-color); }
.wk-flat { color: var(--text-muted); }
.wk-sub {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}
.wk-list { list-style: none; padding: 0; margin: 0; }
.wk-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.wk-list li:last-child { border-bottom: none; }
.wk-list li > span:first-child { flex: none; color: var(--text-muted); font-weight: 700; }
.wk-list li > span:last-child {
  text-align: right;
  font-family: var(--font-heading);
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* Reading challenges */
.chal {
  border-radius: 14px;
  background: rgba(139, 92, 246, 0.06);
  padding: 14px;
}
.chal + .chal { margin-top: 10px; }
.chal-done { background: rgba(47, 190, 134, 0.12); }
.chal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.chal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.chal-status {
  flex: none;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.chal-active { color: var(--accent-purple); }
.chal-upcoming, .chal-ended { color: var(--text-muted); }
.chal-done .chal-status { color: #2FBE86; }
.chal-dates {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 2px 0 8px;
}
.chal-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(57, 47, 77, 0.12);
  overflow: hidden;
}
.chal-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-purple);
  transition: width 0.3s ease;
}
.chal-done .chal-bar-fill { background: #2FBE86; }
.chal-prog {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.chal-pages {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.chal-pages .emo { width: 15px; height: 15px; }
.chal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.chal-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: rgba(57, 47, 77, 0.14);
}
.chal-dot.filled { background: var(--accent-purple); }
.chal-done .chal-dot.filled { background: #2FBE86; }
.chal-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.chal-del { margin: 0; }
.chal-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}
.chal-edit-btn svg { width: 14px; height: 14px; }
.chal-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.chal-new {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.chal-new > summary {
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-purple);
  list-style: none;
}
.chal-new > summary::-webkit-details-marker { display: none; }
.chal-goal-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chal-goal-row > div { flex: 1; }
.chal-goal-row > input[type="number"] { flex: 1; }
.chal-goal-row > select { flex: 0 0 auto; width: auto; }

/* Year summary card (Raamatud page) */
.ys-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.ys-head h2 { margin: 0; }
.ys-year {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  flex: none;
}
.ys-year a {
  color: var(--accent-purple);
  text-decoration: none;
  padding: 2px 8px;
  font-size: 18px;
  line-height: 1;
}
.ys-year .disabled { color: var(--border); padding: 2px 8px; font-size: 18px; line-height: 1; }
.ys-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ys-stat {
  background: rgba(139, 92, 246, 0.06);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ys-n {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ys-l {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* "Enim aega" — same grouped tinted-card look as the book list */
.top-block + .top-block { margin-top: 20px; }
.top-heading {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.top-block.tb-reading .top-heading { color: #C93E68; }
.top-block.tb-screen  .top-heading { color: #5069C9; }
.top-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.top-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  border-left: 4px solid transparent;
  font-size: 14px;
}
.top-block.tb-reading .top-list li { background: #FFF3F8; border-left-color: #F0578F; }
.top-block.tb-screen  .top-list li { background: #EEF3FF; border-left-color: #5B7FE8; }
.top-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
}
.top-minutes {
  flex: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Quick-add presets */
.quick-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}
.quick-add-btn {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.quick-add-btn:hover { border-color: var(--accent-purple); color: var(--accent-purple); }

/* Search box */
.search-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 16px;
}
.search-row input[type="text"] { flex: 1 1 auto; min-width: 0; }
.search-row .btn {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
  border-radius: 14px;
}

/* Reading timer */
.timer-book {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 4px;
  font-weight: 600;
}
.timer-display {
  font-family: var(--font-heading);
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin: 8px 0;
  color: var(--ink);
}
.timer-display.timer-overtime { color: var(--owed-color); }
.timer-status {
  font-size: 14px;
  color: var(--text-muted);
  min-height: 20px;
  font-weight: 600;
}
.finish-minutes {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  margin-top: 8px;
}
.btn-ghost-solid {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 16px;
  padding: 14px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.btn-ghost-solid:hover { background: var(--screen-bg); }

/* Secondary action button (outline) */
.btn-outline {
  background: var(--card-bg);
  color: var(--accent-purple);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.btn-outline:hover { filter: none; background: var(--screen-bg); }
.actions-stack { flex-direction: column; }
.actions-stack .btn { flex: none; }

/* Pere+ upgrade gate */
.gate-card {
  background: linear-gradient(135deg, #F6EEFF 0%, #FFF0F7 100%);
  border: 1.5px solid #EADCFB;
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
}
.gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--gradient-primary);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.gate-text {
  font-size: 14px;
  color: var(--ink);
  margin: 0 0 14px;
  line-height: 1.5;
}
.gate-text:last-child { margin-bottom: 0; }
.gate-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-purple);
  background: #F6EEFF;
  border-radius: 999px;
  padding: 4px 10px;
  margin-top: 6px;
}

/* Admin: Free vs. Pere+ plan comparison table */
.plan-table th.plan-col,
.plan-table td.plan-col { text-align: center; width: 110px; }
.plan-table td.plan-col form { display: inline-block; }
.plan-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--gradient-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.plan-col:first-of-type .plan-check { background: #E9E4F3; color: #6B6280; }
.plan-move-btn {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1.5px dashed var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.plan-move-btn:hover { border-color: var(--accent-purple); color: var(--accent-purple); }

/* Child self-log — parent approval queue */
.pending-card { border: 1.5px solid var(--accent-purple); }
.pending-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--gradient-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  margin-left: 6px;
}
.pending-list { display: flex; flex-direction: column; gap: 12px; }
.pending-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.pending-row:last-child { border-bottom: none; padding-bottom: 0; }
.pending-main { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
.pending-label {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.pending-meta {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-body);
}
.pending-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.pending-actions form { margin: 0; }
.pending-edit {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  flex: none;
}
.pending-edit svg { width: 16px; height: 16px; }
.pending-edit:active { transform: scale(0.9); }
.btn-approve,
.btn-reject {
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 9px 14px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.1s ease;
}
.btn-approve:active,
.btn-reject:active { transform: scale(0.96); }
.btn-approve { background: var(--gradient-primary); color: #fff; }
.btn-approve svg { width: 15px; height: 15px; }
.btn-reject { background: var(--border); color: var(--text-muted); }
.pending-wait {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Family logins list */
.fl-row {
  display: flex;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.fl-row:last-child { border-bottom: none; }
.fl-main { flex: 1 1 auto; min-width: 0; }
.fl-email {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.fl-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 1px;
}

@media (max-width: 480px) {
  h1 { font-size: 20px; }
}

/* ============================================================
   Dark theme — automatic, follows the device's colour-scheme
   setting. Redefines the palette tokens, then patches the spots
   that hard-coded a light colour.
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --screen-color: #86A6FF;
    --reading-color: #FF7BA6;
    --owed-color: #FFB454;
    --credit-color: #45D9A0;
    --success-color: #45D9A0;
    --even-color: #B0A3DE;

    --screen-bg: #232A45;
    --reading-bg: #3E2334;

    --bg-grad-start: #221B34;
    --bg-grad-mid: #2A1D3A;
    --bg-grad-end: #1A1928;

    --card-bg: #2C2745;
    --ink: #ECE8F6;
    --text-muted: #A79EC4;
    --border: #3B3357;

    --accent-purple: #B79EFF;
    --accent-pink: #F773B4;
    /* deeper than the light gradient so active tabs / buttons don't glare */
    --gradient-primary: linear-gradient(135deg, #7349DD 0%, #CC4686 100%);

    --bg: #1A1828;
  }

  body { background-color: var(--bg); }

  /* Raised surfaces need a real shadow — the light purple glow disappears. */
  .card,
  .balance-card,
  .stat-card,
  .period-tile,
  .goal-card {
    box-shadow: 0 16px 34px -22px rgba(0, 0, 0, 0.7), 0 2px 8px -5px rgba(0, 0, 0, 0.5);
  }
  .icon-btn,
  .header-actions .link-muted,
  .tabs { box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.5); }
  .tab.active { box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.6); }
  .icon-btn,
  .header-actions .link-muted { background: rgba(255, 255, 255, 0.07); }

  /* Form controls */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="password"],
  input[type="email"],
  textarea,
  select { background: #241F3B; background-color: #241F3B; color: var(--text); }

  /* Reward card text sits on the dark-blue --screen-bg */
  .reward-label,
  .reward-sub { color: #A6BCFF; }
  .reward-value { color: #C9D6FF; }
  .reward-icon { background: rgba(255, 255, 255, 0.08); }

  /* Category text colours tuned for pale backgrounds → lighten */
  .pt-row.pt-screen .pt-v,
  .tag-screen,
  .top-block.tb-screen .top-heading,
  .bl-group-head.bl-reading { color: #A6BCFF; }
  .pt-row.pt-reading .pt-v,
  .tag-reading,
  .top-block.tb-reading .top-heading,
  .bl-group-head.bl-done,
  .bl-mins,
  .bl-pct { color: #FF9DBE; }
  .tag-unread,
  .bl-group-head.bl-unread { color: #B7ADD6; }
  .bd-status.bl-reading { background: #1F2740; color: #A6BCFF; }
  .bd-status.bl-unread  { background: #262038; color: #B7ADD6; }
  .bd-status.bl-done    { background: #33202E; color: #FF9DBE; }
  .bd-s-min { color: #FF9DBE; }
  .bd-status.bd-archived { background: rgba(255, 255, 255, 0.08); color: #B7ADD6; }

  /* Entry day-group tints */
  .day-blue   { background: #242C48; }
  .day-green  { background: #1E3A31; }
  .day-peach  { background: #3C3020; }
  .day-purple { background: #312748; }
  .entry-row { border-top-color: rgba(255, 255, 255, 0.09); }

  /* Book-list rows + "Enim aega" rows */
  .bl-item.bl-reading,
  .top-block.tb-screen .top-list li { background: #1F2740; }
  .bl-item.bl-unread { background: #262038; }
  .bl-item.bl-done,
  .top-block.tb-reading .top-list li { background: #33202E; }
  .tag-unread { background: rgba(255, 255, 255, 0.06); }
  .bl-count { background: rgba(255, 255, 255, 0.08); }
  .bl-progress { background: rgba(255, 255, 255, 0.12); }
  .bl-progress-fill { background: var(--reading-color); }

  /* Rings / bars / progress tracks */
  .goal-ring {
    background: conic-gradient(var(--goal-color, var(--reading-color)) calc(var(--pct, 0) * 1%),
                               rgba(255, 255, 255, 0.13) calc(var(--pct, 0) * 1%));
  }
  .goal-card.done .goal-ring { --goal-color: var(--success-color); }
  .goal-card.done .goal-ring-num,
  .wk-good,
  .chal-done .chal-status { color: var(--success-color); }
  .chal-bar,
  .chal-dot { background: rgba(255, 255, 255, 0.13); }
  .chal-done .chal-bar-fill,
  .chal-done .chal-dot.filled { background: var(--success-color); }
  .chal-done { background: rgba(69, 217, 160, 0.12); }
  .wk-stat { background: rgba(255, 255, 255, 0.04); }
  .pt-row.pt-balance .pt-k { background: rgba(255, 255, 255, 0.08); }

  /* Warm accent surfaces — dial the gold banners back so they don't blaze */
  .streak-badge { background: linear-gradient(90deg, #CFA062, #C98AAC); color: #2E1E00; }
  .milestone-banner,
  .achievement-banner { background: linear-gradient(90deg, #C9A24E, #C67FA4); color: #2E1E00; }
  .poem-star { color: #FFC94D; }

  /* Error + delete affordances */
  .error { background: #3A2230; color: #FFA9C0; }
  .btn-delete,
  .btn-delete-full { color: #FF9DBE; }
  .btn-delete-full { background: #33222C; }
  .btn-delete-full:hover { background: #3E2833; }

  /* Subtle purple/pink tints read a bit stronger on dark */
  .period-tile.pt-total {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(236, 72, 153, 0.22));
  }
  .wk-banner {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.18));
  }
}
