:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #12211f;
  --muted: #5d6b68;
  --line: #dfe6e4;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --soft: #e3f3f0;
  --good: #15803d;
  --good-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1413;
    --card: #17211f;
    --ink: #e8efed;
    --muted: #9aaba7;
    --line: #2a3835;
    --brand: #2dd4bf;
    --brand-ink: #06201d;
    --soft: #12302c;
    --good: #4ade80;
    --good-bg: #123821;
    --bad: #f87171;
    --bad-bg: #40191a;
    --warn: #fbbf24;
    --warn-bg: #3a2c0c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  padding-bottom: 84px;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0 0 .4rem; line-height: 1.4; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); font-size: .92rem; }
.en { direction: ltr; unicode-bidi: isolate; font-family: "Segoe UI", system-ui, sans-serif; }
.ltr { direction: ltr; text-align: left; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--ink); letter-spacing: -.02em; }
.brand span { color: var(--brand); }
.topstats { display: flex; gap: .5rem; font-size: .85rem; }
.pill {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .6rem; border-radius: 999px; background: var(--soft); color: var(--brand); font-weight: 600;
}

main { max-width: 760px; margin: 0 auto; padding: 1rem; }

.tabs {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 5;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; text-align: center; padding: .45rem 0 .5rem; font-size: .72rem; color: var(--muted);
  display: flex; flex-direction: column; line-height: 1.3;
}
.tabs a b { font-size: 1.25rem; font-weight: 400; filter: grayscale(.6); }
.tabs a.on { color: var(--brand); font-weight: 700; }
.tabs a.on b { filter: none; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin: .8rem 0;
}
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: .55rem 1rem; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
button:hover, .btn:hover { border-color: var(--brand); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px;
}
.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.primary:hover { filter: brightness(1.08); }
.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.big { width: 100%; padding: .8rem 1rem; font-size: 1.05rem; }
.say { min-height: 36px; padding: .2rem .55rem; border-radius: 999px; font-size: .95rem; }
.danger { color: var(--bad); }

input[type=text], input[type=password], input[type=number], textarea, select {
  font: inherit; width: 100%; padding: .6rem .75rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
textarea { min-height: 150px; resize: vertical; }
label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }
.chip {
  padding: .25rem .8rem; min-height: 36px; border-radius: 999px; font-size: .9rem;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }

.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li a {
  display: flex; align-items: center; gap: .8rem; padding: .75rem .2rem; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.tasks li:last-child a { border-bottom: 0; }
.tick {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; font-size: .85rem; color: transparent;
}
.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.done .t { text-decoration: line-through; color: var(--muted); }

.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }

.flash { text-align: center; padding: 1.6rem 1rem; }
.flash .w { font-size: 2rem; font-weight: 800; line-height: 1.3; }
.flash .ar { font-size: 1.3rem; margin: .6rem 0; color: var(--brand); font-weight: 700; }
.flash .ex { font-size: 1.05rem; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: 1rem; }
.grades button { padding: .5rem .2rem; font-size: .9rem; }

.q { font-size: 1.15rem; font-weight: 600; margin: .4rem 0 .8rem; }
.opts { display: grid; gap: .5rem; }
.opts button { justify-content: flex-start; text-align: start; width: 100%; }
.opts button.right { background: var(--good-bg); border-color: var(--good); color: var(--good); font-weight: 700; }
.opts button.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

.note { padding: .7rem .9rem; border-radius: 10px; margin: .7rem 0; font-size: .95rem; }
.note.ok { background: var(--good-bg); color: var(--good); }
.note.no { background: var(--bad-bg); color: var(--bad); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.info { background: var(--soft); color: var(--ink); }

.diff { direction: ltr; text-align: left; font-size: 1.15rem; line-height: 2.1; }
.diff span { padding: .1rem .3rem; border-radius: 6px; margin-inline-end: .15rem; }
.diff .ok { background: var(--good-bg); color: var(--good); }
.diff .miss { background: var(--bad-bg); color: var(--bad); text-decoration: underline wavy; }

.sentence { font-size: 1.3rem; font-weight: 600; line-height: 1.6; margin: .6rem 0; }
.score { font-size: 2.4rem; font-weight: 800; color: var(--brand); line-height: 1.2; }
.passage { font-size: 1.08rem; line-height: 1.9; white-space: pre-wrap; }

.chat { display: flex; flex-direction: column; gap: .6rem; margin: .8rem 0; }
.msg { max-width: 88%; padding: .6rem .9rem; border-radius: 14px; direction: ltr; text-align: left; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); }
.fix { align-self: flex-end; max-width: 88%; font-size: .9rem; padding: .5rem .8rem; border-radius: 10px; background: var(--warn-bg); color: var(--warn); }
.fix .en { display: block; font-weight: 700; }
.composer { position: sticky; bottom: 84px; background: var(--bg); padding: .5rem 0; display: flex; gap: .4rem; }
.mic.live { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .mic.live { animation: none; } .bar i { transition: none; } }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.stat { text-align: center; padding: .8rem .4rem; }
.stat b { display: block; font-size: 1.7rem; color: var(--brand); line-height: 1.2; }
.list a { display: flex; justify-content: space-between; gap: .6rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.list a:last-child { border-bottom: 0; }
table.ex { width: 100%; border-collapse: collapse; }
table.ex td { padding: .35rem 0; vertical-align: top; border-bottom: 1px dashed var(--line); }
audio { width: 100%; margin-top: .5rem; }
.spin { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: rot .8s linear infinite; vertical-align: middle; }
@keyframes rot { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }
