:root {
  --paper: #F4F5F6;
  --surface: #FFFFFF;
  --ink: #14161A;
  --muted: #6E737B;
  --rule: #DFE2E6;
  --tod: #1B2A4A;
  --theatre: #7A2E3C;
  --personal: #3F6B5C;
  --accent: var(--ink);
  --step: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Kufi Arabic", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- شاشة الدخول ---------- */

.screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 28px 22px;
}

.login__title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login__note {
  margin: 4px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- الشريط العلوي ---------- */

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 5;
}

.bar__side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar__section { font-weight: 600; white-space: nowrap; }
.bar__date, .bar__user { color: var(--muted); font-size: 12px; white-space: nowrap; }

.tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- الصفحة ---------- */

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.panel > * + * { margin-top: 28px; }

.h {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.lede { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

/* ---------- قوائم المهام ---------- */

.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule); }
.rows:empty { display: none; }

.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-inline-start: 3px solid var(--rowcolor, var(--rule));
  border-bottom: 1px solid var(--rule);
}
.row:last-child { border-bottom: none; }

.row__body { flex: 1; min-width: 0; }
.row__title { display: block; word-break: break-word; }
.row__meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.row--done .row__title { color: var(--muted); text-decoration: line-through; }
.row--late .row__meta { color: var(--theatre); font-weight: 600; }

.check {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 1px solid var(--muted);
  background: var(--surface);
  cursor: pointer;
  flex: 0 0 auto;
}
.check:checked { background: var(--ink); border-color: var(--ink); }

.row__del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
}
.row__del:hover { color: var(--theatre); }

.empty {
  background: var(--surface);
  border: 1px dashed var(--rule);
  padding: 18px 14px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- بطاقات الأقسام ---------- */

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }

.tile {
  background: var(--surface);
  border: none;
  border-top: 3px solid var(--tilecolor, var(--rule));
  padding: 14px;
  text-align: start;
  cursor: pointer;
}
.tile__count { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--tilecolor, var(--ink)); }
.tile__label { display: block; font-size: 13px; margin-top: 2px; }
.tile__meta { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- الحقول والأزرار ---------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

input[type="text"], input[type="password"], input[type="date"], textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 9px 10px;
  border-radius: 0;
}
textarea { resize: vertical; }

.compose { background: var(--surface); border: 1px solid var(--rule); padding: 14px; }
.compose__row { display: flex; gap: 8px; margin-top: 8px; }
.compose__row input { flex: 1; }

.btn {
  border: 1px solid var(--ink);
  background: var(--surface);
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 0;
}
.btn--solid { background: var(--ink); color: var(--surface); }
.btn--quiet { border-color: var(--rule); color: var(--muted); padding: 5px 10px; font-size: 12px; }
.btn--wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: progress; }

/* ---------- نتيجة الراوتر ---------- */

.result { margin-top: 20px; background: var(--surface); border: 1px solid var(--rule); }
.result__head { padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.result__cat { font-weight: 700; font-size: 17px; }
.result__conf { color: var(--muted); font-size: 12px; margin-inline-start: 8px; }
.result__tools { list-style: none; margin: 0; padding: 0; }
.result__tools li { padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.result__tool { font-weight: 600; }
.result__why { color: var(--muted); font-size: 13px; }
.result__prompt { padding: 12px 14px; }
.result__prompt pre {
  margin: 0 0 10px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  background: var(--paper);
  padding: 10px;
  border: 1px solid var(--rule);
}

.msg { font-size: 13px; margin: 12px 0 0; }
.msg--error { color: var(--theatre); }

.toast {
  position: fixed;
  inset-block-end: 18px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--ink);
  color: var(--surface);
  padding: 8px 16px;
  font-size: 13px;
  margin: 0;
  z-index: 20;
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .page { padding: 16px 12px 56px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
