/* styles.css — AiKupBoard v4 "Field Ops Console" design system.
   Dark + Light themes, self-hosted type, layered surfaces, instrument-panel aesthetic. */

/* ---------- Self-hosted fonts ---------- */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('fonts/space-grotesk/latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('fonts/manrope/latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('fonts/ibm-plex-mono/latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Design tokens ---------- */
:root,
:root[data-theme="dark"] {
  /* Surface — warm-black with faint green undertone, not cold slate */
  --bg: #0b0e0c;
  --bg-1: #131714;
  --bg-2: #1a1f1b;
  --bg-3: #222823;
  --text: #e8ebf2;
  --text-muted: #a3adbf;
  --text-dim: #9ca3af;

  /* Layered glass — transparent surfaces, no blur */
  --glass: rgba(26, 30, 28, 0.30);
  --glass-strong: rgba(28, 33, 30, 0.50);
  --glass-soft: rgba(40, 46, 42, 0.20);
  --surface-flat: rgba(22, 26, 23, 0.55);
  --card-flat: rgba(34, 39, 36, 0.65);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Layered shadow system — 3 layers of increasing softness */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.15);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.30), 0 8px 24px rgba(0, 0, 0, 0.20), 0 16px 48px rgba(0, 0, 0, 0.12);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.20), 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35), 0 16px 48px rgba(0, 0, 0, 0.25), 0 32px 80px rgba(0, 0, 0, 0.15);

  /* Hero & overlay */
  --overlay: linear-gradient(135deg, rgba(8, 10, 9, 0.88), rgba(8, 10, 9, 0.72));
  --hero-gradient: radial-gradient(1100px 520px at 85% -5%, rgba(37, 99, 235, 0.16), transparent 55%), radial-gradient(900px 480px at -5% 105%, rgba(74, 144, 217, 0.11), transparent 55%), linear-gradient(165deg, #0f1210 0%, #0b0e0c 100%);

  /* Accent — brand blue (non-negotiable) */
  --accent: #2563EB;
  --accent-deep: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.16);
  --accent-glow: rgba(37, 99, 235, 0.38);

  /* Secondary signal — amber for live/active indicators */
  --accent2: #f5a623;
  --accent2-soft: rgba(245, 166, 35, 0.16);
  --accent2-glow: rgba(245, 166, 35, 0.38);

  /* Priority colors */
  --p0: #e5484d;
  --p1: #f5a623;
  --p2: #4a90d9;
  --p3: #9ca3af;

  /* Type pills */
  --type-sprint: rgba(76, 175, 80, 0.20);
  --type-task: rgba(74, 144, 217, 0.20);
  --type-backlog: rgba(124, 138, 126, 0.20);
  --type-decision: rgba(245, 166, 35, 0.20);
  --type-institutional: rgba(167, 139, 250, 0.20);

  /* Signal colors — notification type indicators + KPI states */
  --signal-mention: #818cf8;
  --signal-mention-soft: rgba(129, 140, 248, 0.16);
  --signal-assign: #2563EB;
  --signal-assign-soft: rgba(37, 99, 235, 0.16);
  --signal-move: #a78bfa;
  --signal-move-soft: rgba(167, 139, 250, 0.16);
  --signal-mail: #f5a623;
  --signal-mail-soft: rgba(245, 166, 35, 0.16);
  --signal-success: #34d399;
  --signal-success-soft: rgba(52, 211, 153, 0.16);
  --signal-overdue: #e5484d;
  --signal-overdue-soft: rgba(229, 72, 77, 0.16);

  /* Panel tokens */
  --panel-w: 420px;
  --panel-bg: var(--bg-1);
  --gauge-ring: 88px;

  /* Border radius scale — exactly 4 tokens */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Typography scale */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --fs-xs: 0.6875rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --lh-tight: 1.2;
  --lh-base: 1.45;
  --lh-relaxed: 1.6;
}

:root[data-theme="light"] {
  --bg: #eef2f7;
  --bg-1: #e7edf4;
  --bg-2: #dde6f0;
  --bg-3: #cfdae8;
  --text: #16202c;
  --text-muted: #4d5a6b;
  --text-dim: #6b7280;

  --glass: rgba(255, 255, 255, 0.35);
  --glass-strong: rgba(255, 255, 255, 0.55);
  --glass-soft: rgba(255, 255, 255, 0.25);
  --surface-flat: rgba(255, 255, 255, 0.50);
  --card-flat: rgba(255, 255, 255, 0.60);
  --border: rgba(20, 40, 70, 0.10);
  --border-strong: rgba(20, 40, 70, 0.20);

  --shadow-sm: 0 1px 3px rgba(30, 50, 80, 0.08), 0 2px 6px rgba(30, 50, 80, 0.06);
  --shadow: 0 4px 12px rgba(30, 50, 80, 0.10), 0 8px 24px rgba(30, 50, 80, 0.08), 0 16px 48px rgba(30, 50, 80, 0.05);
  --shadow-soft: 0 2px 8px rgba(30, 50, 80, 0.08), 0 4px 16px rgba(30, 50, 80, 0.05);
  --shadow-lg: 0 8px 24px rgba(30, 50, 80, 0.12), 0 16px 48px rgba(30, 50, 80, 0.08), 0 32px 80px rgba(30, 50, 80, 0.05);

  --overlay: linear-gradient(135deg, rgba(238, 242, 247, 0.80), rgba(214, 224, 234, 0.66));
  --hero-gradient: radial-gradient(1100px 520px at 85% -5%, rgba(37, 99, 235, 0.14), transparent 55%), radial-gradient(900px 480px at -5% 105%, rgba(74, 144, 217, 0.13), transparent 55%), linear-gradient(165deg, #f4f7fb 0%, #e4ebf3 100%);

  --accent: #1d4ed8;
  --accent-deep: #1e40af;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-glow: rgba(37, 99, 235, 0.30);

  --accent2: #d98a12;
  --accent2-soft: rgba(217, 138, 18, 0.14);
  --accent2-glow: rgba(217, 138, 18, 0.30);

  --p0: #d23b40;
  --p1: #d98a12;
  --p2: #3a78bf;
  --p3: #6b7280;

  --type-sprint: rgba(34, 139, 58, 0.18);
  --type-task: rgba(43, 108, 176, 0.18);
  --type-backlog: rgba(107, 122, 110, 0.20);
  --type-decision: rgba(214, 138, 18, 0.20);
  --type-institutional: rgba(124, 58, 237, 0.18);

  /* Signal colors — light theme */
  --signal-mention: #6366f1;
  --signal-mention-soft: rgba(99, 102, 241, 0.12);
  --signal-assign: #1d4ed8;
  --signal-assign-soft: rgba(37, 99, 235, 0.10);
  --signal-move: #8b5cf6;
  --signal-move-soft: rgba(139, 92, 246, 0.12);
  --signal-mail: #d98a12;
  --signal-mail-soft: rgba(217, 138, 18, 0.12);
  --signal-success: #059669;
  --signal-success-soft: rgba(5, 150, 105, 0.12);
  --signal-overdue: #d23b40;
  --signal-overdue-soft: rgba(210, 59, 64, 0.12);

  /* Panel tokens — light */
  --panel-bg: var(--bg-1);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  margin: 0;
}

code, pre, .mono, .coord-tag, .cal-sub-url {
  font-family: var(--font-mono);
}

/* Background.
   The hero PHOTO is the default. It lives on its OWN compositor layer
   (transform: translateZ(0)) so the browser paints it once and never re-blends
   it on scroll — this is the performant way to show a fixed image background.
   Toggle it off with the 🖼️ button (adds .no-hero) if you ever want max speed. */
body {
  position: relative;
  background: var(--bg);
  transition: color 250ms ease;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url('img/AiKupLogoBrandDesign.png') center / cover no-repeat;
  transform: translateZ(0);
  will-change: transform;
}
@media (orientation: portrait) {
  body::before {
    background-image: url('img/portraitBackground.jpg');
  }
}
body.no-hero::before { display: none; }
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--overlay);
}

/* Glass utility (flat — no per-element blur, for performance) */
.glass {
  background: var(--surface-flat);
  border: 1px solid var(--border);
}

button {
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  background: var(--glass-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 8px 14px;
  transition: background 180ms ease, border-color 180ms ease, transform 120ms ease, box-shadow 180ms ease, color 180ms ease;
}
button:hover { background: var(--glass-strong); border-color: var(--accent); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  border: 1px solid transparent; color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: all 180ms ease;
}
button.primary:hover {
  background: linear-gradient(135deg, var(--accent-deep) 0%, var(--accent) 100%);
  box-shadow: 0 4px 16px var(--accent-glow), 0 0 24px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-1px);
}
button.primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px var(--accent-glow);
}
button.ghost { background: transparent; }
button.danger { background: transparent; border-color: var(--p0); color: var(--p0); }
button.danger:hover { background: rgba(229, 72, 77, 0.14); }

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--glass-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  width: 100%;
  transition: border-color 180ms ease, background 180ms ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--glass-strong); }
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
label { display: block; font-size: 12px; color: var(--text-muted); margin: 0 0 5px; font-weight: 600; letter-spacing: 0.2px; }

/* SVG icons */
.ico { width: 17px; height: 17px; display: inline-block; vertical-align: middle; flex: 0 0 auto; }
button .ic, .seg-btn .ic { margin-inline-end: 7px; }
.theme-toggle .ic, .icon-btn .ic, .logo-ic { margin: 0; display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; }
.card .title .ico { width: 15px; height: 15px; margin-inline-end: 6px; }

.hidden { display: none !important; }

/* ---------- Screen reader only ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Card context menu (keyboard accessible) ---------- */
.card-menu-btn {
  position: absolute; top: 8px; inset-inline-end: 8px; z-index: 6;
  width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-soft); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-dim);
  font-size: 16px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 140ms ease, background 140ms ease, color 140ms ease;
}
.card:hover .card-menu-btn, .card:focus-within .card-menu-btn { opacity: 1; }
.card-menu-btn:hover, .card-menu-btn:focus-visible { background: var(--glass-strong); color: var(--accent); }

.card-menu-dropdown {
  position: absolute; top: 36px; inset-inline-end: 8px; z-index: 10;
  min-width: 160px; background: var(--glass-strong);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow); padding: 4px; display: none;
}
.card-menu-dropdown.open { display: block; }
.card-menu-dropdown button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; border: none; background: transparent;
  color: var(--text); font-size: 13px; text-align: start;
  border-radius: var(--r-sm); cursor: pointer;
}
.card-menu-dropdown button:hover { background: var(--accent-soft); color: var(--accent); }
.card-menu-dropdown button.danger-menu { color: var(--p0); }
.card-menu-dropdown button.danger-menu:hover { background: rgba(229,72,77,0.12); }
.card-menu-dropdown button .ico { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Layout ---------- */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 22px;
  background: var(--glass-strong);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; margin-inline-end: auto; }
.brand-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand .logo-img {
  height: 38px;
  width: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand .logo { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; letter-spacing: 0.4px; }
.brand .logo .name { color: var(--accent); }
.brand .logo .dot { color: var(--accent); }
.brand .sub { font-size: var(--fs-xs); color: var(--text-dim); letter-spacing: 0.2px; }

/* Coordinate tag — monospace grid reference */
.coord-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--accent2);
  background: var(--accent2-soft);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  margin-inline-start: 8px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Segmented nav */
.seg {
  display: inline-flex;
  background: var(--glass-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 4px;
  gap: 4px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18);
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 180ms ease;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); background: var(--glass-strong); }
.seg-btn.active {
  color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.topbar-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.cross-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-flat);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: var(--r-xl);
  white-space: nowrap;
}
.cross-badge b { color: var(--text); }
.cross-badge .live { color: var(--accent); }

