@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════ */
:root {
  --bg:            #F4F5F7;
  --surface:       #FFFFFF;
  --surface-hover: #FAFBFC;
  --border:        #E2E4E9;
  --border-light:  #EDEEF1;
  --border-focus:  #2F2FE4;
  --text:          #1B1D21;
  --text-mid:      #4B4F58;
  --text-muted:    #8A8F9A;
  --text-faint:    #B0B5BF;
  --accent:        #2F2FE4;
  --accent-soft:   #EAEAFD;
  --accent-text:   #1E1EB8;
  --green:         #10B981;
  --green-soft:    #D1FAE5;
  --green-text:    #047857;
  --amber:         #F59E0B;
  --amber-soft:    #FEF3C7;
  --amber-text:    #92400E;
  --red:           #EF4444;
  --red-soft:      #FEE2E2;
  --red-text:      #B91C1C;
  --blue:          #3B82F6;
  --blue-soft:     #DBEAFE;
  --blue-text:     #1D4ED8;
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     14px;
  --shadow:        0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-lg:     0 8px 30px rgba(0,0,0,0.12);
  --font:          'Plus Jakarta Sans', sans-serif;
  --mono:          'IBM Plex Mono', monospace;
  --sidebar-width: 200px;
}

@media (prefers-color-scheme: dark) { :root {
  --bg:            #0F1117;
  --surface:       #1A1C24;
  --surface-hover: #22242E;
  --border:        #2A2D38;
  --border-light:  #23262F;
  --border-focus:  #5C5CF7;
  --text:          #E8E9ED;
  --text-mid:      #A0A3AD;
  --text-muted:    #6B6F7A;
  --text-faint:    #484C57;
  --accent:        #5C5CF7;
  --accent-soft:   #151540;
  --accent-text:   #9B9BFF;
  --green:         #34D399;
  --green-soft:    #0D2818;
  --green-text:    #6EE7B7;
  --amber:         #FBBF24;
  --amber-soft:    #2A1F06;
  --amber-text:    #FCD34D;
  --red:           #F87171;
  --red-soft:      #2D1215;
  --red-text:      #FCA5A5;
  --blue:          #60A5FA;
  --blue-soft:     #0F1D33;
  --blue-text:     #93C5FD;
  --shadow:        0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg:     0 8px 30px rgba(0,0,0,0.4);
}}

html.dark {
  --bg:            #0F1117;
  --surface:       #1A1C24;
  --surface-hover: #22242E;
  --border:        #2A2D38;
  --border-light:  #23262F;
  --border-focus:  #5C5CF7;
  --text:          #E8E9ED;
  --text-mid:      #A0A3AD;
  --text-muted:    #6B6F7A;
  --text-faint:    #484C57;
  --accent:        #5C5CF7;
  --accent-soft:   #151540;
  --accent-text:   #9B9BFF;
  --green:         #34D399;
  --green-soft:    #0D2818;
  --green-text:    #6EE7B7;
  --amber:         #FBBF24;
  --amber-soft:    #2A1F06;
  --amber-text:    #FCD34D;
  --red:           #F87171;
  --red-soft:      #2D1215;
  --red-text:      #FCA5A5;
  --blue:          #60A5FA;
  --blue-soft:     #0F1D33;
  --blue-text:     #93C5FD;
  --shadow:        0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg:     0 8px 30px rgba(0,0,0,0.4);
}

html.light { /* force light even if OS is dark */
  --bg:            #F4F5F7;
  --surface:       #FFFFFF;
  --surface-hover: #FAFBFC;
  --border:        #E2E4E9;
  --border-light:  #EDEEF1;
  --border-focus:  #2F2FE4;
  --text:          #1B1D21;
  --text-mid:      #4B4F58;
  --text-muted:    #8A8F9A;
  --text-faint:    #B0B5BF;
  --accent:        #2F2FE4;
  --accent-soft:   #EAEAFD;
  --accent-text:   #1E1EB8;
  --green:         #10B981;
  --green-soft:    #D1FAE5;
  --green-text:    #047857;
  --amber:         #F59E0B;
  --amber-soft:    #FEF3C7;
  --amber-text:    #92400E;
  --red:           #EF4444;
  --red-soft:      #FEE2E2;
  --red-text:      #B91C1C;
  --blue:          #3B82F6;
  --blue-soft:     #DBEAFE;
  --blue-text:     #1D4ED8;
  --shadow:        0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-lg:     0 8px 30px rgba(0,0,0,0.12);
}

