/* Baitna — warm, playful, tidy. Tokens first; light/dark each defined explicitly. */
:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --bg-tint-1: rgba(27, 175, 122, 0.10);
  --bg-tint-2: rgba(42, 120, 214, 0.10);
  --surface: #ffffff;
  --surface-2: #f7f6f2;
  --ink: #15171c;
  --ink-2: #52514e;
  --muted: #7d7b75;
  --line: #e8e6df;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #0e7a64;
  --accent-ink: #ffffff;
  --accent-soft: #dcf3ea;
  --accent-chart: #2a78d6;
  --cat-prayer: #1baf7a;
  --cat-health: #eb6834;
  --cat-edu: #2a78d6;
  --cat-prayer-soft: #e4f6ee;
  --cat-health-soft: #fdece3;
  --cat-edu-soft: #e7f0fc;
  --ring-prayer: #1baf7a;
  --ring-health: #eb6834;
  --ring-edu: #2a78d6;
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --good-ink: #006300;
  --bad-ink: #b3261e;
  --member-1: #2a78d6; --member-2: #eb6834; --member-3: #1baf7a; --member-4: #eda100;
  --member-5: #e87ba4; --member-6: #008300; --member-7: #4a3aa7; --member-8: #e34948;
  --shadow: 0 1px 2px rgba(20, 24, 32, 0.04), 0 10px 30px rgba(20, 24, 32, 0.07);
  --shadow-lift: 0 2px 4px rgba(20, 24, 32, 0.06), 0 16px 40px rgba(20, 24, 32, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "SF Arabic", "Noto Sans Arabic", Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f12;
    --bg-tint-1: rgba(25, 158, 112, 0.14);
    --bg-tint-2: rgba(57, 135, 229, 0.14);
    --surface: #171a1f;
    --surface-2: #1f232a;
    --ink: #f3f4f6;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --line: #2a2e35;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #2cc4a2;
    --accent-ink: #062b25;
    --accent-soft: #12352e;
    --accent-chart: #3987e5;
    --cat-prayer: #199e70;
    --cat-health: #d95926;
    --cat-edu: #3987e5;
    --cat-prayer-soft: #10302a;
    --cat-health-soft: #37201a;
    --cat-edu-soft: #16283f;
    --ring-prayer: #199e70;
    --ring-health: #d95926;
    --ring-edu: #3987e5;
    --good-ink: #0ca30c;
    --bad-ink: #f2b8b5;
    --member-1: #3987e5; --member-2: #d95926; --member-3: #199e70; --member-4: #c98500;
    --member-5: #d55181; --member-6: #008300; --member-7: #9085e9; --member-8: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f12;
  --bg-tint-1: rgba(25, 158, 112, 0.14);
  --bg-tint-2: rgba(57, 135, 229, 0.14);
  --surface: #171a1f;
  --surface-2: #1f232a;
  --ink: #f3f4f6;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --line: #2a2e35;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #2cc4a2;
  --accent-ink: #062b25;
  --accent-soft: #12352e;
  --accent-chart: #3987e5;
  --cat-prayer: #199e70;
  --cat-health: #d95926;
  --cat-edu: #3987e5;
  --cat-prayer-soft: #10302a;
  --cat-health-soft: #37201a;
  --cat-edu-soft: #16283f;
  --ring-prayer: #199e70;
  --ring-health: #d95926;
  --ring-edu: #3987e5;
  --good-ink: #0ca30c;
  --bad-ink: #f2b8b5;
  --member-1: #3987e5; --member-2: #d95926; --member-3: #199e70; --member-4: #c98500;
  --member-5: #d55181; --member-6: #008300; --member-7: #9085e9; --member-8: #e66767;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 0% -10%, var(--bg-tint-1), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, var(--bg-tint-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
small { color: var(--muted); }
.muted { color: var(--ink-2); }
.grow { flex: 1; min-width: 0; }

/* ---------- top bar & tab bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; font-size: 22px;
  background: linear-gradient(135deg, #1baf7a, #2a78d6);
  box-shadow: 0 6px 16px rgba(27, 175, 122, 0.35);
}
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name b { font-size: 18px; letter-spacing: -0.01em; }
.brand-name small { font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.tabbar {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 4px; padding: 6px;
  width: min(460px, calc(100% - 24px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(18px);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-lift);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 18px;
  text-decoration: none; color: var(--ink-2); font-size: 12px; font-weight: 600;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.tab-icon { font-size: 21px; line-height: 1; transition: transform 0.2s; }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.tab.active .tab-icon { transform: translateY(-1px) scale(1.12); }
.tab:active { transform: scale(0.95); }

.view { max-width: 760px; margin: 0 auto; padding: 16px 16px 120px; display: flex; flex-direction: column; gap: 16px; }
.view.enter > * { animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.view.enter > *:nth-child(2) { animation-delay: 0.05s; }
.view.enter > *:nth-child(3) { animation-delay: 0.1s; }
.view.enter > *:nth-child(4) { animation-delay: 0.15s; }
.view.enter > *:nth-child(n+5) { animation-delay: 0.2s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-weight: 650; text-decoration: none;
  transition: transform 0.12s, filter 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 11px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 16px;
  transition: transform 0.12s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.ghost { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.2); color: inherit; font-size: 20px; width: 34px; height: 34px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.x-btn {
  width: 30px; height: 30px; border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; flex: none;
}
.x-btn:hover { background: var(--surface-2); color: var(--bad-ink); }

input, select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.stack-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.stack-form label, .label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- avatars ---------- */
.avatar {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 50%; font-size: 22px; text-decoration: none;
  background: color-mix(in srgb, var(--mc, var(--member-1)) 16%, var(--surface));
  box-shadow: 0 0 0 2px var(--mc, var(--member-1));
}
.avatar.sm { width: 36px; height: 36px; font-size: 19px; }
.avatar.lg { width: 60px; height: 60px; font-size: 32px; box-shadow: 0 0 0 3px var(--mc, var(--member-1)); }
.avatar.xl { width: 84px; height: 84px; font-size: 46px; box-shadow: 0 0 0 4px var(--mc, var(--member-1)); }
.switcher {
  position: relative; display: flex; align-items: center; gap: 6px; height: 40px;
  padding-inline: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
}
.switcher-avatar { font-size: 20px; }
.switcher select { min-height: 0; height: 36px; padding: 0 6px; border: 0; background: transparent; width: auto; field-sizing: content; min-width: 84px; max-width: 130px; font-weight: 600; box-shadow: none; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 20px; border-radius: 26px; color: #fff;
  background: linear-gradient(135deg, #0c3f3a 0%, #133466 55%, #3a2163 100%);
  box-shadow: var(--shadow-lift);
  --ring-prayer: #3fd39d; --ring-health: #ff8a5c; --ring-edu: #6aa8ff;
}
.hero::before, .hero::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(40px); opacity: 0.55;
}
.hero::before { width: 220px; height: 220px; background: #1baf7a; top: -80px; inset-inline-end: -60px; }
.hero::after { width: 200px; height: 200px; background: #e87ba4; bottom: -110px; inset-inline-start: -40px; opacity: 0.35; }
.hero-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.hero-hello { margin: 0 0 6px; font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
.hero-sub { margin: 12px 0 0; opacity: 0.8; font-size: 14px; text-align: center; }
.datenav { display: flex; align-items: center; gap: 8px; }
.date-label { font-weight: 600; opacity: 0.92; font-size: 15px; }
.hero .link-btn { color: #bfeee0; font-size: 14px; }
.hero-points { text-align: end; flex: none; }
.hero-points b { display: block; font-size: 44px; line-height: 1; font-weight: 800; letter-spacing: -0.03em; }
.hero-points span { font-size: 13px; opacity: 0.8; }
.rings { display: flex; justify-content: space-around; margin: 18px 0 8px; }
.ring-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 650; }
.ring-track { fill: none; stroke: rgba(127, 127, 127, 0.22); stroke-width: 7; }
.hero .ring-track { stroke: rgba(255, 255, 255, 0.16); }
.ring-fill { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.ring-text { font-size: 14px; font-weight: 750; fill: currentColor; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 650; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.18);
}
.viewing {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; font-weight: 650;
  background: color-mix(in srgb, var(--mc) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--mc) 35%, transparent);
}

/* ---------- cards ---------- */
.cards { display: flex; flex-direction: column; gap: 16px; }
.card {
  position: relative; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.card[class*="cat-"]::before {
  content: ""; position: absolute; inset-inline: 18px; top: 0; height: 4px; border-radius: 0 0 6px 6px; background: var(--cat);
}
.cat-prayer { --cat: var(--cat-prayer); --cat-soft: var(--cat-prayer-soft); }
.cat-health { --cat: var(--cat-health); --cat-soft: var(--cat-health-soft); }
.cat-edu { --cat: var(--cat-edu); --cat-soft: var(--cat-edu-soft); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 750; }
.card-icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; font-size: 19px;
  background: var(--cat-soft, var(--surface-2));
}
.card-pts {
  padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 750; white-space: nowrap;
  background: var(--cat-soft, var(--surface-2)); color: var(--ink);
}
.sub-head { font-size: 15px; margin: 18px 0 8px; }
.field { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; border-top: 1px dashed var(--line); }
.field:first-of-type { border-top: 0; padding-top: 0; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 650; }
.row-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; margin-top: 4px; border-top: 1px dashed var(--line); }
.rf-label { font-weight: 650; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px dashed var(--line); }
.grid2 .field { border-top: 0; }
.empty-state { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; list-style: none; }

/* ---------- prayers ---------- */
.prayers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prayer-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid transparent;
  transition: background 0.25s, border-color 0.25s;
}
.prayer-row.s-ontime { background: color-mix(in srgb, var(--good) 12%, var(--surface)); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.prayer-row.s-late { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.prayer-row.s-missed { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.prayer-row.locked { opacity: 0.75; }
.p-name { display: flex; flex-direction: column; min-width: 64px; }
.p-name b { font-size: 16px; }
.p-name small { font-variant-numeric: tabular-nums; }
.p-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; min-height: 38px; padding: 6px 10px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 650;
  transition: transform 0.12s, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.pill:active { transform: scale(0.93); }
.pill:disabled { opacity: 0.35; cursor: default; }
.pill.on { box-shadow: 0 0 0 2px var(--pill-c) inset; background: color-mix(in srgb, var(--pill-c) 16%, var(--surface)); }
.pill.st-ontime { --pill-c: var(--good); }
.pill.st-late { --pill-c: var(--warn); }
.pill.st-missed { --pill-c: var(--bad); }
.pill.jam { --pill-c: var(--cat-prayer); }
.pill.on { animation: pop 0.3s ease; }
@keyframes pop { 50% { transform: scale(1.1); } }

/* ---------- steppers, cups, moods, chips ---------- */
.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.step-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 0; background: var(--surface);
  font-size: 20px; font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); transition: transform 0.12s;
}
.step-btn:active { transform: scale(0.9); }
.step-btn:disabled { opacity: 0.35; cursor: default; }
.stepper output { min-width: 64px; text-align: center; display: flex; flex-direction: column; line-height: 1.1; }
.stepper output b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stepper output small { font-size: 11px; }
.cups { display: flex; flex-wrap: wrap; gap: 6px; }
.cup {
  width: 40px; height: 44px; border-radius: 10px 10px 14px 14px; border: 2px solid var(--line); background: var(--surface-2);
  font-size: 18px; filter: grayscale(1); opacity: 0.45; transition: transform 0.15s, filter 0.2s, opacity 0.2s, background 0.2s;
}
.cup.full { filter: none; opacity: 1; background: color-mix(in srgb, #3987e5 18%, var(--surface)); border-color: color-mix(in srgb, #3987e5 45%, transparent); }
.cup:active { transform: scale(0.88) rotate(-6deg); }
.cup.extra { filter: none; opacity: 1; font-size: 18px; font-weight: 800; color: var(--ink-2); }
.moods { display: flex; gap: 8px; }
.mood {
  flex: 1; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 26px; filter: grayscale(0.7); opacity: 0.7; transition: transform 0.15s, filter 0.2s, opacity 0.2s;
}
.mood.on { filter: none; opacity: 1; transform: scale(1.08); background: var(--cat-soft); border-color: var(--cat); }
.chip-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 14px; font-weight: 600; transition: background 0.2s, transform 0.12s;
}
.chip-btn.on { background: var(--cat, var(--accent)); border-color: transparent; color: #fff; }
.chip-btn:active { transform: scale(0.94); }
.more { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 4px; }
.more summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 6px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); transition: transform 0.2s; }
.more[open] summary::after { transform: rotate(180deg); }
.vitals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.vital { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input-unit { position: relative; display: block; }
.input-unit small { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.input-unit input { padding-inline-end: 56px; }

/* ---------- lists, tasks, forms ---------- */
.list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.list li span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list li b { font-variant-numeric: tabular-nums; }
.list li b.good { color: var(--good-ink); }
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.task-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.check {
  width: 28px; height: 28px; flex: none; border-radius: 9px; border: 2px solid var(--axis); background: var(--surface);
  color: transparent; font-weight: 900; font-size: 15px; transition: background 0.2s, border-color 0.2s, transform 0.12s;
}
.check[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }
.check:active { transform: scale(0.88); }
.due { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.due.soon { background: color-mix(in srgb, var(--warn) 25%, var(--surface)); color: var(--ink); }
.due.late { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); color: var(--bad-ink); }
.inline-form { display: flex; gap: 6px; }
.inline-form input[name="title"] { flex: 1; min-width: 0; }
.inline-form input[type="date"] { width: 150px; flex: none; }
.inline-form .btn { flex: none; width: 44px; padding: 0; font-size: 20px; }
.grade-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.grade-form .btn { grid-column: 1 / -1; }

/* ---------- progress ---------- */
.level-card { display: flex; align-items: center; gap: 16px; }
.level-icon {
  display: grid; place-items: center; width: 72px; height: 72px; flex: none; border-radius: 22px; font-size: 40px;
  background: linear-gradient(135deg, color-mix(in srgb, #eda100 30%, var(--surface)), color-mix(in srgb, #e87ba4 25%, var(--surface)));
}
.level-body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.level-body h2 { font-size: 20px; }
.meter { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1baf7a, #2a78d6); transition: width 0.6s; }
[dir="rtl"] .meter span { background: linear-gradient(270deg, #1baf7a, #2a78d6); }
.meter.sm { height: 6px; }
.streaks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.streak-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 14px 6px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.st-icon { font-size: 24px; }
.streak-tile b { font-size: 26px; line-height: 1.1; }
.streak-tile small { font-size: 11.5px; line-height: 1.3; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 10px; font-size: 14px; font-weight: 650; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-weight: 650; }
.setting-row + .setting-row { margin-top: 12px; }
.setting-row .seg { margin: 0; }

/* charts */
.bchart, .lchart { direction: ltr; }
.bchart-plot, .lchart-plot { position: relative; height: 150px; margin: 18px 0 0; border-bottom: 1px solid var(--axis); }
.bchart-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.bcol { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bcol .bar { width: 100%; background: var(--c); border-radius: 4px 4px 0 0; transition: filter 0.15s, height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bcol:hover .bar, .bcol:focus .bar { filter: brightness(1.15) saturate(1.1); }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.gridline i, .goalline i { position: absolute; left: 0; bottom: 2px; font-style: normal; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.goalline { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--ink-2); opacity: 0.55; z-index: 1; pointer-events: none; }
.goalline i { left: auto; right: 0; color: var(--ink-2); font-weight: 650; }
.chart-x { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); direction: ltr; }
.lchart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.lchart path { fill: none; stroke: var(--c); stroke-width: 2px; stroke-linejoin: round; }
.lchart .dot {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 0 2px var(--surface);
}
.heat { display: flex; flex-direction: column; gap: 3px; }
.heat-row { display: flex; align-items: center; gap: 8px; }
.heat-label { width: 58px; flex: none; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.heat-cells { flex: 1; display: flex; gap: 2px; direction: ltr; }
.heat-row .chart-x { flex: 1; }
.cell { flex: 1; aspect-ratio: 1; border-radius: 3px; background: var(--grid); min-width: 0; }
.cell.s-ontime, .swatch.s-ontime { background: var(--good); }
.cell.s-late, .swatch.s-late { background: var(--warn); }
.cell.s-missed, .swatch.s-missed { background: var(--bad); }
.swatch.s-none { background: var(--grid); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hbars li { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.hb-label { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 14px; border-radius: 0 4px 4px 0; background: var(--surface-2); overflow: hidden; }
[dir="rtl"] .hb-track { border-radius: 4px 0 0 4px; }
.hb-fill { display: block; height: 100%; background: var(--c); border-radius: inherit; }
.hb-value { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 650; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.badge {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 12px 8px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px;
}
.badge-icon { font-size: 32px; filter: grayscale(1); opacity: 0.4; }
.badge.earned { background: linear-gradient(160deg, color-mix(in srgb, #eda100 18%, var(--surface)), color-mix(in srgb, #1baf7a 12%, var(--surface))); border-color: color-mix(in srgb, #eda100 45%, transparent); }
.badge.earned .badge-icon { filter: none; opacity: 1; animation: shine 3s ease-in-out infinite; }
.badge .meter { width: 100%; }
@keyframes shine { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg) scale(1.06); } }

/* ---------- family ---------- */
.family-hero { padding-bottom: 16px; }
.family-hero .hero-hello { text-align: center; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin-top: 14px; }
.podium-spot { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 32%; max-width: 150px; text-align: center; }
.podium-spot b { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-spot small { color: rgba(255, 255, 255, 0.8); font-weight: 650; }
.podium-block {
  width: 100%; display: grid; place-items: center; font-size: 28px; border-radius: 16px 16px 6px 6px;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.2);
}
.p1 .podium-block { height: 96px; background: rgba(255, 214, 102, 0.28); }
.p2 .podium-block { height: 70px; }
.p3 .podium-block { height: 52px; }
.p1 .avatar { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.lb-rank { width: 28px; text-align: center; font-weight: 800; font-size: 18px; flex: none; }
.lb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mini-chip { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.lb-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.lb-bar span { display: block; height: 100%; background: var(--mc); border-radius: inherit; transition: width 0.6s; }
.lb-sub { font-size: 12.5px; }
.lb-rings { display: flex; gap: 2px; flex: none; }
.lb-rings .ring-text { font-size: 0; }

/* ---------- settings ---------- */
.profile-card { display: flex; align-items: center; gap: 16px; }
.profile-card h2 { font-size: 20px; }
.member-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.member-list > li { padding: 10px 12px; border-radius: 16px; background: var(--surface-2); }
.member-row { display: flex; align-items: center; gap: 12px; }
.avatar-pick, .color-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-pick input, .color-pick input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-pick span {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; font-size: 22px;
  background: var(--surface); border: 2px solid var(--line); cursor: pointer; transition: transform 0.12s;
}
.avatar-pick input:checked + span { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.08); }
.avatar-pick input:focus-visible + span, .color-pick input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.color-pick span { display: block; width: 32px; height: 32px; border-radius: 50%; background: var(--mc); cursor: pointer; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.color-pick input:checked + span { box-shadow: 0 0 0 3px var(--mc); }
.privacy { text-align: center; font-size: 13px; color: var(--ink-2); margin: 4px 12px; }

/* ---------- auth ---------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; }
.float-lang { position: absolute; top: max(16px, env(safe-area-inset-top)); inset-inline-end: 16px; }
.auth-card {
  width: min(460px, 100%); padding: 28px 22px; border-radius: 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lift);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.auth-card .stack-form { text-align: start; }
.auth-card h1 { font-size: 26px; margin-top: 8px; }
.auth-logo {
  display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto; border-radius: 24px; font-size: 40px;
  background: linear-gradient(135deg, #1baf7a, #2a78d6); box-shadow: 0 12px 30px rgba(27, 175, 122, 0.35);
  animation: bob 3s ease-in-out infinite;
}
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin-top: 18px; }
.who {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 8px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; transition: transform 0.15s, box-shadow 0.2s;
}
.who:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.who:active { transform: scale(0.96); }
.login-pick { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 18px 0 4px; }
.center-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-2); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- feedback ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 100px; transform: translate(-50%, 0);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 16px; font-weight: 700;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lift);
  animation: toast-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
.toast.gain { background: linear-gradient(135deg, #0e7a64, #2a78d6); color: #fff; }
.toast.error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translate(-50%, 10px); transition: opacity 0.3s, transform 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 20px) scale(0.9); } }
.tooltip {
  position: absolute; z-index: 70; max-width: 260px; padding: 7px 10px; border-radius: 10px; pointer-events: none;
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600; opacity: 0; transition: opacity 0.12s;
}
.tooltip.show { opacity: 1; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px;
  animation: fall 2.2s cubic-bezier(0.25, 0.6, 0.4, 1) forwards;
}
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); opacity: 0.9; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- layout breakpoints ---------- */
@media (max-width: 520px) {
  .pill-label { display: none; }
  .pill { min-width: 42px; justify-content: center; padding: 6px 8px; }
  .hero-points b { font-size: 38px; }
  .brand-name small { display: none; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input[name="title"] { flex-basis: 100%; }
  .inline-form input[type="date"] { flex: 1; width: auto; }
  .streaks { grid-template-columns: repeat(2, 1fr); }
  .lb-rings { display: none; }
  .hbars li { grid-template-columns: 80px 1fr auto; }
}
@media (max-width: 420px) {
  .brand-name { display: none; }
}
@media (max-width: 380px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (min-width: 1000px) {
  .view { max-width: 1080px; }
  .cards { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .cards .cat-edu { grid-column: 1 / -1; }
}
.who.no-pass { opacity: 0.6; }
.who small { font-size: 12px; font-weight: 600; }
