/* FADISHA. Layout: sticky top bar with child tabs; one centered column of rounded cards below.
   Light theme only, on purpose: pages get printed at home and a dark page wastes ink.
   Each exam day keeps the color of the school's own schedule poster. */
@font-face { font-family: "Baloo 2"; font-weight: 600; font-display: swap; src: url("../fonts/baloo-2-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Baloo 2"; font-weight: 700; font-display: swap; src: url("../fonts/baloo-2-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Baloo 2"; font-weight: 800; font-display: swap; src: url("../fonts/baloo-2-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 500; font-display: swap; src: url("../fonts/nunito-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("../fonts/nunito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url("../fonts/nunito-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Noto Naskh Arabic"; font-weight: 500; font-display: swap; src: url("../fonts/noto-naskh-arabic-arabic-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Noto Naskh Arabic"; font-weight: 700; font-display: swap; src: url("../fonts/noto-naskh-arabic-arabic-700-normal.woff2") format("woff2"); }
/* Klee One: textbook-style kana, so the letter looks like the one Faiz writes by hand. */
@font-face { font-family: "Klee One"; font-weight: 600; font-display: swap; src: url("../fonts/klee-one-119-600-normal.woff2") format("woff2"); unicode-range: U+3041-307F, U+3081-308F, U+3091-3093, U+3099-309E; }
@font-face { font-family: "Klee One"; font-weight: 600; font-display: swap; src: url("../fonts/klee-one-115-600-normal.woff2") format("woff2"); unicode-range: U+3080; }

:root {
  --sky: #dff1fb; --sky2: #c4e4f7; --paper: #ffffff; --ink: #22314a; --muted: #56647c; --line: #d3e2ee; --guide: #e8a0a0;
  --pink: #d93a70; --amber: #b96f00; --blue: #1f6fcf; --purple: #7446c9; --green: #178a50; --green-dark: #10603a; --red: #c8332b;
  --skin: #f1c59b; --hair: #3a2a20; --mark: #e5352b; --gold: #f5b300; --mat: #2c9c63; --ghost: #e4ebf2;
  --s1: #e5352b; --s2: #1f6fcf; --s3: #178a50; --s4: #b96f00; --s5: #7446c9; --s6: #d93a70;
  --f-display: "Baloo 2", "Nunito", system-ui, sans-serif;
  --f-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-ar: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", serif;
  --f-kana: "Klee One", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --day: var(--green);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(140px + env(safe-area-inset-top, 0px)); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--sky); color: var(--ink); font: 500 16px/1.55 var(--f-body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--blue); }
.wrap { max-width: 780px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { text-align: center; padding-block: 30vh; color: var(--muted); font-weight: 700; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 8px; }

/* ---------- top bar + tabs ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--paper); border-bottom: 2px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 10px; padding-block: 8px; }
.brand { font: 800 1rem/1 var(--f-display); letter-spacing: .12em; color: var(--green); text-decoration: none; flex: none; }
.tabs { display: flex; gap: 6px; flex: 1; min-width: 0; justify-content: center; }
.tab { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px; text-decoration: none; color: var(--ink); border: 2px solid transparent; min-width: 0; }
.tab-av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 800 1.05rem/1 var(--f-display); color: #fff; background: var(--tc); }
.tab-txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.tab-txt b { font: 700 .98rem/1.15 var(--f-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-txt small { font-size: .72rem; color: var(--muted); font-weight: 700; }
.t-pink { --tc: var(--pink); } .t-blue { --tc: var(--blue); }
.tab[aria-selected="true"] { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 9%, var(--paper)); }
.tab:not([aria-selected="true"]) .tab-av { background: color-mix(in srgb, var(--tc) 45%, var(--paper)); }
.progress-row { padding-block: 0 8px; }
.progress { display: flex; align-items: center; gap: 10px; }
.progress-txt { display: flex; align-items: center; gap: 6px; font-size: .9rem; white-space: nowrap; }
.progress-txt svg { width: 20px; height: 20px; fill: var(--gold); }
.bar { flex: 1; height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .35s; }
.demo-banner { margin-top: 10px; background: #fff6da; border: 2px dashed var(--gold); border-radius: 14px; padding-block: 6px; font-size: .88rem; font-weight: 700; color: var(--amber); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid transparent; font-weight: 800; cursor: pointer; background: var(--paper); }
.btn svg { flex: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-rec { background: var(--day); color: #fff; }
.btn-rec-live { background: var(--red); color: #fff; }
.btn-play { background: color-mix(in srgb, var(--day) 12%, var(--paper)); color: var(--day); border-color: color-mix(in srgb, var(--day) 40%, var(--paper)); }
.btn-ghost { border-color: var(--line); }
.btn-danger { background: var(--red); color: #fff; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--ink); }
.spin { display: inline-block; width: 16px; height: 16px; border: 3px solid var(--line); border-top-color: var(--day); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- hero + day navigation ---------- */
main { padding-bottom: 32px; }
.hero { text-align: center; padding-block: 22px 8px; }
.school { display: inline-block; font: 700 .82rem/1.6 var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--green); background: var(--paper); border: 2px dashed var(--line); border-radius: 999px; padding: 1px 14px; }
.hero h1 { font: 800 clamp(1.8rem, 6.5vw, 2.6rem)/1.1 var(--f-display); margin: 10px 0 4px; color: var(--green); text-wrap: balance; }
.hero-faiz .school { color: var(--blue); } .hero-faiz h1 { color: var(--blue); }
.sub { color: var(--muted); margin: 0; font-weight: 700; }
.daynav { display: flex; gap: 8px; overflow-x: auto; padding-block: 12px 4px; scrollbar-width: none; }
.daynav button { flex: none; font: 700 .95rem/1 var(--f-display); color: #fff; background: var(--day); border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer; }
.d-pink { --day: var(--pink); } .d-amber { --day: var(--amber); } .d-blue { --day: var(--blue); } .d-purple { --day: var(--purple); } .d-green { --day: var(--green); }

.day { --tint: color-mix(in srgb, var(--day) 9%, var(--paper)); margin-top: 26px; }
.dayhead { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.blob { flex: none; width: 88px; background: var(--day); color: #fff; border-radius: 26px 26px 26px 8px; text-align: center; padding: 8px 6px; font-family: var(--f-display); line-height: 1.05; }
.blob .dn { font-weight: 700; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; }
.blob .dd { font-weight: 800; font-size: 2rem; }
.blob .dm { font-weight: 600; font-size: .78rem; }
.dayhead h2 { font: 800 1.5rem/1.15 var(--f-display); margin: 0; color: var(--day); text-wrap: balance; }
.dayhead p { margin: 2px 0 0; color: var(--muted); font-size: .95rem; }

/* ---------- cards ---------- */
.cards { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--paper); border: 2px solid color-mix(in srgb, var(--day) 32%, var(--line)); border-radius: 22px; padding: 14px 16px 16px; }
.chead { display: flex; align-items: center; gap: 10px; }
.ico { flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--tint); display: grid; place-items: center; }
.ico-txt { font: 700 1.1rem/1 var(--f-ar); color: var(--day); }
.ico-art svg { width: 30px; height: 30px; }
.chead h4 { flex: 1; min-width: 0; margin: 0; font: 700 1.2rem/1.2 var(--f-display); }
.chead h4 small { display: block; font: 800 .74rem/1.4 var(--f-body); color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.star { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); cursor: pointer; display: grid; place-items: center; padding: 0; }
.star svg path, .btn-star svg path { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; }
.star[aria-pressed="true"] { border-color: var(--gold); background: #fff6da; }
.star[aria-pressed="true"] svg path, .btn-star[aria-pressed="true"] svg path { fill: var(--gold); stroke: var(--gold); }
.entry { margin-top: 12px; }
.entry + .entry { border-top: 2px dashed var(--line); padding-top: 12px; }
.lab { display: inline-block; font-weight: 800; font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--day); border-radius: 8px; padding: 1px 9px; margin-bottom: 4px; }
.ar { font-family: var(--f-ar); font-size: clamp(2.05rem, 8.4vw, 2.7rem); line-height: 2.05; text-align: right; margin: 2px 0 4px; font-weight: 500; }
.lat { color: var(--day); font-weight: 800; font-size: 1.06rem; margin: 0; }
.idn { margin: 4px 0 0; } .idn b { color: var(--muted); }
.src { margin: 8px 0 0; font-size: .84rem; color: var(--muted); font-weight: 700; }
.pic { display: flex; justify-content: center; margin-top: 8px; } .pic svg { width: 150px; height: auto; max-width: 100%; }
.hint { color: var(--muted); font-size: .92rem; margin: 12px 0 0; }
.note-box { margin-top: 12px; background: var(--tint); border-radius: 14px; padding: 8px 12px; font-size: .92rem; }
.note-box summary { cursor: pointer; font-weight: 800; color: var(--day); min-height: 32px; display: flex; align-items: center; }
.note-box .ar { font-size: 1.9rem; }
.note-box p { margin: 6px 0; }

/* recorder */
.rec { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--tint); }
.rec-meta { font-size: .82rem; color: var(--muted); font-weight: 700; }
.rec-tools { display: flex; gap: 6px; margin-left: auto; }
.rec-live { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--red); }
.rec-live .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: pulse 1s ease-in-out infinite; }
.rec-status { font-weight: 800; color: var(--muted); }
@keyframes pulse { 50% { opacity: .25; } }

/* number, body and name grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.tile { background: var(--paper); border: 2px solid color-mix(in srgb, var(--day) 30%, var(--line)); border-radius: 18px; padding: 10px 8px 12px; text-align: center; min-width: 0; }
.tile .num { font: 700 3rem/1.25 var(--f-ar); color: var(--day); }
.tile .latn { font: 800 .95rem/1 var(--f-display); color: var(--muted); }
.dots { display: grid; grid-template-columns: repeat(5, 12px); gap: 4px; justify-content: center; margin: 6px auto 4px; min-height: 28px; align-content: center; }
.dots.many { grid-template-columns: repeat(10, 8px); gap: 3px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); }
.dots.many i { width: 8px; height: 8px; }
.dots.many i:nth-child(n+11) { background: var(--day); } .dots.many i:nth-child(n+21) { background: var(--mark); }
.tile .w { font: 500 2.1rem/1.85 var(--f-ar); }
.tile .r { color: var(--day); font-weight: 800; margin: 0; overflow-wrap: anywhere; }
.tile .m { margin: 0; font-weight: 700; }
.tile .art { height: 104px; display: grid; place-items: center; }
.tile .art svg { height: 100px; width: auto; max-width: 100%; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.name { border: 2px solid color-mix(in srgb, var(--day) 30%, var(--line)); border-radius: 18px; padding: 8px 14px; display: flex; align-items: center; gap: 12px; min-width: 0; }
.name .n { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--day); color: #fff; display: grid; place-items: center; font: 800 1.05rem/1 var(--f-display); }
.name > div { min-width: 0; flex: 1; }
.name .w { font: 500 2.3rem/1.75 var(--f-ar); text-align: right; }
.name .r { color: var(--day); font-weight: 800; margin: 0; } .name .m { margin: 0; }

/* ---------- Faiz: hiragana ---------- */
.howto { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; margin: 14px 0 0; }
.howto li { counter-increment: s; background: var(--paper); border: 2px solid var(--line); border-radius: 16px; padding: 8px 10px; font-size: .92rem; display: flex; align-items: center; gap: 8px; min-width: 0; }
.howto li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font: 800 .9rem/1 var(--f-display); }
.howto b { color: var(--blue); }
.kana-section { margin-top: 26px; }
.kana-section h2 { font: 800 1.4rem/1.2 var(--f-display); color: var(--blue); margin: 0 0 4px; }
.kana-section .hint { margin: 0 0 10px; }
.kana-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.kana-col { text-align: center; font: 800 .8rem/1 var(--f-display); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.kana { position: relative; aspect-ratio: 1 / 1.08; border-radius: 18px; border: 2px solid var(--line); background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 2px 6px; cursor: pointer; min-width: 0; max-width: 100%; }
.kana-empty { border-style: dashed; background: transparent; cursor: default; opacity: .5; }
.kana-ch { font: 600 clamp(1.9rem, 9vw, 3rem)/1.1 var(--f-kana); }
.kana-ro { font: 800 .9rem/1 var(--f-display); color: var(--blue); }
.kana-flags { position: absolute; top: 5px; right: 6px; display: flex; gap: 3px; }
.kana-flags i { width: 10px; height: 10px; border-radius: 50%; display: none; }
.kana.is-done { border-color: var(--gold); background: #fffaea; }
.kana.is-done .f-star { display: block; background: var(--gold); }
.kana.has-photo .f-photo { display: block; background: var(--blue); }
.credit { font-size: .8rem; color: var(--muted); margin-top: 20px; }

.kana-dialog { border: 0; padding: 0; border-radius: 24px; width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgb(20 40 70 / .3); }
.kana-dialog::backdrop { background: rgb(20 40 70 / .45); }
.kd { padding: 14px 16px 18px; }
.kd-head { display: flex; align-items: center; gap: 8px; }
.kd-head h2 { flex: 1; text-align: center; margin: 0; font: 800 2rem/1.1 var(--f-display); }
.kd-head h2 span { font-family: var(--f-kana); font-weight: 600; }
.kd-head h2 small { color: var(--blue); font-size: 1.3rem; }
.kd-close { margin-left: 6px; }
.kd-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.kd-model, .kd-practice { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stroke-svg { width: 100%; max-width: 360px; height: auto; margin: 0 auto; display: block; }
.stroke-svg .ghost { fill: none; stroke: var(--ghost); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.stroke-svg .stroke { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.stroke-svg .snum text { font: 800 6.5px/1 var(--f-body); fill: #fff; }
.stroke-svg .snum { opacity: 0; }
.kd-controls { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.step-label { font-weight: 800; color: var(--muted); min-width: 9.5em; text-align: center; font-variant-numeric: tabular-nums; }
.kd-practice h3 { margin: 0; font: 800 1.15rem/1.2 var(--f-display); color: var(--blue); }
.photo { display: flex; flex-direction: column; gap: 10px; --day: var(--blue); }
.photo-frame { aspect-ratio: 1; border-radius: 16px; border: 2px dashed var(--line); background: var(--sky); overflow: hidden; display: grid; place-items: center; }
.photo-frame img { width: 100%; height: 100%; object-fit: contain; background: var(--paper); }
.photo-empty { text-align: center; color: var(--muted); font-weight: 700; padding: 16px; }
.photo-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-star { border-color: var(--line); align-self: flex-start; }
.btn-star[aria-pressed="true"] { border-color: var(--gold); background: #fff6da; }
@media (max-width: 620px) { .kd-body { grid-template-columns: 1fr; } .kana-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; } .howto { grid-template-columns: 1fr; } }

/* ---------- PIN ---------- */
.pin-screen { position: fixed; inset: 0; z-index: 50; background: var(--sky); display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); overflow-y: auto; }
.pin-card { width: min(340px, 100%); background: var(--paper); border: 2px solid var(--line); border-radius: 28px; padding: 24px 20px; text-align: center; }
.pin-card.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-lock { width: 56px; height: 56px; margin: 0 auto 8px; border-radius: 18px; background: #e6f4ec; color: var(--green); display: grid; place-items: center; }
.pin-lock svg { width: 28px; height: 28px; }
.pin-card h1 { font: 800 1.45rem/1.2 var(--f-display); margin: 0; color: var(--green); }
.pin-msg { color: var(--muted); font-size: .92rem; margin: 6px 0 14px; min-height: 2.8em; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots i.on { background: var(--green); border-color: var(--green); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { height: 60px; border-radius: 18px; border: 2px solid var(--line); background: var(--paper); font: 800 1.5rem/1 var(--f-display); cursor: pointer; display: grid; place-items: center; }
.pin-pad button:active { background: var(--sky); }

/* ---------- toasts + footer ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 14px; font-weight: 700; font-size: .92rem; transition: opacity .3s, transform .3s; }
.toast-ok { background: var(--green-dark); } .toast-error { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(8px); }
.foot { color: var(--muted); font-size: .8rem; text-align: center; padding-block: 8px 28px; }

@media (max-width: 520px) {
  .brand, .print-btn { display: none !important; }
  .tabs { justify-content: stretch; } .tab { flex: 1; }
}

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

/* ---------- print: white pages, only the open tab, no buttons ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; }
  body::before, .topbar, .demo-banner, .daynav, .star, .rec, .foot, .howto, .kana-dialog, #toasts, .pin-screen { display: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hero { padding-block: 0 6px; }
  .day { break-before: page; margin-top: 0; } .day:first-of-type { break-before: auto; }
  .tile, .name, .entry, .dayhead, .chead, .note-box, .kana { break-inside: avoid; }
  .chead, .dayhead { break-after: avoid; }
  .cards { display: block; } .card { margin-bottom: 10px; }
  .note-box { background: none; border: 1px dashed var(--line); }
  .grid { grid-template-columns: repeat(4, 1fr); } .names { grid-template-columns: repeat(2, 1fr); }
  .ar { font-size: 2.3rem; line-height: 2; }
}
