:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8e6e1;
  --muted: #9aa0ab;
  --accent: #e7b75f;
  --accent-ink: #1a1408;
  --blue: #8fb3ff;
  --good: #6fcf97;
  --warn: #f2c94c;
  --bad: #ff7b72;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f4ef;
    --panel: #ffffff;
    --panel-2: #f1eee7;
    --line: #e2ddd2;
    --text: #1d1c1a;
    --muted: #6b6860;
    --accent: #b9832a;
    --accent-ink: #ffffff;
    --blue: #2f5bd3;
    --good: #1f8a54;
    --warn: #9a6b00;
    --bad: #c2362c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Vazirmatn", sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--accent); letter-spacing: 0.02em; }
.tabs { display: flex; gap: 0.25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs a {
  padding: 0.4rem 0.7rem; border-radius: 999px; color: var(--muted); white-space: nowrap;
}
.tabs a.active { background: var(--panel-2); color: var(--text); text-decoration: none; }

main { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 5rem; outline: none; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.9rem; box-shadow: var(--shadow);
}
.card.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 0.6rem; }
.grid2 { display: grid; gap: 0.6rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 0.86rem; color: var(--muted); margin-bottom: 0.2rem; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="password"], input[type="date"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2);
}
textarea { min-height: 6rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
button {
  cursor: pointer; border: 1px solid var(--line); background: var(--panel-2);
  padding: 0.5rem 0.9rem; border-radius: 10px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.good { border-color: var(--good); color: var(--good); }
button.bad { border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: 0.55; cursor: progress; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

.badge {
  display: inline-block; font-size: 0.74rem; padding: 0.1rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.A { color: var(--good); border-color: var(--good); }
.badge.B { color: var(--blue); border-color: var(--blue); }
.badge.C { color: var(--warn); border-color: var(--warn); }
.badge.D { color: var(--bad); border-color: var(--bad); }
.badge.must { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.progress { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

.big { font-size: 2rem; font-weight: 700; }
.stat { min-width: 6rem; }

.week { margin-bottom: 1rem; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.35rem; }
.day {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 0.85rem; cursor: pointer; padding: 0;
}
.day.done { background: color-mix(in srgb, var(--good) 28%, var(--panel-2)); border-color: var(--good); }
.day.today { outline: 2px solid var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }

.output { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel-2); border-radius: 10px; padding: 0.9rem; }
.pred.open { border-left: 3px solid var(--warn); }
.pred.right { border-left: 3px solid var(--good); }
.pred.partial { border-left: 3px solid var(--blue); }
.pred.wrong { border-left: 3px solid var(--bad); }
.overdue { color: var(--bad); }

.filters { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 0.9rem; }
details > summary { cursor: pointer; color: var(--muted); }
.fa { direction: rtl; text-align: right; }

#toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.5rem 1rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.2s;
  max-width: calc(100vw - 2rem);
}
#toast.show { opacity: 1; }
#toast.err { border-color: var(--bad); color: var(--bad); }

.login { max-width: 360px; margin: 12vh auto 0; }
.spinner { display: inline-block; width: 1rem; height: 1rem; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; vertical-align: -0.15rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.grow { flex: 1; min-width: 12rem; }
#agy-out { max-height: 22rem; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
ol.small { padding-left: 1.2rem; margin: 0; }
