/* ------------------------------------------------------------------
   Todos — a quiet task manager
   ------------------------------------------------------------------ */

:root {
  color-scheme: light;
  --bg: #f5f4f1;
  --bg-deep: #efece7;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --sidebar: #f1efeb;
  --sidebar-line: #e2dfd9;
  --text: #1d1c1a;
  --text-soft: #4b4a47;
  --muted: #8b8880;
  --muted-2: #a9a59c;
  --line: #e7e4de;
  --line-strong: #dbd7d0;
  --chip: #f0eee9;
  --chip-text: #6a675f;
  --accent: #3a6ff0;
  --accent-hover: #2f5fd6;
  --accent-soft: #e9efff;
  --accent-text: #2a58cc;
  --gold: #c98a1f;
  --gold-soft: #f8efd9;
  --danger: #d9534a;
  --danger-soft: #fbeceb;
  --green: #2f9e6e;
  --shadow-sm: 0 1px 2px rgba(29, 28, 26, 0.04);
  --shadow-md: 0 2px 10px rgba(29, 28, 26, 0.06), 0 1px 3px rgba(29, 28, 26, 0.05);
  --shadow-lg: 0 24px 70px rgba(29, 28, 26, 0.18), 0 6px 20px rgba(29, 28, 26, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 258px;
  --ease: cubic-bezier(0.32, 0.72, 0.24, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161619;
  --bg-deep: #111114;
  --surface: #1e1e22;
  --surface-2: #232328;
  --sidebar: #121215;
  --sidebar-line: #26262b;
  --text: #f0efec;
  --text-soft: #c8c6c1;
  --muted: #8f8d88;
  --muted-2: #6f6d69;
  --line: #2a2a30;
  --line-strong: #34343b;
  --chip: #2a2a30;
  --chip-text: #b9b6b0;
  --accent: #5f8bff;
  --accent-hover: #7ba0ff;
  --accent-soft: #1e2a47;
  --accent-text: #9db8ff;
  --gold: #e0aa4d;
  --gold-soft: #33291a;
  --danger: #f07168;
  --danger-soft: #3a2222;
  --green: #4cbb8c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.6), 0 6px 20px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body.drawer-open,
body.dialog-open { overflow: hidden; }

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

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

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

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

.ico { display: block; flex: none; }

/* ------------------------------------------------------------------ layout */

.app {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(15, 15, 17, 0.34);
  backdrop-filter: blur(2px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 18px 12px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(145deg, #4b7bf5, #2f5fd6);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(47, 95, 214, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.brand-mark svg { width: 15px; height: 15px; }

.brand-name {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.sidebar-close { display: none; margin-left: auto; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
  scrollbar-width: thin;
}

.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid var(--sidebar); }

.nav { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.3;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
  min-height: 32px;
}

.nav-item .ico { color: var(--muted); transition: color 0.14s var(--ease); }

.nav-item:hover { background: rgba(128, 122, 108, 0.09); color: var(--text); }
.nav-item:hover .ico { color: var(--text-soft); }

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 560;
}

.nav-item.is-active .ico { color: var(--accent); }

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 500;
  padding-left: 4px;
}

.nav-item.is-active .nav-count { color: var(--accent-text); opacity: 0.8; }

.nav-item-sub { font-size: 13px; padding-left: 11px; }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 9px 6px;
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-head-gap { padding-top: 18px; }

.mini-btn {
  min-width: 21px;
  height: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 560;
  white-space: nowrap;
  flex: none;
  opacity: 0.75;
  transition: background 0.14s, opacity 0.14s;
}

.mini-btn:hover { background: rgba(128, 122, 108, 0.14); opacity: 1; }

.mini-link {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 3px;
  text-transform: uppercase;
  font-weight: 600;
}

.mini-link:hover { color: var(--accent); }

.side-subtle {
  font-size: 12px;
  color: var(--muted-2);
  padding: 5px 11px;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-line);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  padding: 5px 6px;
  border-radius: 6px;
  min-width: 0;
  flex: 1;
}

.sync-status:hover { background: rgba(128, 122, 108, 0.1); color: var(--text-soft); }

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}

.sync-status.is-connected .sync-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(47, 158, 110, 0.14); }
.sync-status.is-warn .sync-dot { background: var(--gold); }
.sync-status.is-error .sync-dot { background: var(--danger); }

.sync-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-actions { display: flex; gap: 1px; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  transition: background 0.14s var(--ease), color 0.14s var(--ease), transform 0.1s;
  flex: none;
}

.icon-btn:hover { background: rgba(128, 122, 108, 0.12); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.subtle { width: 24px; height: 24px; opacity: 0.5; }
.icon-btn.subtle:hover { opacity: 1; }

.icon-btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(42, 88, 204, 0.28);
}

.icon-btn.primary:hover { background: var(--accent-hover); color: #fff; }

/* ------------------------------------------------------------------ main */

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 32px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}

.topbar-context {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}

body.is-scrolled .topbar-context,
body.is-scrolled .topbar {
  opacity: 1;
}

body.is-scrolled .topbar-context {
  transform: none;
  pointer-events: auto;
}

body.is-scrolled .topbar {
  border-bottom-color: var(--line);
}

.search-close {
  display: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px;
  border-radius: 4px;
  place-items: center;
}

.search-close:hover { background: var(--chip); color: var(--text); }

.topbar-title {
  font-size: 15px;
  font-weight: 640;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.menu-btn { display: none; }

.search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 232px;
  height: 31px;
  padding: 0 9px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  width: 13px;
  height: 13px;
  border: 1.7px solid currentColor;
  border-radius: 50%;
  position: relative;
  flex: none;
  opacity: 0.75;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 1.7px;
  background: currentColor;
  border-radius: 2px;
  right: -3px;
  bottom: -1px;
  transform: rotate(45deg);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 12.5px;
  color: var(--text);
}

.search-field input::placeholder { color: var(--muted-2); }
.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.search-field kbd {
  font-family: var(--font);
  font-size: 10.5px;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 15px;
}

.search-toggle { display: none; }

.add-btn { width: 31px; height: 31px; border-radius: 8px; }
.add-btn .ico { width: 17px; height: 17px; }

.view {
  width: 100%;
  max-width: 812px;
  margin: 0 auto;
  padding: 14px 32px 120px;
}

/* ------------------------------------------------------------------ view head */

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 2px 22px;
}