.theme-toggle {
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; border-radius: var(--r-md);
  background: var(--glass-soft);
}

/* ---------- Filter bar ---------- */
.filterbar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 14px 22px;
  background: var(--surface-flat);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filterbar .field { min-width: 160px; flex: 1 1 200px; }
.filterbar .field.search { flex: 2 1 320px; }
.filterbar .field.small { flex: 0 0 auto; min-width: 140px; }
.filterbar .btn-row { display: flex; gap: 8px; align-items: flex-end; }

/* ---------- KPI strip ---------- */
.kpis {
  display: flex;
  gap: 11px;
  padding: 14px 22px 0;
  flex-wrap: wrap;
}
.kpi {
  background: var(--surface-flat);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 16px;
  min-width: 96px;
  box-shadow: var(--shadow-soft);
}
.kpi .n { font-size: 22px; font-weight: 800; line-height: 1; }
.kpi .l { font-size: 11px; color: var(--text-muted); margin-top: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi.wip { border-color: var(--p1); }
.kpi.wip .n { color: var(--p1); }
.kpi.done { border-color: var(--accent); }
.kpi.done .n { color: var(--accent); }

/* ---------- Board ---------- */
.board {
  display: flex;
  gap: 16px;
  padding: 18px 22px 44px;
  overflow-x: auto;
  align-items: flex-start;
  flex: 1;
  contain: layout style;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.board::-webkit-scrollbar { height: 6px; }
.board::-webkit-scrollbar-track { background: transparent; }
.board::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.board::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.col {
  background: var(--surface-flat);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 300px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  max-height: calc(85vh - 210px);
  box-shadow: var(--shadow-soft);
  transition: border-color 160ms ease, background 160ms ease;
}
.col.drop-target {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 22px var(--accent-glow);
}
.col-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.col-head .name { font-weight: 800; font-size: 13.5px; letter-spacing: 0.3px; }
.col-head .count {
  background: var(--glass-soft);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 9px;
  border-radius: var(--r-md);
}
.col-head .col-actions { margin-inline-start: auto; display: flex; gap: 6px; }
.col-head .icon-btn {
  border: none; background: transparent; color: var(--text-dim);
  padding: 3px 7px; font-size: 16px; border-radius: var(--r-sm); line-height: 1;
}
.col-head .icon-btn:hover { background: var(--glass-strong); color: var(--accent); }

.col-wip-flag { font-size: 10px; color: var(--p1); border: 1px solid var(--p1); border-radius: var(--r-md); padding: 0 7px; }

.cards {
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  overflow-y: auto;
  flex: 1;
  contain: layout paint;
  overscroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.cards::-webkit-scrollbar { width: 5px; }
.cards::-webkit-scrollbar-track { background: transparent; }
.cards::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.cards::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.col-add {
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  margin: 0 11px 11px;
  padding: 9px;
  border-radius: var(--r-md);
  font-size: 12px;
}
.col-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.empty-hint {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 18px 8px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}

/* ---------- Card ---------- */
.card {
  background: var(--card-flat);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--p3);
  border-radius: var(--r-lg);
  padding: 12px 13px;
  cursor: grab;
  transition: border-color 160ms ease, opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.15), var(--shadow-soft);
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card.dragging { opacity: 0.45; cursor: grabbing; will-change: transform; }
.card.p0 { border-inline-start-color: var(--p0); }
.card.p1 { border-inline-start-color: var(--p1); }
.card.p2 { border-inline-start-color: var(--p2); }
.card.p3 { border-inline-start-color: var(--p3); }

.card .title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-base); margin-bottom: 6px; line-height: var(--lh-tight); }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }

/* Monospace data row — due date, card ID */
.card-data-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-dim);
}
.card-due { font-weight: 500; }
.card-due.overdue { color: var(--p0); font-weight: 600; }
.card-id { opacity: 0.6; }

/* Card assignees */
.card-assignees { display: flex; gap: 4px; margin-top: 6px; }
.card-avatar {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-size: 9px; font-weight: 700; font-family: var(--font-mono);
}

/* Pinned card */
.card.is-pinned { border-color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow-soft) !important; }
.pin-indicator {
  position: absolute; top: 6px; inset-inline-end: 6px;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  color: var(--accent); opacity: 0.85; pointer-events: none; z-index: 10;
}
.pin-indicator .ic { width: 16px; height: 16px; filter: drop-shadow(0 1px 2px var(--accent-glow)); }

.pill { font-size: var(--fs-xs); font-weight: 700; padding: 2px 9px; border-radius: var(--r-xl); letter-spacing: 0.2px; white-space: nowrap; }
.pill.type-Sprint { background: var(--type-sprint); color: #7ee08a; }
.pill.type-Task { background: var(--type-task); color: #8ec5f0; }
.pill.type-BacklogItem { background: var(--type-backlog); color: #c2c7d0; }
.pill.type-Decision { background: var(--type-decision); color: #f6c66b; }
.pill.type-Institutional { background: var(--type-institutional); color: #c4b5fd; }

.prio-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }
.prio-dot.p0 { background: var(--p0); color: var(--p0); }
.prio-dot.p1 { background: var(--p1); color: var(--p1); }
.prio-dot.p2 { background: var(--p2); color: var(--p2); }
.prio-dot.p3 { background: var(--p3); color: var(--p3); }

.card .tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.card .tag { font-size: var(--fs-xs); color: var(--text-muted); background: var(--glass-soft); padding: 1px 8px; border-radius: var(--r-sm); }
.card .dep { margin-top: 8px; font-size: var(--fs-xs); color: var(--text-dim); border-top: 1px dashed var(--border); padding-top: 7px; }
.card .dep b { color: var(--p2); }
.card .blocked-note {
  margin-top: 8px; font-size: var(--fs-xs); color: var(--p0);
  background: rgba(229, 72, 77, 0.10); border: 1px solid rgba(229, 72, 77, 0.32);
  padding: 5px 8px; border-radius: var(--r-sm);
}
.card .check-progress { margin-top: 8px; font-size: var(--fs-xs); color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.card .check-progress .bar { flex: 1; height: 5px; background: var(--glass-soft); border-radius: var(--r-sm); overflow: hidden; }
.card .check-progress .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); }

/* ---------- Reference panels (reference.html + (legacy) mobile) ---------- */
.ref-wrap { padding: 26px 22px 0; display: flex; flex-direction: column; gap: 22px; max-width: 1200px; margin: 0 auto; width: 100%; }
.ref-page-head { text-align: center; padding: 30px 20px 4px; }
.ref-page-head h1 { font-size: 28px; margin: 0 0 8px; font-weight: 800; letter-spacing: 0.3px; }
.ref-page-head h1 .accent { color: var(--accent); }
.ref-page-head p { color: var(--text-muted); max-width: 640px; margin: 0 auto; font-size: 14px; }

.ref-panel {
  background: var(--surface-flat);
  border: 1px solid var(--border);
  border-inline-start: 5px solid var(--accent);
  border-radius: var(--r-xl);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.ref-panel.offline { border-inline-start-color: var(--p2); }
.ref-panel h2 {
  font-size: 18px; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; font-weight: 800;
}
.ref-panel h2 .reduce {
  margin-inline-start: auto; font-size: 11px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 5px;
  background: var(--glass-soft); border: 1px solid var(--border); padding: 4px 12px; border-radius: var(--r-lg); cursor: pointer;
}
.ref-panel h2 .reduce:hover { color: var(--text); border-color: var(--accent); }
.ref-panel h2 .reduce .ico { transition: transform 200ms ease; }
.ref-panel h2 .reduce .ico.up { transform: rotate(180deg); }
.ref-panel.collapsed .ref-body { display: none; }

.actor-groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .actor-groups { grid-template-columns: 1fr; } }
.actor-group {
  background: var(--glass-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 17px;
}
.actor-group.primary { border-inline-start: 5px solid var(--accent); }
.actor-group.complementary { border-inline-start: 5px solid var(--p1); }
.actor-group.never { border-inline-start: 5px solid var(--p0); }
.actor-group h3 { font-size: 13px; margin: 0 0 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.actor-group.primary h3 { color: #7ee08a; }
.actor-group.complementary h3 { color: #f6c66b; }
.actor-group.never h3 { color: #f08a8d; }
.actor-group ul { margin: 0; padding-inline-start: 18px; }
.actor-group li { font-size: 13px; margin-bottom: 6px; }
.actor-group .note { font-size: 12px; color: var(--text-dim); margin-top: 10px; font-style: italic; }

.never-list { margin: 0; padding-inline-start: 20px; }
.never-list li { font-size: 14px; margin-bottom: 9px; }
.never-list li b { color: var(--text); }
.never-list .ok { color: var(--accent); font-weight: 600; }

.offline-text { font-size: 14px; line-height: 1.6; color: var(--text); }
.offline-text b { color: var(--p2); }

/* ---------- Overlay / drawer / modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(6, 8, 12, 0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: flex-end;
  z-index: 120; opacity: 0; pointer-events: none; transition: opacity 200ms ease;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.overlay.center { align-items: center; justify-content: center; }

.drawer {
  width: 500px; max-width: 95vw; height: 100%;
  background: var(--glass-strong);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px 24px; overflow-y: auto;
  transform: translateX(24px); transition: transform 220ms ease;
}
.overlay.open .drawer { transform: translateX(0); }
.modal {
  width: 480px; max-width: 95vw;
  background: var(--glass-strong);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 24px 26px; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 14px; font-size: 17px; font-weight: 800; }
.modal .modal-body { font-size: 13.5px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }
.modal .modal-body ul { margin: 10px 0 0; padding-inline-start: 20px; }
.modal .modal-body li { margin-bottom: 5px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.drawer-head h2 { font-size: 18px; margin: 0; flex: 1; font-weight: 800; }
.drawer-close { border: none; background: transparent; font-size: 24px; color: var(--text-dim); line-height: 1; padding: 0 6px; }
.drawer-close:hover { color: var(--text); }

.form-row { margin-bottom: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

.checklist { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.checklist .item {
  display: flex; align-items: center; gap: 9px;
  background: var(--glass-soft); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: var(--r-md);
}
.checklist .item input[type=checkbox] { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--accent); }
.checklist .item .ctext { flex: 1; font-size: 13px; }
.checklist .item.done .ctext { text-decoration: line-through; color: var(--text-dim); }
.checklist .item .del { border: none; background: transparent; color: var(--text-dim); font-size: 15px; padding: 0 5px; }
.checklist .item .del:hover { color: var(--p0); }
.checklist-add { display: flex; gap: 8px; margin-top: 9px; }
.checklist-add input { flex: 1; }

.drawer-actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }

/* decision log */
.log-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.log-entry {
  background: var(--glass-soft); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent); border-radius: var(--r-md);
  padding: 10px 12px; font-size: 12.5px; line-height: 1.5;
}
.log-entry .ts { font-size: 10.5px; color: var(--text-dim); margin-top: 5px; }
.log-entry .del { float: right; border: none; background: transparent; color: var(--text-dim); font-size: 13px; }
.log-entry .del:hover { color: var(--p0); }

/* toast */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 240; display: flex; flex-direction: column; gap: 9px; align-items: center; }
.toast {
  background: var(--glass-strong);
  border: 1px solid var(--border-strong); color: var(--text);
  padding: 11px 18px; border-radius: var(--r-xl); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); animation: toastIn 220ms ease;
}
.toast.warn { border-color: var(--p1); color: var(--p1); }
.toast.err { border-color: var(--p0); color: #ff9a9d; }
.toast-action {
  margin-inline-start: 12px; border: 1px solid var(--accent); background: transparent;
  color: var(--accent); border-radius: var(--r-lg); padding: 3px 12px; font-size: 12px; font-weight: 700;
}
.toast-action:hover { background: var(--accent-soft); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* footer */
.app-footer {
  position: static; margin-top: auto;
  padding: 14px 22px;
  background: var(--surface-flat);
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
}

/* board groups (index picker) */
.board-group { margin-bottom: 26px; }
.group-title {
  font-size: 13px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0 12px; padding-inline-start: 2px;
}

/* read-only banner on a board */
.ro-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: var(--r-lg);
  padding: 9px 14px;
  font-size: 13px;
  margin: 0 0 14px;
}

/* team board assignment */
.team-boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.board-assign {
  background: var(--surface-flat);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.board-assign h3 { margin: 0 0 4px; font-size: 15px; }
.board-assign .ba-sub { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.assign-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.assign-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.assign-list .am-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assign-list .am-role { width: 110px; }
.assign-list .am-rm { flex: 0 0 auto; }
.assign-add { display: flex; gap: 8px; align-items: center; }
.assign-add select, .assign-add input { flex: 1; min-width: 0; }
.assn-note { font-size: 11px; color: var(--text-dim); margin-top: 8px; }

/* guest trial screens */
.guest-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  padding: 10px 16px;
  font-size: 13px;
  margin: 0 0 18px;
}
.guest-banner.warn { border-color: var(--p1); color: var(--p1); }
.board-screen .back-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 10px;
}
.board-screen .back-link:hover { text-decoration: underline; }

/* expiry overlay */
.expiry-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  background: rgba(4, 8, 6, 0.92); backdrop-filter: blur(4px);
}
.expiry-box {
  background: var(--surface-flat);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 30px 34px;
  max-width: 440px;
  text-align: center;
}
.expiry-box h2 { margin: 0 0 12px; }
.expiry-box p { color: var(--text-dim); font-size: 14px; margin: 0 0 20px; }
.expiry-box .btn-row { display: flex; gap: 12px; justify-content: center; }

/* ===================== Team page (elegant redesign) ===================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 2px 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: 0.3px; }
.page-head .muted { margin: 4px 0 0; }

.team-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface-flat); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 16px 18px; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(var(--accent), var(--accent-deep)); }
.stat-n { font-size: 26px; font-weight: 800; color: var(--text); }
.stat-l { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; margin-top: 2px; }

.panel { background: var(--surface-flat); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 20px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel > .muted { margin: 0 0 16px; }

.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.user-card { background: var(--card-flat); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; display: flex; flex-direction: column; gap: 12px; transition: border-color 0.2s, transform 0.2s; }
.user-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.uc-top { display: flex; align-items: center; gap: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; background: var(--av, var(--accent)); font-size: 15px; letter-spacing: 0.5px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.uc-id { flex: 1; min-width: 0; }
.uc-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.uc-email { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--r-xl); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.role-badge.is-admin { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.role-badge.is-member { background: rgba(138, 143, 152, 0.16); color: var(--text-muted); border: 1px solid var(--border-strong); }
.tag-flag { font-size: 10px; font-weight: 700; color: var(--p1); background: rgba(245, 166, 35, 0.14); border: 1px solid rgba(245, 166, 35, 0.4); padding: 1px 6px; border-radius: var(--r-sm); text-transform: uppercase; letter-spacing: 0.4px; }
.uc-bottom { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.status-pill { padding: 3px 10px; border-radius: var(--r-xl); font-weight: 600; }
.status-pill.on { background: rgba(37, 99, 235, 0.14); color: #7aa2ff; border: 1px solid rgba(37, 99, 235, 0.4); }
.status-pill.off { background: rgba(229, 72, 77, 0.14); color: #ff9a9d; border: 1px solid rgba(229, 72, 77, 0.4); }
.uc-login { color: var(--text-dim); flex: 1; min-width: 120px; }
.uc-actions { margin-inline-start: auto; }
.danger-btn { color: var(--p0); }

.board-grid-assign { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.board-card { background: var(--card-flat); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bc-head h3 { margin: 0; font-size: 15px; }
.group-tag { font-size: 11px; color: var(--text-dim); background: var(--glass-soft); border: 1px solid var(--border); padding: 2px 8px; border-radius: var(--r-md); }
.bc-count { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 10px; background: var(--glass-soft); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 8px 10px; }
.member-row .m-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assign-add { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.assign-add .user-sel { flex: 1; min-width: 0; }
.assign-add .role-add { width: 120px; }
.assign-add .add-btn { width: 42px; height: 38px; display: flex; align-items: center; justify-content: center; padding: 0; }
.filter-search.sm { width: 220px; max-width: 100%; padding: 8px 12px; font-size: 13px; }

/* Breadcrumb (projects -> board orientation) */
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
  margin: 0; padding: 10px 22px;
  background: var(--surface-flat);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.breadcrumb a { color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 13px; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--text-dim); opacity: .5; font-size: 11px; margin: 0 2px; }
.breadcrumb .ic { width: 14px; height: 14px; }
.board-crumb { margin: 0; }

/* Project tiles */
.project-tile { position: relative; }
.star-btn { background: transparent; border: none; color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 4px; transition: color 0.15s; }
.star-btn:hover { color: var(--accent); }
.edit-btn { background: transparent; border: none; color: var(--text-muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 2px 4px; transition: color 0.15s; }
.edit-btn:hover { color: var(--accent); }
.tile-role { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); border: 1px solid var(--accent); border-radius: var(--r-md); padding: 1px 7px; align-self: flex-start; }

/* Project logo (tile + breadcrumb) and page background */
.tile-logo { width: 34px; height: 34px; object-fit: contain; border-radius: var(--r-sm); }
.crumb-logo { width: 20px; height: 20px; object-fit: contain; border-radius: var(--r-sm); vertical-align: middle; margin-inline-end: 4px; }
.app.has-bg {
  background-image: var(--bg-url); background-size: cover; background-position: center;
  background-attachment: fixed; min-height: 100vh; position: relative;
}
.app.has-bg::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: rgba(11, 14, 12, 0.50);
}
[data-theme="light"] .app.has-bg::before {
  background: rgba(255, 255, 255, 0.50);
}
.app.has-bg > *:not(.topbar) { position: relative; z-index: 1; }
.app.has-bg > .topbar,
.app.has-bg > nav.topbar { position: sticky; z-index: 60; }
.app.has-bg > .notif-overlay,
.app.has-bg > .chat-overlay,
.app.has-bg > .mail-overlay { position: fixed; z-index: 210; }
.app.has-bg > .notif-panel,
.app.has-bg > .chat-panel,
.app.has-bg > .mail-panel { position: fixed; z-index: 220; }
.app.bg-hidden { background-image: none !important; }
.app.bg-hidden::before { display: none; }

/* BG toggle button */
.bg-toggle {
  position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 90;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--glass-strong); border: 1px solid var(--border-strong);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 120ms ease;
}
.bg-toggle:hover { background: var(--accent-soft); color: var(--accent); transform: scale(1.08); }
.bg-toggle .ic { width: 18px; height: 18px; }

/* Edit modal fields */
.field-row { margin: 10px 0; }
.field-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.upload-row img { max-width: 64px; max-height: 64px; border-radius: var(--r-sm); border: 1px solid var(--border); }
.icon-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.icon-grid button { width: 34px; height: 34px; border: 1px solid var(--border); background: var(--bg-2); border-radius: var(--r-sm); cursor: pointer; color: var(--text); display: flex; align-items: center; justify-content: center; }
.icon-grid button.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.swatch-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* (old agenda/calendar rules removed — replaced by v3 block) */

/* Multi-select dropdown */
.ms-wrap { position: relative; display: inline-block; }
.ms-btn { font-size: 13px; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 12px; cursor: pointer; transition: border-color 160ms ease; }
.ms-btn:hover, .ms-btn.has-sel { border-color: var(--accent); }
.ms-panel { display: none; position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 200px; max-height: 280px; overflow: auto; background: var(--glass-strong); backdrop-filter: blur(10px); border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: 6px; box-shadow: var(--shadow); }
.ms-panel.open { display: block; }
.ms-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer; }
.ms-item:hover { background: var(--glass-soft); }
.ms-item input { accent-color: var(--accent); }

/* (old calendar rules removed — replaced by v3 block below) */
/* tag list in detail */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: var(--r-md); background: var(--bg-3); color: var(--text); }

/* Motion: smooth view/period transitions */
/* ===================== Calendar v4 — Elegant Redesign ===================== */

/* ---- Layout ---- */
.cal-app { display: flex; gap: 20px; align-items: stretch; flex: 1; min-height: 0; }
.cal-app.sb-collapsed .cal-sidebar { display: none; }
.cal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.cal-view-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.cal-view-scroll::-webkit-scrollbar { width: 5px; }
.cal-view-scroll::-webkit-scrollbar-track { background: transparent; }
.cal-view-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.cal-view-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---- Sidebar ---- */
.cal-sidebar {
  width: 300px; flex: 0 0 300px;
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); padding: 16px;
  overflow-y: auto;
  box-shadow: var(--shadow-soft);
}
.cal-sidebar::-webkit-scrollbar { width: 4px; }
.cal-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.cal-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.cal-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.cal-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); font-weight: 700;
  margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
.cal-section-title .ico { width: 14px; height: 14px; opacity: .6; }
.cal-section-title input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); margin-inline-start: auto; }
.cal-section-badge {
  background: var(--accent); color: #fff; border-radius: var(--r-md);
  padding: 1px 7px; font-size: 10px; font-weight: 700; margin-inline-start: auto;
}

/* Mini date picker */
.cal-mini-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.cal-mini-label { flex: 1; text-align: center; font-weight: 700; font-size: 13px; letter-spacing: .01em; }
.cal-mini-nav { padding: 4px 8px; min-width: 32px; min-height: 32px; justify-content: center; }
.cal-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-mini-dow { font-size: 9px; text-align: center; color: var(--text-dim); font-weight: 700; padding: 2px 0 4px; letter-spacing: .03em; }
.cal-mini-cell {
  font-size: 11px; text-align: center; padding: 5px 0; border-radius: var(--r-sm);
  color: var(--text); cursor: pointer; position: relative;
  transition: background 120ms ease;
}
.cal-mini-cell:hover { background: var(--glass-soft); }
.cal-mini-cell.out { opacity: .3; }
.cal-mini-cell.today { background: var(--accent); color: #fff; font-weight: 700; border-radius: 50%; }
.cal-mini-today { width: 100%; margin-top: 10px; }

/* Layers */
.cal-layer {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px;
  transition: background 120ms ease;
}
.cal-layer:hover { background: var(--glass-soft); }
.cal-layer input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
.cal-swatch { width: 14px; height: 14px; border-radius: var(--r-sm); flex: 0 0 auto; }
.cal-layer-name { flex: 1; font-weight: 500; }

/* Filters */
.cal-field { margin-bottom: 12px; }
.cal-field > label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); margin-bottom: 5px; font-weight: 700; letter-spacing: .02em; }
.cal-field > label .ico { width: 13px; height: 13px; opacity: .6; }
.cal-filters { display: flex; flex-direction: column; gap: 0; }
.cal-layers { display: flex; flex-direction: column; gap: 0; }
.cal-layer-list { display: flex; flex-direction: column; gap: 0; }
.cal-select {
  width: 100%; padding: 8px 10px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text);
  transition: border-color 140ms ease;
}
.cal-select:focus { border-color: var(--accent); outline: none; }
.cal-check { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 0; cursor: pointer; }
.cal-check .ico { width: 15px; height: 15px; color: var(--accent); opacity: .7; }
.cal-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.cal-reset { width: 100%; margin-top: 8px; }

