/* Töte / Kazakh Perso-Arabic font (local file). */
@font-face {
  font-family: "KerwenTro";
  src: url("./fonts/KerwenTro.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #fcfcfb;
  --surface-3: #fafaf8;
  --text: #1b1b19;
  --text-2: #3a3a36;
  --muted: #6f6d65;
  --muted-2: #8a887f;
  --muted-3: #9b9890;
  --border: #e4e3de;
  --border-2: #d8d7d2;
  --chip-bg: #eceae5;
  --accent: #2563eb;
  --accent-soft: #eaf0fe;
  --accent-border: #cdddfb;
  --feature: #2563eb;
  --bug: #c0392b;
  --bug-soft: #fdeceb;
  --bug-border: #f4c9c5;
  --done: #15803d;
  --done-soft: #eaf6ee;
  --done-border: #cfe9d6;
  --done-circle: #15a34a;
  --amber: #b4530a;
  --amber-soft: #fef3e2;
  --amber-soft-2: #fffaf2;
  --amber-border: #f0b352;
  --amber-strong: #e08a1e;
  --danger: #d6453c;
  --danger-soft: #fdeceb;
  --danger-border: #f4c9c5;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-arabic: "KerwenTro", "Noto Naskh Arabic", "Scheherazade New", "Geeza Pro", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  font-family: var(--font-sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Töte / Arabic script mode: right-to-left + Töte (KerwenTro) font EVERYWHERE.
   Redefining the font variables here makes every element that resolves
   var(--font-sans) or var(--font-mono) — including .mono badges, counts,
   summary line, dates, inputs, buttons — use KerwenTro first. Latin / Cyrillic
   / digits fall through to the Plex fonts per-glyph (KerwenTro lacks them). */
body.tote {
  direction: rtl;
  --font-sans: "KerwenTro", "IBM Plex Sans", "Noto Naskh Arabic", system-ui, sans-serif;
  --font-mono: "KerwenTro", "IBM Plex Mono", "Noto Naskh Arabic", ui-monospace, monospace;
  --font-arabic: "KerwenTro", "Noto Naskh Arabic", "Scheherazade New", "Geeza Pro", serif;
  font-family: var(--font-sans);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d4d3ce; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #bcbab3; background-clip: padding-box; border: 2px solid transparent; }
input::placeholder, textarea::placeholder { color: #b3b1a9; }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

.app-root { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---- Buttons ---- */
button { font-family: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500;
}
.btn:hover { background: var(--surface-3); }
.btn-dashed { border-style: dashed; border-color: #c9c7c0; color: #5a5852; }
.btn-primary {
  padding: 9px 16px; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 600; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { filter: brightness(0.96); }
.btn-ghost {
  padding: 7px 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 500; border-radius: 8px;
}
.btn-amber {
  border: 1px solid var(--amber-strong); background: var(--amber-strong);
  color: #fff; font-weight: 600; padding: 9px 15px; border-radius: 8px; font-size: 13px;
}
.btn-danger {
  border: 1px solid var(--danger); background: var(--danger);
  color: #fff; font-weight: 600; padding: 9px 15px; border-radius: 8px; font-size: 13px;
}

/* ---- Header ---- */
.header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 22px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex: none;
}
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark {
  width: 27px; height: 27px; border-radius: 7px; background: var(--text);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
}
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.divider { width: 1px; height: 22px; background: var(--border); flex: none; }
.project-pills { display: flex; align-items: center; gap: 8px; overflow-x: auto; flex: 1; padding-bottom: 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.pill.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.pill .count { font-family: var(--font-mono); font-size: 11px; opacity: 0.65; }
.pill.active .count { opacity: 0.85; }

.user-area { display: flex; align-items: center; gap: 9px; flex: none; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--text);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; font-family: var(--font-mono);
}
.script-toggle {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 600;
}

/* ---- Toolbar ---- */
.toolbar { display: flex; align-items: flex-end; gap: 12px; padding: 16px 22px 12px; flex: none; }
.toolbar .title-block { min-width: 0; }
.project-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.summary { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-2); margin-top: 3px; }
.spacer { flex: 1; }

/* ---- Tabs ---- */
.tabs { display: flex; align-items: center; gap: 22px; padding: 0 22px; border-bottom: 1px solid var(--border); flex: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 2px 9px;
  border: none; border-bottom: 2px solid transparent; background: none;
  color: var(--muted-2); font-size: 13.5px; font-weight: 500;
}
.tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tab .count {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted-2);
  background: var(--chip-bg); border-radius: 20px; padding: 1px 7px;
}
.tab.active .count { color: #fff; background: var(--accent); }

/* ---- Content ---- */
.content { display: flex; flex-direction: column; gap: 14px; padding: 18px 22px 28px; flex: 1; min-height: 0; overflow: auto; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-head {
  display: flex; align-items: center; gap: 9px; padding: 9px 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  cursor: pointer; user-select: none;
}
.section-chevron { font-size: 11px; color: var(--muted-2); width: 12px; display: inline-block; text-align: center; }
.section-name { font-weight: 600; font-size: 14px; }
.section-count { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); background: var(--chip-bg); border-radius: 20px; padding: 1px 8px; }
.badge-blocked-count {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--amber);
  background: #fdebd0; border: 1px solid #f3cd8f; border-radius: 5px; padding: 1px 7px; white-space: nowrap; flex: none;
}
.section-list { display: flex; flex-direction: column; gap: 8px; padding-inline-start: 2px; }
.empty-note { color: #a8a69e; font-size: 12px; font-family: var(--font-mono); padding: 10px 4px; }
.empty-block {
  text-align: center; color: #a8a69e; font-size: 13px; font-family: var(--font-mono);
  padding: 40px 8px; border: 1.5px dashed var(--border-2); border-radius: 12px;
}

/* ---- Task card ---- */
.card { display: flex; gap: 11px; align-items: flex-start; border-radius: 9px; padding: 11px 13px; border: 1px solid var(--border); background: var(--surface); }
.card.done { background: #fbfbfa; }
.card.blocked { background: var(--amber-soft-2); border-color: var(--amber-border); }
.card-circle {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #c9c7c0; background: #fff;
  color: transparent; display: flex; align-items: center; justify-content: center; flex: none;
  line-height: 1; padding: 0; margin-top: 1px; font-size: 12px; font-weight: 700;
}
.card-circle.done { border: none; background: var(--done-circle); color: #fff; }
.card-circle.locked { cursor: default; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.card-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 14.5px; font-weight: 500; color: var(--text); }
.card-title.done { color: var(--muted-3); text-decoration: line-through; text-decoration-color: #c7c5be; }
.card-desc { font-size: 12.5px; color: #76746c; line-height: 1.45; white-space: pre-wrap; }
.card-meta { display: flex; align-items: center; gap: 12px; margin-top: 1px; flex-wrap: wrap; }
.meta-text { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-3); }
.meta-done { font-family: var(--font-mono); font-size: 10.5px; color: var(--done); }
.card-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--muted); font-size: 12px;
  display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0;
}
.icon-btn.amber { border-color: #f0b352; background: var(--amber-soft); color: var(--amber); }
.icon-btn.del { color: var(--muted-3); }

/* badges */
.badge { font-size: 10.5px; font-weight: 600; font-family: var(--font-mono); border-radius: 5px; padding: 1px 7px; white-space: nowrap; flex: none; }
.badge-feature { color: var(--feature); background: var(--accent-soft); border: 1px solid var(--accent-border); }
.badge-bug { color: var(--bug); background: var(--bug-soft); border: 1px solid var(--bug-border); }
.badge-done { color: var(--done); background: var(--done-soft); border: 1px solid var(--done-border); }
.badge-todo { color: var(--muted); background: var(--chip-bg); }
.badge-blocked { color: var(--amber); background: #fdebd0; border: 1px solid #f3cd8f; }

.blocked-box { display: flex; flex-direction: column; gap: 3px; background: var(--amber-soft); border: 1px solid #f3cd8f; border-inline-start: 3px solid var(--amber-strong); border-radius: 7px; padding: 7px 9px; }
.blocked-box .label { font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .05em; color: var(--amber); }
.blocked-box .reason { font-size: 12px; color: #7c4a12; line-height: 1.45; white-space: pre-wrap; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(27,27,25,0.38);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 440px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25); padding: 22px;
  display: flex; flex-direction: column; gap: 15px;
}
.modal.narrow { max-width: 400px; }
.modal.block-top { border-top: 4px solid var(--amber-strong); }
/* Content wrapper inside a modal — keeps even spacing between every field/row. */
.modal-body { display: flex; flex-direction: column; gap: 15px; }
.modal-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-text { font-size: 13.5px; color: #5a5852; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 2px; }
.field { display: flex; flex-direction: column; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
label.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid var(--border-2);
  border-radius: 8px; font-size: 13.5px; font-family: inherit; background: var(--surface-2);
}
.textarea { resize: vertical; line-height: 1.5; }
.select { cursor: pointer; }
.type-toggle { display: flex; gap: 8px; }
.type-btn { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 500; }
.type-btn.active-feature { border-color: var(--feature); background: var(--accent-soft); color: var(--feature); font-weight: 600; }
.type-btn.active-bug { border-color: var(--bug); background: var(--bug-soft); color: var(--bug); font-weight: 600; }
.form-error { font-size: 12.5px; color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-border); border-radius: 8px; padding: 8px 11px; }

/* ---- Login screen ---- */
.login-screen { position: fixed; inset: 0; z-index: 200; display: flex; background: var(--bg); }
.login-hero {
  flex: 1; background: var(--text); color: #fff; display: flex; flex-direction: column;
  justify-content: space-between; padding: 48px;
}
.login-hero .brand-mark { background: #fff; color: var(--text); width: 30px; height: 30px; border-radius: 8px; font-size: 16px; }
.login-hero h1 { font-size: 30px; font-weight: 600; line-height: 1.25; letter-spacing: -0.02em; margin: 0; }
.login-hero .desc { font-size: 14px; color: #a8a69e; margin-top: 14px; line-height: 1.6; max-width: 360px; }
.login-hero .copy { font-family: var(--font-mono); font-size: 11.5px; color: #75736b; }
.login-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 18px; }
.login-form h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.login-form .sub { font-size: 13px; color: var(--muted-2); margin-top: 5px; }
.login-form .input { padding: 11px 12px; font-size: 14px; background: #fff; border-radius: 9px; }
.login-submit { padding: 12px; border-radius: 9px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; }
.login-switch { font-size: 13px; color: var(--muted); text-align: center; background: none; border: none; }
.login-switch b { color: var(--accent); }
.login-topbar { position: absolute; top: 18px; inset-inline-end: 22px; }

@media (max-width: 720px) {
  .login-hero { display: none; }
}