html.ember { /* warm light content + black sidebar + orange accent — inspired by TeamUnity */
  --bg:            #F5F5F4;
  --surface:       #FFFFFF;
  --surface-hover: #FAFAF9;
  --border:        #E7E5E4;
  --border-light:  #F0EFEE;
  --border-focus:  #F97316;
  --text:          #1C1917;
  --text-mid:      #44403C;
  --text-muted:    #78716C;
  --text-faint:    #A8A29E;
  --accent:        #F97316;
  --accent-soft:   #FFEDD5;
  --accent-text:   #C2410C;
  --green:         #10B981;
  --green-soft:    #D1FAE5;
  --green-text:    #047857;
  --amber:         #D97706;
  --amber-soft:    #FEF3C7;
  --amber-text:    #92400E;
  --red:           #EF4444;
  --red-soft:      #FEE2E2;
  --red-text:      #B91C1C;
  --blue:          #3B82F6;
  --blue-soft:     #DBEAFE;
  --blue-text:     #1D4ED8;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --shadow:        0 1px 3px rgba(28,25,23,0.06), 0 1px 2px rgba(28,25,23,0.04);
  --shadow-lg:     0 10px 40px rgba(28,25,23,0.12);
  color-scheme:    light;
}
/* Ember: the sidebar gets its own dark scope — CSS variables re-scoped here
   cascade to every descendant, so all .sb-* styles read the dark values. */
html.ember .sidebar {
  --surface:       #0F1014;
  --surface-hover: #1C1D23;
  --border:        #2A2B34;
  --border-light:  #23242C;
  --text:          #F1F1F3;
  --text-mid:      #B3B5BD;
  --text-muted:    #8A8D97;
  --text-faint:    #56595F;
  --accent-soft:   #3A1D08;
  --accent-text:   #FDBA74;
  border-right-color: #1A1B21;
}

html.midnight { /* dark main content + white sidebar — inverse of Ember */
  --bg:            #0E0F13;
  --surface:       #17181E;
  --surface-hover: #1F2027;
  --border:        #2A2B34;
  --border-light:  #23242C;
  --border-focus:  #5C5CF7;
  --text:          #E8E9ED;
  --text-mid:      #A0A3AD;
  --text-muted:    #6B6F7A;
  --text-faint:    #484C57;
  --accent:        #5C5CF7;
  --accent-soft:   #151540;
  --accent-text:   #9B9BFF;
  --green:         #34D399;
  --green-soft:    #0D2818;
  --green-text:    #6EE7B7;
  --amber:         #FBBF24;
  --amber-soft:    #2A1F06;
  --amber-text:    #FCD34D;
  --red:           #F87171;
  --red-soft:      #2D1215;
  --red-text:      #FCA5A5;
  --blue:          #60A5FA;
  --blue-soft:     #0F1D33;
  --blue-text:     #93C5FD;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --shadow:        0 1px 3px rgba(0,0,0,0.35);
  --shadow-lg:     0 10px 40px rgba(0,0,0,0.55);
  color-scheme:    dark;
}
/* Midnight: sidebar is scoped back to light tokens */
html.midnight .sidebar {
  --surface:       #FFFFFF;
  --surface-hover: #F4F4F5;
  --border:        #E4E4E7;
  --border-light:  #EDEDEF;
  --text:          #1B1D21;
  --text-mid:      #4B4F58;
  --text-muted:    #8A8F9A;
  --text-faint:    #B0B5BF;
  --accent-soft:   #EAEAFD;
  --accent-text:   #1E1EB8;
  border-right-color: #E4E4E7;
}
/* Midnight picks up the dark-mode calendar/date-picker filter everywhere
   except inside the sidebar (which is light). */
