:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7385;
  --border: #e3e6ee;
  --primary: #3b5bdb;
  --primary-text: #ffffff;
  --red: #d6336c;
  --red-bg: #fff0f5;
  --amber: #e8590c;
  --amber-bg: #fff4e6;
  --green: #2b8a3e;
  --green-bg: #ebfbee;
  --blue-bg: #edf2ff;
  --c0: #ae3ec9;
  --c0-bg: #f8f0fc;
  --c1: #1971c2;
  --c1-bg: #e7f5ff;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1b1e27;
    --text: #e6e8ef;
    --muted: #9198a8;
    --border: #2c303c;
    --primary: #6d8cff;
    --primary-text: #0d1020;
    --red: #ff6b9a;
    --red-bg: #3a1a26;
    --amber: #ffa94d;
    --amber-bg: #3a2614;
    --green: #69db7c;
    --green-bg: #17301d;
    --blue-bg: #1e2643;
    --c0: #e599f7;
    --c0-bg: #33203a;
    --c1: #74c0fc;
    --c1-bg: #16283a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.red { color: var(--red); }
.error { color: var(--red); min-height: 1.2em; margin: .4em 0 0; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 8px; }

/* buttons & inputs */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .55; cursor: wait; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .btn { width: 100%; margin-top: 4px; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap;
}
.brand { font-weight: 700; }
.tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.tab {
  border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 999px;
  padding: 6px 12px; font: inherit; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--blue-bg); color: var(--text); font-size: 12px; text-align: center; margin-left: 4px; }