/* Multi-select */
.cal-ms { position: relative; margin-bottom: 12px; }
.cal-ms-btn {
  width: 100%; display: flex; align-items: center; gap: 8px;
  justify-content: space-between; padding: 8px 10px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text); cursor: pointer;
  font-size: 13px; transition: border-color 140ms ease;
}
.cal-ms-btn:hover { border-color: var(--accent); }
.cal-ms-label { display: flex; align-items: center; gap: 6px; }
.cal-ms-label .ico { width: 13px; height: 13px; opacity: .6; }
.cal-ms-count {
  background: var(--accent); color: #fff; border-radius: var(--r-md);
  padding: 1px 7px; font-size: 11px; font-weight: 700;
  min-width: 20px; text-align: center;
}
.cal-ms-pop {
  display: none; position: absolute; z-index: 30;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--glass-strong);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  padding: 8px; box-shadow: var(--shadow);
}
.cal-ms-pop.show { display: block; }
.cal-ms-search {
  width: 100%; padding: 8px 10px; margin-bottom: 6px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text); font-size: 13px;
}
.cal-ms-search:focus { border-color: var(--accent); outline: none; }
.cal-ms-list { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 1px; }

/* Unscheduled */
.cal-unscheduled { display: flex; flex-direction: column; gap: 4px; }
.cal-unitem {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: var(--r-md);
  border-left: 3px solid var(--c);
  background: var(--glass-soft); cursor: grab;
  font-size: 12px; transition: transform 120ms ease, box-shadow 140ms ease;
}
.cal-unitem:hover { transform: translateX(3px); box-shadow: var(--shadow-soft); }
.cal-unitem:active { cursor: grabbing; transform: translateX(0); }
.cal-unitem-title { font-weight: 600; line-height: 1.3; display: flex; align-items: center; gap: 6px; }
.cal-unitem-title .ico { width: 13px; height: 13px; opacity: .7; flex-shrink: 0; }
.cal-unitem-meta { color: var(--text-dim); font-size: 11px; display: flex; align-items: center; gap: 4px; }
.cal-unitem-meta .ico { width: 11px; height: 11px; opacity: .5; }
.cal-empty { font-size: 12px; color: var(--text-dim); padding: 8px 0; display: flex; align-items: center; gap: 8px; }
.cal-empty .ico { width: 16px; height: 16px; opacity: .5; }

/* ---- Calendar page ---- */
.cal-page { padding: 18px 22px 0; display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
#calRoot { flex: 1; min-height: 0; display: flex; }

/* ---- Toolbar ---- */
.cal-toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; flex-shrink: 0; }
.cal-pagehead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cal-ph-left { display: flex; align-items: center; gap: 10px; }
.cal-ph-right { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; flex-wrap: wrap; }
.cal-title {
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
.cal-title .ico { width: 22px; height: 22px; color: var(--accent); }
.cal-title span { overflow: hidden; text-overflow: ellipsis; }
.cal-toolbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-tb-left, .cal-tb-right { display: flex; align-items: center; gap: 8px; }
.cal-tb-right { margin-inline-start: auto; }
.cal-badge {
  background: var(--accent); color: #fff; border-radius: var(--r-md);
  padding: 1px 8px; font-size: 11px; font-weight: 700; line-height: 1.4;
}
.cal-views { display: inline-flex; }
.cal-btn {
  padding: 8px 14px; background: var(--glass-soft); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text); cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 500;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease;
}
.cal-btn .ico { width: 16px; height: 16px; flex-shrink: 0; }
.cal-btn:hover { background: var(--glass-strong); border-color: var(--accent); box-shadow: 0 0 14px var(--accent-glow); }
.cal-btn:active { transform: translateY(1px); }
.cal-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cal-icon-btn { padding: 8px; min-width: 36px; min-height: 36px; justify-content: center; }
.cal-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.cal-primary:hover { background: var(--accent-deep); box-shadow: 0 0 20px var(--accent-glow); }
.cal-nav { font-size: 18px; padding: 6px 10px; min-width: 36px; min-height: 36px; justify-content: center; }
.cal-today-btn { font-weight: 600; }
.cal-color-mode, .cal-jump {
  padding: 8px 10px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text); font-size: 13px;
  transition: border-color 140ms ease;
}
.cal-color-mode:focus, .cal-jump:focus { border-color: var(--accent); outline: none; }
.cal-sb-toggle { font-size: 16px; }
.cal-view-label { }
.cal-filter-ind .cal-badge { margin-inline-start: 4px; }

