/* Colours follow Telegram's theme when opened in Telegram, with the
   academy's navy and turquoise as the fallback (light and dark). */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f4f7);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1b2333);
  --muted: var(--tg-theme-hint-color, #6b7588);
  --brand: #1f3a68;
  --accent: var(--tg-theme-button-color, #1aa3a3);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #138a8a);
  --line: rgba(127, 127, 127, 0.18);
  --ok: #1f9d55;
  --warn: #c98a00;
  --bad: #d64545;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) {
    --bg: #0f1520; --card: #1a2230; --text: #e8edf5; --muted: #95a0b3; --brand: #9fb8e6;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { padding: 12px 16px 96px; max-width: 720px; margin: 0 auto; }
h1 { font-size: 20px; margin: 4px 0 2px; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; }
p { margin: 6px 0; }
.sub { color: var(--muted); font-size: 13px; }
a { color: var(--link); text-decoration: none; }

.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0;
  display: block; color: inherit; border: 1px solid var(--line); }
a.card:active, .row:active { opacity: .7; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .card { margin: 0; border-radius: 0; border-width: 0 0 1px; }
.list { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin: 8px 0; }
.list .card:last-child { border-bottom: 0; }

button, .btn { font: inherit; border: 0; border-radius: 12px; padding: 11px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); font-weight: 600; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
button.ghost, .btn.ghost { background: transparent; color: var(--link); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
button.small { min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 10px; }
button:disabled { opacity: .5; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.buttons.full > * { flex: 1; }
.wide { width: 100%; }

input, select, textarea { font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); }
textarea.arabic { direction: rtl; font-size: 19px; line-height: 1.9; min-height: 160px;
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", serif; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.check input { width: 20px; height: 20px; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--line); color: var(--text); white-space: nowrap; }
.chip.ok { background: rgba(31,157,85,.15); color: var(--ok); }
.chip.warn { background: rgba(201,138,0,.16); color: var(--warn); }
.chip.bad { background: rgba(214,69,69,.14); color: var(--bad); }
.chip.info { background: rgba(26,163,163,.15); color: var(--link); }

.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--line); margin-top: 8px; }
.bar i { display: block; }
.bar .ok { background: var(--ok); } .bar .warn { background: var(--warn); } .bar .late { background: #7aa7d8; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin: 8px 0 4px; }
.seg a { flex: 1; text-align: center; padding: 8px; border-radius: 10px; color: var(--text); font-weight: 600; }
.seg a.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: 7px 2px 9px; font-size: 11px; color: var(--muted); }
.tabs a span { display: block; font-size: 20px; line-height: 1.3; }
.tabs a.on { color: var(--link); font-weight: 600; }

.toast { position: fixed; left: 16px; right: 16px; bottom: 84px; background: #1b2333; color: #fff;
  padding: 12px 14px; border-radius: 12px; opacity: 0; transform: translateY(10px); transition: .2s;
  pointer-events: none; z-index: 20; text-align: center; max-width: 560px; margin: 0 auto; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--bad); }

[hidden] { display: none !important; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; }
.sheet > div { background: var(--card); width: 100%; max-width: 720px; margin: 0 auto; padding: 18px 16px 24px;
  border-radius: 18px 18px 0 0; }
.sheet button { width: 100%; margin-top: 8px; }

.task { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 10px 0; }
.task .head { display: flex; gap: 8px; align-items: center; }
.task .num { font-weight: 700; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 2px; background: var(--bad); opacity: .7; }
.dots i.y { background: var(--ok); opacity: 1; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.mono { font-variant-numeric: tabular-nums; }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- deadline picker */
.picker-field { width: 100%; background: var(--card); color: var(--text); border: 1px solid var(--line);
  justify-content: flex-start; text-align: left; font-weight: 400; padding: 10px 12px; gap: 12px; min-height: 60px; }
.picker-field .block { display: block; }
.picker-field .grow { flex: 1; min-width: 0; }
.cal-icon { width: 44px; height: 44px; border-radius: 10px; background: rgba(26,163,163,.14); color: var(--link);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; flex: none; }
.cal-icon b { font-size: 18px; } .cal-icon small { font-size: 10px; text-transform: uppercase; font-weight: 600; }
.time-pill { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 6px 12px;
  font-weight: 700; font-variant-numeric: tabular-nums; }
.buttons.quick { margin-top: 8px; }
.picker { max-height: 88vh; overflow-y: auto; }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.picker-head b { font-size: 17px; }
.picker .nav { width: 44px; min-height: 40px; margin: 0; font-size: 22px; background: transparent; color: var(--link);
  border: 1px solid var(--line); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-grid.week span { font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.picker .day { width: 100%; aspect-ratio: 1; min-height: 0; max-height: 46px; margin: 0; padding: 0; border-radius: 50%;
  background: transparent; color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.picker .day.today { box-shadow: inset 0 0 0 1.5px var(--link); color: var(--link); }
.picker .day.on { background: var(--accent); color: var(--accent-text); box-shadow: none; font-weight: 700; }
.picker .day:disabled { opacity: .3; }
.picker-time { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.picker-time .sub { margin-right: auto; }
.picker-time select { width: 76px; text-align: center; font-size: 20px; font-weight: 700; padding: 8px;
  font-variant-numeric: tabular-nums; }
.picker .quick button { margin-top: 0; width: auto; flex: 1; }
.picker-sum { text-align: center; margin: 12px 0 4px; }
.picker .quick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.picker .quick button { padding: 6px 0; font-size: 13px; }
.picker .quick button.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }
