/* Life in the UK with Reza: iOS-style, mobile first */

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --opt-bg: #f9f9fb;
  --score-bg: #efeff2;
  --expl-bg: #f0f7ff;
  --primary: #007aff;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #e09400;
  --warning-bg: #fff8e6;
  --success-bg: #e9f7ee;
  --danger-bg: #fdecee;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --card: #1c1c1e;
    --text: #e5e5ea;
    --muted: #98989d;
    --border: #38383a;
    --opt-bg: #2c2c2e;
    --score-bg: #2c2c2e;
    --expl-bg: #1a2a3a;
    --primary: #0a84ff;
    --success: #30d158;
    --danger: #ff453a;
    --warning: #fbbf24;
    --warning-bg: #2a2000;
    --success-bg: #12301c;
    --danger-bg: #3a1614;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111113;
  --card: #1c1c1e;
  --text: #e5e5ea;
  --muted: #98989d;
  --border: #38383a;
  --opt-bg: #2c2c2e;
  --score-bg: #2c2c2e;
  --expl-bg: #1a2a3a;
  --primary: #0a84ff;
  --success: #30d158;
  --danger: #ff453a;
  --warning: #fbbf24;
  --warning-bg: #2a2000;
  --success-bg: #12301c;
  --danger-bg: #3a1614;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 16px calc(32px + env(safe-area-inset-bottom));
  outline: none;
}

.loading { color: var(--muted); text-align: center; padding: 40px 0; }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 10px; }

a { color: var(--primary); }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 12px;
  padding-top: env(safe-area-inset-top);
}

.topbar h1 { font-size: 1.3rem; }

.back {
  background: none;
  border: 0;
  color: var(--primary);
  padding: 8px 0;
  font-size: 1rem;
  text-align: start;
}

