:root {
  color-scheme: light dark;
  --bg: light-dark(#f2f1ed, #0e0e0d);
  --panel: light-dark(#fcfcfb, #161615);
  --surface: light-dark(#ffffff, #1c1c1a);
  --surface-2: light-dark(#f7f6f3, #212120);
  --surface-3: light-dark(#efeee9, #2a2a27);
  --border: light-dark(#e8e6e0, #282826);
  --border-2: light-dark(#dad7cf, #383734);
  --text: light-dark(#1c1b18, #edece8);
  --text-2: light-dark(#625e56, #a9a69e);
  --text-3: light-dark(#98938a, #75726b);
  --accent: light-dark(#cf4a1b, #cd4f1f);
  --accent-hover: light-dark(#b83f14, #dc5925);
  --accent-fg: light-dark(#bf4312, #ff8d61);
  --accent-soft: light-dark(#fdefe8, #2f1d16);
  --accent-line: light-dark(#f5cdbb, #5b2f1e);
  --accent-ring: light-dark(rgb(207 74 27 / .22), rgb(255 141 97 / .3));
  --on-accent: #fff;
  --on-status: light-dark(#fff, #161615);
  --s-todo: light-dark(#8f8a80, #8e8b83);
  --s-doing: light-dark(#2c6be6, #5d92f8);
  --s-review: light-dark(#7650df, #a98ff8);
  --s-blocked: light-dark(#d5393f, #f26b70);
  --s-done: light-dark(#23935a, #4fc78d);
  --s-dropped: light-dark(#aca79d, #6f6c66);
  --p1: light-dark(#cf8209, #f1b54d);
  --danger: light-dark(#c8353b, #f26b70);
  --danger-soft: light-dark(#fdeeee, #36191b);
  --ok-soft: light-dark(#e5f4eb, #14291d);
  --violet-soft: light-dark(#efeafd, #231d38);
  --hover: light-dark(rgb(28 27 24 / .05), rgb(255 255 255 / .05));
  --shadow-sm: 0 1px 2px light-dark(rgb(28 27 24 / .05), rgb(0 0 0 / .35));
  --shadow-md: 0 1px 2px light-dark(rgb(28 27 24 / .05), rgb(0 0 0 / .3)), 0 8px 24px -10px light-dark(rgb(28 27 24 / .16), rgb(0 0 0 / .65));
  --shadow-lg: 0 0 0 1px light-dark(rgb(28 27 24 / .06), rgb(255 255 255 / .07)), 0 28px 70px -16px light-dark(rgb(28 27 24 / .32), rgb(0 0 0 / .8));
  --r-sm: 7px;
  --r: 10px;
  --r-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t: 140ms;
  --sidebar-w: 252px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-fg); }
h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }
.num, time, .tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.i { flex: none; display: block; }
.text-muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .92em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dot-sep { color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 13px;
  border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text);
  font-weight: 560; font-size: 13px; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform 80ms var(--ease), color var(--t);
}
.btn:hover { background: var(--surface-2); border-color: light-dark(#cdc9c0, #45443f); }
.btn:active { transform: translateY(.5px) scale(.99); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn .i { opacity: .85; }
.btn-accent {
  background: var(--accent); border-color: transparent; color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .16), 0 1px 2px rgb(110 30 0 / .28), 0 0 0 1px rgb(110 30 0 / .12);
}
.btn-accent:hover { background: var(--accent-hover); border-color: transparent; }
.btn-accent .i { opacity: 1; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--text); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); box-shadow: none; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; gap: 6px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn-block { width: 100%; }
.btn-lg { height: 38px; padding: 0 16px; font-size: 14px; border-radius: 9px; }

.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center; flex: none;
  border-radius: 7px; border: 0; background: transparent; color: var(--text-2);
  transition: background var(--t), color var(--t);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.is-on { color: var(--accent-fg); }

kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px;
  font: 600 10.5px/1 var(--font); color: var(--text-3);
  border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px; background: var(--surface);
}
.btn-accent kbd { background: rgb(255 255 255 / .14); border-color: rgb(255 255 255 / .28); color: #fff; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input:not([type]), textarea, select {
  width: 100%; height: 34px; padding: 0 11px;
  border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
textarea { height: auto; padding: 9px 11px; line-height: 1.55; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, textarea:hover, select:hover { border-color: light-dark(#cbc7bd, #47463f); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238f8a80' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.form-error { min-height: 0; color: var(--danger); font-size: 12.5px; font-weight: 550; }
.form-error:empty { display: none; }
.form-error:not(:empty) { margin: -2px 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--danger-soft); }
.input-icon { position: relative; display: flex; align-items: center; min-width: 0; }
.input-icon > .i { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-icon > input { padding-left: 32px; }

.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border); }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font-weight: 560; font-size: 12.5px;
  transition: background var(--t), color var(--t), box-shadow var(--t);
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg .count { color: var(--text-3); font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 560; white-space: nowrap; line-height: 1;
}
.chip .i { width: 12px; height: 12px; }
.chip-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border-2); }
.chip-accent { background: var(--accent-soft); color: var(--accent-fg); }
.label-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px;
  border-radius: 999px; font-size: 11.5px; font-weight: 560; color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--border-2); white-space: nowrap;
}
.label-chip::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: light-dark(oklch(.66 .15 var(--h, 40)), oklch(.72 .13 var(--h, 40)));
}
.space-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); font-weight: 550; text-decoration: none; }
.space-chip:hover { color: var(--text); }

.st { flex: none; display: block; }
.st-todo { color: var(--s-todo); }
.st-doing { color: var(--s-doing); }
.st-review { color: var(--s-review); }
.st-blocked { color: var(--s-blocked); }
.st-done { color: var(--s-done); }
.st-dropped { color: var(--s-dropped); }
.st-disc { color: var(--s-done); }
.st-disc-closed { color: var(--s-review); }
.pr { flex: none; display: block; color: var(--text-2); }
.pr-P0 { color: var(--s-blocked); }
.pr-P1 { color: var(--p1); }
.pr-P3 { color: var(--text-3); }
.status-badge, .priority-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 560; color: var(--text-2); white-space: nowrap; }
.status-badge.is-pill, .priority-badge.is-pill { height: 22px; padding: 0 8px 0 6px; border-radius: 999px; background: var(--surface-3); }
.state-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px 0 8px;
  border-radius: 999px; font-weight: 620; font-size: 12.5px; color: var(--on-status); background: var(--s-done);
}
.state-pill.is-closed { background: var(--s-review); }
.state-pill .i { width: 14px; height: 14px; }

.av {
  --size: 24px;
  width: var(--size); height: var(--size); flex: none;
  display: inline-grid; place-items: center; border-radius: 50%;
  font: 650 calc(var(--size) * .4)/1 var(--font); letter-spacing: .01em;
  background: light-dark(oklch(.93 .05 var(--h, 40)), oklch(.36 .075 var(--h, 40)));
  color: light-dark(oklch(.43 .12 var(--h, 40)), oklch(.9 .07 var(--h, 40)));
  box-shadow: inset 0 0 0 1px light-dark(oklch(.84 .06 var(--h, 40) / .7), oklch(.5 .09 var(--h, 40) / .5));
  user-select: none;
}
.av-bot {
  border-radius: 30%;
  background: linear-gradient(145deg, oklch(.64 .16 var(--h, 40)), oklch(.44 .15 calc(var(--h, 40) + 38)));
  color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .16), 0 1px 2px rgb(0 0 0 / .18);
}
.av-bot svg { width: 66%; height: 66%; }
.av-xs { --size: 18px; }
.av-sm { --size: 20px; }
.av-md { --size: 28px; }
.av-lg { --size: 36px; }
.av-xl { --size: 52px; }
.av-ring { box-shadow: 0 0 0 3px var(--panel); }

.agent-chip {
  display: inline-flex; align-items: center; gap: 0; height: 22px; padding: 0 8px 0 6px;
  border-radius: 7px; background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 600;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.agent-chip .emoji { margin-right: 5px; font-size: 12px; }
.agent-chip .bits { color: var(--text-2); font-weight: 520; }
.agent-chip .bits::before { content: "·"; margin: 0 5px; color: var(--text-3); }
.via { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.via b { color: var(--text-2); font-weight: 560; }
.bot-tag {
  display: inline-flex; align-items: center; height: 17px; padding: 0 5px; border-radius: 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-fg); background: var(--accent-soft);
}
.admin-tag { color: var(--text-2); background: var(--surface-3); }

.sk {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 40%, var(--surface-3) 80%);
  background-size: 300% 100%; animation: shimmer 1.3s linear infinite;
}
.sk-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); }
.sk-row:first-child { border-top: 0; }
.sk-circle { width: 16px; height: 16px; border-radius: 50%; flex: none; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto;
  display: flex; align-items: flex-start; justify-content: center; padding: 11vh 16px 24px;
  background: light-dark(rgb(28 27 24 / .3), rgb(0 0 0 / .62));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade-in 160ms var(--ease);
}
.modal {
  width: min(540px, 100%); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: pop-in 200ms var(--ease);
}
.modal-wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 6px 22px; }
.modal-head h2 { font: 660 17px/1.3 var(--font-display); letter-spacing: -.012em; }
.modal-sub { color: var(--text-2); margin-top: 3px; font-size: 13px; }
.modal-body { padding: 12px 22px 4px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 18px; margin-top: 10px; border-top: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 0 16px 16px;
}
.modal-foot .hint { margin-right: auto; color: var(--text-3); font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; max-width: min(460px, calc(100vw - 32px));
  padding: 10px 15px 10px 12px; border-radius: 11px; pointer-events: auto;
  background: light-dark(#1f1e1b, #f0efeb); color: light-dark(#f6f5f1, #1c1b18);
  font-weight: 560; font-size: 13px; box-shadow: var(--shadow-lg);
  animation: toast-in 220ms var(--ease);
}
.toast .i { color: light-dark(#5fd39a, #1f8f55); }
.toast.is-error .i { color: light-dark(#ff8a8e, #c8353b); }
.toast.is-leaving { animation: toast-out 180ms var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

.confirm-row { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); animation: fade-in 120ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