.view-head h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.15;
  font-weight: 690;
  letter-spacing: -0.028em;
}

.view-head p {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.view-actions { display: flex; gap: 8px; padding-bottom: 3px; }

.primary-btn, .ghost-btn, .danger-btn, .success-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 560;
  padding: 7px 12px;
  transition: background 0.14s var(--ease), border-color 0.14s, color 0.14s, transform 0.1s;
  white-space: nowrap;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(42, 88, 204, 0.25);
}

.primary-btn:hover { background: var(--accent-hover); }
.success-btn {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--green) 35%, transparent);
}
.success-btn:hover { filter: brightness(0.94); }
.primary-btn:active, .ghost-btn:active, .danger-btn:active, .success-btn:active { transform: translateY(0.5px); }

.ghost-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}

.ghost-btn:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--text); }

.danger-btn { background: var(--danger); color: #fff; }
.danger-btn:hover { filter: brightness(0.94); }

.danger-text { color: var(--danger); }
.ghost-btn.danger-text { background: var(--surface); }
.ghost-btn.danger-text:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); color: var(--danger); }

.muted-small { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--gold-soft);
  color: var(--gold);
}

/* ------------------------------------------------------------------ composer */

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 22px;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-icon { color: var(--accent); opacity: 0.85; display: grid; place-items: center; }

.composer input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
  color: var(--text);
  padding: 0;
}

.composer input::placeholder { color: var(--muted-2); }

.composer-submit {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-2);
  display: grid;
  place-items: center;
  transition: background 0.14s, color 0.14s;
}

.composer:focus-within .composer-submit { color: var(--accent); background: var(--accent-soft); }
.composer-submit:hover { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------ groups + tasks */

.group { margin-bottom: 24px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
}

.group-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  padding: 2px 2px 2px 0;
  border-radius: 5px;
  color: var(--muted);
}

.group-toggle:hover { color: var(--text-soft); }

.group-chevron {
  display: grid;
  place-items: center;
  transition: transform 0.18s var(--ease);
  color: var(--muted-2);
}

.group-chevron.is-open { transform: rotate(90deg); }

.group-title {
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.group-meta {
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  background: var(--chip);
  padding: 1px 6px;
  border-radius: 20px;
}

.group-body { animation: fadeUp 0.2s var(--ease); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: none; }
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 9px 10px 9px 12px;
  border-top: 1px solid var(--line);
  transition: background 0.12s var(--ease);
  position: relative;
}

.task-card > .task-row:first-child,
.subtasks > .task-row:first-child { border-top: 0; }

.task-row:hover { background: var(--surface-2); }

.task-row.is-done .task-title { color: var(--muted-2); text-decoration: line-through; text-decoration-thickness: 1px; }
.task-row.is-done .task-meta { opacity: 0.55; }

.task-rail {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-top: 1px;
  width: 46px;
  flex: none;
}

.check {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  display: grid;
  place-items: center;
  color: transparent;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
  flex: none;
  padding: 0;
}

.check svg { width: 12px; height: 12px; stroke-width: 3.2; opacity: 0; transition: opacity 0.12s; }

.check:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.check:hover svg { opacity: 1; }
.check:active { transform: scale(0.9); }

.check.is-done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.check.is-done svg { opacity: 1; }
.check.is-done:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.expand-btn {
  width: 18px;
  height: 18px;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  display: grid;
  place-items: center;
  border-radius: 4px;
  transition: transform 0.16s var(--ease), background 0.14s;
}

.expand-btn:hover { background: var(--chip); color: var(--text-soft); }
.expand-btn.is-open { transform: rotate(90deg); }

.expand-spacer { width: 18px; flex: none; }

.task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  color: inherit;
}

.task-title {
  font-size: 13.5px;
  line-height: 1.4;
  font-weight: 450;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
}

.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.row-open {
  border: 0;
  background: transparent;
  color: var(--muted-2);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
  flex: none;
  align-self: center;
}

.task-row:hover .row-open { opacity: 1; }
.row-open:hover { background: var(--chip); color: var(--text-soft); }

.subtasks {
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
  border-top: 1px solid var(--line);
}

.subtasks .task-row {
  padding-left: 34px;
  border-top-color: color-mix(in srgb, var(--line) 65%, transparent);
}

.subtasks .task-row::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.subtasks .task-rail { width: 44px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--chip-text);
  background: var(--chip);
  padding: 1.5px 6px;
  border-radius: 5px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip .ico { opacity: 0.7; }

.chip.is-overdue { background: var(--danger-soft); color: var(--danger); }
.chip.is-today { background: var(--gold-soft); color: var(--gold); }
.chip.is-tomorrow { background: var(--accent-soft); color: var(--accent-text); }

.chip.icon-only { padding: 2px 4px; }

.chip.project-chip { background: transparent; padding-left: 2px; color: var(--muted); }
.chip.project-chip .dot { margin-right: 1px; }

.chip.section-chip { background: transparent; padding-left: 0; color: var(--muted); }
.chip.section-chip .ico { opacity: 0.55; }

.chip.tag-chip {
  background: color-mix(in srgb, var(--tag) 10%, transparent);
  color: color-mix(in srgb, var(--tag) 78%, var(--text));
}

.chip.tag-chip .tag-dot { width: 5px; height: 5px; }

.chip.category-chip { background: transparent; padding-left: 0; color: var(--muted); }

.chip.check-progress { background: transparent; padding-left: 0; color: var(--muted); font-variant-numeric: tabular-nums; }

.chip.prio-chip.prio-1 { background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--accent-text); }
.chip.prio-chip.prio-2 { background: var(--gold-soft); color: var(--gold); }
.chip.prio-chip.prio-3 { background: var(--danger-soft); color: var(--danger); }

.chip.parent-chip { background: transparent; padding-left: 0; color: var(--muted); }

.chip.tiny { font-size: 10px; padding: 1px 5px; }

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tag, var(--muted-2));
  flex: none;
  display: inline-block;
}

.tag-dot.square { border-radius: 2px; }
.tag-dot.xl { width: 13px; height: 13px; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--muted-2));
  flex: none;
  display: inline-block;
}

.dot.lg { width: 10px; height: 10px; }
.dot.xl { width: 14px; height: 14px; }

.prio-mark { display: grid; place-items: center; color: var(--muted-2); }
.prio-mark.prio-1 { color: var(--accent); }
.prio-mark.prio-2 { color: var(--gold); }
.prio-mark.prio-3 { color: var(--danger); }

/* check items */

.checkitem-row .task-rail { width: 32px; }
.checkitem-row .task-main { padding-top: 1px; }

/* ------------------------------------------------------------------ empty state */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 58px 24px 64px;
  color: var(--muted);
  animation: fadeUp 0.3s var(--ease);
}

.empty-art {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted-2);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.empty-art .ico { opacity: 0.7; }

.empty-state h3 {
  margin: 0 0 5px;
  font-size: 14.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
  color: var(--text-soft);
}

.empty-state p {
  margin: 0 0 16px;
  max-width: 330px;
  font-size: 12.5px;
  line-height: 1.55;
}

/* ------------------------------------------------------------------ segmented */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--chip);
  border-radius: 9px;
  margin-bottom: 18px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  padding: 5px 12px;
  border-radius: 6px;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}

.segmented button span {
  margin-left: 4px;
  font-size: 10.5px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.segmented.is-small { margin-bottom: 0; }
.segmented.is-small button { padding: 4px 10px; font-size: 11.5px; }

/* ------------------------------------------------------------------ progress */

.progress {
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  width: 100%;
}

.progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 3px;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.35s var(--ease);
}

/* ------------------------------------------------------------------ project grid */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 12px;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 15px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.16s var(--ease);
  color: var(--text);
  min-height: 118px;
}

.project-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.project-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-card-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.project-card-notes {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.project-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.project-card .progress { margin-top: 2px; }

.project-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.project-grid.is-archived { opacity: 0.62; }

.archive-group { margin-top: 30px; }

/* ------------------------------------------------------------------ project page */

.project-head, .section-page-head {
  padding: 12px 2px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-title-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 26px;
  font-weight: 690;
  letter-spacing: -0.028em;
  padding: 2px 4px;
  margin-left: -4px;
  border-radius: 6px;
  outline: 0;
  color: var(--text);
}

.project-title-input:hover { background: color-mix(in srgb, var(--chip) 55%, transparent); }
.project-title-input:focus { background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }

.project-menu { display: flex; gap: 2px; }

.project-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11.5px;
  color: var(--muted);
  padding-left: 2px;
  font-variant-numeric: tabular-nums;
}

.project-stats span + span::before { content: "·"; margin-right: 14px; color: var(--line-strong); }
.project-stats .badge::before { content: none; margin: 0; }

.project-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 2px;
}

.project-head .progress, .section-page-head .progress { max-width: 320px; }

.project-notes-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.card-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 640;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.project-notes {
  width: 100%;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
  min-height: 62px;
  padding: 0;
}

.project-notes::placeholder { color: var(--muted-2); }

.section-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
}

.section-card.is-done { opacity: 0.7; }

.section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
}

.section-head .check { width: 18px; height: 18px; }
.section-head .check svg { width: 10px; height: 10px; }

.section-title-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 9px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  color: var(--text);
}

.section-title {
  font-size: 13px;
  font-weight: 610;
  letter-spacing: -0.008em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-card.is-done .section-title { text-decoration: line-through; color: var(--muted); }

.section-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

.section-progress-mini { width: 54px; flex: none; }
.section-progress-mini .progress { height: 2px; }

.section-body { border-top: 1px solid var(--line); padding: 0 0 0; }

.section-body .task-card { border: 0; border-radius: 0; box-shadow: none; }
.section-body .task-card > .task-row { padding-left: 14px; }

.section-body .composer {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  height: 38px;
}

.section-body .composer:focus-within { box-shadow: inset 0 0 0 2px var(--accent-soft); }

.section-empty {
  margin: 0;
  padding: 14px 16px;
  font-size: 12px;
  color: var(--muted-2);
  border-bottom: 1px solid var(--line);
}

.project-section-actions { display: flex; padding: 2px 0 8px; }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  padding: 3px 6px 3px 2px;
  border-radius: 5px;
  align-self: flex-start;
  margin-left: -2px;
}

.crumb:hover { color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------------ tags / categories */

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.chip-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s var(--ease), box-shadow 0.15s;
}

.chip-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.chip-card-top { display: flex; align-items: center; gap: 7px; }

.chip-card-title {
  flex: 1;
  font-size: 13px;
  font-weight: 570;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-card-count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tag-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 2px 22px;
}

.tag-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 680;
  letter-spacing: -0.026em;
}

.tag-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.search-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 10px 13px;
  font-size: 13px;
  color: var(--text-soft);
}

.search-row:first-child { border-top: 0; }
.search-row:hover { background: var(--surface-2); }
.search-row span:nth-child(2) { flex: 1; }

/* ------------------------------------------------------------------ drawer */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 15, 17, 0.3);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  z-index: 61;
  inset: 0 0 0 auto;
  width: min(430px, 100vw);
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.drawer-sheet {
  pointer-events: auto;
  width: 100%;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.28s var(--ease);
}

@keyframes slideIn {
  from { transform: translateX(24px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.drawer-grip { display: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px 11px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.drawer-head-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.drawer-head-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.drawer-sub {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-crumb {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-head-actions { display: flex; gap: 2px; flex: none; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 26px;
  scrollbar-width: thin;
}

.drawer-body::-webkit-scrollbar { width: 10px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid var(--surface); }

.drawer-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}

.drawer-foot .primary-btn, .drawer-foot .ghost-btn, .drawer-foot .success-btn { flex: 1; justify-content: center; }
.drawer-foot .drawer-delete { flex: none; }

.detail-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.detail-title-wrap .check { width: 23px; height: 23px; margin-top: 3px; }
.detail-title-wrap .check svg { width: 13px; height: 13px; }

.detail-title {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 620;
  letter-spacing: -0.02em;
  color: var(--text);
  padding: 0;
  overflow: hidden;
}

.detail-kind {
  font-size: 11px;
  color: var(--muted-2);
  padding: 6px 0 0 34px;
  letter-spacing: 0.01em;
}

.detail-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 30px;
  padding: 2px 0;
}

.detail-row.is-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 7px 0;
}

.detail-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-soft);
  font-weight: 500;
  flex: none;
}

.detail-row-main .ico { color: var(--muted); }

.detail-row-value { font-size: 12.5px; color: var(--text-soft); text-align: right; }

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.block-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--muted);
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--muted);
}

.text-input, .select-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--text);
  outline: 0;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.text-input:focus, .select-input:focus, .notes-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

.select-input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) calc(50% - 1px), calc(100% - 9px) calc(50% - 1px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

.notes-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  resize: vertical;
  outline: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.notes-input::placeholder { color: var(--muted-2); }

.priority-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.prio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 540;
  padding: 6px 4px;
  border-radius: 7px;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.prio-btn:hover { border-color: var(--line-strong); color: var(--text-soft); }

.prio-btn.is-active { font-weight: 600; }
.prio-btn.prio-0.is-active { background: var(--chip); border-color: var(--line-strong); color: var(--text-soft); }
.prio-btn.prio-1.is-active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent-text); }
.prio-btn.prio-2.is-active { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 35%, transparent); color: var(--gold); }
.prio-btn.prio-3.is-active { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }

.date-input-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 9px;
  color: var(--muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.date-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.date-input-wrap input {
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12.5px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  padding: 0;
}

.date-input-wrap input::-webkit-calendar-picker-indicator { opacity: 0.45; cursor: pointer; }
html[data-theme="dark"] .date-input-wrap input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.4; }

.quick-dates { display: flex; flex-wrap: wrap; gap: 5px; }

.quick-dates button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 20px;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.quick-dates button:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent-text); }

.tags-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 540;
  color: color-mix(in srgb, var(--tag) 78%, var(--text));
  background: color-mix(in srgb, var(--tag) 11%, transparent);
  padding: 2px 4px 2px 8px;
  border-radius: 20px;
}

.tag-pill button {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  display: grid;
  place-items: center;
  padding: 2px;
  border-radius: 50%;
}

.tag-pill button:hover { opacity: 1; background: color-mix(in srgb, var(--tag) 20%, transparent); }

.tag-form { flex: 1; min-width: 92px; }
.tag-form input {
  width: 100%;
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 11.5px;
  outline: 0;
  color: var(--text);
}

.tag-form input::placeholder { color: var(--muted-2); }
.tag-form input:focus { border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  padding: 0;
  text-align: right;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn:hover { text-decoration: underline; }

/* checklists */

.checklist {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px 4px;
  margin-bottom: 9px;
}

.checklist-head { display: flex; align-items: center; gap: 8px; padding-bottom: 5px; }

.checklist-title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 12px;
  font-weight: 620;
  letter-spacing: -0.005em;
  color: var(--text);
  padding: 1px 3px;
  margin-left: -3px;
  border-radius: 4px;
}

.checklist-title:hover { background: var(--chip); }
.checklist-title:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent-soft); }

.checklist-items { display: flex; flex-direction: column; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  border-radius: 5px;
}

.checklist-item .check { width: 17px; height: 17px; border-width: 1.4px; }
.checklist-item .check svg { width: 9px; height: 9px; }

.checklist-item-title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 12.5px;
  color: var(--text-soft);
  padding: 1px 2px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.checklist-item-title:hover { background: var(--chip); color: var(--text); }
.checklist-item.is-done .checklist-item-title { color: var(--muted-2); text-decoration: line-through; }

.checklist-item .icon-btn.subtle { width: 20px; height: 20px; opacity: 0; }
.checklist-item:hover .icon-btn.subtle { opacity: 0.6; }

.inline-add {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0 5px;
}

.inline-add-icon { color: var(--muted-2); display: grid; place-items: center; width: 17px; flex: none; }

.inline-add input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 12.5px;
  color: var(--text);
  padding: 2px;
}

.inline-add input::placeholder { color: var(--muted-2); }

.subtask-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }

.subtask-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-radius: 5px;
}

.subtask-row .check { width: 18px; height: 18px; }
.subtask-row .check svg { width: 10px; height: 10px; }

.subtask-title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 12.5px;
  color: var(--text-soft);
  padding: 2px 3px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtask-title:hover { background: var(--chip); color: var(--text); }

.attach-list { display: flex; flex-direction: column; gap: 2px; }

.attach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--chip);
}

.attach-row + .attach-row { margin-top: 2px; }

.attach-icon { color: var(--muted); display: grid; place-items: center; flex: none; }

.attach-name {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  font-size: 12.5px;
  color: var(--text-soft);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-name:hover { color: var(--accent); text-decoration: underline; }

.attach-size { flex: none; }

.recur-chip { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.subtask-row .icon-btn.subtle { width: 20px; height: 20px; opacity: 0; }
.subtask-row:hover .icon-btn.subtle { opacity: 0.6; }

.section-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 7px 4px;
  border-radius: 6px;
  text-align: left;
  font-size: 12.5px;
  color: var(--text-soft);
}

.section-link-row:hover { background: var(--chip); }
.section-link-row span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-link-row .ico { color: var(--muted); }

.drawer-project-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.drawer-project-head h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.drawer-project-head p { margin: 1px 0 0; }
.drawer-project-head + .progress { margin-bottom: 20px; }

/* ------------------------------------------------------------------ dialogs */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 15, 17, 0.34);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.18s var(--ease);
}

.dialog {
  position: fixed;
  z-index: 81;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 60px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 0.22s var(--ease);
}

@keyframes dialogIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.985); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 0 20px;
}

.dialog-head h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.018em; }

.dialog-body { padding: 14px 20px 4px; }

.dialog-body > p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted); }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px 18px;
}

.dialog-inline-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.sync-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}

.sync-box .sync-dot { margin-top: 5px; }
.sync-box .sync-dot.is-connected { background: var(--green); }
.sync-box .sync-dot.is-error { background: var(--danger); }

.sync-box p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }

.swatch { cursor: pointer; }

.swatch[type], button.swatch {
  background: none;
  border: 0;
  padding: 0;
  line-height: 0;
}

.swatch input { position: absolute; opacity: 0; pointer-events: none; }

.swatch span {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s var(--ease), box-shadow 0.12s;
}

.swatch:hover span { transform: scale(1.08); }

.swatch input:checked + span {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch);
}

.swatch.is-selected span {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch);
}

.shortcut-list { display: flex; flex-direction: column; gap: 2px; }

.shortcut-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-soft);
}

.shortcut-list > div:last-child { border-bottom: 0; }

kbd {
  font-family: var(--font);
  font-size: 11px;
  background: var(--chip);
  color: var(--text-soft);
  border-radius: 5px;
  padding: 2px 7px;
  min-width: 22px;
  text-align: center;
  box-shadow: inset 0 -1px 0 var(--line-strong);
}

/* ------------------------------------------------------------------ toast */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom);
}