.pill {
  flex: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card > h2 { margin-bottom: 10px; }

.intro { color: var(--muted); margin-bottom: 14px; }

.eyebrow {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Fact tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

.tile {
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px;
  text-align: center;
}
.tile b { display: block; font-size: 1.35rem; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 0.85rem; }
.tile.countdown b { color: var(--primary); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: var(--opt-bg); color: var(--text); border-color: var(--border); }
.btn.warn { background: var(--opt-bg); color: var(--text); border-color: var(--warning); }
.btn.warn.on { background: var(--warning); color: #1d1d1f; }
.btn.block { display: flex; width: 100%; }

.bigbtn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: start;
  background: var(--opt-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
}
.bigbtn:last-child { margin-bottom: 0; }
.bigbtn .ico { font-size: 1.6rem; line-height: 1; flex: none; }
.bigbtn .txt { flex: 1; min-width: 0; }
.bigbtn .txt b { display: block; }
.bigbtn .txt span { color: var(--muted); font-size: 0.9rem; }
.bigbtn:disabled { opacity: 0.55; cursor: not-allowed; }
.bigbtn.bank { border-color: var(--danger); }
.bigbtn.bank:disabled { border-color: var(--border); }

.badge {
  flex: none;
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
}
.bigbtn:disabled .badge { background: var(--muted); }

.twocol { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .twocol { grid-template-columns: 1fr 1fr; } }
.twocol .bigbtn { margin: 0; flex-direction: column; align-items: flex-start; height: 100%; }

/* ---------- Rows (chapters, tests) ---------- */

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 12px 2px;
  text-align: start;
}
.rows li:last-child .row { border-bottom: 0; }
.row .txt { flex: 1; min-width: 0; }
.row .txt b { display: block; }
.row .txt span { color: var(--muted); font-size: 0.9rem; }
.row .right { flex: none; max-width: 92px; color: var(--muted); font-size: 0.85rem; line-height: 1.3; text-align: end; }
.row .right.good { color: var(--success); font-weight: 600; }

.num {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}
.num.grey { background: var(--opt-bg); color: var(--muted); border: 1px solid var(--border); }
.num.green { background: var(--success); }
.num.red { background: var(--danger); }

/* ---------- Lecture ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.pills button {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--primary);
}

.section h2 { margin-bottom: 10px; scroll-margin-top: 12px; }

/* Importance of each lesson */
.share { margin: 8px 0 0; font-size: 0.9rem; font-weight: 600; }
.section.prio-high { border-inline-start: 5px solid var(--warning); }
.badge-prio {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 6px;
}
.badge-prio.high { background: var(--warning); color: #1d1d1f; }
.badge-prio.medium { background: var(--expl-bg); color: var(--primary); }
.badge-prio.low { background: var(--score-bg); color: var(--muted); }

/* Contents list */
.toc summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary b::after { content: " ▾"; color: var(--muted); font-weight: 400; }
.toc:not([open]) summary b::after { content: " ▸"; }
.toc-parts { margin-top: 6px; }
@media (min-width: 700px) { .toc-parts { columns: 2; column-gap: 28px; } }
.toc-group { break-inside: avoid; }
.toc-group h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 10px 0 2px;
}
.toc-group ol { list-style: none; margin: 0; padding: 0; }
.toc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 8px 2px;
  text-align: start;
  color: var(--text);
}
.toc-group li:last-child .toc-row { border-bottom: 0; }
.toc-row:hover .toc-t { color: var(--primary); }
.toc-n {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--score-bg);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.toc-t { flex: 1; min-width: 0; font-size: 0.95rem; }
.toc-row.low .toc-t { color: var(--muted); }
.toc-star { flex: none; font-size: 0.85rem; }

.toc-row.active { background: var(--expl-bg); border-radius: 8px; }
.toc-row.active .toc-t { color: var(--primary); font-weight: 600; }
.toc-row.active .toc-n { background: var(--primary); color: #fff; }

/* Sidebar layout: phones = one column; wide screens = fixed contents on the left */
.layout { display: block; }
.fab {
  position: fixed;
  inset-inline-end: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-size: 1.4rem;
  z-index: 10;
}
@media (min-width: 1000px) {
  .wrap.wide { max-width: 1240px; }
  .wide .layout {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
  .wide .side {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
  .wide .side .toc-parts { columns: 1; }
  .wide .side .filter p { display: none; }
  .wide .side .card { margin-bottom: 10px; }
  .wide .main > .part-head:first-child { margin-top: 4px; }
  .wide .fab, .wide .totop { display: none; }
}

.part-head {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 22px 4px 8px;
}
.totop { display: block; margin: 8px 0 -6px; margin-inline-start: auto; text-decoration: none; }
.filter p { margin: 8px 0 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--score-bg); border-radius: var(--radius-sm); padding: 4px; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 8px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.section p { margin-bottom: 10px; }

.tablebox {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 10px 0;
}
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { padding: 8px 10px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
th { background: var(--score-bg); font-size: 0.85rem; color: var(--muted); }
td:first-child { font-weight: 700; color: var(--primary); }
.facts td:first-child { width: 38%; }
tbody tr:nth-child(even) td { background: var(--opt-bg); }
.cheat td { white-space: nowrap; }
.cheat.wide td { white-space: normal; min-width: 110px; }

.box {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 0.95rem;
}
.box .boxhead { font-weight: 700; margin-bottom: 4px; }
.box.words { background: var(--opt-bg); border: 1px solid var(--border); }
.box.words dl { margin: 0; }
.box.words dt { font-weight: 700; display: inline; }
.box.words dd { display: inline; margin: 0; }
.box.words dd::after { content: ""; display: block; margin-bottom: 4px; }
.box.watch { background: var(--warning-bg); border-inline-start: 4px solid var(--warning); }
.box.tip { background: var(--expl-bg); border-inline-start: 4px solid var(--primary); }
.box.note { background: var(--score-bg); border-inline-start: 4px solid var(--muted); }
.box.memory { background: var(--success-bg); border-inline-start: 4px solid var(--success); }
.box.memory ul { margin: 0; padding-inline-start: 20px; }
.box.memory li { margin-bottom: 4px; }

/* Test yourself: hide answers, tap a row to show it */
.selftest { display: flex; justify-content: flex-end; margin: 10px 0 -4px; }
.selftest .pill { color: var(--primary); }
.tablebox.hide tbody tr { cursor: pointer; }
.tablebox.hide tbody tr:not(.shown) td:not(:first-child) {
  color: transparent;
  background: var(--score-bg);
  background-image: repeating-linear-gradient(135deg, transparent 0 8px, var(--border) 8px 9px);
  user-select: none;
}
.selftest .hint { color: var(--muted); font-size: 0.8rem; margin-inline-end: auto; align-self: center; }

/* ---------- Quiz ---------- */

.score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--score-bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.score .counts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-weight: 600; }
.score .pct { text-align: end; }
.score .pct b { display: block; font-size: 1.6rem; line-height: 1.1; color: var(--primary); }
.score .pct b.good { color: var(--success); }
.score .pct b.bad { color: var(--danger); }
.score .pct span { color: var(--muted); font-size: 0.75rem; }

.progress {
  height: 5px;
  background: var(--score-bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress div { height: 100%; background: var(--primary); width: 0; transition: width 0.25s; }

.meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.qtext { font-size: 1.15rem; font-weight: 600; margin-bottom: 12px; }
.choose { color: var(--primary); font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; }

.opts { display: grid; gap: 10px; margin-bottom: 12px; border: 0; padding: 0; margin-inline: 0; }
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--opt-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
}
.opt input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--primary); }
.opt.selected { border-color: var(--primary); }
.opt.locked { cursor: default; }
.opt.correct { border-color: var(--success); background: var(--success-bg); }
.opt.wrong { border-color: var(--danger); background: var(--danger-bg); }
.opt .mark { margin-inline-start: auto; flex: none; }

.feedback { min-height: 1px; }
.feedback .fb { font-weight: 700; margin-bottom: 6px; }
.feedback .fb.good { color: var(--success); }
.feedback .fb.bad { color: var(--danger); }
.feedback .bankmsg { font-size: 0.95rem; margin-bottom: 8px; }

.expl {
  background: var(--expl-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.expl b { color: var(--primary); }

.qbtns {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-bottom: 10px;
}
.qbtns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Result ---------- */

.result { text-align: center; }
.result .big { font-size: 3rem; font-weight: 800; line-height: 1.1; }
.result .verdict { font-size: 1.15rem; font-weight: 700; margin: 4px 0 8px; }
.result .verdict.good { color: var(--success); }
.result .verdict.bad { color: var(--danger); }
.result .actions { display: grid; gap: 10px; margin-top: 14px; }
@media (min-width: 560px) { .result .actions { grid-template-columns: repeat(3, 1fr); } }

.review { list-style: none; margin: 0; padding: 0; }
.review li { border-bottom: 1px solid var(--border); padding: 10px 0; }
.review li:last-child { border-bottom: 0; }
.review .ans { color: var(--success); font-weight: 600; }

/* ---------- Footer, reset, transfer ---------- */

.footer { color: var(--muted); font-size: 0.8rem; text-align: center; margin-top: 18px; }
.footer p { margin-bottom: 6px; }
.linkbtn {
  background: none;
  border: 0;
  color: var(--primary);
  text-decoration: underline;
  font-size: 0.85rem;
  padding: 6px;
}
.linkbtn.danger { color: var(--danger); }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-top: 6px; }

textarea {
  width: 100%;
  min-height: 90px;
  font: 0.8rem/1.4 ui-monospace, Menlo, Consolas, monospace;
  background: var(--opt-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  margin: 8px 0;
}

.empty { text-align: center; color: var(--muted); padding: 20px 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Persian: Vazirmatn font, right-to-left ---------- */

html[lang="fa"] body {
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  line-height: 1.75;
}
html[lang="fa"] [lang="en"] {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
html[lang="fa"] .eyebrow { letter-spacing: 0; text-transform: none; }
.fa, [lang="fa"] { font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif; }

.pills-top { display: flex; gap: 6px; flex: none; }
.fa-title { color: var(--primary); font-weight: 600; margin: -6px 0 10px; }
.btn.practise { display: flex; width: 100%; margin-top: 14px; background: var(--success); }
.practice-note {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--score-bg);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin: 0 0 10px;
}
.box[dir="rtl"] { text-align: start; }
.box.words[dir="rtl"] dt bdi { font-weight: 700; }

/* ---------- Language page and login page ---------- */

.gate { min-height: 82vh; display: grid; place-items: center; padding: 20px 0; }
.gate-card { width: 100%; max-width: 440px; text-align: center; padding: 26px 22px; }
.gate-card h1 { margin-bottom: 6px; }
.gate-logo { display: block; width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 14px; }
.gate-sub span { display: block; }
.langs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.langbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 10px;
  background: var(--opt-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
}
.langbtn:hover { border-color: var(--primary); }
.langbtn img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }
.login-h { margin: 10px 0 4px; }
.field { display: block; text-align: start; margin: 14px 0 4px; }
.field span { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.field input {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--opt-bg);
  color: var(--text);
}
.field input:focus { outline: 3px solid var(--primary); outline-offset: 1px; }
.showpw { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); margin: 6px 0; }
.login-err { color: var(--danger); font-weight: 600; min-height: 1.5em; margin: 6px 0; }
.login-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 10px; }
.langbtn.fa b, .gate-sub .fa { font-family: "Vazirmatn", Tahoma, sans-serif; font-weight: 700; }
.gate-sub .fa { font-weight: 600; margin-top: 2px; }

/* ---------- Study plan ---------- */

.tile.countdown { border: 0; font: inherit; color: inherit; cursor: pointer; }
.bigbtn.plan-card { background: var(--card); border-color: var(--primary); }
.badge.plan-badge { background: var(--primary); }

.plan-setup .days { border: 0; padding: 0; margin: 14px 0 4px; text-align: start; }
.plan-setup legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.daychip { display: inline-flex; margin: 0 6px 8px 0; cursor: pointer; }
.daychip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.daychip span {
  min-width: 52px; text-align: center; padding: 8px 10px; border-radius: 999px;
  border: 2px solid var(--border); background: var(--opt-bg); font-weight: 600; font-size: 0.9rem;
}
.daychip input:checked + span { border-color: var(--primary); background: var(--primary); color: #fff; }
.daychip input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.plan-setup input[type="date"] { min-height: 46px; }

.track-bar { height: 12px; background: var(--score-bg); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.track-bar div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); }
.track-num { margin: 0 0 4px; }
.track-status { font-weight: 700; margin: 4px 0 8px; }
.track-status.good { color: var(--success); }
.track-status.bad { color: var(--danger); }
.tracker h3 { margin: 14px 0 6px; font-size: 1rem; }
.missed-h { color: var(--danger); }

.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.task {
  display: flex; align-items: center; gap: 8px;
  background: var(--opt-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; border-inline-start: 4px solid var(--border);
}
.task.st-done { border-inline-start-color: var(--success); opacity: 0.75; }
.task.st-done .task-txt > span { text-decoration: line-through; }
.task.st-missed { border-inline-start-color: var(--danger); background: var(--danger-bg); }
.task.st-today { border-inline-start-color: var(--primary); }
.task.st-exam { border-inline-start-color: var(--warning); background: var(--warning-bg); }
.task-check { flex: none; display: grid; place-items: center; width: 28px; }
.task-check input { width: 20px; height: 20px; accent-color: var(--success); margin: 0; }
.task-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 4px 0; text-align: start; color: var(--text);
}
.task-open:disabled { cursor: default; }
.task-ico { flex: none; }
.task-txt { min-width: 0; display: flex; flex-direction: column; }
.task-txt > span { font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.task-txt small { color: var(--muted); font-size: 0.78rem; }
.task:not(.st-exam) .task-open:hover .task-txt > span { color: var(--primary); }
.mini {
  flex: none; border: 1px solid var(--success); color: var(--success); background: var(--card);
  border-radius: 999px; padding: 4px 10px; font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cal-head h2 { margin: 0; }
.cal-seg { min-width: 180px; }
.cal-nav { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; }
.cal-nav b { flex: 1; text-align: center; }

.week { display: grid; gap: 10px; }
.wday { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; }
.wday.is-today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.wday-h { font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.wday .muted { margin: 0; }
@media (min-width: 1000px) {
  .wrap:has(.week) { max-width: 1240px; }
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .week .task { flex-wrap: wrap; }
}

.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mhead { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); padding: 2px 0; }
.mday {
  min-height: 54px; border: 1px solid var(--border); border-radius: 8px; background: var(--opt-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 4px 2px;
  font-weight: 600; font-size: 0.9rem; color: var(--text);
}
.mday.other { opacity: 0.4; }
.mday.is-today { border-color: var(--primary); color: var(--primary); }
.mday.is-sel { background: var(--primary); color: #fff; border-color: var(--primary); }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.st-done { background: var(--success); }
.dot.st-missed { background: var(--danger); }
.dot.st-today, .dot.st-todo { background: var(--primary); }
.dot.st-exam { background: var(--warning); width: 9px; height: 9px; }
.mday.is-sel .dot { box-shadow: 0 0 0 1px #fff; }
.mday-detail { margin-top: 12px; }
.mday-detail h3 { font-size: 1rem; margin-bottom: 6px; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }