:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1f2328;
  --muted: #646a73;
  --line: #e2ded4;
  --accent: #1f6f5c;
  --accent-soft: #dcefe8;
  --warn: #b5541c;
  --warn-soft: #fbe7da;
  --good: #2c7a3f;
  --bad: #b3261e;
  --bar: #1f6f5c;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --surface-2: #262a2f;
    --text: #e8e6e1;
    --muted: #9aa0a8;
    --line: #30353b;
    --accent: #5cc0a2;
    --accent-soft: #1d3a32;
    --warn: #f0a070;
    --warn-soft: #3a2a20;
    --good: #6cc47f;
    --bad: #f08a80;
    --bar: #5cc0a2;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
a { color: var(--accent); }
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
}
.brand { font-weight: 700; white-space: nowrap; }
nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav a {
  text-decoration: none; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
nav a.more-link { display: none; }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 80px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.2rem; margin: 28px 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.stat .n { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .9rem; }
.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: .85rem; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.scroll { overflow-x: auto; }
td.nw { white-space: nowrap; }
form.stack { display: grid; gap: 12px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { min-height: 70px; }
button, .btn {
  font: inherit; cursor: pointer;
  background: var(--accent); color: #fff; border: 0;
  padding: 8px 16px; border-radius: 8px; text-decoration: none; display: inline-block;
}
@media (prefers-color-scheme: dark) { button, .btn { color: #0f1a17; } }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); padding: 2px 10px; }
button:disabled { opacity: .5; cursor: default; }
.en { direction: ltr; text-align: left; font-family: "Literata", Georgia, serif; }
.passage { background: var(--surface-2); border-radius: 10px; padding: 16px 18px; line-height: 1.75; white-space: pre-wrap; }
.q { padding: 14px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q .opts { display: grid; gap: 6px; margin-top: 8px; }
.q .opts label { display: flex; gap: 8px; align-items: baseline; color: var(--text); font-size: 1rem; cursor: pointer; }
.q .opts input { width: auto; }
.q.right { background: color-mix(in srgb, var(--good) 8%, transparent); }
.q.wrong { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.q.right, .q.wrong { padding-inline: 10px; border-radius: 8px; }
.explain { color: var(--muted); font-size: .92rem; margin-top: 6px; }
.routine td:first-child { white-space: nowrap; font-weight: 600; }
.chart svg { width: 100%; height: 140px; display: block; }
.chart rect { fill: var(--bar); }
.chart text { fill: var(--muted); font-size: 10px; }
.flash { position: fixed; bottom: 20px; inset-inline: 0; margin: auto; width: fit-content; background: var(--text); color: var(--bg); padding: 8px 18px; border-radius: 99px; }
.card-review { text-align: center; padding: 32px 18px; }
.card-review .word { font-size: 2rem; font-weight: 600; }
.login { max-width: 360px; margin: 12vh auto; }
.empty { color: var(--muted); padding: 12px 0; }
details > summary { cursor: pointer; font-weight: 600; }
ul.tight { margin: 0; padding-inline-start: 20px; }
@media (min-width: 761px) {
  nav svg { display: none; }
  nav a { padding: 6px 9px; }
  nav a:not(.desk):not(.more-link) { display: none; }
  nav a.more-link { display: flex; }
}
/* reader and highlight-to-add */
.reader-text { font-family: "Literata", Georgia, serif; direction: ltr; text-align: left; font-size: 1.12rem; line-height: 1.9; }
.reader-text p { margin: 0 0 1em; }
.w { cursor: pointer; border-radius: 3px; }
.w:hover { background: var(--surface-2); }
.w.saved { background: var(--warn-soft); box-shadow: inset 0 -2px 0 var(--warn); }
.hl-add {
  position: absolute; z-index: 30; transform: translate(-50%, -100%);
  box-shadow: 0 4px 14px rgb(0 0 0 / .18); white-space: nowrap; min-height: 0 !important; padding: 6px 12px !important;
}
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .35); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 761px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 16px; } }
.def { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: .92rem; }
.menu-list a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 1.05rem; }
.menu-list svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rule { white-space: pre-line; line-height: 1.9; }
.guide h2 { margin-top: 30px; }
.guide ol, .guide ul { padding-inline-start: 22px; }
.guide li { margin: 4px 0; }
.tip { border-inline-start: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  .top { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); justify-content: center; }
  nav {
    position: fixed; bottom: 0; inset-inline: 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--line);
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 0;
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
  }
  nav { grid-template-columns: repeat(6, 1fr); }
  nav a:not(.primary):not(.more-link) { display: none; }
  nav a.more-link { display: flex; }
  nav a { flex-direction: column; gap: 2px; padding: 6px 0; font-size: 10.5px; text-align: center; border-radius: 8px; }
  nav svg { width: 22px; height: 22px; }
  main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.1rem; margin-top: 24px; }
  .card { padding: 14px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid > .card:only-child, .grid.wide { grid-template-columns: 1fr; }
  .stat .n { font-size: 1.4rem; }
  .stat .l { font-size: .8rem; line-height: 1.5; }
  button, .btn { min-height: 44px; padding: 10px 16px; }
  button.danger { min-height: 36px; }
  input, select, textarea { font-size: 16px; min-height: 44px; }
  .row > .btn, .row > button { flex: 1; text-align: center; }
  .fields { grid-template-columns: 1fr 1fr; }
  /* tables become stacked rows */
  table.rt thead { display: none; }
  table.rt tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.rt td { display: inline-block; border: 0; padding: 2px 8px 2px 0; }
  table.rt td.full { display: block; padding: 4px 0; }
  .routine tr { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .routine td { border: 0; padding: 0; }
  .routine td:last-child { grid-column: 1 / -1; }
  .q .opts label { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
  .q .opts label { align-items: center; }
  input[type=radio], input[type=checkbox] { min-height: 0; width: 18px; height: 18px; flex: none; margin: 0; }
  .q .opts label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
  .passage { padding: 14px; font-size: 1rem; }
  .card-review .word { font-size: 1.7rem; }
  .flash { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 340px) {
  .fields { grid-template-columns: 1fr; }
  nav a { font-size: 9.5px; }
}
nav a.more-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { font-weight: 500; color: var(--muted); font-size: .9rem; margin-inline-start: 6px; }
.who:not(:empty)::before { content: "· "; }

/* mentor view */
.viewbar { position: sticky; top: 0; z-index: 6; background: var(--warn-soft); color: var(--warn); padding: 8px 16px; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; font-weight: 600; }
.viewbar button { min-height: 0 !important; padding: 4px 12px !important; }
body.viewing .wo { display: none !important; }
.mentor-only { display: none; }
body.viewing .mentor-only { display: block; }
/* IELTS practice */
.band { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bands { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bands .card { text-align: center; padding: 12px 8px; }
.bands .l { color: var(--muted); font-size: .85rem; }
.ok-text { color: var(--good); } .bad-text { color: var(--bad); }
.timer { position: sticky; top: 56px; z-index: 4; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 4px 14px; width: fit-content; margin: 0 auto 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.timer.low { color: var(--bad); border-color: var(--bad); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.split > .sticky { position: sticky; top: 100px; max-height: calc(100vh - 120px); overflow: auto; }
.para-label { font-weight: 700; color: var(--accent); margin-inline-end: 6px; }
.essay { width: 100%; min-height: 340px; font-family: "Literata", Georgia, serif; font-size: 1.05rem; line-height: 1.8; direction: ltr; text-align: left; }
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-box text { fill: var(--text); font-size: 13px; font-family: system-ui, sans-serif; }
@media (max-width: 760px) { .chart-box text { font-size: 17px; } }
.chart-box .grid line { stroke: var(--line); }
.feedback h3 { margin-top: 18px; }
.corr { padding: 8px 0; border-bottom: 1px solid var(--line); }
.corr del { color: var(--bad); }
.corr ins { color: var(--good); text-decoration: none; font-weight: 600; }
.rec { width: 72px; height: 72px; border-radius: 50%; font-size: 1.6rem; padding: 0 !important; }
.rec.on { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.hub { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.hub a { display: block; text-decoration: none; color: var(--text); }
.hub svg { width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
input.gap { width: 11em; display: inline-block; padding: 2px 8px; min-height: 0 !important; }
select.gap { width: auto; display: inline-block; padding: 2px 6px; min-height: 0 !important; }
@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .split > .sticky { position: static; max-height: 45vh; }
  .bands { grid-template-columns: repeat(2, 1fr); }
  .timer { top: 8px; }
}
body.viewing form:not(.mentor-form), body.viewing #rev, body.viewing [data-del], body.viewing .danger { display: none !important; }
@media (min-width: 761px) { .ml { display: none; } }