html.midnight input[type="date"]::-webkit-calendar-picker-indicator,
html.midnight input[type="time"]::-webkit-calendar-picker-indicator,
html.midnight input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(.75);
}
html.midnight .sidebar input[type="date"]::-webkit-calendar-picker-indicator,
html.midnight .sidebar input[type="time"]::-webkit-calendar-picker-indicator,
html.midnight .sidebar input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: none;
}

/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ═══════════════════════════════════════════
   AUTH PAGE
═══════════════════════════════════════════ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.auth-brand {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent-text);
  margin-bottom: 4px;
}
.auth-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.auth-error {
  font-size: 12px;
  color: var(--red-text);
  background: var(--red-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .2s ease;
}
.sidebar.collapsed { width: 54px; }

.sb-brand {
  padding: 16px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 60px;
}
.sb-brand-text { flex: 1; min-width: 0; }
.sb-brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-text);
}
.sb-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 2px;
}

/* Sidebar toggle button */
.sb-toggle {
  width: 22px; height: 22px;
  background: transparent; border: none;
  color: var(--text-faint); cursor: pointer;
  border-radius: 4px; padding: 0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color .12s, background .12s;
}
.sb-toggle:hover { color: var(--text-mid); background: var(--surface-hover); }

/* ── Collapsed sidebar state ── */
.sidebar.collapsed .sb-brand { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .sb-brand-text { display: none; }
.sidebar.collapsed .sb-nav-item { padding: 8px; justify-content: center; gap: 0; }
.sidebar.collapsed .sb-nav-label { display: none; }
.sidebar.collapsed .sb-nav-grip  { display: none; }
.sidebar.collapsed .sb-nav-icon  { opacity: 1; }
.sidebar.collapsed .sb-footer-btn { justify-content: center; padding: 7px; }
.sidebar.collapsed .sb-footer-label { display: none; }
.sb-nav {
  flex: 0 0 auto;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: calc(100vh - 220px);
}
.sb-spacer { flex: 1; }
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}
.sb-nav-item:hover { background: var(--surface-hover); color: var(--text); }
.sb-nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.sb-nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sb-nav-item.active .sb-nav-icon { opacity: 1; }

/* Nav drag reorder */
.sb-nav-item { position: relative; }
.sb-nav-grip { color: var(--text-faint); opacity: 0; transition: opacity .12s; flex-shrink: 0; cursor: grab; display: flex; align-items: center; margin-right: -2px; }
.sb-nav-item:hover .sb-nav-grip { opacity: 1; }
.sb-nav-grip:active { cursor: grabbing; }
.sb-nav-item.nav-dragging { opacity: .3; }
.sb-nav-item.nav-drag-over-top::before { content: ''; position: absolute; top: -1px; left: 6px; right: 6px; height: 2px; background: var(--accent); border-radius: 1px; pointer-events: none; }
.sb-nav-item.nav-drag-over-bot::after  { content: ''; position: absolute; bottom: -1px; left: 6px; right: 6px; height: 2px; background: var(--accent); border-radius: 1px; pointer-events: none; }

/* ── V3: Section groups + project items in sidebar ──
   Sections wrap projects; project items are flat nav links to
   #<slug> that open the composite project page. The section-group
   styles below reuse the existing .sb-project-group rules verbatim
   (the v2-era class is repurposed in v3). */
.sb-project-item {
  position: relative;
  /* gap-from-section-stripe: indent project items so they read as
     children of the section header. */
  padding-left: 26px !important;
  font-weight: 500;
}
.sb-project-item-dot {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translateY(-50%);
}
.sb-project-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ── Per-project groups ──
   One collapsible block per non-archived project. Header has a color
   stripe down the left edge using the project's `color` field; clicking
   anywhere on the header toggles collapse. */