.toast {
  background: color-mix(in srgb, var(--text) 92%, transparent);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.toast.is-visible { opacity: 1; transform: none; }

html[data-theme="dark"] .toast { background: #f0efec; color: #1d1c1a; }

/* ------------------------------------------------------------------ tabbar */

.tabbar { display: none; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1000px) {
  :root { --sidebar-w: 236px; }
  .topbar { padding: 12px 22px 10px; }
  .view { padding: 12px 22px 110px; }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-102%);
    transition: transform 0.26s var(--ease);
    width: 274px;
    z-index: 45;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open { transform: none; }
  .sidebar.is-open + .sidebar-scrim { display: block; }

  .sidebar-close { display: grid; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }

  .topbar { padding: 10px 16px 9px; gap: 8px; }
  .topbar-context { opacity: 1; transform: none; pointer-events: auto; }
  .topbar-title { font-size: 14px; }
  .topbar-sub { font-size: 11px; }

  .search-field {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 8px;
    width: auto;
    z-index: 30;
    height: 38px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.18s, transform 0.18s;
    box-shadow: var(--shadow-md);
  }

  .search-field:focus-within { width: auto; }

  body.search-open .search-field {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  body.search-open .topbar-context,
  body.search-open .search-toggle { visibility: hidden; }

  .search-field kbd { display: none; }
  .search-toggle { display: grid; }
  .search-close { display: grid; }

  .view { padding: 8px 16px 118px; max-width: 100%; }

  .view-head { padding: 14px 0 16px; align-items: flex-start; flex-direction: column; gap: 12px; }
  .view-head h1 { font-size: 23px; }

  .composer { margin-bottom: 18px; }

  .drawer {
    inset: auto 0 0 0;
    width: 100%;
    align-items: flex-end;
  }

  .drawer-sheet {
    height: auto;
    max-height: 92dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    animation: sheetIn 0.3s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }

  @keyframes sheetIn {
    from { transform: translateY(40px); opacity: 0.5; }
    to { transform: none; opacity: 1; }
  }

  .drawer-grip {
    display: block;
    width: 34px;
    height: 4px;
    border-radius: 4px;
    background: var(--line-strong);
    margin: 7px auto 0;
    flex: none;
  }

  .drawer-head { padding: 9px 12px 10px 16px; }

  .drawer-body { padding: 16px 16px 20px; }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--line);
  }

  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px 2px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 9.5px;
    font-weight: 540;
    letter-spacing: 0.005em;
    transition: color 0.14s;
  }

  .tab-item .ico { opacity: 0.8; }
  .tab-item.is-active { color: var(--accent); }
  .tab-item.is-active .ico { opacity: 1; }

  .toast-root { bottom: calc(72px + env(safe-area-inset-bottom)); }

  .dialog { top: auto; bottom: 0; left: 0; right: 0; transform: none; width: 100%; max-height: 90dvh; border-radius: 16px 16px 0 0; border-bottom: 0; animation: sheetIn 0.28s var(--ease); }

  @keyframes dialogIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: none; }
  }

  .project-title-input { font-size: 21px; }
  .project-title-row { flex-wrap: wrap; }
  .project-grid { grid-template-columns: 1fr; }
  .chip-grid { grid-template-columns: 1fr 1fr; }
  .section-head { padding: 10px; }
  .section-progress-mini { display: none; }
  .row-open { opacity: 0.5; }
  .tag-head { padding: 12px 0 18px; }
  .tag-head h1 { font-size: 21px; }
}

@media (max-width: 520px) {
  .view-head h1 { font-size: 21px; }
  .chip-grid { grid-template-columns: 1fr; }
  .view-actions { width: 100%; }
  .view-actions .primary-btn { width: 100%; justify-content: center; }
  .search-field { left: 10px; right: 10px; }
  .priority-picker { grid-template-columns: repeat(2, 1fr); }
  .task-rail { width: 42px; }
  .checklist-item .chip.tiny { display: none; }
  .drawer-foot .ghost-btn.danger-text { flex: 0 0 auto; }
  .drawer-foot .ghost-btn.danger-text { padding: 7px 10px; }
}

@media (hover: none) {
  .row-open { opacity: 0.45; }
  .checklist-item .icon-btn.subtle { opacity: 0.45; }
  .subtask-row .icon-btn.subtle { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* print */
@media print {
  .sidebar, .topbar, .tabbar, .drawer, .dialog-backdrop, .dialog, .composer, .row-open, .project-menu, .project-section-actions { display: none !important; }
  .main { margin: 0; }
  .view { padding: 0; max-width: none; }
  .task-card { box-shadow: none; }
}

/* custom colors */
.swatch-custom span {
  display: grid;
  place-items: center;
  background: transparent;
  border: 1.5px dashed var(--line-strong);
  color: var(--muted);
  box-shadow: none;
}

.swatch-custom.is-selected span {
  background: var(--swatch);
  border-style: solid;
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch);
}

.color-popover {
  position: fixed;
  z-index: 120;
  width: 272px;
  max-width: calc(100vw - 16px);
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.color-popover-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.color-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--swatch, var(--accent));
  box-shadow: inset 0 0 0 1px var(--line);
}

.color-popover-row { display: flex; align-items: center; gap: 8px; }

.color-native {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  flex: none;
}

.color-native::-webkit-color-swatch-wrapper { padding: 3px; }
.color-native::-webkit-color-swatch { border: 0; border-radius: 5px; }

.color-hex { flex: 1; min-width: 0; }

.color-popover-rgb { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }

.color-popover-rgb label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.color-popover-rgb input { width: 100%; min-width: 0; padding: 5px 6px; }

.color-popover-rgb input::-webkit-outer-spin-button,
.color-popover-rgb input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.color-popover-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.tag-head-main { flex: 1; min-width: 0; }

.tag-head .tag-desc {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
}

.tag-edit { flex: none; margin-left: auto; align-self: flex-start; }

/* iOS zoomt in Eingabefelder hinein, wenn deren Schrift kleiner als 16px ist. */
@media (max-width: 820px), (pointer: coarse) {
  input:not(.project-title-input),
  textarea,
  select,
  .text-input,
  .select-input,
  .notes-input,
  .project-notes,
  .composer input,
  .search-field input,
  .tag-form input,
  .inline-add input,
  .date-input-wrap input {
    font-size: 16px;
  }
}

/* Sidebar-Sichtbarkeit in den Einstellungen */
.sidebar-toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.sidebar-toggle-grid button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.sidebar-toggle-grid button:hover { border-color: var(--line-strong); color: var(--text); }

.sidebar-toggle-grid button.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-text);
}

/* Auf Mobilgeräten übernimmt die Tabbar die Hauptnavigation. */
@media (max-width: 820px) {
  #nav .nav-mobile-dup { display: none; }
}

/* Projektteile sortieren */
.section-sort-list { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; }

.section-link-row.is-sortable { gap: 4px; padding: 3px 2px; }

.section-drag-handle {
  display: grid;
  place-items: center;
  width: 22px;
  height: 30px;
  flex: none;
  border-radius: 6px;
  color: var(--muted-2);
  cursor: grab;
  touch-action: none;
}

.section-drag-handle:hover { color: var(--text-soft); background: var(--chip); }
.section-drag-handle:active { cursor: grabbing; }

.section-link-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 5px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-size: 12.5px;
  text-align: left;
}

.section-link-main:hover { background: var(--chip); }
.section-link-main .ico { color: var(--muted); }
.section-link-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-link-row.is-done .section-link-title { color: var(--muted); text-decoration: line-through; }
.section-link-row.is-dragging { opacity: 0.6; background: var(--accent-soft); }

.section-sort-divider {
  margin: 8px 6px 3px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

body.is-section-dragging { user-select: none; cursor: grabbing; }
.hint-tight { margin-top: 8px; }

/* Passwortschutz */
body.auth-locked { overflow: hidden; }
body.auth-locked .app,
body.auth-locked #drawer-root,
body.auth-locked #dialog-root { visibility: hidden; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 100%);
  padding: 28px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}

.auth-card h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.auth-sub, .auth-hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.auth-card .field { margin: 2px 0 0; }
.auth-error { min-height: 17px; margin: 0; color: var(--danger); font-size: 12px; }
.auth-submit { width: 100%; justify-content: center; padding: 10px 14px; }
.auth-card.is-shaking { animation: authShake 0.35s var(--ease); }

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* Statistiken */
.stats-seg { flex: none; }

.stats-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.stats-period { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.stats-period strong { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.stats-period span { font-size: 11.5px; color: var(--muted); }
.stats-current { flex: none; padding: 6px 10px; font-size: 12px; }

.stats-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.stats-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.stats-card-label { font-size: 11.5px; font-weight: 550; color: var(--muted); }
.stats-card-value { font-size: 24px; font-weight: 650; line-height: 1.15; letter-spacing: -0.03em; }
.stats-card-hint { font-size: 11px; color: var(--muted-2); }
.stats-card.is-green .stats-card-value { color: var(--green); }
.stats-card.is-accent .stats-card-value { color: var(--accent); }
.stats-card.is-danger .stats-card-value { color: var(--danger); }

.stats-block {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.stats-block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.stats-block-head h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.stats-legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.stats-legend span { display: inline-flex; align-items: center; gap: 5px; }
.stats-legend span::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--green); }
.stats-legend .is-new::before { background: var(--accent); }
.stats-note { margin: 0 0 12px; font-size: 11.5px; color: var(--muted); }

.stat-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 150px;
  padding-top: 8px;
  border-bottom: 1px solid var(--line);
}

.stat-bucket {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  height: 100%;
}

.stat-bar-pair { display: flex; flex: 1; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; }
.stat-bar { width: min(14px, 45%); border-radius: 3px 3px 0 0; background: var(--green); opacity: 0.9; }
.stat-bar.is-new { background: var(--accent); opacity: 0.55; }
.stat-axis { height: 14px; font-size: 9px; color: var(--muted-2); white-space: nowrap; }

.stat-chart.is-month .stat-axis { visibility: hidden; }
.stat-chart.is-month .stat-bucket:nth-child(5n + 1) .stat-axis,
.stat-chart.is-month .stat-bucket:last-child .stat-axis { visibility: visible; }

.stats-breakdowns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stats-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.stats-bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.stats-bar-name { width: 34%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.stats-bar-track { flex: 1; height: 7px; overflow: hidden; border-radius: 99px; background: var(--chip); }
.stats-bar-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.stats-bar-track.is-accent span { background: var(--accent); }
.stats-bar-value { width: 26px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats-bar-row .prio-mark { display: grid; place-items: center; width: 18px; flex: none; }
.stats-empty { margin-top: 16px; }

@media (max-width: 700px) {
  .stats-cards { grid-template-columns: 1fr 1fr; }
  .stats-breakdowns { grid-template-columns: 1fr; }
  .stat-chart { height: 120px; }
  .stats-toolbar { flex-wrap: wrap; }
  .stats-current { width: 100%; justify-content: center; }
}

/* ------------------------------------------------------------------ Warten */
.check.is-waiting {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  opacity: 1;
}

.check.is-waiting svg { opacity: 1; }

.check.is-waiting:hover { border-color: var(--gold); background: color-mix(in srgb, var(--gold-soft) 70%, var(--gold) 12%); }
.task-row.is-waiting .task-title { color: var(--text-soft); }
.chip.wait-chip { background: var(--gold-soft); color: var(--gold); }
.nav-item.nav-wait .ico { color: var(--gold); opacity: 1; }
.wait-hint { margin: -2px 0 16px; }

/* ------------------------------------------------------------------ Projektteile ein-/ausklappen */
.section-expand { flex: none; color: var(--muted); }
.section-expand .ico { transition: transform 0.16s var(--ease); }
.section-expand.is-open .ico { transform: rotate(90deg); }

/* ------------------------------------------------------------------ Statistik: Tags */
.stats-breakdowns > .stats-block:nth-child(odd):last-child { grid-column: 1 / -1; }
.stats-bar-row .tag-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--tag, var(--gold)); }
.stats-bar-track.is-tag span { background: var(--gold); }
.stats-bar-track.is-category span { background: var(--accent); }

