/* ---------------------------------------------------------------------
   دفتر روزانه — "Ember Ledger" theme
   Warm charcoal/near-black base, embered orange accent, soft grey ink.
   Signature element: the radial "امروز" progress ring on the dashboard.
--------------------------------------------------------------------- */

:root {
  --bg: #15130f;
  --bg-glow: radial-gradient(1100px 520px at 50% -12%, rgba(239,125,60,.16), transparent 60%);
  --surface: #1e1b16;
  --surface-2: #272319;
  --surface-3: #322c1f;
  --border: #3a3527;
  --border-soft: #2a2619;

  --accent: #ef7d3c;
  --accent-2: #d9642a;
  --accent-soft: #f7ab78;
  --accent-glow: rgba(239,125,60,.38);
  --accent-ink: #241205;

  --sage: #6fbf8b;
  --sage-soft: #9adcb3;
  --clay: #e35b4e;
  --clay-soft: #f0968c;

  --text: #f4efe6;
  --text-muted: #a89e8c;
  --text-faint: #6f6656;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.35), 0 10px 26px -14px rgba(0,0,0,.55);
  --shadow-pop: 0 24px 70px -18px rgba(0,0,0,.65);

  --font-body: 'Vazirmatn', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Light ("روشن") theme — same structure, warm paper palette */
[data-theme="light"] {
  --bg: #f6f2ea;
  --bg-glow: radial-gradient(1100px 480px at 50% -12%, rgba(217,100,42,.10), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f2ece0;
  --surface-3: #e9e0cf;
  --border: #e1d6c1;
  --border-soft: #ece3d2;

  --accent: #d9642a;
  --accent-2: #b84f1d;
  --accent-soft: #f0b287;
  --accent-glow: rgba(217,100,42,.28);
  --accent-ink: #fff6ee;

  --sage: #2f9260;
  --sage-soft: #cdeedb;
  --clay: #c9392b;
  --clay-soft: #fbd9d4;

  --text: #241f16;
  --text-muted: #756b57;
  --text-faint: #a89b81;

  --shadow-card: 0 1px 2px rgba(60,45,20,.06), 0 10px 26px -16px rgba(60,45,20,.18);
  --shadow-pop: 0 24px 70px -20px rgba(60,45,20,.35);
}

/* Accent alternates — every other accent swatch swaps the same three tokens */
[data-accent="blue"]   { --accent: #4f9bdb; --accent-2: #3a7fbd; --accent-soft: #9ecdf2; --accent-glow: rgba(79,155,219,.35); --accent-ink: #051422; }
[data-accent="purple"] { --accent: #a487e8; --accent-2: #8a68d6; --accent-soft: #cdbdf5; --accent-glow: rgba(164,135,232,.35); --accent-ink: #150c26; }
[data-accent="rose"]   { --accent: #e06e94; --accent-2: #c94f78; --accent-soft: #f3b0c6; --accent-glow: rgba(224,110,148,.35); --accent-ink: #250912; }
[data-theme="light"][data-accent="blue"]   { --accent-ink: #ffffff; }
[data-theme="light"][data-accent="purple"] { --accent-ink: #ffffff; }
[data-theme="light"][data-accent="rose"]   { --accent-ink: #ffffff; }

/* Completed items are removed from view entirely when this preference is on */
body.hide-completed .item-row.done { display: none; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-weight: 900; }

button, input, select, textarea { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-glow); color: var(--text); }

svg.icon { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- Top bar / nav ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.4rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  color: #1c0e02;
  box-shadow: 0 4px 14px -4px var(--accent-glow);
  flex-shrink: 0;
}
.brand-mark svg { width: 17px; height: 17px; stroke: #1c0e02; stroke-width: 2.4; }

.mainnav {
  display: flex;
  gap: .25rem;
  flex: 1;
  justify-content: center;
}

.mainnav a {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .85rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .88rem;
  transition: background .15s, color .15s;
}
.mainnav a svg { width: 16px; height: 16px; }

.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a.active { background: linear-gradient(150deg, var(--accent), var(--accent-2)); color: var(--accent-ink); font-weight: 700; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--clay);
  color: #fff;
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 700;
  line-height: 1;
}
.mainnav a.active .nav-badge { background: var(--accent-ink); color: var(--accent-soft); }

.userbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.93); }
.icon-btn svg { width: 17px; height: 17px; }

.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: flex; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: flex; }

.userbox .username { color: var(--text); font-weight: 500; padding-inline-start: .3rem; }
.userbox .logout { color: var(--clay); }

/* ---------- Layout ---------- */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.7rem 1.2rem 5rem;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1.3rem;
}

.page-header .date-line {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-mono);
  color: var(--accent-soft);
  font-size: .92rem;
}
.page-header .date-line svg { width: 14px; height: 14px; }

/* ---------- Flash messages ---------- */
.flash-wrap { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.flash {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  border: 1px solid var(--border);
  animation: flash-in .25s ease;
}
.flash svg { width: 16px; height: 16px; flex-shrink: 0; }
.flash-success { background: color-mix(in srgb, var(--sage) 14%, var(--surface)); border-color: var(--sage); color: var(--sage-soft); }
.flash-error { background: color-mix(in srgb, var(--clay) 14%, var(--surface)); border-color: var(--clay); color: var(--clay-soft); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.flash.flash-out { opacity: 0; transform: translateY(-6px); max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; transition: all .35s ease; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-card);
}

.card + .card { margin-top: .8rem; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}

.auth-shell {
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-pop);
  background: var(--surface);
}

.auth-hero {
  background:
    var(--bg-glow),
    linear-gradient(160deg, var(--surface-3), var(--surface-2));
  padding: 2.4rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-hero::after {
  content: "";
  position: absolute;
  inset: auto -30% -40% auto;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
}
.auth-hero-mark {
  width: 46px; height: 46px;
  border-radius: 13px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px -6px var(--accent-glow);
}
.auth-hero-mark svg { width: 24px; height: 24px; stroke: #1c0e02; stroke-width: 2.2; }
.auth-hero h2 { font-size: 1.3rem; margin-top: 1.1rem; }
.auth-hero p { color: var(--text-muted); font-size: .87rem; line-height: 1.8; margin: 0; }
.auth-hero-list { list-style: none; padding: 0; margin: 1.2rem 0 0; display: flex; flex-direction: column; gap: .6rem; position: relative; }
.auth-hero-list li { display: flex; align-items: center; gap: .55rem; font-size: .82rem; color: var(--text-muted); }
.auth-hero-list svg { width: 15px; height: 15px; color: var(--accent-soft); }

.auth-card {
  width: 100%;
  padding: 2.3rem 2rem;
}

.auth-card h1 {
  color: var(--text);
  font-size: 1.35rem;
  margin-bottom: .2rem;
}

.auth-sub {
  text-align: right;
  color: var(--text-muted);
  font-size: .85rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card { padding: 1.8rem 1.4rem; }
}

/* ---------- Forms ---------- */
.field { margin-bottom: .9rem; }
.field label {
  display: block;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: .35rem;
}

input[type="text"], input[type="password"], input[type="date"],
input[type="time"], input[type="search"], textarea, select {
  width: 100%;
  padding: .62rem .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .92rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .62rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: filter .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 6px 18px -8px var(--accent-glow);
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { filter: brightness(1.06); box-shadow: 0 8px 22px -6px var(--accent-glow); }
.btn:active { transform: scale(.97); }

.btn-block { width: 100%; }
.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger {
  background: transparent;
  border-color: var(--clay);
  color: var(--clay-soft);
  box-shadow: none;
}
.btn-danger:hover { background: color-mix(in srgb, var(--clay) 14%, transparent); }
.btn-sm { padding: .38rem .75rem; font-size: .78rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 999px; }

.inline-form { display: inline; }

/* quick-add row */
.quick-add {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.quick-add input[type="text"] { flex: 1; min-width: 160px; }

/* ---------- Today ring (signature element) ---------- */
.today-hero {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.3rem;
  flex-wrap: wrap;
}
.ring-wrap { position: relative; width: 116px; height: 116px; flex-shrink: 0; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.ring-fill {
  fill: none; stroke: url(#ringGradient); stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(.3,.9,.3,1);
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-center .pct { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: var(--text); }
.ring-center .pct::after { content: "٪"; font-size: .9rem; color: var(--accent-soft); margin-inline-start: 1px; }

.today-summary { flex: 1; min-width: 180px; }
.today-summary .lbl { color: var(--text-muted); font-size: .85rem; margin-bottom: .3rem; }
.today-summary .count { font-family: var(--font-mono); font-size: 1.1rem; color: var(--text); }
.today-summary .count b { color: var(--accent-soft); font-weight: 700; }

/* legacy slim progress bar — reused on stat listings if needed */
.progress-wrap { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.2rem; }
.progress-bar { flex: 1; height: 9px; background: var(--surface-2); border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .5s ease; }
.progress-label { font-family: var(--font-mono); font-size: .82rem; color: var(--accent-soft); white-space: nowrap; }

/* ---------- Overdue banner ---------- */
.overdue-card {
  border-color: var(--clay);
  background: color-mix(in srgb, var(--clay) 8%, var(--surface));
  margin-bottom: 1rem;
}
.overdue-card h3 { display: flex; align-items: center; gap: .45rem; font-size: .92rem; color: var(--clay-soft); margin-bottom: .7rem; }
.overdue-card h3 svg { width: 16px; height: 16px; }
.overdue-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 0;
  border-top: 1px solid color-mix(in srgb, var(--clay) 22%, transparent);
  font-size: .87rem;
}
.overdue-row:first-of-type { border-top: none; }
.overdue-row .od-title { flex: 1; }
.overdue-row .od-date { color: var(--text-muted); font-family: var(--font-mono); font-size: .76rem; }
.overdue-row.done { opacity: .5; }
.overdue-row.done .od-title { text-decoration: line-through; }
.overdue-row .check { width: 21px; height: 21px; }
.overdue-row .check-icon { width: 11px; height: 11px; }

/* ---------- Item rows (tasks / routines) ---------- */
.item-list { display: flex; flex-direction: column; gap: .55rem; }

.item-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: opacity .15s, border-color .15s, transform .12s;
}
.item-row:hover { border-color: var(--border); }

.item-row.done { opacity: .55; }
.item-row.done .item-title { text-decoration: line-through; }

.check {
  flex-shrink: 0;
  width: 25px;
  height: 25px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  cursor: pointer;
  position: relative;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, transform .1s;
}
.check:active { transform: scale(.9); }
.check.checked { background: linear-gradient(150deg, var(--sage), #4a9c6c); border-color: transparent; }
.check-icon { width: 13px; height: 13px; color: #08210f; stroke-width: 3; opacity: 0; transform: scale(.4); transition: opacity .15s, transform .15s; }
.check.checked .check-icon { opacity: 1; transform: scale(1); }

.item-actions { display: flex; gap: .3rem; flex-shrink: 0; align-self: flex-start; }

.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 500; font-size: .95rem; }
.item-meta {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .4rem;
  font-size: .74rem;
  color: var(--text-muted);
}
.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .16rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
}
.tag svg { width: 11px; height: 11px; }
.tag-time { color: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tag-priority-زیاد .dot { background: var(--clay); }
.tag-priority-زیاد { color: var(--clay-soft); }
.tag-priority-متوسط .dot { background: var(--accent-soft); }
.tag-priority-متوسط { color: var(--accent-soft); }
.tag-priority-کم .dot { background: var(--text-faint); }
.tag-priority-کم { color: var(--text-muted); }

.item-desc { margin-top: .4rem; font-size: .82rem; color: var(--text-muted); line-height: 1.6; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: .9rem;
}
.empty-state svg { width: 40px; height: 40px; color: var(--text-faint); margin-bottom: .8rem; }
.empty-state .empty-title { color: var(--text); font-weight: 700; font-size: .98rem; margin-bottom: .3rem; }

/* ---------- Filter bar (daily tasks) ---------- */
.filter-bar {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-search { position: relative; flex: 1; min-width: 190px; }
.filter-search svg {
  position: absolute; top: 50%; right: .75rem; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-faint); pointer-events: none;
}
.filter-search input { padding-right: 2.2rem; }
.filter-select { min-width: 130px; }
.filter-chips { display: flex; gap: .35rem; }
.filter-chip {
  padding: .5rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  white-space: nowrap;
}
.filter-chip.active { background: linear-gradient(150deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; font-weight: 700; }

/* ---------- Weekly ledger ---------- */
.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .8rem;
}

.day-col {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: .85rem;
  min-height: 120px;
  box-shadow: var(--shadow-card);
}

.day-col.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow-card); }

.day-col h3 {
  font-size: .84rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .65rem;
  font-weight: 700;
}

.day-col.today h3 { color: var(--accent-soft); }

.routine-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .65rem;
  margin-bottom: .4rem;
  font-size: .82rem;
}
.routine-chip.inactive { opacity: .45; }
.routine-chip .rt-title { font-weight: 500; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.routine-chip .rt-title .tag { font-size: .68rem; padding: .1rem .45rem; }
.routine-chip .rt-time { color: var(--accent-soft); font-family: var(--font-mono); font-size: .75rem; }
.routine-chip .rt-actions { margin-top: .4rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.routine-chip .rt-actions button, .routine-chip .rt-actions .btn {
  font-size: .7rem;
  padding: .25rem .55rem;
}

/* ---------- Stats ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .8rem;
  margin-bottom: 1.2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-card);
  display: flex; align-items: center; gap: .8rem;
}
.stat-card .stat-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
}
.stat-card .stat-icon svg { width: 21px; height: 21px; stroke-width: 2.2; }
.stat-card .num { font-family: var(--font-mono); font-size: 1.55rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-card .lbl { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-card);
}
.chart-wrap h3 { font-size: .9rem; color: var(--text-muted); margin-bottom: .8rem; }

.cat-bar-wrap { display: flex; flex-direction: column; gap: .55rem; }
.cat-bar-row { display: flex; align-items: center; gap: .7rem; font-size: .85rem; }
.cat-bar-row .cat-name { width: 90px; flex-shrink: 0; color: var(--text-muted); }
.cat-bar-track { flex: 1; height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.cat-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 6px; }
.cat-bar-row .cat-count { font-family: var(--font-mono); color: var(--accent-soft); width: 22px; text-align: left; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav { display: none; }

@media (max-width: 680px) {
  .topbar { padding: .7rem 1rem; }
  .mainnav { display: none; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-soft);
    z-index: 30;
    padding: .35rem .2rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    position: relative;
    flex: 1;
    text-align: center;
    font-size: .66rem;
    color: var(--text-muted);
    padding: .4rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    border-radius: var(--radius-sm);
  }
  .bottom-nav a svg { width: 19px; height: 19px; }
  .bottom-nav a.active { color: var(--accent-soft); }
  .bottom-nav a.active::before {
    content: "";
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 22px; height: 3px; border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
  }
  .bottom-nav .nav-badge { position: absolute; top: 0; left: calc(50% - 20px); }

  .container { padding-bottom: 5.4rem; }
  .week-grid { grid-template-columns: 1fr; }
  .today-hero { justify-content: center; text-align: center; }
  .auth-hero-list { align-items: flex-start; }
}

/* ---------- Settings page ---------- */
.settings-card h3 {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: .9rem;
  font-size: 1rem;
  color: var(--text);
}
.settings-card h3 svg { width: 17px; height: 17px; color: var(--accent-soft); }

.settings-note {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin: .4rem 0 .8rem;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.segmented-option {
  position: relative;
  cursor: pointer;
  border-left: 1px solid var(--border);
}
[dir="rtl"] .segmented-option { border-left: none; border-right: 1px solid var(--border); }
.segmented-option:last-child { border: none; }
.segmented-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented-option span {
  display: flex; align-items: center; gap: .35rem;
  padding: .48rem 1.1rem;
  font-size: .85rem;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.segmented-option span svg { width: 14px; height: 14px; }
.segmented-option.active span {
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 700;
}

.swatch-row { display: flex; gap: .8rem; }
.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  box-shadow: 0 2px 8px -2px rgba(0,0,0,.4);
}
.swatch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.swatch.active { border-color: var(--text); }
.swatch.active::after {
  content: "";
  position: absolute; inset: -5px;
  border-radius: 50%; border: 1px solid var(--border);
}
.swatch-gold   { background: linear-gradient(150deg, #ef7d3c, #d9642a); }
.swatch-blue   { background: linear-gradient(150deg, #4f9bdb, #3a7fbd); }
.swatch-purple { background: linear-gradient(150deg, #a487e8, #8a68d6); }
.swatch-rose   { background: linear-gradient(150deg, #e06e94, #c94f78); }

.toggle-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: .9rem;
  color: var(--text);
  cursor: pointer;
  margin-bottom: .5rem;
}
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 40px; height: 23px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border);
  position: relative; flex-shrink: 0;
  transition: background .2s;
}
.switch::after {
  content: "";
  position: absolute; top: 2px; right: 2px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--text-muted);
  transition: transform .2s, background .2s;
}
.toggle-row input:checked + .switch { background: color-mix(in srgb, var(--accent) 35%, var(--surface-3)); border-color: var(--accent); }
.toggle-row input:checked + .switch::after { transform: translateX(-17px); background: var(--accent); }

.category-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .3rem .4rem .3rem .9rem;
  font-size: .85rem;
}
.chip-remove {
  background: transparent;
  border: none;
  color: var(--clay);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: .15rem .45rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.chip-remove svg { width: 12px; height: 12px; }
.chip-remove:hover { background: color-mix(in srgb, var(--clay) 16%, transparent); }

/* ---------- Modal (edit forms + confirm dialogs) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8,6,3,.6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal-panel {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 1.5rem;
  transform: translateY(10px) scale(.98);
  transition: transform .18s ease;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-backdrop.open .modal-panel { transform: none; }
.modal-panel h3 { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; margin-bottom: 1.1rem; }
.modal-panel h3 svg { width: 18px; height: 18px; color: var(--accent-soft); }
.modal-actions { display: flex; gap: .6rem; margin-top: 1.1rem; }
.modal-actions .btn { flex: 1; }
.modal-close {
  position: absolute; top: 1.1rem; left: 1.1rem;
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--surface-2); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.modal-close svg { width: 14px; height: 14px; }
.modal-panel { position: relative; }

.confirm-icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: color-mix(in srgb, var(--clay) 16%, var(--surface));
  color: var(--clay);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .9rem;
}
.confirm-icon svg { width: 22px; height: 22px; }
.confirm-text { color: var(--text-muted); font-size: .88rem; line-height: 1.7; margin-bottom: 0; }
