/* ===================================================================== tokens */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 248px;
  --column-width: 288px;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --accent-text: #0f766e;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --review: #c2410c;
  --review-soft: rgba(234, 88, 12, 0.12);
  --focus: 0 0 0 3px rgba(20, 184, 166, 0.4);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-board: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eceef2;
  --column-bg: #e6e9ef;
  --border: #dfe2e8;
  --border-strong: #c9ced8;
  --text: #1c2030;
  --text-muted: #636a7c;
  --text-faint: #8d93a3;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.08);
  --shadow: 0 4px 12px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.22);
  --sidebar-bg: #14202c;
  --sidebar-text: #c7c9d6;
  --sidebar-text-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(255, 255, 255, 0.13);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12131a;
  --bg-board: #14151d;
  --surface: #1d1f2a;
  --surface-2: #232532;
  --surface-3: #2b2e3d;
  --column-bg: #191b25;
  --border: #2d3040;
  --border-strong: #3c4054;
  --text: #e7e8ee;
  --text-muted: #9a9fb2;
  --text-faint: #6f7489;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  --sidebar-bg: #0b1219;
  --sidebar-text: #a9acbd;
  --sidebar-text-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --accent: #0e857b;
  --accent-hover: #0d9488;
  --accent-soft: rgba(45, 212, 191, 0.15);
  --accent-text: #5eead4;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.13);
  --review: #fb923c;
  --review-soft: rgba(251, 146, 60, 0.15);
}

/* ===================================================================== base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.25;
}

p {
  margin: 0;
}

code, kbd, pre {
  font-family: var(--mono);
  font-size: 0.92em;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden],
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.pad { padding: 8px 10px; }
.nowrap { white-space: nowrap; }
.align-end { text-align: right; }
.align-center { text-align: center; }
.full { width: 100%; justify-content: center; }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-tight { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-tight { gap: 4px; flex-wrap: nowrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.toolbar-spacer { flex: 1; }

/* ===================================================================== splash & spinner */

.app-loading { display: grid; place-items: center; height: 100%; }
.splash { display: flex; align-items: center; gap: 10px; color: var(--text-muted); }

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================================== buttons & inputs */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn-xs { height: 24px; width: 24px; padding: 0; justify-content: center; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
.btn-sm.btn-icon { width: 28px; }
.btn-xs.btn-icon { width: 24px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.btn-accent:hover:not(:disabled) { background: var(--accent-soft); filter: brightness(0.97); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

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

.input {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
.input-sm { min-height: 30px; padding: 4px 8px; font-size: 13px; }
.input-narrow { width: 80px; }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { cursor: pointer; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-error { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 13px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}

.check-row:hover { background: var(--surface-2); }
.check-row input { margin: 0; accent-color: var(--accent); }

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  gap: 2px;
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented-sm button { padding: 3px 8px; font-size: 12px; }
.priority-control { display: flex; }
.priority-control button { flex: 1; justify-content: center; }
.priority-control button.active.priority-high { color: var(--danger); }
.priority-control button.active.priority-medium { color: var(--warning); }
.priority-control button.active.priority-low { color: var(--accent-text); }

/* ===================================================================== pills, tags, avatars, badges */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill .icon { width: 12px; height: 12px; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-review { background: var(--review-soft); color: var(--review); }
.pill-accent { background: var(--accent-soft); color: var(--accent-text); }

.tag {
  --tag-color: #6b7280;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color) 16%, transparent);
  color: color-mix(in srgb, var(--tag-color) 75%, var(--text));
  border: 1px solid color-mix(in srgb, var(--tag-color) 35%, transparent);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.tag-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-sm { padding: 0 6px; font-size: 11px; line-height: 16px; }

.tag-remove {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}

.tag-remove:hover { background: color-mix(in srgb, var(--tag-color) 30%, transparent); }
.tag-remove .icon { width: 10px; height: 10px; }

.avatar {
  --avatar-hue: 230;
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: hsl(var(--avatar-hue) 55% 52%);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}

.avatar-xs { width: 18px; height: 18px; font-size: 8px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 5px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}

.badge .icon { width: 13px; height: 13px; }
.badge.complete { background: var(--success-soft); color: var(--success); }
.badge.priority-high { color: var(--danger); background: var(--danger-soft); }
.badge.priority-medium { color: var(--warning); background: var(--warning-soft); }
.badge.priority-low { color: var(--accent-text); background: var(--accent-soft); }
.badge.due-overdue { color: #fff; background: var(--danger); }
.badge.due-today { color: var(--warning); background: var(--warning-soft); font-weight: 600; }
.badge.due-soon { color: var(--warning); }
.badge.due-done { color: var(--success); background: var(--success-soft); }
.badge.blocked { color: var(--danger); background: var(--danger-soft); font-weight: 600; }
.badge.review { color: var(--review); background: var(--review-soft); font-weight: 600; }

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

.progress-sm { height: 4px; }

.progress-bar {
  --progress: 0%;
  height: 100%;
  width: var(--progress);
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.25s;
}

.progress-bar.complete { background: var(--success); }

/* ===================================================================== layout */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  height: 100dvh;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  outline: none;
}

.mobile-bar { display: none; }
.scrim { display: none; }

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
}

.org-name {
  overflow: hidden;
  color: var(--sidebar-text-strong);
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-weight: 500;
}

.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-strong); }
.nav-item.archived { opacity: 0.6; font-style: italic; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-count {
  margin-left: auto;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 11px;
  line-height: 18px;
}

.nav-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 4px;
  padding: 0 4px 0 10px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-section .btn { color: var(--sidebar-text); }
.nav-section .btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }

.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.06); }

.user-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--sidebar-text-strong);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.user-button:hover { background: var(--sidebar-hover); }
.user-name { flex: 1; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }

/* ===================================================================== board */

.board-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-board);
}