/* ---- Stats ---- */
.cal-stats { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; flex-shrink: 0; }
.stat-pill {
  background: var(--glass-soft); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 18px;
  display: flex; align-items: center; gap: 12px; min-width: 100px;
  box-shadow: var(--shadow-soft);
  transition: border-color 140ms ease, transform 120ms ease;
}
.stat-pill:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat-icon { flex: 0 0 auto; }
.stat-icon .ico { width: 22px; height: 22px; }
.stat-text { display: flex; flex-direction: column; }
.stat-n { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-l { font-size: 11px; color: var(--text-dim); font-weight: 600; letter-spacing: .03em; margin-top: 2px; }
.stat-over .stat-icon .ico { color: #f87171; }
.stat-done .stat-icon .ico { color: #34d399; }
.stat-open .stat-icon .ico { color: var(--accent); }

/* ---- Month View ---- */
.cal-month-head { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.cal-col-head {
  text-align: center; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); padding: 10px 0;
}
.cal-col-head.today { color: var(--accent); }
.cal-month-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px;
  background: var(--border); border-radius: var(--r-lg); overflow: hidden;
  max-width: 100%;
}
.cal-cell {
  background: var(--bg-2); min-height: 130px;
  padding: 6px 8px; display: flex; flex-direction: column; gap: 3px;
  cursor: pointer; position: relative;
  min-width: 0; overflow: hidden;
  transition: background 140ms ease;
}
.cal-cell:hover { background: var(--glass-soft); }
.cal-cell.out { background: var(--bg-1); opacity: .45; }
.cal-cell.out:hover { opacity: .65; }
.cal-cell.we { background: color-mix(in srgb, var(--bg-1) 60%, var(--bg-2)); }
.cal-cell.today { background: var(--accent-soft); }
.cal-cell.today:hover { background: color-mix(in srgb, var(--accent) 18%, var(--bg-2)); }
.cal-cell-num {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  width: 28px; height: 28px; display: flex; align-items: center;
  justify-content: center; border-radius: 50%; margin-bottom: 2px;
}
.cal-cell.today .cal-cell-num {
  background: var(--accent); color: #fff; font-weight: 700;
}
.cal-cell-list { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden; }
.cal-count {
  position: absolute; top: 6px; inset-inline-end: 6px;
  background: var(--bg-3); border-radius: var(--r-md);
  padding: 1px 7px; font-size: 10px; font-weight: 600;
  color: var(--text-dim);
}
.cal-count.hot { background: var(--p0); color: #fff; }
.cal-more {
  font-size: 11px; color: var(--accent); font-weight: 600;
  cursor: pointer; padding: 2px 0; letter-spacing: .01em;
  display: flex; align-items: center; gap: 4px;
}
.cal-more:hover { text-decoration: underline; }

/* ---- Week View ---- */
.cal-week-head {
  display: grid; grid-template-columns: 56px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}
.cal-col-head .cal-dow { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.cal-col-head .cal-dn { display: block; font-size: 18px; font-weight: 800; margin-top: 1px; }
.cal-allday {
  display: grid; grid-template-columns: 56px repeat(7, 1fr);
  border: 1px solid var(--border); border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--bg-2); overflow: hidden;
}
.cal-allday-label { font-size: 10px; color: var(--text-dim); padding: 10px 6px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.cal-allday-label .ico { width: 12px; height: 12px; }
.cal-allday-cell {
  min-height: 40px; border-left: 1px solid var(--border);
  padding: 3px; display: flex; flex-direction: column; gap: 2px;
}
.cal-grid {
  display: grid; grid-template-columns: 56px repeat(7, 1fr);
  grid-template-rows: 44px repeat(24, 44px);
  border: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: var(--bg-2); overflow: hidden;
}
.cal-gutter-cell {
  grid-column: 1;   font-size: 10px; color: var(--text-dim);
  text-align: end; padding: 2px 8px 0 0;
  border-top: 1px solid var(--border); font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.cal-gcell {
  border-top: 1px solid var(--border); border-left: 1px solid var(--border);
  transition: background 120ms ease;
}
.cal-gcell:hover { background: var(--glass-soft); }
.cal-gcell.today { background: var(--accent-soft); }
.cal-gcell.drop { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.cal-gcell.sel { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.cal-daylayer { position: relative; pointer-events: none; }
.cal-wevent {
  position: absolute; pointer-events: auto;
  background: var(--c); color: #fff;
  border-radius: var(--r-sm); padding: 3px 8px;
  font-size: 11px; font-weight: 500; overflow: hidden;
  cursor: grab; box-shadow: 0 2px 8px rgba(0,0,0,.3);
  border-left: 3px solid rgba(0,0,0,.2);
  transition: box-shadow 140ms ease, transform 140ms ease;
}
.cal-wevent:hover { box-shadow: 0 4px 16px rgba(0,0,0,.4); transform: translateY(-1px); }
.cal-wevent:active { cursor: grabbing; transform: translateY(0); }
.cal-wevent.done { opacity: .55; }
.cal-wevent-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-resize {
  position: absolute; left: 0; right: 0; height: 7px;
  cursor: ns-resize; opacity: 0; transition: opacity 140ms ease;
}
.cal-wevent:hover .cal-resize { opacity: 1; }
.cal-resize.top { top: 0; }
.cal-resize.bottom { bottom: 0; }
.cal-resize:hover { background: rgba(255,255,255,.25); border-radius: 0 0 var(--r-sm) var(--r-sm); }
.cal-resize.top:hover { border-radius: var(--r-sm) var(--r-sm) 0 0; }

/* ---- Day View ---- */
.cal-dayview { }
.cal-day-single { }

/* ---- Year View ---- */
.cal-year { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.cal-year-month {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 10px;
  transition: border-color 140ms ease;
}
.cal-year-month:hover { border-color: var(--accent); }
.cal-year-month.now { border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }
.cal-year-month-title { font-size: 13px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.cal-year-grid { gap: 2px; }

/* ---- List View ---- */
.cal-list { display: flex; flex-direction: column; gap: 16px; }
.cal-list-day {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  transition: border-color 140ms ease;
}
.cal-list-day.today { border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }
.cal-list-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--bg-3);
  font-weight: 700; font-size: 14px;
}
.cal-list-date { display: flex; align-items: center; gap: 6px; }
.cal-list-date .ico { width: 16px; height: 16px; opacity: .6; }
.cal-list-count {
  background: var(--accent); color: #fff;
  border-radius: var(--r-md); padding: 2px 10px;
  font-size: 12px; font-weight: 700;
}
.cal-list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-top: 1px solid var(--border);
  transition: background 120ms ease;
}
.cal-list-row:hover { background: var(--glass-soft); }
.cal-list-time {
  width: 56px; font-size: 12px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.cal-list-time .ico { width: 12px; height: 12px; }
.cal-list-chip { flex: 1; }

/* ---- Chips ---- */
.cal-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-left: 3px solid var(--c);
  background: var(--bg-3); border-radius: var(--r-sm);
  font-size: 11px; cursor: pointer;
  min-width: 0; max-width: 100%;
  transition: transform 120ms ease, box-shadow 140ms ease, background 140ms ease;
}
.cal-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.3); background: var(--glass-strong); }
.cal-chip.done { opacity: .5; }
.cal-chip.done .cal-chip-title { text-decoration: line-through; }
.cal-chip.overdue { border-left-color: #f87171; }
.cal-chip-icon { color: var(--c); flex-shrink: 0; display: flex; align-items: center; }
.cal-chip-icon .ico { width: 12px; height: 12px; }
.cal-chip-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip-label {
  font-size: 9px; padding: 1px 6px; border-radius: var(--r-sm); font-weight: 600;
  white-space: nowrap; flex-shrink: 0;
}

/* ---- Hover Preview ---- */
.cal-preview {
  position: fixed; z-index: 200; width: 280px;
  background: var(--glass-strong);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  padding: 14px 16px; box-shadow: var(--shadow);
  pointer-events: none;
}
.cal-preview-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.cal-preview-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.cal-preview-meta span { display: flex; align-items: center; gap: 4px; }
.cal-preview-meta .ico { width: 12px; height: 12px; }
.cal-preview-dates { font-size: 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.cal-preview-dates .ico { width: 14px; height: 14px; }
.cal-preview-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.cal-plabel { font-size: 10px; padding: 2px 8px; border-radius: var(--r-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.cal-plabel .ico { width: 10px; height: 10px; }

/* ---- Forms ---- */
.cal-muted { color: var(--text-dim); font-size: 13px; line-height: 1.5; display: flex; align-items: center; gap: 6px; }
.cal-muted .ico { width: 16px; height: 16px; }
.cal-form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.cal-input {
  width: 100%; padding: 9px 12px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text); font-size: 13px;
  transition: border-color 140ms ease;
}
.cal-input:focus { border-color: var(--accent); outline: none; }
.cal-form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.cal-sub-url {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px;
  font-size: 11px; word-break: break-all; margin-bottom: 10px;
  font-family: var(--font-mono); line-height: 1.5;
}
.cal-sub-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Detail Drawer ---- */
.cal-detail-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.cal-detail-sub .ico { width: 14px; height: 14px; }
.cal-detail-body { display: flex; flex-direction: column; gap: 10px; }
.cal-detail-row { font-size: 13px; line-height: 1.5; display: flex; align-items: flex-start; gap: 8px; }
.cal-detail-icon { flex: 0 0 auto; color: var(--text-dim); margin-top: 2px; }
.cal-detail-icon .ico { width: 16px; height: 16px; }
.cal-detail-row b { color: var(--text-muted); font-weight: 600; }
.cal-detail-desc { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; margin-top: 8px; line-height: 1.6; }

/* ---- Responsive — Portrait / Mobile ---- */
.cal-page, .cal-app, .cal-main { max-width: 100%; overflow-x: hidden; }

/* --- Tablet / small desktop (≤ 900px) --- */
@media (max-width: 900px) {
  .cal-app { flex-direction: column; gap: 12px; }
  .cal-app .cal-sidebar {
    width: 100%; flex: 0 0 auto;
    max-height: 200px; overflow-y: auto;
    border-radius: var(--r-lg); padding: 12px;
  }
  .cal-page { padding: 10px 10px 0; }
  .cal-pagehead { flex-direction: column; align-items: flex-start; gap: 8px; }
  .cal-ph-right { margin-inline-start: 0; }
  .cal-toolbar-row { flex-wrap: wrap; gap: 6px; }
  .cal-title { font-size: 18px; }
  .cal-view-label { display: none; }
  .cal-stats { gap: 8px; }
  .stat-pill { padding: 10px 14px; min-width: 80px; }
  .stat-n { font-size: 18px; }
  .stat-icon .ico { width: 18px; height: 18px; }
  .cal-col-head { font-size: 10px; padding: 6px 0; letter-spacing: 0; }
  .cal-month-grid { border-radius: var(--r-md); }
  .cal-cell { min-height: 80px; padding: 4px 4px; min-width: 0; overflow: hidden; }
  .cal-cell-num { width: 20px; height: 20px; font-size: 11px; }
  .cal-cell .cal-chip { font-size: 9px; padding: 1px 4px; }
  .cal-cell .cal-more { font-size: 9px; }
  .cal-count { font-size: 9px; padding: 1px 5px; }
  .cal-grid { grid-template-columns: 44px repeat(7, 1fr); grid-auto-rows: 34px; }
  .cal-week-head { grid-template-columns: 44px repeat(7, 1fr); }
  .cal-allday { grid-template-columns: 44px repeat(7, 1fr); }
  .cal-gutter-cell { font-size: 9px; }
  .cal-wevent { font-size: 10px; }
  .cal-allday-label { font-size: 10px; }
  .cal-list-row { padding: 8px 10px; }
  .cal-list-time { font-size: 11px; }
  .cal-year { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cal-preview { max-width: 100%; }
  .cal-form { gap: 8px; }
  .cal-detail-body { gap: 8px; }
}

/* --- Phone portrait (≤ 600px) --- */
@media (max-width: 600px) {
  .cal-page { padding: 8px 6px 0; }
  .cal-pagehead { gap: 6px; }
  .cal-ph-left { gap: 8px; }
  .cal-title { font-size: 16px; }
  .cal-title .ico { width: 18px; height: 18px; }
  .cal-badge { font-size: 10px; padding: 1px 6px; }
  .cal-toolbar-row { gap: 4px; }
  .cal-view-label { display: none; }
  .cal-btn-text { display: none; }
  .cal-stats { gap: 4px; flex-wrap: wrap; }
  .stat-pill { padding: 6px 10px; min-width: 0; flex: 1 1 calc(50% - 4px); }
  .stat-n { font-size: 16px; }
  .stat-l { font-size: 10px; }
  .stat-icon .ico { width: 16px; height: 16px; }
  .cal-col-head { font-size: 9px; padding: 4px 0; }
  .cal-cell { min-height: 52px; padding: 2px 3px; min-width: 0; overflow: hidden; }
  .cal-cell-num { width: 18px; height: 18px; font-size: 10px; border-radius: 50%; }
  .cal-cell .cal-chip { font-size: 8px; padding: 1px 3px; border-left-width: 2px; gap: 3px; }
  .cal-cell .cal-chip-label, .cal-cell .cal-chip-icon { display: none; }
  .cal-cell .cal-more { font-size: 8px; }
  .cal-count { font-size: 8px; padding: 0 4px; }
  .cal-month-grid { border-radius: var(--r-sm); }
  .cal-grid { grid-template-columns: 36px repeat(7, 1fr); grid-auto-rows: 30px; }
  .cal-week-head { grid-template-columns: 36px repeat(7, 1fr); }
  .cal-allday { grid-template-columns: 36px repeat(7, 1fr); }
  .cal-gutter-cell { font-size: 8px; }
  .cal-wevent { font-size: 9px; padding: 1px 3px; }
  .cal-wevent-title { font-size: 9px; }
  .cal-allday-label { font-size: 9px; padding: 6px 3px; }
  .cal-allday-cell { min-height: 28px; padding: 2px; }
  .cal-list-row { padding: 6px 8px; }
  .cal-list-time { font-size: 10px; }
  .cal-year { grid-template-columns: 1fr 1fr; gap: 6px; }
  .cal-preview { max-width: 100%; }
  .cal-form { gap: 6px; }
  .cal-detail-body { gap: 6px; }
  .cal-chip-title { font-size: 12px; }
  .cal-sub-actions { flex-direction: column; }
  .cal-sub-actions .cal-btn { width: 100%; justify-content: center; }
}

/* --- Very small (≤ 400px) --- */
@media (max-width: 400px) {
  .cal-page { padding: 4px 4px 0; }
  .cal-title { font-size: 14px; }
  .cal-title .ico { width: 16px; height: 16px; }
  .cal-col-head { font-size: 8px; padding: 3px 0; }
  .cal-cell { min-height: 42px; padding: 2px 2px; }
  .cal-cell-num { width: 16px; height: 16px; font-size: 9px; }
  .cal-cell .cal-chip { font-size: 7px; padding: 0 2px; border-left-width: 2px; gap: 2px; }
  .cal-cell .cal-more { display: none; }
  .cal-count { font-size: 7px; padding: 0 3px; top: 2px; inset-inline-end: 2px; }
  .cal-month-grid { gap: 1px; border-radius: var(--r-sm); }
  .stat-pill { padding: 4px 8px; }
  .stat-n { font-size: 14px; }
  .stat-l { font-size: 9px; }
  .cal-grid { grid-template-columns: 30px repeat(7, 1fr); grid-auto-rows: 26px; }
  .cal-week-head { grid-template-columns: 30px repeat(7, 1fr); }
  .cal-allday { grid-template-columns: 30px repeat(7, 1fr); }
  .cal-gutter-cell { font-size: 7px; }
  .cal-wevent { font-size: 8px; padding: 0 2px; }
  .cal-wevent-title { font-size: 8px; }
  .cal-allday-label { font-size: 8px; }
  .cal-allday-cell { min-height: 22px; }
  .cal-year { grid-template-columns: 1fr; gap: 8px; }
}

/* ========== Command palette ========== */
.cmd-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px);
  align-items: flex-start; justify-content: center; padding-top: 18vh;
}
.cmd-overlay.open { display: flex; }
.cmd-box {
  width: 100%; max-width: 560px; background: var(--glass-strong);
  border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cmd-icon { color: var(--text-dim); flex-shrink: 0; width: 18px; height: 18px; }
.cmd-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font-body); font-size: var(--fs-md); color: var(--text);
}
.cmd-input::placeholder { color: var(--text-dim); }
.cmd-kbd {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-dim);
  background: var(--glass-soft); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 2px 8px; flex-shrink: 0;
}
.cmd-results { max-height: 360px; overflow-y: auto; padding: 6px; }
.cmd-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: var(--r-md); cursor: pointer; transition: background 100ms ease;
}
.cmd-item:hover, .cmd-item.active { background: var(--accent-soft); }
.cmd-item-icon { color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.cmd-item-text { flex: 1; min-width: 0; }
.cmd-item-name { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.cmd-item-context { display: block; font-size: var(--fs-xs); color: var(--text-dim); margin-top: 1px; }
.cmd-item-type { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-dim); flex-shrink: 0; }
.cmd-empty { padding: 24px; text-align: center; color: var(--text-dim); font-size: var(--fs-sm); }

/* ========== Comments in card detail ========== */
.comments-section { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.comments-title { font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 600; margin: 0 0 12px; color: var(--text-muted); }
.comments-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.comment-item { background: var(--glass-soft); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-author { font-size: var(--fs-xs); font-weight: 600; color: var(--text); }
.comment-date { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-dim); }
.comment-edited { font-size: var(--fs-xs); color: var(--text-dim); font-style: italic; }
.comment-body { font-size: var(--fs-sm); color: var(--text); line-height: var(--lh-relaxed); white-space: pre-wrap; word-break: break-word; }
.comment-actions { display: flex; gap: 6px; margin-top: 6px; }
.comment-actions .sm { font-size: var(--fs-xs); padding: 4px 10px; min-height: 32px; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.comment-input { flex: 1; min-width: 0; background: var(--glass-soft); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 12px; font-family: var(--font-body); font-size: var(--fs-sm); color: var(--text); resize: vertical; min-height: 60px; }
.comment-input:focus { border-color: var(--accent); outline: none; }
.comment-form .primary { flex-shrink: 0; }
.comments-loading { padding: 12px; color: var(--text-dim); font-size: var(--fs-sm); }

/* ========== Focus states — accessibility ========== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.seg-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ========== Bulk selection checkboxes ========== */
.card-checkbox {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  width: 20px; height: 20px; accent-color: var(--accent);
  cursor: pointer; opacity: 0; transition: opacity 140ms ease;
  pointer-events: none;
}
.selecting .card-checkbox { opacity: 1; pointer-events: auto; }
.selecting .card { cursor: pointer; }
.card.selected { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-soft) !important; }

.bulk-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--glass-strong); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-strong);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  animation: bulkBarIn 200ms ease;
}
@keyframes bulkBarIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
.bulk-count {
  font-size: var(--fs-sm); font-weight: 700; color: var(--text);
  min-width: 80px;
}
.bulk-count b { color: var(--accent); }
.bulk-actions { display: flex; gap: 8px; flex: 1; }
.bulk-actions button { font-size: var(--fs-sm); padding: 8px 14px; min-height: 40px; }

.btn-select-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ========== COMPREHENSIVE RESPONSIVE — EVERY PAGE, EVERY DETAIL ========== */

/* --- TABLET (≤ 900px) --- */
@media (max-width: 900px) {
  /* Topbar */
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand .logo { font-size: var(--fs-md); }
  .seg { flex-wrap: wrap; }
  .seg-btn { padding: 6px 12px; font-size: var(--fs-xs); }

  /* Picker / Projects */
  .featured-body { flex-direction: column; align-items: flex-start; gap: 10px; }
  .featured-stats { gap: 8px; }
  .fst { padding: 6px 12px; min-width: 60px; }
  .board-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
  .picker { padding: 20px 14px 36px; }
  .picker-head h1 { font-size: var(--fs-2xl); }

  /* Board page */
  .filterbar { flex-wrap: wrap; }

  /* Drawer / Modal */
  .drawer { max-width: 85vw; }

  /* Team */
  .board-grid-assign { grid-template-columns: 1fr; }

  /* Panels */
  .panel { padding: 16px; }
  .brief-pill { font-size: 10px; padding: 4px 10px; }
}

/* --- PHONE (≤ 600px) — the critical breakpoint --- */
@media (max-width: 600px) {
  /* === Topbar — compact 2-row === */
  .topbar { padding: 8px 10px; gap: 6px; }
  /* Row 1: brand left, actions right — single line */
  .brand { margin-inline-end: 0; flex: 1 1 auto; min-width: 0; }
  .brand-link { gap: 8px; }
  .brand .logo-img { height: 30px; width: 30px; }
  .brand .logo { font-size: var(--fs-base); }
  .brand .sub { display: none; }
  .coord-tag { display: none; }
  .topbar-actions { flex: 0 0 auto; gap: 4px; }
  .btn-ghost-logout span:last-child { display: none; }
  .btn-ghost-logout { padding: 6px 8px; font-size: 11px; }
  .theme-toggle { width: 32px; height: 32px; }
  /* Row 2: nav — horizontal scroll, no wrap */
  .seg { flex: 1 1 100%; order: 10; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 3px; padding: 3px; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg-btn { padding: 5px 10px; font-size: 11px; gap: 4px; white-space: nowrap; flex: 0 0 auto; }
  .seg-btn .ic { width: 13px; height: 13px; }

  /* === Picker / Projects — full-width cards === */
  .picker { padding: 14px 10px 30px; }
  .picker-head { margin-bottom: 16px; }
  .picker-head h1 { font-size: var(--fs-xl); margin-bottom: 2px; }
  .picker-head .muted { font-size: var(--fs-xs); }
  .pj-page { padding: 18px 14px 36px; }
  .pj-head { gap: 10px; margin-bottom: 18px; }
  .pj-head h1 { font-size: var(--fs-xl); }
  .pj-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
  .pj-stat-l { font-size: 10px; }
  .featured-top { flex-wrap: wrap; gap: 6px; }
  .featured-badge { font-size: 10px; padding: 2px 8px; }
  .featured-body { gap: 10px; }
  .featured-icon { width: 44px; height: 44px; border-radius: var(--r-md); }
  .featured-icon .ic { width: 22px; height: 22px; }
  .featured-icon img { width: 30px; height: 30px; }
  .featured-info h2 { font-size: var(--fs-base); font-weight: 700; }
  .featured-desc { font-size: var(--fs-xs); }
  .featured-stats { gap: 6px; flex-wrap: wrap; }
  .fst { padding: 6px 10px; min-width: 50px; border-radius: var(--r-sm); }
  .fst-n { font-size: var(--fs-md); }
  .fst-l { font-size: 9px; }
  /* Project page — phone */
  .pj-page { padding: 12px 10px 24px; border-radius: var(--r-lg); }
  .pj-grid { grid-template-columns: 1fr; gap: 12px; }
  .pj-card-icon { width: 32px; height: 32px; }
  .pj-card-icon img { width: 20px; height: 20px; }
  .pj-card-icon .ic { width: 16px; height: 16px; }
  .pj-card-body { padding: 8px 10px 4px; }
  .pj-card-name { font-size: var(--fs-base); }
  .pj-card-stats { padding: 6px 10px 0; }
  .pj-card-progress { margin: 8px 10px 0; }
  .pj-drag-handle { opacity: 1; }
  .board-grid { grid-template-columns: 1fr; gap: 10px; }
  .board-tile { padding: 14px; gap: 8px; }
  .tile-icon { width: 36px; height: 36px; border-radius: var(--r-sm); }
  .tile-icon .ic { width: 18px; height: 18px; }
  .tile-name { font-size: var(--fs-sm); }
  .tile-strip { width: 3px; }
  .tile-counts { font-size: 10px; gap: 4px 8px; }
  .tile-role { font-size: 9px; padding: 1px 5px; }
  .board-tile .coord-tag { font-size: 9px; padding: 1px 6px; top: 8px; inset-inline-end: 8px; }
  .board-tile .tile-actions { bottom: 8px; inset-inline-end: 8px; }
  .board-tile .tile-actions .star-btn,
  .board-tile .tile-actions .edit-btn { width: 26px; height: 24px; font-size: 13px; }
  .tile-add { min-height: 60px; }

  /* === Breadcrumb — compact === */
  .breadcrumb { font-size: 11px; gap: 5px; padding: 6px 10px; }
  .board-crumb { margin: 0; }

  /* === Board page — compact filters === */
  .filterbar { padding: 8px 10px; gap: 6px; align-items: stretch; }
  .filterbar .field { flex: 1 1 0; min-width: 0; }
  .filterbar .field.search { flex: 2 1 0; }
  .filterbar .field label { font-size: 9px; margin-bottom: 2px; }
  .filterbar .field small { display: none; }
  .filterbar select, .filterbar input { width: 100%; font-size: 13px; padding: 6px 8px; min-height: 36px; }
  .filterbar .btn-row { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; overflow-x: auto; }
  .filterbar .btn-row button { white-space: nowrap; flex: 0 0 auto; font-size: 11px; padding: 6px 10px; min-height: 36px; }
  .board { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 16px; }
  .col { min-width: 260px; max-width: 300px; max-height: calc(85vh - 210px); }
  .col-head { padding: 10px 12px 8px; }
  .col-head .name { font-size: 13px; }
  .col-head .count { font-size: 10px; }
  .col-add { padding: 10px; font-size: 12px; min-height: 40px; }
  .card { padding: 10px 11px; }
  .card .title { font-size: var(--fs-sm); margin-bottom: 4px; }
  .card .meta { gap: 4px; margin-bottom: 4px; }
  .card-data-row { font-size: 10px; gap: 6px; margin-bottom: 4px; }
  .card .tags { gap: 3px; margin-top: 4px; }
  .card .tag { font-size: 9px; padding: 1px 6px; }
  .card .dep { font-size: 10px; margin-top: 4px; }
  .card .blocked-note { font-size: 10px; margin-top: 4px; padding: 4px 6px; }
  .card .check-progress { font-size: 10px; margin-top: 4px; }
  .card-assignees { gap: 3px; margin-top: 4px; }
  .card-avatar { width: 20px; height: 20px; font-size: 8px; }
  .pill { font-size: 9px; padding: 1px 7px; }
  .prio-dot { width: 7px; height: 7px; }
  .card-menu-btn { width: 32px; height: 32px; font-size: 16px; }
  .card-menu-dropdown { font-size: 13px; }
  .card-checkbox { width: 22px; height: 22px; }
  .kpis { flex-wrap: nowrap; overflow-x: auto; padding: 0 10px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; gap: 8px; }
  .kpi { min-width: 70px; flex: 0 0 auto; padding: 8px 10px; scroll-snap-align: start; }
  .kpi .n { font-size: var(--fs-lg); }
  .kpi .l { font-size: 10px; }

  /* === Drawer / Modal — reduce padding, full-width === */
  .drawer { max-width: 100vw; padding: 16px 14px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .drawer-head { gap: 8px; margin-bottom: 12px; }
  .drawer-head h2 { font-size: var(--fs-md); }
  .drawer-close { width: 40px; height: 40px; font-size: 22px; }
  .drawer-actions { flex-wrap: wrap; gap: 8px; }
  .drawer-actions button { flex: 1; min-width: 100px; min-height: 44px; }
  .modal { max-width: 95vw; padding: 18px 16px; }
  .modal h2 { font-size: var(--fs-md); }
  .form-grid { grid-template-columns: 1fr; }
  .form-row { margin-bottom: 12px; }
  .form-row label { font-size: var(--fs-xs); margin-bottom: 4px; }
  .form-row input, .form-row select, .form-row textarea { font-size: 14px; padding: 10px 12px; }
  .checklist .item { padding: 6px 8px; }
  .checklist .item .del { width: 32px; height: 32px; font-size: 16px; }

  /* === Comments === */
  .comments-section { margin-top: 12px; padding-top: 10px; }
  .comment-item { padding: 8px 10px; }
  .comment-body { font-size: var(--fs-xs); }
  .comment-form { flex-direction: column; }
  .comment-input { min-height: 50px; font-size: 14px; }
  .comment-form .primary { width: 100%; min-height: 44px; }

  /* === Calendar page === */
  .cal-page { padding: 8px 6px 0; }
  .cal-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .cal-nav { font-size: 18px; padding: 4px 8px; min-width: 36px; min-height: 36px; }
  .cal-sidebar { width: 100%; flex: none; border-radius: 0; border: none; border-bottom: 1px solid var(--border); max-height: 50vh; overflow-y: auto; }
  .cal-chip { font-size: 10px; padding: 2px 6px; min-height: 28px; }
  .cal-btn { font-size: 12px; padding: 6px 10px; min-height: 36px; }
  .cal-mini-cell { min-width: 28px; min-height: 28px; font-size: 10px; padding: 4px 0; }
  .cal-mini-nav { min-width: 32px; min-height: 32px; font-size: 14px; padding: 4px 8px; }
  .cal-month-grid { gap: 1px; }
  .cal-cell { min-height: 48px; padding: 2px 3px; }
  .cal-cell-num { width: 16px; height: 16px; font-size: 9px; }
  .cal-count { font-size: 8px; padding: 0 3px; }
  .cal-wevent { font-size: 9px; padding: 1px 3px; }
  .cal-resize { height: 6px; }
  .cal-grid { grid-template-columns: 32px repeat(7, 1fr); grid-auto-rows: 28px; }
  .cal-week-head { grid-template-columns: 32px repeat(7, 1fr); font-size: 10px; }
  .cal-allday { grid-template-columns: 32px repeat(7, 1fr); }
  .cal-gutter-cell { font-size: 8px; }
  .cal-year { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cal-year-month { padding: 8px; font-size: 11px; }
  .cal-list-day { padding: 8px 10px; }
  .cal-list-row { padding: 6px 8px; font-size: 11px; }
  .cal-sub-url { font-size: 11px; word-break: break-all; }

  /* === Team page === */
  .team-page { padding: 14px 10px 36px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head h1 { font-size: var(--fs-xl); }
  .team-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-n { font-size: var(--fs-xl); }
  .stat-l { font-size: 10px; }
  .user-grid { grid-template-columns: 1fr; gap: 10px; }
  .user-card { padding: 12px; }
  .uc-top { flex-wrap: wrap; gap: 8px; }
  .uc-name { font-size: var(--fs-sm); }
  .uc-email { font-size: var(--fs-xs); }
  .uc-bottom { gap: 6px; }
  .uc-actions { flex-wrap: wrap; gap: 6px; }
  .uc-actions button { font-size: 12px; padding: 6px 10px; min-height: 36px; }
  .panel { padding: 12px; border-radius: var(--r-lg); }
  .panel h2 { font-size: var(--fs-md); }
  .board-grid-assign { grid-template-columns: 1fr; gap: 10px; }
  .board-card { padding: 12px; }
  .member-row { padding: 6px 8px; gap: 8px; }
  .member-row select { font-size: 12px; padding: 4px 6px; }
  .member-row .rm { min-width: 32px; min-height: 32px; }
  .assign-add { flex-wrap: wrap; }
  .assign-add select { flex: 1; min-width: 0; font-size: 12px; }
  .assign-add .add-btn { min-width: 40px; min-height: 40px; }
  .team-table { font-size: 12px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .team-table th, .team-table td { padding: 8px 10px; white-space: nowrap; }

  /* === Today page === */
  .today-page { padding: 14px 10px 30px; }
  .today-page h1 { font-size: var(--fs-xl); }
  .today-section { margin-bottom: 18px; }
  .today-section h2 { font-size: var(--fs-md); }
  .tc-list { gap: 6px; }
  .today-card { padding: 10px 12px; gap: 6px; }
  .tc-title { font-size: var(--fs-sm); }
  .tc-board { font-size: 10px; }
  .tc-meta { gap: 4px; }
  .tc-prio { font-size: 9px; padding: 1px 6px; }
  .tc-date { font-size: 10px; }

  /* === Activity panel === */
  .af-row { flex-direction: column; gap: 6px; }
  .af-desc { font-size: 12px; }
  .af-detail { font-size: 11px; }
  .af-time { font-size: 10px; }

  /* === Command palette === */
  .cmd-overlay { padding-top: 8vh; }
  .cmd-box { max-width: 100%; margin: 0 8px; border-radius: var(--r-lg); }
  .cmd-input-wrap { padding: 12px 14px; }
  .cmd-input { font-size: 16px; }
  .cmd-results { max-height: 55vh; }
  .cmd-item { padding: 10px 12px; gap: 10px; }
  .cmd-item-icon { width: 16px; height: 16px; }

  /* === Bulk bar === */
  .bulk-bar { flex-wrap: nowrap; padding: 10px 10px; overflow-x: auto; gap: 6px; }
  .bulk-count { font-size: 12px; min-width: 50px; white-space: nowrap; }
  .bulk-actions { flex-wrap: nowrap; gap: 4px; }
  .bulk-actions button { font-size: 11px; padding: 6px 10px; white-space: nowrap; min-height: 36px; }

  /* === Login === */
  body.auth-body { padding: 16px 12px; }
  .auth-wrap { max-width: 100%; padding: 20px 16px 24px; }
  .auth-title { font-size: 20px; }
  .auth-form input { font-size: 16px; padding: 12px; }

  /* === Brief pill === */
  .brief-pill { font-size: 10px; padding: 4px 10px; }
  .brief-pill .ic { width: 12px; height: 12px; }

  /* === Toast === */
  .toast { font-size: 13px; padding: 10px 14px; max-width: 90vw; }

  /* === Reference pages === */
  .ref-wrap { padding: 14px 10px 0; }
  .ref-panel { padding: 14px; }

  /* === Expiry box === */
  .expiry-box { padding: 18px 16px; }
}

/* --- VERY SMALL (≤ 400px) --- */
@media (max-width: 400px) {
  .topbar { padding: 6px 8px; }
  .brand .logo { font-size: var(--fs-sm); }
  .seg-btn { padding: 4px 8px; font-size: 10px; }
  .seg-btn .ic { display: none; }
  .filterbar .btn-row button { font-size: 10px; padding: 5px 8px; }
  .featured-badge { font-size: 9px; }
  .featured-icon { width: 38px; height: 38px; }
  .featured-icon .ic { width: 18px; height: 18px; }
  .pj-hero { padding: 10px 10px 8px; }
  .pj-hero-icon { width: 38px; height: 38px; }
  .pj-hero-icon .ic { width: 18px; height: 18px; }
  .pj-hero-icon img { width: 26px; height: 26px; }
  .pj-hero-info h1 { font-size: var(--fs-lg); }
  .pj-stat { padding: 4px 8px; }
  .pj-stat-icon { width: 22px; height: 22px; }
  .pj-stat-icon .ic { width: 11px; height: 11px; }
  .pj-stat-n { font-size: var(--fs-base); }
  .pj-stat-l { font-size: 8px; }
  .coord-tag { font-size: 9px; padding: 1px 5px; }
  .board-tile { padding: 12px; }
  .tile-name { font-size: 13px; }
  .col { min-width: 240px; max-height: calc(85vh - 210px); }
  .drawer { padding: 12px 10px; }
  .modal { padding: 14px 12px; }
  .team-stats { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card { padding: 8px; }
  .stat-n { font-size: var(--fs-lg); }
  .auth-wrap { padding: 16px 14px 20px; }
}

/* ========== Responsive — panels ========== */
@media (max-width: 600px) {
  .notif-panel { width: 100vw; }
  .chat-panel { width: 100vw; }
  .mail-panel { width: 100vw; }
  .mail-body { flex-direction: column; }
  .mail-thread-list { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .mail-thread-pane { min-height: 0; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { padding: 18px; }
  .kpi-filters { flex-direction: column; align-items: stretch; }
  .kpi-filters select { width: 100%; }
}
@media (max-width: 400px) {
  .notif-panel { width: 100vw; }
  .chat-panel { width: 100vw; }
  .mail-panel { width: 100vw; }
}

/* ========== Reduced motion — site-wide ========== */
@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;
  }
}

/* Touch devices — hide hover-only elements */
@media (hover: none) {
  .cal-preview { display: none !important; }
  .card-menu-btn { opacity: 1; }
}

/* ========== Notification panel — slide-in status board ========== */
/* ========== Notifications panel — redesign v2 ========== */
.notif-wrapper { position: relative; }
.notif-badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
  background: var(--signal-overdue); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 99px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1; pointer-events: none;
  box-shadow: 0 0 0 2px var(--bg-1);
}
.notif-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 210;
  opacity: 0; pointer-events: none; transition: opacity 280ms ease;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.notif-overlay.open { opacity: 1; pointer-events: auto; }
.notif-panel {
  position: fixed; top: 0; right: 0; width: var(--panel-w); height: 100vh;
  background: var(--bg-1); border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0,0,0,0.25); z-index: 220;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.notif-panel.open { transform: translateX(0); pointer-events: auto; }
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 18px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-soft) 0%, transparent 60%);
  border-bottom: 1px solid var(--border);
}
.notif-panel-head h2 {
  margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700;
  letter-spacing: -0.3px;
}
.notif-mark-all {
  background: none; border: 1px solid var(--border); color: var(--accent);
  font-size: 11px; cursor: pointer; padding: 5px 12px; font-weight: 600;
  border-radius: var(--r-md); letter-spacing: 0.2px;
  transition: all 150ms ease;
}
.notif-mark-all:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.notif-panel-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.notif-day-group { padding: 0 16px; }
.notif-day-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim);
  padding: 18px 8px 8px; position: sticky; top: 0; background: var(--bg-1); z-index: 1;
  border-bottom: 1px solid var(--border);
}
.notif-item {
  display: flex; gap: 12px; padding: 14px 12px; margin: 4px 0; border-radius: var(--r-lg);
  cursor: pointer; position: relative; align-items: flex-start;
  border: 1px solid transparent; transition: all 160ms ease;
  background: var(--glass-soft);
}
.notif-item:hover { border-color: var(--border-strong); background: var(--bg-2); transform: translateX(-2px); }
.notif-item.read { opacity: 0.5; }
.notif-item.read:hover { opacity: 0.8; }
.notif-item-bar {
  width: 3px; border-radius: 2px; flex-shrink: 0; align-self: stretch; min-height: 36px;
}
.notif-item-bar.mention { background: var(--signal-mention); }
.notif-item-bar.assign { background: var(--signal-assign); }
.notif-item-bar.move { background: var(--signal-move); }
.notif-item-bar.mail { background: var(--signal-mail); }
.notif-item-bar.comment { background: var(--accent2); }
.notif-item-bar.due_soon, .notif-item-bar.overdue { background: var(--signal-overdue); }
.notif-item-icon {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.notif-item-icon.mention { color: var(--signal-mention); background: var(--signal-mention-soft); }
.notif-item-icon.assign { color: var(--signal-assign); background: var(--signal-assign-soft); }
.notif-item-icon.move { color: var(--signal-move); background: var(--signal-move-soft); }
.notif-item-icon.mail { color: var(--signal-mail); background: var(--signal-mail-soft); }
.notif-item-icon.comment { color: var(--accent2); background: var(--accent2-soft); }
.notif-item-icon.due_soon, .notif-item-icon.overdue { color: var(--signal-overdue); background: var(--signal-overdue-soft); }
.notif-item-icon .ico { width: 16px; height: 16px; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-msg {
  font-size: 13px; line-height: 1.5; color: var(--text); font-weight: 500;
}
.notif-item-time {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}
.notif-item-time::before {
  content: ''; width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-dim); opacity: 0.5;
}
.notif-empty {
  padding: 60px 24px; text-align: center; color: var(--text-muted); font-size: 13px;
  line-height: 1.6;
}
.notif-empty-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--glass-soft); border: 1px dashed var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; color: var(--text-dim);
}
.notif-empty-icon .ico { width: 22px; height: 22px; }

/* ========== Chat panel — redesigned v2 ========== */
.chat-wrapper { position: relative; }
.chat-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 210;
  opacity: 0; pointer-events: none; transition: opacity 280ms ease;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.chat-overlay.open { opacity: 1; pointer-events: auto; }
.chat-panel {
  position: fixed; top: 0; right: 0; width: 460px; height: 100vh;
  background: var(--bg-1); border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0,0,0,0.25); z-index: 220;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.chat-panel.open { transform: translateX(0); pointer-events: auto; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 18px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--signal-assign-soft) 0%, transparent 60%);
  border-bottom: 1px solid var(--border);
}
.chat-head h2 {
  margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700;
  letter-spacing: -0.3px; display: flex; align-items: center; gap: 8px;
}
.chat-head h2 .ico { width: 20px; height: 20px; color: var(--accent); }
.chat-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
  background: var(--glass-soft);
}
.chat-tab {
  flex: 1; padding: 11px; text-align: center; font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; background: none; color: var(--text-muted);
  border-bottom: 2px solid transparent; transition: all 180ms ease;
  letter-spacing: 0.3px; position: relative;
}
.chat-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--bg-1); }
.chat-tab:hover:not(.active) { color: var(--text); background: var(--glass-soft); }

