/* Hajiri — same visual family as Taas Scorebook: indigo felt header, Mukta body, Rozha One headings. */
:root {
  --bg: #f2f4fa; --surface: #ffffff; --surface-2: #eef1f8; --ink: #151b30; --muted: #5a6382; --line: #dce1ee;
  --felt: #1f2b5c; --felt-ink: #ffffff; --felt-muted: #b7c0e3; --felt-sunk: #17214b;
  --primary: #3550e0; --primary-ink: #ffffff;
  --pos: #12825a; --pos-bg: #e3f4ec; --neg: #d23f4b; --neg-bg: #fde8ea; --gold: #a8670f; --gold-bg: #fff3d9;
  --f-display: "Rozha One", Georgia, "Times New Roman", serif;
  --f-body: "Mukta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f1e; --surface: #131a2d; --surface-2: #1a2238; --ink: #e7ebf7; --muted: #97a1bf; --line: #27304b;
    --felt: #10172c; --felt-ink: #e7ebf7; --felt-muted: #8e98ba; --felt-sunk: #0a0f20;
    --primary: #7d91ff; --primary-ink: #0b0f1e;
    --pos: #4ed39a; --pos-bg: #12271f; --neg: #ff7d86; --neg-bg: #2e1519; --gold: #f0bd5e; --gold-bg: #2a2313;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f1e; --surface: #131a2d; --surface-2: #1a2238; --ink: #e7ebf7; --muted: #97a1bf; --line: #27304b;
  --felt: #10172c; --felt-ink: #e7ebf7; --felt-muted: #8e98ba; --felt-sunk: #0a0f20;
  --primary: #7d91ff; --primary-ink: #0b0f1e;
  --pos: #4ed39a; --pos-bg: #12271f; --neg: #ff7d86; --neg-bg: #2e1519; --gold: #f0bd5e; --gold-bg: #2a2313;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--f-body); min-height: 100vh; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--felt); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-family: var(--f-display); font-weight: 400; font-size: 30px; line-height: 1.1; }
h2 { font-size: 19px; font-weight: 700; line-height: 1.25; }
p { margin: 0; }
small { color: var(--muted); }
[hidden] { display: none !important; }

.wrap { max-width: 680px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6; background: var(--felt); color: var(--felt-ink); box-shadow: 0 1px 0 var(--felt-sunk); }
.top .wrap { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 8px; color: inherit; text-decoration: none; }
.brand .dev { font-family: var(--f-display); font-size: 28px; line-height: 1; }
.brand .en { font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; color: var(--felt-muted); }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--felt-sunk); color: var(--felt-ink); font-weight: 700; font-size: 15px; border: 1px solid var(--felt-muted); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 6px; display: grid; }
.menu-pop a, .menu-pop button { display: block; text-align: left; padding: 10px 12px; border-radius: 8px; border: 0; background: none; color: var(--ink); text-decoration: none; font-weight: 600; cursor: pointer; min-height: 44px; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.menu-who span { color: var(--muted); font-size: 14px; }
.menu-note { padding: 8px 12px; font-size: 13px; color: var(--muted); }

main.wrap { padding-top: 20px; padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 16px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel.empty { text-align: left; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lede { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.err { color: var(--neg); font-size: 14px; font-weight: 600; }
.err:empty { display: none; }
.lbl { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sechead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.loading { padding: 24px 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 15px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; min-height: 44px; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--neg); }
.btn.sm { min-height: 36px; padding: 5px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.armed, .x.armed { background: var(--neg); color: #fff; border-color: var(--neg); }
.btn.busy { opacity: .6; pointer-events: none; }
.x { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 0 12px; height: 36px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.actions.start { justify-content: flex-start; }
.iconbtn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 24px; line-height: 1; cursor: pointer; flex: none; }
.iconbtn:disabled { opacity: .3; cursor: not-allowed; }

/* forms */
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), textarea {
  font: 500 16px var(--f-body); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); width: 100%; min-width: 0; }
textarea { font: 500 15px/1.5 var(--f-num); resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
.field { display: grid; gap: 4px; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
form { display: grid; gap: 12px; }
.auth { max-width: 420px; width: 100%; justify-self: center; margin-top: 12px; }
.auth form { margin-top: 4px; }
input[name=pin], input[name=pin2] { font-family: var(--f-num); letter-spacing: .3em; font-size: 20px; }

/* home */
.hello { display: grid; gap: 2px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ccard { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); text-decoration: none; min-height: 72px; }
.ccard:hover { border-color: var(--primary); }
.ccard .cname { font-weight: 700; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.ccard .cmeta { grid-column: 1; font-size: 14px; color: var(--muted); }
.ccard .pill { grid-column: 2; grid-row: 1 / span 2; }
.addform { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.archived summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 8px 0; }
.archived .cards { margin-top: 8px; }
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font: 600 13px var(--f-body); background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--pos); border-color: var(--pos); background: var(--pos-bg); }
.pill.warn { color: var(--neg); border-color: var(--neg); background: var(--neg-bg); }
.badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); vertical-align: 2px; }

/* class header + section nav */
.back { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; justify-self: start; padding: 4px 0; }
.seg-nav { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg-nav a { flex: 1; text-align: center; padding: 8px 6px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; min-height: 40px; display: grid; place-items: center; }
.seg-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* attendance */
.datebar { display: flex; gap: 8px; align-items: center; }
.datepick { flex: 1; position: relative; display: grid; place-items: center; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-weight: 700; cursor: pointer; }
.datepick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.banner { padding: 10px 14px; border-radius: 10px; background: var(--gold-bg); border: 1px solid var(--gold); font-size: 15px; }
.banner.ok { background: var(--pos-bg); border-color: var(--pos); }
.filter { margin: 0; }
.roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.srow { width: 100%; display: grid; grid-template-columns: 4.2em minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; min-height: 56px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.srow .roll, .roll { font-family: var(--f-num); font-weight: 600; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.srow .sname { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.srow .mark { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; color: var(--pos); background: var(--pos-bg); min-width: 70px; text-align: center; }
.srow.is-absent { background: var(--neg-bg); border-color: var(--neg); }
.srow.is-absent .sname { color: var(--neg); }
.srow.is-absent .mark { color: #fff; background: var(--neg); }
@media (prefers-reduced-motion: no-preference) { .srow { transition: background-color .12s, border-color .12s; } }
.dayactions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.attbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(0,0,0,.06);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.attbar .in { max-width: 648px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.counts { font-size: 16px; font-weight: 600; }
.counts b { font-family: var(--f-num); font-size: 20px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.sync { font-size: 14px; font-weight: 600; color: var(--pos); }
.sync.wait { color: var(--gold); }

/* students */
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.slist { list-style: none; margin: 0; padding: 0; display: grid; }
.sitem { display: grid; grid-template-columns: 4.2em minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); min-height: 52px; }
.sitem .sname { font-weight: 600; overflow-wrap: anywhere; }
.sedit { padding: 10px 0; border-top: 1px solid var(--line); }
.sedit form { grid-template-columns: 6em minmax(0, 1fr); gap: 8px; }
.sedit .actions { grid-column: 1 / -1; }
.addone { grid-template-columns: 6em minmax(0, 1fr) auto; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.removed summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.chip.pos { color: var(--pos); border-color: var(--pos); background: var(--pos-bg); }
.chip.neg { color: var(--neg); border-color: var(--neg); background: var(--neg-bg); }
.preview { border-color: var(--primary); }
.preview details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.plist { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 2px; font-size: 15px; }
.choice { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 0; display: grid; gap: 6px; }
.choice legend { font-weight: 700; padding: 0 4px; }
.choice label { display: flex; gap: 10px; align-items: center; min-height: 36px; cursor: pointer; }
.choice input { width: 20px; height: 20px; accent-color: var(--primary); }

/* report */
.statrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 2px; }
.stat b { font-family: var(--f-num); font-size: 24px; font-weight: 600; }
.stat.warn { border-color: var(--neg); background: var(--neg-bg); }
.stat.warn b { color: var(--neg); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 36px; padding: 0 12px; border: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); }
thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-family: var(--f-num); }
tr.low td { background: var(--neg-bg); }
tr.low .pct { color: var(--neg); font-weight: 700; }
.daylist { list-style: none; margin: 0; padding: 0; display: grid; }
.daylist a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; min-height: 48px; align-items: center; }
.daylist a:hover { color: var(--primary); }
.dcount { font-family: var(--f-num); font-size: 14px; color: var(--muted); }
.settings { grid-template-columns: minmax(0, 1fr) 9em auto; align-items: end; gap: 8px; }

/* admin */
.tlist { list-style: none; margin: 0; padding: 0; display: grid; }
.titem { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.titem.off { opacity: .6; }
.share { border-color: var(--pos); }
.linkrow { display: flex; gap: 8px; min-width: 0; }
.linkrow input { flex: 1; font: 500 13px var(--f-num); }

/* toast */
#toast { position: fixed; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 20; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); border-radius: 12px; padding: 12px 16px; font-weight: 600; font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 100%; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .2s ease-out; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 460px) {
  h1 { font-size: 26px; }
  .addform, .settings { grid-template-columns: 1fr; }
  .addone { grid-template-columns: 5em minmax(0, 1fr); }
  .addone .btn { grid-column: 1 / -1; }
  .statrow .stat b { font-size: 20px; }
  .srow, .sitem { grid-template-columns: 3.4em minmax(0, 1fr) auto; }
}