.board-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px 6px;
}

.board-title { min-width: 0; }
.board-title h1 { font-size: 20px; font-weight: 700; }
.board-description { margin-top: 2px; color: var(--text-muted); font-size: 13px; }

.board-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 180px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.board-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 20px;
}

.search-wrap { position: relative; width: 260px; }

.search-wrap .icon {
  position: absolute;
  top: 50%;
  left: 10px;
  color: var(--text-faint);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input { padding-left: 32px; }
.filter-slot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.filter-chip {
  --tag-color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color) 14%, transparent);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.filter-chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.filter-chip button:hover { background: var(--surface-3); color: var(--text); }
.filter-chip .icon { width: 12px; height: 12px; }

.category-bar {
  display: flex;
  gap: 6px;
  padding: 2px 20px 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.category-pill {
  --category-color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.category-pill:hover { border-color: var(--border-strong); color: var(--text); }

.category-pill.active {
  border-color: var(--category-color);
  background: color-mix(in srgb, var(--category-color) 14%, var(--surface));
  color: var(--text);
}

.category-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--category-color); }
.category-count { color: var(--text-faint); font-size: 11px; }

.board-columns {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding: 4px 20px 20px;
  overflow-x: auto;
  overflow-y: hidden;
}

.column {
  display: flex;
  flex-direction: column;
  flex: none;
  width: var(--column-width);
  max-height: 100%;
  border-radius: var(--radius-lg);
  background: var(--column-bg);
}

.column.dragging { opacity: 0.4; }
.column.over-limit { box-shadow: inset 0 0 0 2px var(--warning); }

.column-placeholder {
  align-self: stretch;
  min-height: 120px;
  border: 2px dashed var(--border-strong);
  background: transparent;
}

.column-add { background: transparent; }
.column-add .btn { width: 100%; justify-content: flex-start; height: 40px; border: 1px dashed var(--border-strong); }

.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 6px 12px;
  cursor: grab;
}

.column-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.done-icon { color: var(--success); }