.tab.active .pill { background: rgba(255,255,255,.25); color: inherit; }
.pill.red { background: var(--red); color: #fff; }
.top-actions { display: flex; gap: 4px; }

.container { max-width: 960px; margin: 0 auto; padding: 16px; }
.notice { background: var(--amber-bg); color: var(--text); border: 1px solid var(--amber); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.counters { display: flex; gap: 14px; color: var(--muted); }
.counters b { color: var(--text); }
.counters .red b { color: var(--red); }

/* board */
.bucket { margin-bottom: 22px; }
.bucket h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.b-overdue h2 { color: var(--red); }
.b-soon h2 { color: var(--amber); }
.bucket summary { cursor: pointer; list-style: none; }
.bucket summary h2 { display: inline; }
.tasks { display: grid; gap: 10px; }
.task {
  display: flex; gap: 12px; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow);
}
.task.overdue { border-left-color: var(--red); background: var(--red-bg); }
.task.soon { border-left-color: var(--amber); }
.task.week { border-left-color: var(--primary); }
.task.done { opacity: .7; border-left-color: var(--green); }
.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task h3 { font-size: 16px; margin: 2px 0; overflow-wrap: anywhere; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.child-tag { padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.child-tag.c1 { color: var(--c0); background: var(--c0-bg); }
.child-tag.c2 { color: var(--c1); background: var(--c1-bg); }
.child-tag.c3 { color: var(--muted); background: var(--bg); border: 1px solid var(--border); }
.subject { color: var(--muted); }
.due { font-size: 13px; color: var(--muted); }
.task.overdue .due, .due.overdue { color: var(--red); font-weight: 600; }
.has-help { color: var(--green); }
.status { width: auto; max-width: 150px; font-size: 13px; padding: 6px 8px; }
.s-hazır, .s-təhvil-verildi { color: var(--green); }
.s-işlənir { color: var(--amber); }
.empty { text-align: center; padding: 32px 16px; }
.from-mail { color: var(--primary); }
.notice pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.4 ui-monospace, monospace; margin: 8px 0 0; max-height: 220px; overflow: auto; }
.mail-log { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.mail-log li { font-size: 14px; overflow-wrap: anywhere; }
.mail-status { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); margin-right: 4px; }
.mail-status.st-task { color: var(--green); background: var(--green-bg); border-color: transparent; }
.mail-status.st-error, .mail-status.st-rejected { color: var(--red); background: var(--red-bg); border-color: transparent; }

/* dialogs */
dialog {
  border: 0; border-radius: 14px; padding: 0; background: var(--surface); color: var(--text);
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(10, 14, 25, .45); }
.dialog-body { padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.import-box { background: var(--blue-bg); border-radius: 10px; padding: 12px; margin-bottom: 14px; display: grid; gap: 8px; }
.import-box p { margin: 0; }
.import-box .btn { justify-self: start; }

.drawer { width: min(760px, calc(100vw - 32px)); }
.desc { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 12px; margin-bottom: 12px; overflow-wrap: anywhere; }
.shot { max-width: 100%; max-height: 360px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 12px; }
.help, .notes { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
#chat { display: grid; gap: 10px; margin-bottom: 10px; }
.msg { border-radius: 12px; padding: 10px 14px; overflow-wrap: anywhere; }
.msg.bot { background: var(--bg); }
.msg.bot h3, .msg.bot h4, .msg.bot h5 { margin-top: .8em; font-size: 15px; }
.msg.bot p { margin: .4em 0; }
.msg.bot ul, .msg.bot ol { margin: .3em 0; padding-left: 1.3em; }
.msg.me { background: var(--primary); color: var(--primary-text); justify-self: end; max-width: 85%; white-space: pre-wrap; }
.ask { display: flex; gap: 8px; align-items: flex-end; }
.notes ul { padding-left: 1.2em; }
.notes input { flex: 1; width: auto; min-width: 0; }

.summary { margin-bottom: 12px; }
.summary h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.summary h4 { font-size: 13px; margin: .8em 0 .2em; }
.summary ul { margin: 0; padding-left: 1.2em; }
.grade { display: flex; align-items: center; gap: 4px; margin: 0; }
.grade input { width: 56px; padding: 2px 6px; margin: 0; }

@media (max-width: 600px) {
  .topbar { padding: 8px 16px; }
  .brand { flex: 1; }
  .tabs { order: 3; width: 100%; flex: none; }
  .top-actions .btn { padding: 5px 8px; font-size: 13px; }
  .grid2 { grid-template-columns: 1fr; }
  .task { flex-direction: column; align-items: stretch; }
  .status { max-width: none; width: 100%; }
  .ask { flex-direction: column; align-items: stretch; }
  dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .dialog-body { padding: 14px; }
}

/* ---------- views, stars ---------- */
.views { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.view { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 14px; font: inherit; cursor: pointer; white-space: nowrap; }
.view.active { border-color: var(--primary); color: var(--primary); font-weight: 600; box-shadow: inset 0 -2px 0 var(--primary); }
.stars { margin-left: 6px; font-size: 13px; }
.stars.big { font-size: 18px; font-weight: 700; }
.kid-card { margin-bottom: 16px; }
.kid-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.kid-head h2 { margin: 0; font-size: 20px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat b { font-size: 26px; line-height: 1; }

/* subject bars: one series, one hue, value labels in text ink */
.bars { display: grid; gap: 8px; margin: 6px 0 14px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 160px) 1fr 44px; align-items: center; gap: 10px; }
.bar-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; }
.bar-row:hover .bar-fill { filter: brightness(1.12); }
.bar-value { font-size: 13px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

.grade-tools { display: grid; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.grade-form { display: grid; grid-template-columns: 1.2fr 1.4fr 0.6fr 0.6fr 1fr auto; gap: 6px; }
.grade-form input { padding: 6px 8px; font-size: 14px; }
.grade-tools input[type=file] { width: auto; flex: 1; min-width: 0; border: 0; padding: 0; }
.grade-list { margin-top: 12px; }
.grade-list summary { cursor: pointer; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0; }
td, th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
.icon-btn.small { font-size: 18px; }
.analysis { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
.analysis h3 { margin: 0; }

/* plan */
.focus { margin: 0 0 12px; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.day { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.day.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--blue-bg); }
.day.done { background: var(--green-bg); }
.day-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.day-title { font-weight: 600; }
.day ul { margin: 2px 0; padding-left: 18px; font-size: 14px; display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; margin: 6px 0 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; }
.digest pre { white-space: pre-wrap; font: 13px/1.45 ui-monospace, monospace; background: var(--bg); padding: 10px; border-radius: 8px; }
[data-pin] { width: 90px; padding: 2px 6px; display: inline-block; }

/* kid mode: bigger, friendlier */
body.kid .task h3 { font-size: 18px; }
body.kid .brand::after { content: " · Mənim tapşırıqlarım"; font-weight: 400; color: var(--muted); }

@media (max-width: 600px) {
  .grade-form { grid-template-columns: 1fr 1fr; }
  .grade-form button { grid-column: span 2; }
  .bar-row { grid-template-columns: 90px 1fr 40px; }
}
