:root {
  --paper: oklch(98.6% 0.004 90);
  --sidebar: oklch(96.2% 0.006 88);
  --surface: oklch(96.6% 0.005 90);
  --surface-2: oklch(94% 0.006 90);
  --border: oklch(90% 0.006 90);
  --border-strong: oklch(81% 0.008 90);
  --ink: oklch(22% 0.01 90);
  --ink-2: oklch(38% 0.01 90);
  --muted: oklch(50% 0.01 90);
  --faint: oklch(58% 0.008 90);

  --accent: oklch(55% 0.16 45);
  --accent-hover: oklch(50% 0.16 45);
  --accent-ink: oklch(99% 0.005 45);
  --accent-wash: oklch(95.5% 0.03 50);
  --danger: oklch(50% 0.18 25);
  --danger-wash: oklch(95.5% 0.03 25);
  --success: oklch(46% 0.12 150);
  --warning: oklch(66% 0.15 75);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-pop: 0 10px 30px oklch(22% 0.01 90 / 0.14), 0 2px 6px oklch(22% 0.01 90 / 0.08);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --t-fast: 140ms;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }

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

button { cursor: pointer; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Icons ---------- */

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.is-filled { fill: currentColor; stroke-width: 1.25; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 550;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
a.btn { text-decoration: none; }
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: oklch(32% 0.01 90); }

.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: var(--accent-hover); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-wash); }
.btn-danger.is-armed { background: var(--danger); border-color: var(--danger); color: var(--paper); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon.is-on { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--border-strong); }
.btn-icon.is-on:hover { background: var(--border); }

/* ---------- Form controls ---------- */

.input, .select {
  height: 34px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.input::placeholder { color: var(--faint); }
.input:hover, .select:hover { border-color: var(--muted); }
.input:focus-visible, .select:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px oklch(22% 0.01 90 / 0.12);
}
.input:disabled { background: var(--surface); color: var(--muted); }
.input[type="time"], .input[type="date"] { font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .label, .label { font-size: 12px; font-weight: 550; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 13px; color: var(--danger); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.check input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; }

/* ---------- Project dot, chips ---------- */

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--c, var(--faint));
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Segmented control ---------- */

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.seg button {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 550;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.seg button:hover { color: var(--ink); }
.seg button.is-on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px oklch(22% 0.01 90 / 0.12); }

/* ---------- Popover ---------- */

.popover {
  position: fixed;
  z-index: 100;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(380px, calc(100vh - 16px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.pop-search {
  flex: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  background: transparent;
  outline: none;
}
.pop-search::placeholder { color: var(--faint); }

.pop-list { overflow-y: auto; padding: 4px; }

.pop-heading {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.pop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  color: var(--ink);
}
.pop-item:hover, .pop-item.is-active { background: var(--surface-2); }
.pop-item.is-selected { font-weight: 550; }
.pop-item.is-task { padding-left: 28px; color: var(--ink-2); }
.pop-item .pop-sub { color: var(--muted); font-size: 12px; margin-left: auto; padding-left: 8px; }
.pop-item.is-create { color: var(--ink); font-weight: 550; }
.pop-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; pointer-events: none; }
.pop-empty { padding: 14px 12px; color: var(--muted); }
.pop-foot { flex: none; padding: 6px; border-top: 1px solid var(--border); }

/* ---------- Picker triggers ---------- */

.picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  min-width: 0;
}
.picker:hover { border-color: var(--muted); }
.picker.is-empty { color: var(--muted); }
.picker .picker-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .picker-sub { color: var(--muted); }
.picker .icon-chevron { margin-left: auto; color: var(--faint); }
.picker-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

/* ---------- Toasts ---------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-pop);
  animation: toast-in 180ms var(--ease-out);
}
.toast.is-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Skeleton ---------- */

.skeleton {
  border-radius: 6px;
  background: var(--surface-2);
  animation: skeleton 1.4s ease-in-out infinite;
}
@keyframes skeleton { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- Empty state ---------- */

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; font-weight: 600; }
.empty .btn { margin-top: 16px; }

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