.column-count {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.column-count.over { background: var(--warning-soft); color: var(--warning); }

.column-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 24px;
  padding: 4px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.column-empty {
  padding: 14px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

.column-footer { padding: 4px 8px 8px; }

.add-card {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.add-card:hover { background: var(--surface-3); color: var(--text); }
.show-more { align-self: center; }

.drop-placeholder {
  --placeholder-height: 60px;
  flex: none;
  height: var(--placeholder-height);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.composer-input { min-height: 54px; border: 0; padding: 2px; box-shadow: none !important; resize: none; }
.composer-hint { color: var(--text-faint); font-size: 11px; }
.composer-hint code { padding: 0 3px; border-radius: 3px; background: var(--surface-3); }
.composer-actions { display: flex; gap: 6px; }

/* ===================================================================== card tile */

.card {
  --category-color: transparent;
  position: relative;
  flex: none;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.card.has-category::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 3px;
  width: 3px;
  border-radius: 3px;
  background: var(--category-color);
}

.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card:focus-visible { border-color: var(--accent); }
.card.dragging { opacity: 0.35; }
.card.is-done .card-title { color: var(--text-muted); }
.card.is-blocked { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

.card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
  color: var(--text-faint);
  font-size: 11px;
}

.card-category {
  color: color-mix(in srgb, var(--category-color) 70%, var(--text-muted));
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.card-id { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.card-top .card-id:first-child { margin-left: 0; }
.card-menu { opacity: 0; margin-right: -4px; }
.card:hover .card-menu,
.card:focus-within .card-menu { opacity: 1; }

.card-title {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}

.card-badges { display: flex; flex-wrap: wrap; gap: 3px 4px; }
.card-extra { margin-top: 8px; }

/* ===================================================================== pages */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h1 { display: flex; align-items: center; gap: 8px; font-size: 22px; }
.page-header h1 .icon { width: 22px; height: 22px; color: var(--accent-text); }
.page-header p { margin-top: 4px; max-width: 560px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 20px;
  text-align: center;
}

.empty-icon { width: 40px; height: 40px; color: var(--text-faint); stroke-width: 1.5; }

/* ===================================================================== dialogs */

.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dialog[open] { display: flex; flex-direction: column; animation: dialog-in 0.14s ease-out; }
.dialog::backdrop { background: rgba(10, 12, 20, 0.5); animation: fade-in 0.14s ease-out; }
.dialog-sm { width: min(420px, calc(100vw - 32px)); }
.dialog-lg { width: min(760px, calc(100vw - 32px)); }
.dialog-xl { width: min(1040px, calc(100vw - 32px)); }

@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
@keyframes fade-in { from { opacity: 0; } }

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 { font-size: 16px; }
.dialog-body { flex: 1; min-height: 0; padding: 20px; overflow-y: auto; }
.dialog-message { color: var(--text-muted); }

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ===================================================================== popovers & menus */

.popover {
  position: fixed;
  z-index: 1000;
  min-width: 200px;
  max-width: min(360px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: fade-in 0.1s ease-out;
}

.popover-wide { width: 340px; }
.menu { display: flex; flex-direction: column; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover:not(:disabled),
.menu-item:focus-visible { background: var(--surface-3); box-shadow: none; }
.menu-item:disabled { color: var(--text-faint); cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-item .icon { color: var(--text-muted); }
.menu-item.danger .icon { color: var(--danger); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-check { color: var(--accent-text) !important; }
.menu-item kbd { margin-left: auto; }
.icon-spacer { width: 16px; flex: none; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }

.menu-heading {
  padding: 6px 10px 3px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--swatch); }
.picker { display: flex; flex-direction: column; gap: 6px; }
.tag-picker .menu-item { min-height: 30px; }

.filter-popover { display: flex; flex-direction: column; gap: 12px; padding: 6px; }
.filter-section h4 { margin-bottom: 4px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-section .input { margin-bottom: 4px; }
.check-list { display: flex; flex-direction: column; }
.tag-check-list { max-height: 180px; overflow-y: auto; }

/* ===================================================================== toasts */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: #1f2230;
  color: #f4f5fa;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}

.toast span { flex: 1; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.toast-success { border-left-color: #22c55e; }
.toast-error { border-left-color: #ef4444; }
.toast-warning { border-left-color: #f59e0b; }

.toast-action {
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  background: none;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.toast-close { display: grid; place-items: center; padding: 2px; border: 0; background: none; color: #aab0c4; cursor: pointer; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ===================================================================== card dialog */

.card-dialog { --category-color: transparent; border-top: 4px solid var(--category-color); }
.card-dialog .dialog-body { padding: 0; }
.card-dialog-header { padding: 10px 12px 10px 20px; }
.card-crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; font-size: 13px; }
.card-header-actions { display: flex; gap: 2px; }

.id-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.id-chip:hover { color: var(--text); border-color: var(--border-strong); }
.id-chip .icon { width: 12px; height: 12px; }

.card-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; min-height: 100%; }
.card-main { display: flex; flex-direction: column; gap: 22px; padding: 16px 24px 28px; min-width: 0; }
.card-loading { display: grid; place-items: center; padding: 48px; }

.card-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 18px 24px;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
}

.card-title-input {
  width: 100%;
  padding: 4px 6px;
  margin-left: -6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
  resize: none;
  overflow: hidden;
}

.card-title-input:hover { border-color: var(--border); }
.card-title-input:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; background: var(--surface); }

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}

.banner span { flex: 1; }
.banner.stack { align-items: stretch; }
.banner-warning { background: var(--warning-soft); color: var(--text); }
.banner-warning > .icon { color: var(--warning); }
.banner-danger { background: var(--danger-soft); color: var(--text); }
.banner-danger > .icon { color: var(--danger); }
.banner-success { background: var(--success-soft); color: var(--text); margin-bottom: 16px; }

.card-section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.section-head h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.section-head h3 .icon { color: var(--text-muted); }
.subhead { margin: 4px 0; color: var(--text-muted); font-size: 12px; font-weight: 600; }

.placeholder-button {
  min-height: 64px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text-muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.placeholder-button:hover { background: var(--border); }
.description { padding: 2px 0; cursor: text; }

.checklist { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
}

.checklist-item:hover { background: var(--surface-2); }
.checklist-item input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.checklist-item .btn { opacity: 0; }
.checklist-item:hover .btn,
.checklist-item:focus-within .btn { opacity: 1; }
.checklist-text { flex: 1; min-width: 0; cursor: text; overflow-wrap: anywhere; }
.checklist-item.done .checklist-text { color: var(--text-muted); text-decoration: line-through; }

.dep-list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }

.dep-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.dep-row.done .dep-link { color: var(--text-muted); text-decoration: line-through; }
.dep-status { display: inline-flex; }
.dep-status.done { color: var(--success); }
.dep-status.open { color: var(--warning); }
.dep-link { flex: 1; min-width: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }

.comment-composer { display: flex; gap: 10px; }
.comment-composer-body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.comments { display: flex; flex-direction: column; gap: 14px; margin: 6px 0 0; padding: 0; list-style: none; }
.comment { display: flex; gap: 10px; }
.comment-main { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.comment-body {
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.comment-review.open .comment-body { border-color: color-mix(in srgb, var(--review) 50%, var(--border)); background: var(--review-soft); }
.comment-review.resolved .comment-body { opacity: 0.8; }
.comment-actions { display: flex; gap: 2px; margin-top: 2px; }
.comment-actions .btn { height: 24px; padding: 0 6px; font-size: 12px; }

.history { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.history li { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 8px; font-size: 13px; }

.side-field { display: flex; flex-direction: column; gap: 5px; }

.tag-editor { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

.tag-add {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.tag-add:hover { color: var(--text); border-color: var(--text-muted); }
.tag-add .icon { width: 12px; height: 12px; }

.side-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.side-actions { display: flex; flex-direction: column; gap: 6px; }

/* ===================================================================== markdown */

.markdown { overflow-wrap: anywhere; }
.markdown > * + * { margin-top: 8px; }
.markdown h3, .markdown h4, .markdown h5, .markdown h6 { margin-top: 14px; font-size: 15px; }
.markdown ul, .markdown ol { margin-bottom: 0; padding-left: 22px; }
.markdown li + li { margin-top: 2px; }
.markdown .task-item { list-style: none; margin-left: -20px; }
.markdown .task-item input { margin: 0 6px 0 0; vertical-align: middle; }
.markdown code { padding: 1px 4px; border-radius: 4px; background: var(--surface-3); }

.markdown pre {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  overflow-x: auto;
}

.markdown pre code { padding: 0; background: none; }

.markdown blockquote {
  margin: 0;
  padding: 2px 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.markdown hr { border: 0; border-top: 1px solid var(--border); }
.task-ref { font-family: var(--mono); font-size: 0.92em; }

/* ===================================================================== settings */

.settings-dialog .dialog-body { padding: 0; }
.settings-layout { display: grid; grid-template-columns: 210px 1fr; min-height: 520px; }

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.settings-tab:hover { background: var(--surface-3); color: var(--text); }
.settings-tab.active { background: var(--accent-soft); color: var(--accent-text); }
.settings-panel { padding: 20px 24px 28px; min-width: 0; overflow-x: auto; }
.settings-section + .settings-section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--border); }
.settings-section > h3 { margin-bottom: 4px; font-size: 15px; }
.settings-section > p { margin-bottom: 12px; }
.settings-section .stack { max-width: 520px; }
.settings-section .row .input { flex: 1; min-width: 180px; }

.table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 13px; }
.table th { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-align: left; text-transform: uppercase; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-compact td { padding: 4px 6px; }
.table tr.inactive td { opacity: 0.6; }
.table.shortcuts td:first-child { width: 120px; }

.user-cell { display: flex; align-items: center; gap: 10px; }

.secret-box { display: flex; flex-direction: column; gap: 6px; }

.secret {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow-x: auto;
  white-space: nowrap;
  user-select: all;
}

.code-block {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  font-size: 12px;
  overflow-x: auto;
}

.color-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; max-width: 300px; }

.color-swatch {
  --swatch: #6b7280;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
}

.color-swatch.selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch); }
.color-custom { width: 28px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; }

.archive-list { display: flex; flex-direction: column; }
.archive-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.archive-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.archive-main a { color: var(--text); font-weight: 500; }

/* ===================================================================== auth */

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 45%),
    radial-gradient(circle at 80% 90%, var(--accent-soft), transparent 40%),
    var(--bg);
}

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

.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.auth-card h1 { font-size: 20px; }
.auth-card .btn { height: 38px; }

/* ===================================================================== bots */

.avatar-bot { border-radius: 30%; background: hsl(var(--avatar-hue) 30% 38%); }
.avatar-bot .icon { width: 64%; height: 64%; }
.bot-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}
.bot-badge .icon { width: 12px; height: 12px; }
.comment-bot .comment-body { border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }

.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

/* ===================================================================== markdown extras */

.markdown .table-wrap { overflow-x: auto; }
.markdown table { border-collapse: collapse; font-size: 0.95em; }
.markdown th, .markdown td { padding: 5px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.markdown th { background: var(--surface-2); font-weight: 600; }
.markdown .align-center { text-align: center; }
.markdown .align-right { text-align: right; }
.wiki-link { text-decoration: underline dotted; text-underline-offset: 3px; }

/* ===================================================================== docs */

.docs-view {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.docs-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  overflow: auto;
}

.docs-tree-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.docs-home-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 700; text-decoration: none; }
.docs-home-link .icon { color: var(--accent-text); }
.docs-tree-body { flex: 1; }
.docs-tree ul { margin: 0; padding: 0; list-style: none; }

.docs-node {
  --depth: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 30px;
  padding: 0 2px 0 calc(var(--depth) * 14px);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.docs-node:hover { background: var(--surface-3); color: var(--text); }
.docs-node.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.docs-node.dragging { opacity: 0.4; }
.docs-node.drop-inside { outline: 2px solid var(--accent); outline-offset: -2px; }
.docs-node.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.docs-node.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.docs-toggle, .docs-toggle-spacer { display: grid; flex: none; place-items: center; width: 20px; height: 20px; }
.docs-toggle { padding: 0; border: 0; border-radius: 4px; background: none; color: inherit; cursor: pointer; }
.docs-toggle:hover { background: var(--border); }
.docs-toggle .icon { width: 14px; height: 14px; }
.docs-node-link { flex: 1; min-width: 0; padding: 5px 2px; color: inherit; text-decoration: none; }
.docs-node-link span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-node-action { opacity: 0; }
.docs-node:hover .docs-node-action, .docs-node:focus-within .docs-node-action { opacity: 1; }

.docs-search-results { display: flex; flex-direction: column; gap: 2px; }
.docs-search-hit { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.docs-search-hit:hover, .docs-search-hit.active { background: var(--surface-3); }
.docs-search-title { font-weight: 600; }

.docs-main { min-width: 0; overflow: auto; }
.docs-page { max-width: 860px; margin: 0 auto; padding: 24px 28px 64px; }
.docs-page.with-toc { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 32px; max-width: 1100px; }
.docs-page-main { min-width: 0; }
.docs-section-title { margin: 28px 0 10px; color: var(--text-muted); font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.breadcrumb-sep { color: var(--text-faint); }

.doc-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.doc-title { font-size: 28px; line-height: 1.2; overflow-wrap: anywhere; }
.doc-actions { display: flex; flex: none; gap: 4px; padding-top: 4px; }
.docs-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 8px 0 20px; color: var(--text-muted); }
.docs-meta strong { color: var(--text); font-weight: 600; }

.doc-body { font-size: 15px; line-height: 1.65; }
.doc-body > * + * { margin-top: 12px; }
.doc-body h1, .doc-body h2, .doc-body h3, .doc-body h4 { margin-top: 28px; line-height: 1.3; scroll-margin-top: 16px; }
.doc-body h1 { font-size: 24px; }
.doc-body h2 { padding-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 20px; }
.doc-body h3 { font-size: 17px; }
.doc-body h4, .doc-body h5, .doc-body h6 { font-size: 15px; }
.doc-body > :first-child { margin-top: 0; }
.doc-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }

.doc-children ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin: 0 0 10px; padding: 0; list-style: none; }
.doc-children a { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.doc-children a:hover { border-color: var(--accent); }
.doc-children .icon { flex: none; color: var(--accent-text); }

.docs-toc { position: sticky; top: 24px; align-self: start; font-size: 13px; }
.docs-toc-title { margin-bottom: 6px; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.docs-toc ul { margin: 0; padding: 0 0 0 10px; border-left: 2px solid var(--border); list-style: none; }
.docs-toc li { padding: 2px 0; }
.docs-toc .toc-h2 { padding-left: 8px; }
.docs-toc .toc-h3 { padding-left: 16px; }
.docs-toc .link-button { color: var(--text-muted); text-align: left; }
.docs-toc .link-button:hover { color: var(--text); }

.docs-recent { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.docs-recent-item { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.docs-recent-item:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.docs-recent-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.docs-recent-title .icon { color: var(--accent-text); }
.docs-recent-excerpt { margin: 6px 0 0; color: var(--text-muted); font-size: 13px; }
.docs-recent-item .docs-meta { margin: 6px 0 0; }

.docs-editing { display: flex; flex-direction: column; gap: 10px; max-width: 1280px; height: 100%; padding-bottom: 16px; }
.doc-title-input { height: auto; padding: 8px 10px; font-size: 22px; font-weight: 700; }
.doc-editor { flex: 1; min-height: 0; }
.doc-editor .md-editor-area { flex: 1; min-height: 360px; }
.doc-editor .md-editor-input { height: 100%; min-height: 360px; max-height: none; resize: none; font-size: 13.5px; }
.doc-editor .md-editor-preview { min-height: 360px; max-height: none; padding: 12px 16px; }
.doc-editor .md-editor-preview .markdown { font-size: 15px; line-height: 1.6; }
.doc-editor-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.template-choice { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.template-choice:hover { border-color: var(--border-strong); }
.template-choice.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.template-choice .icon { flex: none; }

.history-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; min-height: 360px; }
.revision-list { display: flex; flex-direction: column; gap: 4px; max-height: 65vh; margin: 0; padding: 0; overflow: auto; list-style: none; }
.revision-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.revision-item strong { display: flex; align-items: center; gap: 6px; }
.revision-item:hover { background: var(--surface-2); }
.revision-item.active { border-color: var(--accent); background: var(--accent-soft); }
.history-preview { max-height: 65vh; padding: 0 4px; overflow: auto; }
.history-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* ===================================================================== markdown editor */

.md-editor { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; }
.md-tool { min-width: 28px; padding: 0 5px; color: var(--text-muted); }
.md-tool .icon { width: 15px; height: 15px; }
.md-tool-sep { width: 1px; height: 16px; margin: 0 4px; background: var(--border); }
.md-editor-status { color: var(--text-muted); font-size: 12px; }
.md-editor-status:not(:empty) { margin-right: 6px; }
.md-editor-area { display: grid; grid-template-columns: 1fr; gap: 12px; min-width: 0; border-radius: var(--radius-sm); }
.md-editor-area[data-mode="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.md-editor-area[data-mode="write"] .md-editor-preview { display: none; }
.md-editor-area[data-mode="preview"] .md-editor-input { display: none; }
.md-editor-area.is-dragover .md-editor-input { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.md-editor-input { min-height: 96px; max-height: 60vh; padding: 8px 10px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.description-editor .md-editor-input { min-height: 180px; }
.md-editor-preview { min-height: 96px; max-height: 60vh; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: auto; }
.description-editor .md-editor-preview { min-height: 180px; }

.markdown mark { padding: 0 2px; border-radius: 3px; background: color-mix(in srgb, var(--warning) 35%, transparent); color: inherit; }
.markdown ol[start] { counter-reset: none; }
.markdown .task-item.is-checked { color: var(--text-muted); }
.markdown .task-item input:not(:disabled) { cursor: pointer; }
.markdown pre[data-lang] { position: relative; }
.markdown pre[data-lang]::after {
  content: attr(data-lang);
  position: absolute;
  top: 4px;
  right: 8px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: lowercase;
}
.md-image {
  display: inline-block;
  max-width: 100%;
  max-height: 520px;
  border-radius: var(--radius-sm);
  vertical-align: middle;
  cursor: zoom-in;
}
.md-image-sized { width: var(--md-image-width, auto); height: var(--md-image-height, auto); object-fit: contain; }
a .md-image { cursor: pointer; }
.md-figure .md-image { display: block; border: 1px solid var(--border); background: var(--surface-2); }
.md-image-broken {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
}
.md-image-broken .icon { width: 14px; height: 14px; }

.callout { padding: 8px 12px; border-left: 3px solid var(--callout-color); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--callout-color) 10%, transparent); }
.callout > * + * { margin-top: 6px; }
.callout-title { color: var(--callout-color); font-weight: 600; }
.callout-note { --callout-color: var(--accent); }
.callout-tip { --callout-color: var(--success); }
.callout-important { --callout-color: var(--review); }
.callout-warning { --callout-color: var(--warning); }
.callout-caution { --callout-color: var(--danger); }

.model-badge { border-color: color-mix(in srgb, var(--review) 35%, transparent); background: var(--review-soft); color: var(--review); }

/* ===================================================================== lightbox */

.dialog-full { width: calc(100vw - 32px); max-width: none; }
.lightbox { background: color-mix(in srgb, #000 88%, transparent); border-color: transparent; color: #fff; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.75); }
.lightbox-header { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.lightbox-header .btn { color: #fff; }
.lightbox-caption { flex: 1; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.lightbox .dialog-body { display: flex; align-items: center; justify-content: center; padding: 0 12px 12px; }
.lightbox-image { max-width: 100%; max-height: calc(100dvh - 120px); object-fit: contain; cursor: zoom-out; }

/* ===================================================================== media */

.card-cover { margin: 6px 0 6px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-2); }
.card-cover img { display: block; width: 100%; max-height: 160px; object-fit: cover; }

.media-view { display: flex; flex-direction: column; gap: 12px; min-height: 100%; padding: 24px 28px; border: 2px dashed transparent; }
.media-view.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.media-header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.media-header .input { width: 240px; }
.media-statusbar { display: flex; gap: 12px; min-height: 18px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.media-grid-picker { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); max-height: 46vh; overflow-y: auto; padding: 2px; }
.media-card { position: relative; display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.media-card figcaption { position: relative; display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-right: 28px; }
.media-name { overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.media-grid-picker .media-card figcaption { padding-right: 0; }
.media-copy { position: absolute; top: 0; right: 0; }
.media-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px;
  cursor: pointer;
}
.media-thumb:hover, .media-thumb:focus-visible { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-empty { grid-column: 1 / -1; }
.media-empty .empty-icon { width: 40px; height: 40px; color: var(--text-faint); }
.media-detail { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; }
.media-detail-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px;
  cursor: zoom-in;
}
.media-detail-preview img { max-width: 100%; max-height: 52vh; object-fit: contain; }
.media-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.media-meta dt { color: var(--text-muted); }
.media-meta dd { margin: 0; }
.media-uploader { display: inline-flex; align-items: center; gap: 4px; }
.media-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.media-usages { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 0; padding: 0; list-style: none; }
.media-usages a { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.media-usages a:hover { background: var(--surface-2); }
.media-usages .icon { flex: none; width: 14px; height: 14px; color: var(--text-muted); }
.media-usages a > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-usages .muted { margin-left: auto; white-space: nowrap; }
.media-picker { min-height: 200px; border: 2px dashed transparent; border-radius: var(--radius); }
.media-picker.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.media-picker-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.media-picker-bar .input { flex: 1; min-width: 180px; }
.media-picker-url summary { cursor: pointer; color: var(--accent-text); font-size: 13px; }
.media-picker-url[open] summary { margin-bottom: 8px; }

/* ===================================================================== responsive */

@media (max-width: 1100px) {
  .docs-page.with-toc { display: block; }
  .docs-toc { display: none; }
}

@media (max-width: 900px) {
  .card-layout { grid-template-columns: 1fr; }
  .docs-view { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .docs-tree { max-height: 32vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .md-editor-area[data-mode="split"] { grid-template-columns: 1fr; }
  .md-editor-area[data-mode="split"] .md-editor-preview { display: none; }
  .media-detail { grid-template-columns: 1fr; }
  .history-layout { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
  .card-side { border-left: 0; border-top: 1px solid var(--border); }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .settings-tab { white-space: nowrap; }
  .board-progress { display: none; }
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 900;
    width: min(280px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 800; background: rgba(0, 0, 0, 0.4); }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .mobile-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .board-header { padding: 12px 12px 4px; }
  .media-view { padding: 14px 12px; }
  .media-header .input { width: 100%; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .board-toolbar, .category-bar { padding-left: 12px; padding-right: 12px; }
  .board-columns { padding: 4px 12px 12px; scroll-snap-type: x mandatory; }
  .column { width: min(var(--column-width), 86vw); scroll-snap-align: start; }
  .search-wrap { width: 100%; }
  .card-menu { opacity: 1; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .dialog { max-height: calc(100dvh - 16px); width: calc(100vw - 16px); }
  .card-main { padding: 12px 14px 20px; }
  .docs-page { padding: 16px 14px 48px; }
  .doc-title { font-size: 22px; }
  .docs-node-action { opacity: 1; }
}

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