.sb-project-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
}
.sb-project-group:first-of-type {
  margin-top: 10px;
}
.sb-project-header {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 10px 6px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.sb-project-header:hover { background: var(--surface-hover); color: var(--text-mid); }
.sb-project-stripe {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}
.sb-project-chev {
  display: flex;
  align-items: center;
  transition: transform 0.15s ease;
  color: var(--text-faint);
  transform: rotate(90deg);   /* expanded state: chevron points down */
}
.sb-project-group.collapsed .sb-project-chev {
  transform: rotate(0deg);    /* collapsed: chevron points right */
}
.sb-project-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-project-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  max-height: 1000px;
  transition: max-height 0.18s ease;
}
.sb-project-group.collapsed .sb-project-body {
  max-height: 0;
}
/* Collapsed sidebar: hide project headers too, show only the per-project
   nav items so the icon column stays scannable. */
.sidebar.collapsed .sb-project-header { display: none; }
.sidebar.collapsed .sb-project-group {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}
.sidebar.collapsed .sb-project-body {
  /* Force expanded in collapsed-sidebar mode so users can still navigate. */
  max-height: none;
}

.sb-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.sb-footer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  width: 100%;
  text-align: left;
}
.sb-footer-btn:hover { background: var(--surface-hover); color: var(--text-mid); }
.sb-footer-btn svg { flex-shrink: 0; }
.sb-footer-label { flex: 1; }
a.sb-footer-btn { text-decoration: none; cursor: pointer; }
.sb-footer-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.sb-footer-btn.active:hover { background: var(--accent-soft); color: var(--accent-text); }

/* ── Main content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  min-width: 0;
  min-height: 0;
}
.main-content::-webkit-scrollbar { width: 8px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Module header ── */
.mod-header {
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.mod-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.mod-actions { display: flex; gap: 8px; align-items: center; }

/* ── Module body ── */
.mod-body { padding: 24px 28px; }

/* ═══════════════════════════════════════════
   COMMON COMPONENTS
═══════════════════════════════════════════ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-mid);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-focus); color: var(--text); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { opacity: 0.9; color: #fff; }
.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-ghost:hover { background: var(--surface-hover); border-color: transparent; }
.btn-danger:hover { border-color: var(--red); color: var(--red-text); background: var(--red-soft); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.w-full { width: 100%; justify-content: center; }

/* Icon button */
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--border-focus); color: var(--text); background: var(--surface-hover); }
.icon-btn svg { width: 14px; height: 14px; }

/* Fields */
.field-group { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.field-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s;
  outline: none;
}
.field-input:focus { border-color: var(--border-focus); }
.field-input::placeholder { color: var(--text-faint); }
textarea.field-input { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.65; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  font-family: var(--mono);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.badge-green  { background: var(--green-soft);  color: var(--green-text); }
.badge-amber  { background: var(--amber-soft);  color: var(--amber-text); }
.badge-red    { background: var(--red-soft);    color: var(--red-text); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue-text); }
.badge-muted  { background: var(--border-light); color: var(--text-muted); }

/* Progress bar */
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-track {
  flex: 1;
  height: 5px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.35s ease;
}
.progress-fill.complete { background: var(--green); }
.progress-pct { font-size: 11px; font-family: var(--mono); color: var(--text-muted); min-width: 32px; text-align: right; }

