/* سكوري · Mon Score — Layout: single phone column; sticky header with segmented tabs;
   a bulletin-style grade sheet; a docked result strip that reads like an official score slip. */
:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --ink: #16181D;
  --muted: #5E6470;
  --line: #E1E3E8;
  --field: #F7F8FA;
  --red: #B5172B;
  --red-ink: #FFFFFF;
  --red-soft: #FBE9EB;
  --ok: #17794A;
  --ok-soft: #E3F4EA;
  --warn: #A15C00;
  --warn-soft: #FFF1DC;
  --shadow: 0 1px 0 rgba(22,24,29,.05), 0 10px 24px -16px rgba(22,24,29,.35);
  --f: "Readex Pro", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  --r: 14px;
  --col: 560px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #1A1D23; --ink: #EEF0F3; --muted: #A0A6B1; --line: #2B2F37; --field: #22262D;
    --red: #F0566A; --red-ink: #1A0B0E; --red-soft: #3A1E23; --ok: #5FD394; --ok-soft: #1B3326; --warn: #F2B35B; --warn-soft: #3A2C17;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 24px -16px rgba(0,0,0,.7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #1A1D23; --ink: #EEF0F3; --muted: #A0A6B1; --line: #2B2F37; --field: #22262D;
  --red: #F0566A; --red-ink: #1A0B0E; --red-soft: #3A1E23; --ok: #5FD394; --ok-soft: #1B3326; --warn: #F2B35B; --warn-soft: #3A2C17;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 24px -16px rgba(0,0,0,.7); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15.5px/1.65 var(--f); min-height: 100%; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--surface); z-index: 30; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { margin: 0; line-height: 1.35; font-weight: 600; text-wrap: balance; }
h2 { font-size: 1.12rem; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.wrap { max-width: var(--col); margin-inline: 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: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px 6px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand b { display: block; font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.mark { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--red); color: var(--red-ink); display: grid; place-items: center; }
.mark svg { width: 24px; height: 24px; }
.lang { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding-block: 6px 10px; }
.tabs button { border: 0; background: transparent; padding: 8px 4px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--red-soft); color: var(--red); }

main { display: grid; gap: 16px; padding-block: 16px 150px; }
main.no-dock { padding-bottom: 40px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.label { font-size: .82rem; font-weight: 600; color: var(--muted); letter-spacing: .01em; }

/* section chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: .9rem; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--red); background: var(--red); color: var(--red-ink); font-weight: 600; }

/* grade sheet */
.sheet { display: grid; }
.row { display: grid; grid-template-columns: 1fr auto 76px; align-items: center; gap: 10px; padding-block: 8px; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
.row.ctrl-on { grid-template-columns: 1fr auto 70px 70px; }
.row .name { min-width: 0; font-size: .95rem; line-height: 1.35; }
.row .c { font-size: .78rem; color: var(--muted); background: var(--field); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
.row .fgmark { color: var(--red); font-weight: 700; margin-inline-start: 4px; }
.in { width: 100%; min-height: 44px; border: 1.5px solid var(--line); background: var(--field); border-radius: 10px; padding: 6px 8px; text-align: center; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.in:focus { border-color: var(--red); background: var(--surface); outline: none; }
.in.bad { border-color: var(--red); background: var(--red-soft); }
.in.ctrl { border-style: dashed; }
.colhead { display: grid; grid-template-columns: 1fr auto 76px; gap: 10px; font-size: .75rem; color: var(--muted); padding-bottom: 2px; }
.colhead.ctrl-on { grid-template-columns: 1fr auto 70px 70px; }
.colhead span:nth-child(n+3) { text-align: center; }

.toggles { display: grid; gap: 4px; }
.tog { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.tog input { width: 20px; height: 20px; accent-color: var(--red); flex: none; }
.hint { font-size: .8rem; color: var(--muted); }
.optrow { display: grid; grid-template-columns: 1fr 76px; gap: 10px; align-items: center; }

/* result */
.dock { position: fixed; inset: auto 0 0 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -10px 24px -18px rgba(0,0,0,.4); padding-bottom: env(safe-area-inset-bottom, 0px); }
.dock .wrap { padding-block: 10px 12px; display: grid; gap: 8px; }
.slip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { display: grid; gap: 0; }
.stat .k { font-size: .75rem; color: var(--muted); }
.stat .v { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.stat.main .v { color: var(--red); }
.stat .sub { font-size: .78rem; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; justify-self: start; }
.status.pass { background: var(--ok-soft); color: var(--ok); }
.status.control { background: var(--warn-soft); color: var(--warn); }
.status.fail { background: var(--red-soft); color: var(--red); }
.dock-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; font-size: .9rem; }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--red-ink); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

details.calc summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.formula { font-size: .85rem; overflow-x: auto; background: var(--field); border-radius: 10px; padding: 10px 12px; margin-top: 8px; line-height: 1.9; }

.big { display: grid; justify-items: center; gap: 2px; text-align: center; padding-block: 8px; }
.big .v { font-size: 2.6rem; font-weight: 700; color: var(--red); line-height: 1.1; }
.note { font-size: .82rem; color: var(--muted); border-inline-start: 3px solid var(--line); padding-inline-start: 10px; }

/* avg rows */
.arow { display: grid; grid-template-columns: 1fr 52px 70px 32px; gap: 8px; align-items: center; }
.arow input.name-in { text-align: start; }
.del { border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 1.2rem; }
.del:hover { color: var(--red); background: var(--red-soft); }
.tri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tri label { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
select.in { text-align: start; }

.foot { font-size: .78rem; color: var(--muted); text-align: center; padding-block: 4px 0; }
.foot a { color: inherit; }

.toast { position: fixed; z-index: 40; inset-inline: 16px; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); max-width: 360px; margin-inline: auto; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; text-align: center; font-weight: 600; }

@media (max-width: 360px) {
  .row, .colhead { grid-template-columns: 1fr auto 64px; }
  .row.ctrl-on, .colhead.ctrl-on { grid-template-columns: 1fr 60px 60px; }
  .row.ctrl-on .c, .colhead.ctrl-on span:nth-child(2) { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.big .sub, .stat .v small { font-size: .45em; color: var(--muted); font-weight: 600; }