/* Room sidebar — board channels */
.chat-rooms {
  flex-shrink: 0; border-bottom: 1px solid var(--border); max-height: 200px; overflow-y: auto;
  padding: 6px 8px;
}
.chat-room-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim);
  padding: 10px 8px 6px;
}
.chat-room {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-md);
  cursor: pointer; font-size: 12px; color: var(--text-muted); transition: all 160ms ease;
  position: relative; border: 1px solid transparent;
}
.chat-room:hover { background: var(--glass-soft); color: var(--text); border-color: var(--border); }
.chat-room.active { background: var(--accent-soft); color: var(--text); font-weight: 600; border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.chat-room-stripe {
  width: 3px; height: 22px; border-radius: 2px; flex-shrink: 0;
  background: var(--accent); transition: background 150ms ease;
}
.chat-room-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-room-badge {
  min-width: 18px; height: 18px; border-radius: 99px; font-size: 10px; font-weight: 700;
  background: var(--signal-overdue); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 5px; flex-shrink: 0;
}
.chat-room-badge:empty { display: none; }

/* Presence dot */
.chat-presence {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--signal-success); border: 1.5px solid var(--bg-1);
  box-shadow: 0 0 4px var(--signal-success);
}

/* Messages */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 16px 8px; display: flex; flex-direction: column; gap: 2px;
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
}
.chat-msg { max-width: 82%; padding: 0 0 2px; }
.chat-msg.mine { align-self: flex-end; }
.chat-msg-group-start { margin-top: 16px; }
.chat-msg-name {
  font-size: 11px; font-weight: 700; margin-bottom: 4px; padding-left: 4px;
  color: var(--accent); display: flex; align-items: center; gap: 6px;
  font-family: var(--font-display); letter-spacing: 0.2px;
}
.chat-msg-bubble {
  padding: 10px 16px; border-radius: var(--r-lg); font-size: 13px; line-height: 1.55;
  position: relative; border: 1px solid transparent;
}
.chat-msg.mine .chat-msg-bubble {
  background: var(--accent); color: #fff;
  border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
}
.chat-msg:not(.mine) .chat-msg-bubble {
  background: var(--glass-strong); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px;
}
.chat-msg-time {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-dim);
  margin-top: 4px; padding-left: 4px; opacity: 0; transition: opacity 150ms ease;
}
.chat-msg:hover .chat-msg-time { opacity: 1; }
.chat-msg.mine .chat-msg-time { text-align: right; padding-right: 4px; color: var(--text-dim); }
.chat-input-row {
  display: flex; gap: 10px; padding: 16px; border-top: 1px solid var(--border); flex-shrink: 0;
  background: var(--glass-soft);
}
.chat-input {
  flex: 1; padding: 11px 16px; border: 1px solid var(--border); border-radius: var(--r-lg);
  font-size: 13px; background: var(--bg-1); color: var(--text); outline: none;
  transition: all 180ms ease;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input::placeholder { color: var(--text-dim); }
.chat-send {
  padding: 11px 20px; background: var(--accent); color: #fff; border: none;
  border-radius: var(--r-lg); font-size: 13px; cursor: pointer; font-weight: 600;
  transition: all 180ms ease; letter-spacing: 0.2px;
}
.chat-send:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.chat-send:active { transform: translateY(0); }

/* ========== Mail panel — redesigned v2 ========== */
.mail-wrapper { position: relative; }
.mail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 210;
  opacity: 0; pointer-events: none; transition: opacity 280ms ease;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.mail-overlay.open { opacity: 1; pointer-events: auto; }
.mail-panel {
  position: fixed; top: 0; right: 0; width: 520px; height: 100vh;
  background: var(--bg-1); border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0,0,0,0.25); z-index: 220;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.mail-panel.open { transform: translateX(0); pointer-events: auto; }
.mail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 18px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--signal-mail-soft) 0%, transparent 60%);
  border-bottom: 1px solid var(--border);
}
.mail-head h2 {
  margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700;
  letter-spacing: -0.3px; display: flex; align-items: center; gap: 8px;
}
.mail-head h2 .ico { width: 20px; height: 20px; color: var(--signal-mail); }
.mail-compose-btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--r-md);
  padding: 7px 16px; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 180ms ease; letter-spacing: 0.2px;
}
.mail-compose-btn:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.mail-compose-btn:active { transform: translateY(0); }
.mail-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
  background: var(--glass-soft);
}
.mail-tab {
  flex: 1; padding: 11px; text-align: center; font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; background: none; color: var(--text-muted);
  border-bottom: 2px solid transparent; transition: all 180ms ease;
  letter-spacing: 0.3px; position: relative;
}
.mail-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--bg-1); }
.mail-tab:hover:not(.active) { color: var(--text); background: var(--glass-soft); }

