:root {
  --teal: #0a4f56;
  --teal-logo: #0a4f56;
  --teal-deep: #08383d;
  --teal-soft: #E6F8F9;
  --yellow: #FFC130;
  --yellow-soft: #FFF6E0;
  --charcoal: #343B45;
  --blue: #0C7EF1;
  --board: #DFDFDF;
  --green: #14B8C2;
  --green-dark: #0E8A92;
  --green-soft: #E6F8F9;
  --ink: #343B45;
  --muted: #5B6270;
  --line: #D5D8DC;
  --bg: #F3F4F5;
  --card: #FFFFFF;
  --warn: #8A4B08;
  --warn-bg: #FFF6E0;
  --bad: #9B1C1C;
  --bad-bg: #FDECEC;
  --ok: #14B8C2;
  --radius: 14px;
  --tap: 48px;
  --font: 16px;
  --title: 22px;
}
body.student { --font: 20px; --title: 26px; --tap: 56px; }
body.dark {
  --teal-soft: #14383C;
  --yellow-soft: #3A2E14;
  --ink: #F2F2F2;
  --muted: #B7C0CC;
  --line: #3A4554;
  --bg: #12161C;
  --card: #1C232C;
  --warn: #FFC130;
  --warn-bg: #3A2E14;
  --bad: #E05A5A;
  --bad-bg: #3A1C1C;
  --green-soft: #14383C;
  --green-dark: #7FE0E6;
}
body.dark .topbar { background: #0a4f56; }
body.dark .nav { background: #1C232C; }
body.dark .chip, body.dark .btn.ghost, body.dark input, body.dark select, body.dark textarea, body.dark .help a, body.dark .sheet {
  background: #1C232C; color: var(--ink);
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sr:focus { position: fixed; left: 8px; top: 8px; width: auto; height: auto; clip: auto; overflow: visible; background: #000; color: #fff; padding: 8px 12px; z-index: 80; }
html, body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font-family: var(--kp-font), Outfit, "Noto Sans", "Noto Sans Arabic", "Noto Sans Ethiopic", Arial, Helvetica, sans-serif;
  font-size: var(--font); line-height: 1.35;
}
html[data-kp-lang="ar"] body,
html[data-kp-lang="fa-AF"] body,
html[data-kp-lang="ti"] body { line-height: 1.55; }
html[dir="rtl"] .kb-bar,
html[dir="rtl"] .topbar,
html[dir="rtl"] .nav { direction: ltr; }
body {
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
button:active, .chip:active, .check:active { transform: scale(0.98); }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: var(--title); }
h2 { font-size: calc(var(--font) + 2px); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: var(--teal); color: #fff;
}
.brand { font-weight: 700; letter-spacing: 0.02em; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 28px; height: 28px; min-width: 28px; max-width: 28px; display: block; }
.verchip {
  font-size: 11px; font-weight: 800; background: #FFC130; color: #343B45;
  border-radius: 999px; padding: 3px 8px; letter-spacing: 0.02em; white-space: nowrap;
}
.topbar .tools { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 420px) {
  .topbar { gap: 6px; }
  .topbar button { min-height: 44px; padding: 4px 8px; font-size: 14px; }
  .brand { font-size: 15px; }
}
.topbar button {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.55);
  border-radius: 10px; min-height: 44px; padding: 6px 10px; cursor: pointer;
}
.wrap { max-width: 780px; margin: 0 auto; padding: 10px 12px 8px; }
.compact { padding: 10px 12px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.quick .btn { margin: 0; }
.hidden { display: none !important; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: 0.9em; color: var(--muted); margin: 8px 0 4px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
}
textarea { min-height: 72px; }
.btn {
  min-height: var(--tap); padding: 8px 14px; border: 0; border-radius: 12px;
  background: var(--teal); color: #fff; font-weight: 700; cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--teal-soft); color: var(--teal-deep); }
.btn.accent { background: var(--yellow); color: var(--charcoal); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn.wide { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips-scroll {
  flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px; margin: 0 -12px 10px; padding-left: 12px; padding-right: 12px;
}
.chips-scroll .chip { flex: 0 0 auto; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 12px; min-height: 44px; cursor: pointer; color: var(--ink);
}
.chip.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.timer-time.is-done { background: #ffe14a; color: #000; border-radius: 12px; }
.gloss { display: flex; gap: 8px; flex-wrap: wrap; }
.gloss article, .check { font-size: 14px; }
.gloss article { width: 8rem; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--card); }
.check svg { width: 28px; height: 28px; vertical-align: middle; }
html[data-kp-lang="ar"] .ar-help { display: block; }
.ar-help { display: none; }
.big { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0; }
.formula { color: var(--muted); font-size: 0.9em; }
.muted { color: var(--muted); }
.pill {
  display: inline-block; padding: 4px 8px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-dark); font-size: 0.85em; font-weight: 700;
}
.pill.low { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
}
.nav button {
  border: 0; background: transparent; padding: 8px 2px 10px;
  min-height: 64px; cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 700;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
body.student .nav button { font-size: 13px; }
.nav button.on { color: var(--teal-deep); background: var(--teal-soft); }
.nav span { display: block; font-size: 18px; line-height: 1.2; }
.spool { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; }
.swatch { width: 14px; height: 100%; min-height: 42px; border-radius: 8px; border: 1px solid var(--line); }
.bar { height: 8px; background: var(--board); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--teal); }
.help a {
  display: block; padding: 12px; margin-bottom: 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
  text-decoration: none; font-weight: 700;
}
.help a small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }
.timer-time { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.callout { background: var(--green-soft); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.warnbox { background: var(--warn-bg); color: var(--ink); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; width: min(780px, 100%); max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 16px;
}
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px;
  z-index: 50; max-width: 90%;
}
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; color: var(--ink); }
.check input { width: 26px; min-width: 26px; min-height: 26px; margin-top: 2px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.pill-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 8px 10px; min-height: 44px; cursor: pointer; font-weight: 700;
}
.pill-btn b { color: var(--teal-deep); }
body.dark .pill-btn b { color: #7FE0E6; }
.help a, .ams-slot { background: var(--card); }
.ams-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.ams-slot {
  border: 2px solid var(--line); border-radius: 12px; padding: 10px;
  min-height: 84px; background: #fff;
}
.ams-slot.empty { color: var(--muted); }
.ams-slot i { display: block; width: 18px; height: 18px; border-radius: 50%; margin-bottom: 6px; }
.ams-slot b, .ams-slot span, .ams-slot small { display: block; }
.ams-slot small { color: var(--muted); }