/* ------------------------------------------------------------------ Gewohnheiten */
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }

.habit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.habit-card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.habit-card-head { display: flex; align-items: flex-start; gap: 8px; }
.habit-card-head .check { margin-top: 1px; flex: none; }
.habit-check-off { display: grid; place-items: center; width: 21px; height: 21px; flex: none; color: var(--muted-2); }

.habit-card-title {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.habit-card-name { overflow: hidden; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; text-overflow: ellipsis; white-space: nowrap; }
.habit-card-schedule { font-size: 11.5px; color: var(--muted); }
.habit-card-title:hover .habit-card-name { color: var(--accent); }

.habit-card-streak {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  padding-top: 3px;
  color: var(--gold);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.habit-dots { display: flex; gap: 4px; }
.habit-dot { width: 18px; height: 18px; border: 1px solid var(--line); border-radius: 50%; background: var(--chip); }
.habit-dot.is-done { border-color: var(--green); background: var(--green); }
.habit-dot.is-today { border: 1.5px solid var(--gold); background: transparent; }
.habit-dot.is-missed { border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }
.habit-dot.is-off { border-style: dashed; background: transparent; opacity: 0.55; }

.habit-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 9px; border-top: 1px solid var(--line); }
.habit-card-foot .mini-btn { width: auto; padding: 0 6px; gap: 2px; color: var(--muted); }

.habit-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  padding: 8px 2px 16px;
  border-bottom: 1px solid var(--line);
}

.habit-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: color-mix(in srgb, var(--habit, var(--gold)) 15%, transparent);
  color: var(--habit, var(--gold));
}

.habit-detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.habit-schedule-line { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--text-soft); font-size: 12.5px; }
.habit-schedule-line .ico { color: var(--gold); }
.habit-today-btn { flex: none; }

.habit-stats { margin-bottom: 4px; }

.habit-calendar-block { margin-top: 18px; }
.habit-cal-head, .habit-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.habit-cal-head { margin: 12px 0 6px; color: var(--muted-2); font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-align: center; text-transform: uppercase; }

.habit-day {
  display: grid;
  place-items: center;
  height: 30px;
  min-height: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted-2);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.habit-day.is-due { border-color: var(--line); background: var(--chip); color: var(--text-soft); cursor: pointer; }
.habit-day.is-due:hover { border-color: var(--gold); color: var(--gold); }
.habit-day.is-done { border-color: var(--green); background: var(--green); color: #fff; }
.habit-day.is-done:hover { border-color: var(--green); color: #fff; }
.habit-day.is-missed { border-color: color-mix(in srgb, var(--danger) 28%, transparent); background: var(--danger-soft); color: var(--danger); }
.habit-day.is-today { box-shadow: inset 0 0 0 1.5px var(--gold); font-weight: 700; }
.habit-day.is-off, .habit-day.is-future { background: transparent; opacity: 0.45; }

.habit-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.habit-legend span { display: inline-flex; align-items: center; gap: 5px; }
.habit-legend span::before { content: ''; width: 8px; height: 8px; border-radius: 3px; background: var(--green); }
.habit-legend .is-missed::before { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.habit-legend .is-off::before { border: 1px dashed var(--line-strong); background: transparent; }

.habit-notes-block { margin-top: 18px; }
.habit-notes-block .field { margin-top: 0; }

.weekday-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 2px; }
.weekday-check { position: relative; display: block; }
.weekday-check input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-check span {
  display: grid;
  place-items: center;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
}
.weekday-check input:checked + span { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); color: var(--accent-text); }
.weekday-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.habit-repeat-panel { margin-top: 0; }
.habit-repeat-panel[hidden] { display: none; }

.habit-row .habit-label { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 7px; }
.habit-row .habit-schedule { color: var(--muted); font-size: 11px; }
.habit-row .chip.habit-chip { background: var(--chip); color: var(--muted); }
.habit-row .chip.habit-streak-chip { background: var(--gold-soft); color: var(--gold); }

@media (max-width: 760px) {
  .habit-grid { grid-template-columns: 1fr; }
  .habit-detail-bar { flex-wrap: wrap; }
  .habit-today-btn { width: 100%; justify-content: center; }
  .habit-head .project-title-input { font-size: 21px; }
  .habit-head .project-title-row { flex-wrap: wrap; }
  .habit-day { height: 27px; }
}