/* Two-pane layout */
.mail-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.mail-thread-list {
  width: 42%; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto;
  display: flex; flex-direction: column;
}
.mail-thread-item {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: all 160ms ease;
  position: relative; border-left: 3px solid transparent;
}
.mail-thread-item:hover { background: var(--glass-soft); border-left-color: var(--border); }
.mail-thread-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.mail-thread-item.unread .mail-thread-subject { font-weight: 700; }
.mail-thread-item.unread { background: var(--glass-soft); }
.mail-thread-unread-dot {
  position: absolute; top: 18px; left: 8px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); flex-shrink: 0;
  box-shadow: 0 0 6px var(--accent);
}
.mail-thread-subject {
  font-size: 13px; color: var(--text); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 10px;
}
.mail-thread-sender {
  font-size: 11px; color: var(--text-muted); padding-left: 10px; font-weight: 500;
}
.mail-thread-preview {
  font-size: 12px; color: var(--text-dim); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 10px;
}

/* Thread pane (right) */
.mail-thread-pane {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.mail-thread-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  background: linear-gradient(180deg, var(--glass-soft) 0%, transparent 100%);
}
.mail-thread-subject-display {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  color: var(--text); margin: 0 0 4px; letter-spacing: -0.2px;
}
.mail-thread-meta {
  font-size: 11px; color: var(--text-muted); font-family: var(--font-mono);
}
.mail-thread-messages {
  flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.mail-msg {
  background: var(--glass-soft); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px;
}
.mail-msg-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.mail-msg-sender { font-size: 13px; font-weight: 700; color: var(--text); font-family: var(--font-display); }
.mail-msg-date { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }
.mail-msg-body { font-size: 13px; line-height: 1.65; color: var(--text); white-space: pre-wrap; }
.mail-reply-box {
  padding: 16px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 12px; background: var(--glass-soft);
}
.mail-reply-input {
  padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--r-lg);
  font-size: 13px; background: var(--bg-1); color: var(--text); outline: none;
  font-family: inherit; min-height: 60px; resize: vertical;
  transition: all 180ms ease;
}
.mail-reply-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mail-reply-input::placeholder { color: var(--text-dim); }
.mail-reply-send {
  align-self: flex-end; padding: 10px 22px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-lg); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 180ms ease; letter-spacing: 0.2px;
}
.mail-reply-send:hover { background: var(--accent-deep); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.mail-reply-send:active { transform: translateY(0); }

/* Compose mode (replaces thread pane) */
.mail-compose {
  flex: 1; display: flex; flex-direction: column; padding: 20px 24px; gap: 14px;
}
.mail-compose-row { display: flex; gap: 10px; align-items: center; }
.mail-compose-row label { margin: 0; flex-shrink: 0; width: 80px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.mail-compose-row select, .mail-compose-row input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13px; background: var(--bg-1); color: var(--text); outline: none;
  transition: all 180ms ease;
}
.mail-compose-row select:focus, .mail-compose-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mail-compose-body {
  flex: 1; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-lg);
  font-size: 13px; line-height: 1.65; background: var(--bg-1); color: var(--text);
  outline: none; font-family: inherit; resize: none;
  transition: all 180ms ease;
}
.mail-compose-body:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mail-compose-body::placeholder { color: var(--text-dim); }
.mail-compose-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ========== KPI page — instrument panel ========== */
.kpi-filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px;
}
.kpi-card {
  background: var(--card-flat); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 24px; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.kpi-card:hover { border-color: var(--accent); box-shadow: var(--shadow-soft); transform: translateY(-2px); }
.kpi-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.kpi-avatar {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.kpi-name { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; }

/* Ring gauge */
.kpi-gauge { display: flex; justify-content: center; margin-bottom: 20px; position: relative; }
.kpi-gauge-svg { width: var(--gauge-ring); height: var(--gauge-ring); transform: rotate(-90deg); }
.kpi-gauge-track { fill: none; stroke: var(--bg-3); stroke-width: 6; }
.kpi-gauge-fill {
  fill: none; stroke: var(--signal-success); stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.kpi-gauge-fill.overdue { stroke: var(--signal-overdue); }
.kpi-gauge-fill.warning { stroke: var(--accent2); }
.kpi-gauge-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center;
}
.kpi-gauge-number {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  color: var(--text); line-height: 1;
}
.kpi-gauge-caption {
  font-size: 10px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.5px; margin-top: 2px;
}

/* Proportion bar */
.kpi-bar {
  height: 4px; border-radius: 2px; background: var(--bg-3);
  display: flex; overflow: hidden; margin-bottom: 16px;
}
.kpi-bar-seg { height: 100%; transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1); }
.kpi-bar-done { background: var(--signal-success); }
.kpi-bar-progress { background: var(--accent2); }
.kpi-bar-late { background: var(--signal-overdue); }

/* Stats row */
.kpi-stats {
  display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 16px;
  flex-wrap: wrap;
}
.kpi-stat { display: flex; align-items: center; gap: 5px; }
.kpi-stat-val { font-family: var(--font-display); font-weight: 700; color: var(--text); font-size: 14px; }
.kpi-stat-lbl { font-size: 11px; }

/* Sparkline */
.kpi-spark { margin-top: 4px; }
.kpi-spark-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin-bottom: 6px;
}
.kpi-spark-svg { width: 100%; height: 48px; overflow: visible; }
.kpi-spark-path {
  fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.kpi-spark-area {
  fill: var(--accent-soft); opacity: 0.5;
}
.kpi-spark-dot {
  fill: var(--accent); r: 3; opacity: 0;
  transition: opacity 150ms ease;
}
.kpi-spark-group:hover .kpi-spark-dot { opacity: 1; }
.kpi-spark-tooltip {
  position: absolute; background: var(--card-flat); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 4px 8px; font-size: 11px; color: var(--text);
  pointer-events: none; white-space: nowrap; z-index: 10;
  box-shadow: var(--shadow-sm); transform: translate(-50%, -100%); margin-top: -8px;
}

/* Empty state */
.kpi-empty {
  text-align: center; padding: 60px 24px; color: var(--text-muted);
  font-size: 14px; line-height: 1.6; grid-column: 1/-1;
}
.kpi-empty-icon { color: var(--text-dim); margin-bottom: 16px; }

/* Detail panel */
.kpi-detail {
  background: var(--card-flat); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 24px;
}
.kpi-detail h2 { margin: 0 0 16px; font-family: var(--font-display); font-size: var(--fs-xl); }
.kpi-detail h3 { font-size: 13px; margin: 0 0 8px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-detail-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.kpi-detail-row span:first-child { flex: 1; color: var(--text); }
.kpi-detail-row b { font-family: var(--font-display); color: var(--text); }

/* Detail trend bars */
.kpi-detail-trend { display: flex; align-items: flex-end; gap: 6px; height: 64px; margin-top: 8px; }
.kpi-detail-bar {
  flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; position: relative;
  transition: height 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.kpi-detail-bar-label {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-family: var(--font-mono); color: var(--text-dim);
}