/* Checkbox */
.chk {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  padding: 0;
}
.chk:hover { border-color: var(--accent); }
.chk.checked { background: var(--green); border-color: var(--green); }
.chk.checked::after {
  content: '';
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}
.chk.in-progress { border-color: var(--amber, #f59e0b); background: var(--amber-soft, #fef3c7); }
.chk.in-progress::after {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--amber-text, #b45309);
  border-radius: 50%;
}

/* Drag grip */
.grip {
  color: var(--text-faint);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 3px;
  padding: 2px;
  transition: color 0.12s;
}
.grip:hover { color: var(--text-muted); }
.grip:active { cursor: grabbing; }
.grip svg { width: 12px; height: 12px; }

/* Delete (×) button */
.del-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.12s;
  flex-shrink: 0;
}
.del-btn:hover { color: var(--red-text); background: var(--red-soft); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 500;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 92%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.18s ease;
}
.modal h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Toast — stacked top-right, stylized variants */
#zpm-toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(90vw, 380px);
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 20px 1fr 18px;
  gap: 10px;
  align-items: start;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.hide { opacity: 0; transform: translateX(16px); }
.toast-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.toast-title { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.toast-msg { color: var(--text-mid); font-weight: 500; }
.toast-close { width: 18px; height: 18px; background: transparent; border: none; color: var(--text-faint); cursor: pointer; font-size: 16px; line-height: 1; padding: 0; border-radius: 3px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .1s, color .1s; }
.toast-close:hover { background: var(--surface-hover); color: var(--text); }
.toast.success { border-left-color: var(--green); }
.toast.success .toast-icon { color: var(--green); }
.toast.success .toast-title { color: var(--green); }
.toast.info { border-left-color: var(--accent); }
.toast.info .toast-icon { color: var(--accent); }
.toast.info .toast-title { color: var(--accent-text, var(--accent)); }
.toast.warning { border-left-color: var(--amber, #f59e0b); }
.toast.warning .toast-icon { color: var(--amber, #f59e0b); }
.toast.warning .toast-title { color: var(--amber, #f59e0b); }
.toast.error { border-left-color: var(--red-text, #dc2626); }
.toast.error .toast-icon { color: var(--red-text, #dc2626); }
.toast.error .toast-title { color: var(--red-text, #dc2626); }

/* Styled confirm modal */
.zpm-confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1500;
  animation: fadeIn 0.15s ease;
}
.zpm-confirm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 92%;
  max-width: 420px;
  padding: 22px 22px 18px;
  animation: slideUp 0.18s ease;
}
.zpm-confirm-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.zpm-confirm-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.zpm-confirm.danger .zpm-confirm-icon { background: var(--red-soft); color: var(--red-text); }
.zpm-confirm.info   .zpm-confirm-icon { background: var(--accent-soft); color: var(--accent); }
.zpm-confirm-title { font-size: 15px; font-weight: 700; color: var(--text); }
.zpm-confirm-msg { font-size: 13px; color: var(--text-mid); line-height: 1.5; margin-bottom: 18px; }
.zpm-confirm-btns { display: flex; gap: 8px; justify-content: flex-end; }
.zpm-confirm-btn { padding: 7px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; font-family: var(--font); transition: all .12s; }
.zpm-confirm-btn:hover { background: var(--surface-hover); }
.zpm-confirm-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.zpm-confirm-btn.primary:hover { filter: brightness(1.06); }
.zpm-confirm-btn.danger { background: var(--red-text, #dc2626); border-color: var(--red-text, #dc2626); color: #fff; }
.zpm-confirm-btn.danger:hover { filter: brightness(1.06); }

/* Prompt modal (extends .zpm-confirm) */
.zpm-prompt .zpm-prompt-body { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.zpm-prompt-field { display: flex; flex-direction: column; gap: 6px; }
.zpm-prompt-lbl { font-size: 12px; font-weight: 600; color: var(--text-mid); }
.zpm-prompt-inp {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.zpm-prompt-inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }

/* Global top-of-viewport loader bar */
.zpm-loader {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.zpm-loader::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 40%;
  background: var(--accent);
  border-radius: 2px;
  animation: zpmLoaderSlide 1.1s ease-in-out infinite;
}
.zpm-loader.show { opacity: 1; }
@keyframes zpmLoaderSlide {
  0%   { transform: translateX(-100%); width: 40%; }
  50%  { transform: translateX(60%);   width: 60%; }
  100% { transform: translateX(250%);  width: 40%; }
}

/* Shortcuts help modal */
.sc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fadeIn .12s ease-out;
}
.sc-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 440px;
  max-width: 92vw;
}
.sc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.sc-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.sc-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.sc-close:hover { color: var(--text); }
.sc-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}
.sc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
}
.sc-row:hover { background: var(--surface-hover); }
.sc-keys {
  flex: 0 0 140px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sc-plus { color: var(--text-faint); font-size: 11px; }
.sc-desc { color: var(--text-mid); font-size: 13px; }
.sc-foot {
  padding: 10px 18px 14px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
}
.sc-modal kbd {
  display: inline-block;
  padding: 2px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  line-height: 1.3;
}

/* Dark-mode native inputs — force dark color scheme so browser uses dark
   calendar pop, dark file picker, and correct placeholder colors. */
html.dark { color-scheme: dark; }
html.light { color-scheme: light; }
html.dark input[type="date"],
html.dark input[type="datetime-local"],
html.dark input[type="time"],
html.dark input[type="month"],
html.dark input[type="week"],
html.dark input[type="file"] { color-scheme: dark; }
html.dark input[type="date"]::-webkit-calendar-picker-indicator,
html.dark input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html.dark input[type="time"]::-webkit-calendar-picker-indicator,
html.dark input[type="month"]::-webkit-calendar-picker-indicator,
html.dark input[type="week"]::-webkit-calendar-picker-indicator { filter: invert(0.85); cursor: pointer; }
@media (prefers-color-scheme: dark) {
  html:not(.light) { color-scheme: dark; }
  html:not(.light) input[type="date"],
  html:not(.light) input[type="datetime-local"],
  html:not(.light) input[type="time"],
  html:not(.light) input[type="month"],
  html:not(.light) input[type="week"],
  html:not(.light) input[type="file"] { color-scheme: dark; }
  html:not(.light) input[type="date"]::-webkit-calendar-picker-indicator,
  html:not(.light) input[type="datetime-local"]::-webkit-calendar-picker-indicator,
  html:not(.light) input[type="time"]::-webkit-calendar-picker-indicator,
  html:not(.light) input[type="month"]::-webkit-calendar-picker-indicator,
  html:not(.light) input[type="week"]::-webkit-calendar-picker-indicator { filter: invert(0.85); cursor: pointer; }
}

/* ═══════════════════════════════════════════
   MODULE STATES
═══════════════════════════════════════════ */
.module-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-faint);
  font-size: 13px;
}
.module-loading::after { content: 'Loading…'; }

/* Canonical empty state. Generated by emptyState({icon,title,text,cta}) in
   js/ui.js — all new empty / error states should go through that helper so
   modules don't drift toward bespoke grey-text variants. Variants: --card
   (smaller padding for inline use in widgets), --inline (single-line). */
.module-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 8px;
}
.module-empty-icon { font-size: 32px; color: var(--text-faint); margin-bottom: 4px; }
.module-empty-title { font-size: 15px; font-weight: 600; color: var(--text-mid); }
.module-empty-text  { font-size: 13px; max-width: 300px; line-height: 1.6; }
.module-empty-cta {
  margin-top: 12px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--btn-primary-fg, #fff);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}
.module-empty-cta:hover { filter: brightness(1.08); }
.module-empty--card   { padding: 24px 14px; gap: 6px; }
.module-empty--card .module-empty-icon  { font-size: 22px; margin-bottom: 2px; }
.module-empty--card .module-empty-title { font-size: 13px; }
.module-empty--card .module-empty-text  { font-size: 12px; }
.module-empty--inline { flex-direction: row; padding: 12px 14px; gap: 10px; justify-content: flex-start; text-align: left; }
.module-empty--inline .module-empty-icon  { font-size: 18px; margin: 0; }
.module-empty--inline .module-empty-title { font-size: 13px; }
.module-empty--inline .module-empty-text  { font-size: 12px; max-width: none; }

/* ═══════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--mono); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.gap-8  { gap: 8px; }
.flex   { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ═══════════════════════════════════════════
   CHECKLISTS MODULE — 2-column layout
   (kept here so it survives JS module caching)
═══════════════════════════════════════════ */
.cl-body { display: flex; flex-direction: column; gap: 12px; }
.cl-cols { display: flex; gap: 12px; align-items: flex-start; }
.cl-col  { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 640px) {
  :root { --sidebar-width: 180px; }
  .mod-header { padding: 14px 16px; }
  .mod-body   { padding: 16px; }
}
