/* The Whiteboard - Premium Architectural Design System */

:root {
  /* Theme: Drafting Table (Warm Studio Light Mode) */
  --bg: #FAF8F5; /* Premium textured archival paper */
  --bg-sidebar: #0F1311; /* Drafting charcoal/ink black */
  --sidebar-text: #E5DFC9;
  --sidebar-text-muted: #6B7870;
  --sidebar-active-bg: rgba(229, 222, 201, 0.08);

  --card-bg: #FFFFFF;
  --text-main: #141A16; /* Deep graphite pen ink */
  --text-muted: #636C66; /* Architectural lead gray */

  --primary: #213B2E; /* Forest Pine */
  --primary-hover: #14251D;
  --primary-rgb: 33, 59, 46;

  --accent-gold: #9E7D4C; /* Warm Brass / Aged Spruce Wood */
  --accent-gold-light: #FBF8F2;

  --accent-blue: #3E5A6B; /* Blueprint Prussian Blue */
  --accent-blue-light: #F4F7F9;

  --accent-red: #B94A4A; /* Terracotta Red Priority Dot / Alert */
  --accent-red-light: #FDF4F4;

  --border: #E3DDD0; /* Hairline technical board lines */
  --border-light: #ECE8DE;
  --input-focus: #213B2E;
  --input-focus-light: rgba(33, 59, 46, 0.04);

  --shadow-sm: 0 1px 2px rgba(20, 26, 22, 0.04);
  --shadow-md: 0 4px 12px rgba(20, 26, 22, 0.05);
  --shadow-lg: 0 12px 32px rgba(20, 26, 22, 0.08);

  /* Sharp, high-end architectural geometries instead of bubbly SaaS UI */
  --radius-sm: 2px;
  --radius-md: 3px;
  --radius-lg: 4px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'Space Mono', 'Courier New', monospace; /* Architectural technical coordinates */

  --transition-smooth: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* Fixed priority colors — same hue in every palette so Low always reads green,
     Medium gold, High red, Stand By gray. Theme primary is intentionally NOT
     used for Low because some palettes (Onyx) use a warm primary that would
     visually conflict with "low / safe / green" semantics. */
  --priority-low: #3B7A57;
  --priority-low-light: rgba(59, 122, 87, 0.08);
}

/* Blueprint — Cool architectural blue palette */
body.theme-blueprint {
  --bg: #EEF3F8;
  --bg-sidebar: #0E2030;
  --sidebar-text: #D8E4EE;
  --sidebar-text-muted: #6B8398;
  --sidebar-active-bg: rgba(216, 228, 238, 0.08);

  --card-bg: #FFFFFF;
  --text-main: #0D1B26;
  --text-muted: #5A6F80;

  --primary: #1F4E79;
  --primary-hover: #143553;
  --primary-rgb: 31, 78, 121;

  --accent-gold: #B68A3E;
  --accent-gold-light: #FBF6EB;

  --accent-blue: #2E6FA8;
  --accent-blue-light: #ECF2F9;

  --accent-red: #B94A4A;
  --accent-red-light: #FDF4F4;

  --border: #CBD8E2;
  --border-light: #DEE7EE;
  --input-focus: #1F4E79;
  --input-focus-light: rgba(31, 78, 121, 0.04);
}

/* Onyx — deep black + warm brass (second dark option) */
body.theme-onyx {
  --bg: #0F0F11;
  --bg-sidebar: #050507;
  --sidebar-text: #EDE5D0;
  --sidebar-text-muted: #8B7E5E;
  --sidebar-active-bg: rgba(237, 229, 208, 0.07);

  --card-bg: #16161A;
  --text-main: #EFE9D8;
  --text-muted: #94896E;

  --primary: #C9A24A;   /* warm brass */
  --primary-hover: #E0B45A;
  --primary-rgb: 201, 162, 74;

  --accent-gold: #D6B362;
  --accent-gold-light: rgba(214, 179, 98, 0.06);

  --accent-blue: #6F8EA8;
  --accent-blue-light: rgba(111, 142, 168, 0.06);

  --accent-red: #C25555;
  --accent-red-light: rgba(194, 85, 85, 0.06);

  --border: #2A2A30;
  --border-light: #1E1E22;
  --input-focus: #C9A24A;
  --input-focus-light: rgba(201, 162, 74, 0.06);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.75);
}

/* Midnight Obsidian (Architect's Studio Dark Mode) */
body.dark-theme {
  /* Dark mode mirrors the light gradient but darkens it */
  --bg-gradient: linear-gradient(135deg, #064D44, #805400);
  --bg: #064D44;
  --bg-sidebar: #00120D;
  --sidebar-text: #E5E5E5;
  --sidebar-text-muted: #A1C5C3;
  
  --card-bg: #0E1210;
  --text-main: #E5ECE7; /* Muted chalk white */
  --text-muted: #839288; /* Faded ink */
  
  --primary: #0F9B8E; /* teal */
  --primary-hover: #09766B;
  --primary-rgb: 15, 155, 142;
  
  --accent-gold: #FFB400; /* amber */
  --accent-gold-light: rgba(255, 180, 0, 0.04);
  
  --accent-blue: #1E88E5; /* blue */
  --accent-blue-light: rgba(30, 136, 229, 0.04);
  
  --accent-red: #E53935; /* red */
  --accent-red-light: rgba(229, 57, 53, 0.04);
  
  --border: #1E2521;
  --border-light: #161D1A;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  transition: var(--transition-smooth);
  height: 100vh; /* fallback */
  height: 100dvh; /* iOS-stable viewport that doesn't jump with the address bar */
  overflow: hidden;
  letter-spacing: -0.01em;
}

/* Premium Typography Rules */
h1, h2, h3, h4, .drawer-title, .ledger-project-name {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* App Grid Layout */
.app-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh; /* fallback */
  height: 100dvh;
  width: 100vw;
}

/* Sidebar Styling (High-End Gallery Feel) */
.app-sidebar {
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 32px 20px;
  border-right: 1px solid rgba(229, 222, 201, 0.06);
  height: 100vh;
  z-index: 10;
}

.brand-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  margin-bottom: 48px;
  padding: 0 8px;
}

.brand-logo {
  width: 140px;
  height: auto;
  display: block;
  /* Crop the "Broad Vision, Careful Thought" tagline below the mark.
     Image is 692x532; logo mark ends at ~row 460. */
  aspect-ratio: 692 / 470;
  object-fit: cover;
  object-position: top;
  /* Convert white PNG → #E5DFC9 (warm sand sidebar-text) */
  filter: brightness(0) invert(90%) sepia(30%) saturate(300%) hue-rotate(345deg) brightness(1.05);
  opacity: 0.9;
  transition: opacity 0.2s ease;
}

.brand-logo.footer-logo {
  width: 32px;
  flex-shrink: 0;
}

.brand-logo:hover {
  opacity: 1;
}

/* Dark theme: teal-tinted logo to match dark mode palette */
body.dark-theme .brand-logo {
  filter: brightness(0) invert(85%) sepia(15%) saturate(500%) hue-rotate(120deg) brightness(0.95);
  opacity: 0.8;
}

/* Blueprint: cool ice-paper tone (sidebar-text is #D8E4EE) */
body.theme-blueprint .brand-logo {
  filter: brightness(0) invert(91%) sepia(8%) saturate(380%) hue-rotate(180deg) brightness(1.02);
  opacity: 0.92;
}

/* Onyx: warm cream to match "The Whiteboard" text (sidebar-text is #EDE5D0).
   Sidebar text is nearly identical to the Drafting palette, so we reuse
   the same filter so the logo blends with the heading. */
body.theme-onyx .brand-logo {
  filter: brightness(0) invert(91%) sepia(20%) saturate(280%) hue-rotate(355deg) brightness(1.02);
  opacity: 0.92;
}

.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--sidebar-text);
  line-height: 1.2;
}

.brand-text span {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 400;
  display: block;
  margin-top: 4px;
}

/* Lock Board sidebar button accent */
#sidebar-logout-btn {
  color: var(--accent-red) !important;
  opacity: 0.7;
  transition: var(--transition-smooth);
}

#sidebar-logout-btn:hover {
  opacity: 1;
  background-color: rgba(185, 74, 74, 0.08);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

/* Sidebar Menu Fonts (Technical Monospace Overhaul) */
.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  padding: 10px 12px;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-btn svg {
  opacity: 0.5;
  stroke-width: 1.5;
  transition: var(--transition-smooth);
}

.nav-btn:hover {
  color: var(--sidebar-text);
  background-color: rgba(255, 255, 255, 0.02);
}

.nav-btn.active {
  color: var(--sidebar-text);
  background-color: var(--sidebar-active-bg);
  border-left: 2px solid var(--sidebar-text);
  padding-left: 10px;
}

.nav-btn.active svg {
  opacity: 0.85;
  stroke: var(--sidebar-text);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 24px;
  margin-bottom: 24px;
}

/* Minimalist crisp buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 100%;
}

.action-btn.primary {
  background-color: var(--primary);
  color: #FFFFFF;
}

.action-btn.primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-0.5px);
}

.action-btn.secondary {
  background-color: transparent;
  color: var(--sidebar-text);
  border: 1px solid rgba(229, 222, 201, 0.15);
}

.action-btn.secondary:hover {
  background-color: rgba(229, 222, 201, 0.03);
  border-color: rgba(229, 222, 201, 0.35);
}

.action-btn.small {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

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

.architect-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: var(--transition-smooth);
}

button.architect-badge:hover {
  background-color: rgba(229, 222, 201, 0.04);
  border-color: rgba(229, 222, 201, 0.15);
}

button.architect-badge:focus-visible {
  outline: none;
  border-color: rgba(229, 222, 201, 0.35);
}

.architect-badge .avatar {
  width: 28px;
  height: 28px;
  border: 1px solid var(--sidebar-text-muted);
  color: var(--sidebar-text);
  border-radius: 50%;
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.architect-badge .info {
  display: flex;
  flex-direction: column;
}

.architect-badge .name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sidebar-text);
}

.architect-badge .role {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  color: var(--sidebar-text-muted);
}

/* Main Content Area */
.app-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header Styling (Clean Layout Lines) */
.app-header {
  height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--card-bg);
  z-index: 5;
}

.header-search-filter {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 600px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  stroke-width: 1.5;
}

.search-input-wrapper input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 38px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  transition: var(--transition-smooth);
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--input-focus);
  background-color: var(--card-bg);
}

.filter-group select {
  height: 36px;
  padding: 0 10px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
}

.filter-group select:focus {
  border-color: var(--input-focus);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions .action-btn {
  width: auto;
  height: 36px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--card-bg);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.theme-toggle:hover {
  background-color: var(--bg);
}

/* Dashboard Insight Stats (Muted, Minimal Grid) */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px; /* Subtle solid divider grid style */
  background-color: var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-card {
  background-color: var(--card-bg);
  padding: 18px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  transition: var(--transition-smooth);
  border-bottom: 3px solid transparent;
}

.stat-card:hover {
  background-color: var(--border-light);
}

body.dark-theme .stat-card:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.stat-card.active-filter[data-stat="projects"] {
  border-bottom-color: var(--primary);
}

.stat-card.active-filter[data-stat="site-visits"] {
  border-bottom-color: var(--accent-gold);
}

.stat-card.active-filter[data-stat="construction"] {
  border-bottom-color: var(--accent-red);
}

.stat-card.active-filter[data-stat="internal"] {
  border-bottom-color: var(--accent-blue);
}

.stat-icon {
  display: none; /* Removed heavy icons for minimalist elegance */
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-info .label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.stat-info .value {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  color: var(--text-main);
  margin-top: 2px;
}

/* Views Layout */
.views-wrapper {
  flex: 1;
  padding: 32px;
  overflow: hidden;
}

.view-panel {
  display: none;
  height: 100%;
  width: 100%;
}

.view-panel.active {
  display: block;
}

/* Board Kanban (Grid Lines Aesthetic) */
.board-canvas {
  display: flex;
  gap: 16px;
  height: 100%;
  overflow-x: auto;
  padding-bottom: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.board-canvas::-webkit-scrollbar {
  height: 6px;
}

.board-canvas::-webkit-scrollbar-thumb {
  background-color: var(--border);
}

.board-column {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column; /* Standard vertical column layout */
  background-color: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  height: 100%;
  transition: flex 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), min-width 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding 0.25s ease, background-color 0.2s ease;
  overflow: hidden;
}

/* Narrow column layout when category is empty */
.board-column:not(.active-column) {
  flex: 0 0 110px;
  min-width: 110px;
  padding: 12px 8px;
  background-color: rgba(33, 59, 46, 0.005);
}

body.dark-theme .board-column:not(.active-column) {
  background-color: rgba(15, 155, 142, 0.002);
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  flex-shrink: 0;
  width: 100%;
}

.board-column:not(.active-column) .column-header {
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border-bottom: 1px dashed var(--border-light);
  margin-bottom: 8px;
  padding-bottom: 6px;
}

.column-header h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-main);
  line-height: 1.3;
}

.board-column:not(.active-column) .column-header h3 {
  font-size: 8.5px;
  letter-spacing: 0.04em;
  text-align: center;
}

.column-header .badge {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.board-column.active-column .badge {
  border-color: var(--primary);
  color: var(--primary);
}

.board-column:not(.active-column) .column-header .badge {
  font-size: 9px;
  padding: 0px 4px;
}

.cards-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
}

.board-column:not(.active-column) .cards-container {
  display: none;
}

/* Drag-over states during project movement */
.board-column.drag-over {
  border: 1px solid var(--primary);
  background-color: var(--accent-blue-light);
  flex: 0 0 280px !important;
  min-width: 280px !important;
  padding: 16px 12px !important;
}

.board-column.drag-over .column-header {
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: center !important;
  border-bottom: 1px solid var(--border) !important;
  margin-bottom: 16px !important;
  padding-bottom: 8px !important;
}

.board-column.drag-over .column-header h3 {
  font-size: 10px !important;
  letter-spacing: 0.08em !important;
  text-align: left !important;
}

.board-column.drag-over .column-header .badge {
  font-size: 10px !important;
  padding: 1px 6px !important;
}

.board-column.drag-over .cards-container {
  display: flex !important;
}

/* Kanban Cards (Ultra-Premium, Solid Outline, Razor-thin borders) */
.project-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 6px solid var(--accent-gold);
}

.project-card:hover {
  border-color: var(--text-main);
  box-shadow: var(--shadow-md);
  transform: translateY(-0.5px);
}

.project-card:active {
  cursor: grabbing;
}

/* Priority Left-border Colors */
.project-card[data-priority="high"] {
  border-left-color: var(--accent-red);
}

.project-card[data-priority="medium"] {
  border-left-color: var(--accent-gold);
}

.project-card[data-priority="low"] {
  border-left-color: var(--priority-low);
}

/* Stand By Priority Visual Styles */
.project-card[data-priority="standby"] {
  border: 1px solid var(--border) !important;
  border-left: 6px solid #D1D5DB !important;
  background-color: var(--bg) !important;
  box-shadow: none !important;
  position: relative;
}

.project-card[data-priority="standby"]::after {
  content: '';
  position: absolute;
  top: -1px;
  left: -6px;
  right: -1px;
  bottom: -1px;
  border: 1.5px dashed var(--text-muted) !important;
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 2;
}

.project-card[data-priority="standby"] .card-title,
.project-card[data-priority="standby"] .card-title span,
.project-card[data-priority="standby"] .priority-indicator,
.project-card[data-priority="standby"] .card-visit-date,
.project-card[data-priority="standby"] .card-location span,
.project-card[data-priority="standby"] .todo-counter span,
.project-card[data-priority="standby"] .visit-badge,
.project-card[data-priority="standby"] svg {
  color: var(--text-muted) !important;
  fill: none;
  stroke: var(--text-muted) !important;
  opacity: 0.75;
}

.project-card[data-priority="standby"] .upcoming-visit-flag {
  fill: var(--text-muted) !important;
}

.project-card[data-priority="standby"] .card-badge {
  border-color: var(--text-muted) !important;
  color: var(--text-muted) !important;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-main);
}

/* Card badges for architects */
.card-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.05em;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.card-badge.trey {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.card-badge.robert {
  background-color: transparent;
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
}

.card-badge.both {
  background-color: transparent;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}

/* Priority dots styling (Red Highest, Yellow, Green) */
.priority-indicator {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 0;
}

.priority-indicator::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.priority-indicator.high {
  color: var(--accent-red);
}
.priority-indicator.high::before {
  background-color: var(--accent-red);
}

.priority-indicator.medium {
  color: var(--accent-gold);
}
.priority-indicator.medium::before {
  background-color: var(--accent-gold);
}

.priority-indicator.low {
  color: var(--priority-low);
}
.priority-indicator.low::before {
  background-color: var(--priority-low);
}

.priority-indicator.standby {
  color: var(--text-muted);
}
.priority-indicator.standby::before {
  background-color: var(--text-muted);
}

.card-location {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-location svg {
  opacity: 0.5;
  stroke-width: 1.5;
}

.card-progress-bar {
  height: 2px;
  background-color: var(--bg);
  border-radius: 0;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background-color: var(--primary);
  transition: width 0.3s ease;
}

.project-card[data-lead="robert"] .card-progress-fill {
  background-color: var(--accent-gold);
}
.project-card[data-lead="both"] .card-progress-fill {
  background-color: var(--accent-blue);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
  padding-top: 8px;
  font-size: 10px;
}

.todo-counter {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.todo-counter svg {
  stroke-width: 1.5;
}

.visit-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
}

.visit-badge.alert {
  background-color: transparent;
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
}

.visit-badge.need-visit {
  background-color: transparent;
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.visit-badge.done {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Card fold-out toggle and dynamic collapse layout */
.card-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

.card-toggle-btn:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

body.dark-theme .card-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.chevron-icon {
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: center;
}

.card-details-foldout {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  border-top: 1px dashed var(--border-light);
  padding-top: 8px;
  animation: foldOutSlide 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes foldOutSlide {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Ledger spreadsheet list view (Minimal Drawing Grid) */
.ledger-container {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.table-responsive {
  flex: 1;
  overflow: auto;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
}

.ledger-table th {
  background-color: var(--bg);
  padding: 14px 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Sortable Table Headers */
.sortable-header {
  cursor: pointer;
  user-select: none;
  transition: var(--transition-smooth);
}

.sortable-header:hover {
  background-color: var(--border-light) !important;
  color: var(--text-main) !important;
}

body.dark-theme .sortable-header:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

.sort-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  vertical-align: middle;
  transition: var(--transition-smooth);
  opacity: 0;
}

.sortable-header:hover .sort-icon {
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23636C66' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

body.dark-theme .sortable-header:hover .sort-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23839288' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.sort-asc .sort-icon {
  opacity: 1 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23213b2e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-size: contain;
  background-repeat: no-repeat;
}

body.dark-theme .sort-asc .sort-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f9b8e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.sort-desc .sort-icon {
  opacity: 1 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23213b2e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-size: contain;
  background-repeat: no-repeat;
}

body.dark-theme .sort-desc .sort-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f9b8e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.ledger-table td {
  padding: 14px 20px;
  font-size: 13px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.ledger-row-clickable { cursor: pointer; }

.ledger-table tr:hover td {
  background-color: var(--bg);
}

.ledger-project-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.ledger-project-name:hover {
  text-decoration: underline;
  color: var(--primary);
}

.ledger-phase-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.ledger-actions-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ledger-actions-btn:hover {
  color: var(--text-main);
}

/* Detail Drawer (Minimalist Slide-Out Drafting File) */
.project-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  height: 100vh;
  background-color: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.project-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 32px 32px 18px 32px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.close-drawer-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-drawer-btn:hover {
  color: var(--text-main);
}

.drawer-subtitle {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 400;
  color: var(--accent-gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

.drawer-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-main);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.drawer-section {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 20px;
}

.drawer-section:last-of-type {
  border-bottom: none;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.drawer-progress-bar {
  height: 2px;
  background-color: var(--bg);
  overflow: hidden;
  margin-bottom: 14px;
}

.drawer-progress-fill {
  height: 100%;
  background-color: var(--primary);
  transition: width 0.2s ease;
}

/* Forms layout */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.full-width {
  grid-column: span 2;
}

.form-group label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  background-color: var(--bg);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: var(--transition-smooth);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--input-focus);
  background-color: var(--card-bg);
}

.margin-top {
  margin-top: 12px;
}

/* Drawer checklists styling */
.drawer-todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  border-left: 4px solid transparent;
  transition: var(--transition-smooth);
}

.todo-item.todo-dragging {
  opacity: 0.4;
  border: 1px dashed var(--primary);
}

.todo-item.drag-over-todo {
  border: 1px solid var(--accent-gold);
  background-color: var(--accent-gold-light);
}

.todo-item.priority-red {
  border-left-color: var(--accent-red);
  background-color: var(--accent-red-light);
}

.todo-item.priority-yellow {
  border-left-color: var(--accent-gold);
  background-color: var(--accent-gold-light);
}

.todo-item.priority-green {
  border-left-color: var(--primary);
  background-color: rgba(33, 59, 46, 0.03);
}

body.dark-theme .todo-item.priority-green {
  background-color: rgba(15, 155, 142, 0.03);
}

/* Inline priority selector buttons */
.task-priority-selectors {
  display: inline-flex;
  gap: 6px;
  margin-right: 12px;
  align-items: center;
}

.priority-selector-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
  opacity: 0.2;
  padding: 0;
}

.priority-selector-btn:hover {
  opacity: 0.6;
  transform: scale(1.2);
}

.priority-selector-btn.active {
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 0 1.5px var(--card-bg), 0 0 0 2.5px currentColor;
}

.priority-selector-btn.btn-red {
  background-color: var(--accent-red);
  color: var(--accent-red);
}

.priority-selector-btn.btn-yellow {
  background-color: var(--accent-gold);
  color: var(--accent-gold);
}

.priority-selector-btn.btn-green {
  background-color: var(--primary);
  color: var(--primary);
}

.todo-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.todo-item-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

.todo-item-text {
  font-size: 13px;
  color: var(--text-main);
}

.todo-item.completed .todo-item-text {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.6;
}

.delete-todo-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: var(--transition-smooth);
  padding: 2px;
}

.todo-item:hover .delete-todo-btn {
  opacity: 1;
}

.delete-todo-btn:hover {
  color: var(--accent-red);
}

.add-todo-inline {
  display: flex;
  gap: 8px;
}

.add-todo-inline input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  background-color: var(--bg);
  color: var(--text-main);
}

.add-todo-inline input:focus {
  outline: none;
  border-color: var(--input-focus);
}

.add-inline-btn {
  background-color: var(--primary);
  color: #FFFFFF;
  border: none;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

/* Site Visit supervision elements */
.visit-logging-card {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}

.visit-logging-card h4 {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.visit-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.visit-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.visit-sub-header {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.visit-item {
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px;
  position: relative;
}

.visit-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.visit-item-date {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-main);
}

.visit-item-visitor {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.visit-item-visitor.trey {
  border: 1px solid var(--primary);
  color: var(--primary);
}

.visit-item-visitor.robert {
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
}

.visit-item-visitor.both {
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
}

.visit-item-notes {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

.delete-visit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: var(--transition-smooth);
}

.visit-item:hover .delete-visit-btn {
  opacity: 1;
}

.delete-visit-btn:hover {
  color: var(--accent-red);
}

.drawer-danger-zone {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}

.delete-project-btn {
  background-color: var(--accent-red-light);
  color: var(--accent-red);
  border: 1px solid rgba(185, 74, 74, 0.15);
  padding: 10px;
  width: 100%;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.delete-project-btn:hover {
  background-color: var(--accent-red);
  color: #FFFFFF;
}

/* Modals & Dialogs (Sharp geometry) */
.project-dialog {
  margin: auto;
  border: 1px solid var(--border);
  background-color: var(--card-bg);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 24px 32px;
  width: 500px;
  max-width: 90vw;
  outline: none;
}

.project-dialog::backdrop {
  background-color: rgba(15, 19, 17, 0.35);
  backdrop-filter: blur(2px);
}

body.dark-theme .project-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.65);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dialog-header h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
}

.close-dialog-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.dialog-actions button {
  width: auto;
}

/* Dialog Button Overrides for readability & contrast */
.project-dialog .action-btn.secondary {
  background-color: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.project-dialog .action-btn.secondary:hover {
  background-color: var(--border-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Specific styling for the Red Logout / Lock button in Settings dialog */
.project-dialog #logout-device-btn {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background-color: transparent;
}

.project-dialog #logout-device-btn:hover {
  background-color: var(--accent-red-light);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* Specific styling for the Gold Reset button in Settings dialog */
.project-dialog #reset-defaults-btn {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background-color: transparent;
}

.project-dialog #reset-defaults-btn:hover {
  background-color: var(--accent-gold-light);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Slide Drawer backdrop shadow */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 19, 17, 0.15);
  backdrop-filter: blur(1px);
  z-index: 90;
  display: none;
}

body.dark-theme .drawer-backdrop {
  background-color: rgba(0, 0, 0, 0.4);
}

.drawer-backdrop.active {
  display: block;
}

/* Toast Notifications */
.toast-notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--primary);
  color: #FFFFFF;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-md);
  z-index: 200;
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
}

/* Securely hide and deactivate Lead Architect visual elements while keeping internal code active */
.card-badge {
  display: none !important;
}

#architect-filter {
  display: none !important;
}

.form-group:has(#new-lead),
.form-group:has(#edit-lead) {
  display: none !important;
}

.ledger-table th:nth-child(3),
.ledger-table td:nth-child(3) {
  display: none !important;
}


/* ──────────────────────────────────────────────────────────────────────────
   Responsive: Tablet (≤1024px) — sidebar becomes bottom nav
   Bottom nav grows with iPhone home-indicator safe area;
   header gains safe-area-top padding so the notch doesn't clip it.
   ────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  /* Bottom nav: the BOX itself grows by the safe-area amount so 56px of
     real estate is always available above the home indicator. */
  .app-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    flex-direction: row;
    border-right: none;
    border-top: 1px solid rgba(229, 222, 201, 0.08);
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.18);
  }

  .brand-section, .sidebar-actions, .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    width: 100%;
    height: 56px;
    justify-content: space-around;
    align-items: center;
    gap: 0;
  }

  .nav-btn {
    width: auto;
    padding: 6px 6px;
    font-size: 9.5px;
    letter-spacing: 0.04em;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    text-align: center;
    border-radius: var(--radius-sm);
    overflow: hidden;
  }

  .nav-btn span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  /* Tutorial button uses margin-top:auto inline — neutralize it for row layout */
  #start-tutorial-btn { margin-top: 0 !important; }

  .nav-btn.active {
    border-left: none;
    border-bottom: 2px solid var(--sidebar-text);
    padding-left: 6px;
    padding-bottom: 4px;
  }

  /* Main area sits between safe-area top and the bottom nav */
  .app-main {
    height: calc(100vh - 56px - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - 56px - env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .project-drawer {
    width: 100%;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Header tightens up + gains safe-area top padding so the notch clears it */
  .app-header {
    height: auto;
    min-height: 64px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px 18px;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
  }

  .header-search-filter {
    flex: 1 1 100%;
    max-width: none;
    flex-wrap: wrap;
    gap: 8px;
    order: 2;
  }

  .header-actions {
    order: 1;
    width: 100%;
    justify-content: flex-end;
  }

  /* Auth lock overlay also needs safe-area awareness so the card isn't behind the notch */
  .auth-lock-overlay {
    padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px) 16px;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Responsive: Mobile (≤768px) — phones, full mobile pass
   ────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Reduce body-level font micro-tweaks so iOS doesn't auto-zoom on inputs */
  body { font-size: 15px; }

  /* Header: stack search row + action row, more compact */
  .app-header {
    padding: 10px 14px;
    gap: 8px;
  }

  .search-input-wrapper input,
  .filter-group select {
    height: 40px;
    font-size: 16px; /* prevent iOS zoom on focus */
  }

  .filter-group { flex: 1 1 calc(50% - 4px); }
  .filter-group select { width: 100%; }

  .header-actions { gap: 8px; }

  .header-actions .action-btn {
    height: 40px;
    padding: 0 12px;
    font-size: 12px;
  }

  .theme-toggle { width: 40px; height: 40px; flex-shrink: 0; }

  /* Dashboard stats: 2×2 grid, tighter padding */
  .dashboard-stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-info .label { font-size: 8.5px; }
  .stat-info .value { font-size: 20px; }

  /* Views wrapper padding tighter */
  .views-wrapper { padding: 14px !important; }

  /* Kanban: narrower active columns + scroll-snap so swipes land cleanly */
  .board-canvas {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    padding-bottom: 12px;
  }

  .board-column {
    flex: 0 0 86vw;
    scroll-snap-align: start;
    padding: 14px 10px;
  }

  .board-column:not(.active-column) {
    flex: 0 0 96px;
    min-width: 96px;
  }

  /* Project cards — taller touch target and clearer hierarchy */
  .project-card {
    padding: 12px;
  }

  /* Ledger table: allow horizontal scroll inside its container */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ledger-table {
    min-width: 640px;
  }

  .ledger-table th,
  .ledger-table td {
    padding: 10px 12px;
    font-size: 12px;
  }

  /* Project drawer: full-screen, slimmer padding */
  .project-drawer {
    width: 100%;
    border-left: none;
  }

  .drawer-header {
    padding: 22px 18px 14px 18px;
  }

  .close-drawer-btn {
    top: 14px; right: 14px;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
  }

  .drawer-title { font-size: 18px; }

  .drawer-content {
    padding: 18px;
    gap: 18px;
  }

  /* Form grids collapse to one column */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .form-group.full-width { grid-column: span 1; }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 10px 12px;
    font-size: 16px; /* prevent iOS zoom */
  }

  /* New Project dialog */
  .project-dialog {
    padding: 18px;
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
    overflow-y: auto;
  }

  .dialog-actions {
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
    padding-top: 12px;
    margin-top: 16px;
    border-top: 1px solid var(--border-light);
  }

  .dialog-actions button {
    flex: 1;
    height: 44px;
  }

  /* Priority pill group wraps cleanly */
  .new-priority-btn-group {
    gap: 6px !important;
  }
  .new-priority-btn-group .new-prio-pill-btn {
    flex: 1 1 calc(50% - 4px) !important;
    min-width: 0 !important;
    padding: 12px 6px !important;
    font-size: 10px !important;
  }

  /* Auth lock — center, breathing room, taller inputs */
  .auth-lock-card {
    padding: 28px 22px;
    width: 100%;
    max-width: 94vw;
  }

  .auth-lock-card h2 { font-size: 19px; }
  .auth-lock-card p { font-size: 12.5px; margin-bottom: 22px; }

  #auth-passcode-input {
    height: 48px;
    font-size: 16px;
  }

  #auth-toggle-show {
    width: 64px !important;
    height: 48px !important;
  }

  #auth-unlock-btn {
    height: 48px;
    font-size: 12px !important;
  }

  /* Visit logging two-column grid → one column on phone */
  .visit-form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Drawer site visit list compact */
  .visit-list li {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  /* Drawer priority dots — slightly larger targets */
  .prio-dot-btn {
    width: 18px !important;
    height: 18px !important;
  }

  /* Toast positioning above bottom nav */
  .toast-notification {
    bottom: 72px;
    width: calc(100% - 32px);
    text-align: center;
  }

  /* Tutorial popovers shrink */
  .driver-popover {
    max-width: calc(100vw - 32px) !important;
    padding: 14px 14px 12px 14px !important;
  }

  .driver-popover-title { font-size: 16px; }
  .driver-popover-description { font-size: 12.5px; }

  /* All native buttons get a min touch target */
  button,
  .action-btn,
  .nav-btn,
  select,
  input[type="checkbox"] {
    -webkit-tap-highlight-color: rgba(33, 59, 46, 0.08);
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Responsive: Narrow phones (≤480px) — final squeeze
   ────────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  /* Hide nav button labels — icons only — at the narrowest sizes */
  .nav-btn span {
    display: none;
  }

  .nav-btn svg { width: 20px; height: 20px; }

  /* Dashboard stats become a single horizontal scrolling row */
  .dashboard-stats {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .dashboard-stats::-webkit-scrollbar { display: none; }

  /* Header New Project + My List shrink to icon-only on narrow phones */
  #add-project-btn span { display: none; }
  #add-project-btn { padding: 0 12px; }
  #my-list-btn span { display: none; }
  #my-list-btn { padding: 0 12px; }

  /* Slightly more aggressive kanban column width */
  .board-column { flex: 0 0 90vw; }
  .board-column:not(.active-column) { flex: 0 0 86px; min-width: 86px; }

  /* Drawer & dialog tighter */
  .drawer-header { padding: 18px 14px 12px 14px; }
  .drawer-content { padding: 14px; gap: 16px; }
  .project-dialog { padding: 14px; }

  /* Stack filters full-width */
  .filter-group { flex: 1 1 100%; }
}

/* To-Do Ledger — grouped by priority, then by project */
.todo-ledger-section {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.todo-ledger-section-header {
  padding: 14px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-left: 4px solid transparent;
}

.todo-ledger-section-header .section-title { color: inherit; }

.todo-ledger-section-header .section-count {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background-color: currentColor;
  color: var(--card-bg);
  opacity: 0.95;
}

/* Quiet, opaque background tint per priority so headers are scannable but not loud */
.todo-ledger-section-header.header-red {
  border-left-color: var(--accent-red);
  color: var(--accent-red);
  background-color: var(--accent-red-light);
}
.todo-ledger-section-header.header-yellow {
  border-left-color: var(--accent-gold);
  color: var(--accent-gold);
  background-color: var(--accent-gold-light);
}
.todo-ledger-section-header.header-green {
  border-left-color: var(--priority-low);
  color: var(--priority-low);
  background-color: var(--priority-low-light);
}
.todo-ledger-section-header.header-none {
  border-left-color: var(--text-muted);
  color: var(--text-muted);
  background-color: var(--bg);
}

/* Project group header — separates one project's tasks from the next inside a section */
.todo-ledger-project-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px;
  background-color: var(--bg);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-serif);
}

.todo-ledger-section .todo-ledger-rows > .todo-ledger-project-group-head:first-child {
  border-top: none;
}

.todo-ledger-project-link {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.todo-ledger-project-link:hover {
  text-decoration: underline;
  color: var(--primary);
}

.todo-ledger-project-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Each task row */
.todo-ledger-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background-color 0.15s ease;
  position: relative;
}

.todo-ledger-row:last-child { border-bottom: none; }

.todo-ledger-row:hover {
  background-color: var(--input-focus-light);
}

/* Thin colored stripe on the left of each row matching its priority */
.todo-ledger-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background-color: transparent;
}
.todo-ledger-row.priority-red::before { background-color: var(--accent-red); }
.todo-ledger-row.priority-yellow::before { background-color: var(--accent-gold); }
.todo-ledger-row.priority-green::before { background-color: var(--priority-low); }
.todo-ledger-row.priority-none::before { background-color: var(--border); }

.todo-ledger-row .todo-item-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.todo-ledger-row .todo-item-text {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--text-main);
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

/* Priority chips quiet until row hover */
.todo-ledger-row .task-priority-selectors {
  display: flex;
  gap: 4px;
  opacity: 0.35;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.todo-ledger-row:hover .task-priority-selectors,
.todo-ledger-row .task-priority-selectors:hover,
.todo-ledger-row .task-priority-selectors:focus-within {
  opacity: 1;
}

/* Currently-set priority chip stays bright even at rest */
.todo-ledger-row .priority-selector-btn.active { opacity: 1; }

.todo-ledger-row .delete-todo-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.todo-ledger-row:hover .delete-todo-btn { opacity: 0.7; }
.todo-ledger-row .delete-todo-btn:hover { opacity: 1; color: var(--accent-red); }

/* Mobile: tighten and reflow */
@media (max-width: 640px) {
  .todo-ledger-section-header { padding: 12px 14px; font-size: 11px; }
  .todo-ledger-project-group-head { padding: 8px 14px; flex-wrap: wrap; gap: 6px; }
  .todo-ledger-project-link { font-size: 13px; }
  .todo-ledger-row { padding: 10px 14px; gap: 8px; }
  .todo-ledger-row .todo-item-text { font-size: 13px; }
  .todo-ledger-row .task-priority-selectors { opacity: 1; }
  .todo-ledger-row .delete-todo-btn { opacity: 0.5; }
}

/* Premium Glassmorphism Lock Screen */
.auth-lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(26, 36, 30, 0.6); /* Warm dark tint */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 99999; /* Higher than everything including slide drawers */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), visibility 0.4s;
}

body.dark-theme .auth-lock-overlay {
  background-color: rgba(6, 18, 15, 0.7);
}

.auth-lock-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-lock-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: lockCardEntrance 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes lockCardEntrance {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-logo-circle {
  width: 48px;
  height: 48px;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  background-color: var(--bg);
}

body.dark-theme .auth-logo-circle {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.auth-lock-card h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 8px;
}

.auth-lock-card p {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 28px;
}

.auth-input-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-input-group input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background-color: var(--bg);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  text-align: center;
  transition: var(--transition-smooth);
}

.auth-input-group input:focus {
  outline: none;
  border-color: var(--input-focus);
  background-color: var(--card-bg);
}

.auth-input-group button {
  width: 100%;
  height: 44px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-error-msg {
  color: var(--accent-red);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 16px;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.auth-error-msg.show {
  opacity: 1;
  height: auto;
  margin-bottom: 16px;
}

.auth-lock-footer {
  width: 100%;
  border-top: 1px dashed var(--border-light);
  padding-top: 20px;
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#auth-toggle-show {
  transition: var(--transition-smooth);
}

#auth-toggle-show:hover {
  background-color: var(--bg) !important;
  color: var(--text-main) !important;
  border-color: var(--text-muted) !important;
}

body.dark-theme #auth-toggle-show:hover {
  background-color: rgba(255, 255, 255, 0.04) !important;
  color: var(--accent-gold) !important;
  border-color: var(--accent-gold) !important;
}

/* ──────────────────────────────────────────────────────────────────────────
   Guest Mode — read-only restrictions for users who unlocked with "guest".
   Buttons that create/edit/delete are hidden; form inputs in the drawer
   become read-only. Settings → Change User is left open so a guest can
   come back to the user-select if needed.
   ────────────────────────────────────────────────────────────────────── */
body.is-guest #add-project-btn,
body.is-guest #my-list-btn,
body.is-guest #shared-list-btn,
body.is-guest .delete-project-btn,
body.is-guest #log-visit-btn,
body.is-guest #add-todo-btn,
body.is-guest #add-note-btn,
body.is-guest #reset-active-btn,
body.is-guest #export-settings-btn,
body.is-guest #import-settings-btn,
body.is-guest .drawer-priority-selector,
body.is-guest .add-todo-inline,
body.is-guest .note-logging-card,
body.is-guest .visit-logging-card,
body.is-guest .drawer-danger-zone,
body.is-guest .list-item-archive,
body.is-guest .list-item-delete,
body.is-guest .archive-note-actions,
body.is-guest .list-item-priority,
body.is-guest .task-priority-selectors,
body.is-guest .delete-todo-btn {
  display: none !important;
}

/* Disable typing in the drawer for guests — they can read but not edit */
body.is-guest #drawer-project-form input,
body.is-guest #drawer-project-form select,
body.is-guest #drawer-project-form textarea {
  pointer-events: none;
  background-color: var(--border-light);
  opacity: 0.85;
}

body.is-guest .todo-ledger-row .todo-item-checkbox,
body.is-guest .drawer-todo-list input[type="checkbox"] {
  pointer-events: none;
  opacity: 0.5;
}

/* Guest-mode pill in the sidebar badge */
body.is-guest #sidebar-user-badge::after {
  content: 'GUEST MODE';
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bg-sidebar);
  background-color: var(--accent-gold);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
}

body.is-guest #sidebar-user-badge { position: relative; }

/* ──────────────────────────────────────────────────────────────────────────
   Driver.js Tutorial — match warm sand / drafting-charcoal aesthetic
   (!important used because Driver.js ships its own font-family rules)
   ────────────────────────────────────────────────────────────────────── */
.driver-popover.whiteboard-tour,
.driver-popover {
  background-color: var(--bg-sidebar) !important;
  color: var(--sidebar-text) !important;
  border: 1px solid rgba(229, 222, 201, 0.12) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-sans) !important;
  max-width: 360px;
  padding: 18px 18px 14px 18px;
}

.driver-popover-title,
.driver-popover .driver-popover-title {
  font-family: var(--font-serif) !important;
  font-size: 19px !important;
  font-weight: 600 !important;
  color: var(--sidebar-text) !important;
  letter-spacing: -0.01em !important;
  margin-bottom: 6px !important;
  line-height: 1.25 !important;
}

.driver-popover-description,
.driver-popover .driver-popover-description {
  font-family: var(--font-sans) !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--sidebar-text) !important;
  opacity: 0.85 !important;
  line-height: 1.55 !important;
  letter-spacing: -0.005em !important;
}

.driver-popover-progress-text,
.driver-popover .driver-popover-progress-text {
  font-family: var(--font-mono) !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  color: var(--sidebar-text-muted) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.12em !important;
}

.driver-popover-footer {
  margin-top: 14px;
  gap: 6px;
}

.driver-popover-footer button.driver-popover-prev-btn,
.driver-popover-footer button.driver-popover-next-btn,
.driver-popover-footer button.driver-popover-close-btn {
  font-family: var(--font-mono) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  padding: 8px 14px !important;
  border-radius: var(--radius-sm) !important;
  text-shadow: none !important;
  transition: var(--transition-smooth) !important;
}

.driver-popover-footer button.driver-popover-prev-btn {
  background-color: transparent;
  color: var(--sidebar-text-muted);
  border: 1px solid rgba(229, 222, 201, 0.15);
}

.driver-popover-footer button.driver-popover-prev-btn:hover {
  background-color: rgba(229, 222, 201, 0.04);
  color: var(--sidebar-text);
  border-color: rgba(229, 222, 201, 0.35);
}

.driver-popover-footer button.driver-popover-next-btn {
  background-color: var(--sidebar-text);
  color: var(--bg-sidebar);
  border: 1px solid var(--sidebar-text);
}

.driver-popover-footer button.driver-popover-next-btn:hover {
  background-color: #FFFFFF;
  border-color: #FFFFFF;
  color: var(--bg-sidebar);
}

.driver-popover-close-btn {
  color: var(--sidebar-text-muted) !important;
  font-size: 18px !important;
  font-weight: 400 !important;
  background: transparent !important;
  top: 8px !important;
  right: 10px !important;
  padding: 2px 6px !important;
  border: none !important;
}

.driver-popover-close-btn:hover {
  color: var(--sidebar-text) !important;
}

/* Spotlight arrow tints */
.driver-popover-arrow-side-left.driver-popover-arrow { border-left-color: var(--bg-sidebar); }
.driver-popover-arrow-side-right.driver-popover-arrow { border-right-color: var(--bg-sidebar); }
.driver-popover-arrow-side-top.driver-popover-arrow { border-top-color: var(--bg-sidebar); }
.driver-popover-arrow-side-bottom.driver-popover-arrow { border-bottom-color: var(--bg-sidebar); }

/* Dim overlay slightly warmer to match the paper background */
.driver-overlay {
  fill: #0F1311;
}

body.dark-theme .driver-popover {
  background-color: #00120D;
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .driver-popover-arrow-side-left.driver-popover-arrow { border-left-color: #00120D; }
body.dark-theme .driver-popover-arrow-side-right.driver-popover-arrow { border-right-color: #00120D; }
body.dark-theme .driver-popover-arrow-side-top.driver-popover-arrow { border-top-color: #00120D; }
body.dark-theme .driver-popover-arrow-side-bottom.driver-popover-arrow { border-bottom-color: #00120D; }

/* ──────────────────────────────────────────────────────────────────────────
   "Who is signing in?" — user select step on the auth lock screen
   ────────────────────────────────────────────────────────────────────── */
.auth-user-select-card {
  width: 460px;
  max-width: 96vw;
}

.user-select-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 14px;
}

.user-card-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 3px;
  width: 100%;
  padding: 14px 16px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  outline: none;
  font-family: inherit;
}

.user-card-btn:hover {
  border-color: var(--primary);
  border-left-color: var(--primary);
  background-color: var(--card-bg);
  transform: translateX(2px);
}

.user-card-btn:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--input-focus-light);
}

.user-card-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.005em;
}

.user-card-subtitle {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.user-card-other {
  border-style: dashed;
}

.user-card-other .user-card-name { color: var(--text-muted); }

/* Currently signed-in user gets a highlighted left rail + "CURRENT" pill */
.user-card-btn.current-user {
  border-color: var(--primary);
  border-left-color: var(--primary);
  background-color: var(--input-focus-light);
}

.user-card-btn.current-user::after {
  content: 'CURRENT';
  position: absolute;
  top: 10px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #FFFFFF;
  background-color: var(--primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.user-card-btn { position: relative; }

/* Close button on the user-select card (shown only when invoked from Change User) */
.user-select-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.user-select-close-btn:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

.auth-user-select-card { position: relative; }

.user-other-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
  margin-bottom: 14px;
}

.user-other-inputs input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  outline: none;
  transition: var(--transition-smooth);
}

.user-other-inputs input:focus {
  border-color: var(--input-focus);
}

/* ──────────────────────────────────────────────────────────────────────────
   "My List" + "Shared List" header buttons (with count badges)
   ────────────────────────────────────────────────────────────────────── */
.list-btn-with-badge {
  position: relative;
  width: auto;
  padding: 0 14px;
  gap: 6px;
  white-space: nowrap;
}

.list-btn-with-badge svg { flex-shrink: 0; }

.list-count-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background-color: var(--primary);
  color: #fff;
  border-radius: 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  border: 1.5px solid var(--card-bg);
}

/* ──────────────────────────────────────────────────────────────────────────
   Personal + Shared list dialogs
   ────────────────────────────────────────────────────────────────────── */
.list-dialog {
  width: 540px;
  max-width: 92vw;
}

.list-dialog .add-todo-inline {
  display: flex;
  gap: 6px;
}

.list-dialog .add-todo-inline input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
}

.list-dialog .add-todo-inline input:focus { border-color: var(--input-focus); }

.list-dialog .add-inline-btn {
  padding: 0 16px;
  height: 38px;
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.list-dialog .add-inline-btn:hover { background-color: var(--primary-hover); }

.list-dialog .list-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}

/* Single shared "li" style for both My List and Shared List */
.list-dialog .list-items li.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}

.list-dialog .list-items li.list-item:hover {
  border-color: var(--border);
}

.list-dialog .list-items li.list-item[data-priority="high"] { border-left-color: var(--accent-red); }
.list-dialog .list-items li.list-item[data-priority="medium"] { border-left-color: var(--accent-gold); }
.list-dialog .list-items li.list-item[data-priority="low"] { border-left-color: var(--priority-low); }
.list-dialog .list-items li.list-item[data-priority="standby"] { border-left-color: var(--text-muted); }

.list-dialog .list-items li.list-item.completed {
  opacity: 0.55;
}

.list-dialog .list-items li.list-item.completed .list-item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.list-dialog .list-items li.list-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.list-dialog .list-items li.list-item .list-item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.list-dialog .list-items li.list-item .list-item-text {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.4;
}

.list-dialog .list-items li.list-item .list-item-meta {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Inline priority dot picker */
.list-item-priority {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.list-item-priority .prio-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  background-color: transparent;
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: var(--transition-smooth);
}

.list-item-priority .prio-dot.standby { background-color: var(--text-muted); }
.list-item-priority .prio-dot.low { background-color: var(--priority-low); }
.list-item-priority .prio-dot.medium { background-color: var(--accent-gold); }
.list-item-priority .prio-dot.high { background-color: var(--accent-red); }

.list-item-priority .prio-dot:hover {
  transform: scale(1.2);
}

.list-item-priority .prio-dot.selected {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 3.5px currentColor;
}

.list-item-priority .prio-dot.standby.selected { color: var(--text-muted); }
.list-item-priority .prio-dot.low.selected { color: var(--priority-low); }
.list-item-priority .prio-dot.medium.selected { color: var(--accent-gold); }
.list-item-priority .prio-dot.high.selected { color: var(--accent-red); }

.list-dialog .list-items li.list-item .list-item-delete,
.list-dialog .list-items li.list-item .list-item-archive,
.list-dialog .list-items li.list-item .list-item-restore {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: var(--transition-smooth);
  padding: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.list-dialog .list-items li.list-item:hover .list-item-delete,
.list-dialog .list-items li.list-item:hover .list-item-archive,
.list-dialog .list-items li.list-item:hover .list-item-restore { opacity: 1; }

.list-dialog .list-items li.list-item .list-item-delete:hover { color: var(--accent-red); }
.list-dialog .list-items li.list-item .list-item-archive:hover { color: var(--accent-gold); }
.list-dialog .list-items li.list-item .list-item-restore:hover { color: var(--primary); }

/* ──────────────────────────────────────────────────────────────────────────
   Archive dialog (aggregated archived items across the app)
   ────────────────────────────────────────────────────────────────────── */
.archive-dialog {
  width: 600px;
  max-width: 92vw;
}

.archive-tabs {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 14px;
  padding-bottom: 4px;
}

.archive-tab {
  background: none;
  border: none;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.archive-tab:hover { color: var(--text-main); }

.archive-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.archive-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  background-color: var(--border-light);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.archive-tab.active .archive-count {
  background-color: var(--primary);
  color: #fff;
}

.archive-body {
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.archive-empty {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.archive-note-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  position: relative;
}

.archive-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.archive-note-header .archive-project-tag {
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.archive-note-text {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.archive-dates {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.archive-dates strong {
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
}

.archive-note-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.archive-note-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.archive-note-actions button:hover { color: var(--text-main); border-color: var(--text-muted); }
.archive-note-actions .archive-restore-btn:hover { color: var(--primary); border-color: var(--primary); }
.archive-note-actions .archive-delete-btn:hover { color: var(--accent-red); border-color: var(--accent-red); }

/* ──────────────────────────────────────────────────────────────────────────
   Palette swatches in Settings
   ────────────────────────────────────────────────────────────────────── */
.palette-system-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.palette-system-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-main);
  outline: none;
  transition: var(--transition-smooth);
}

.palette-system-toggle:hover { color: var(--primary); }

.palette-system-toggle .palette-system-toggle-label { flex: 1; text-align: left; }

.palette-system-toggle-state {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--border-light);
  color: var(--text-muted);
}

.palette-system-row.is-on .palette-system-toggle-state {
  background-color: var(--primary);
  color: #fff;
}

.palette-system-mappers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.palette-system-row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-main);
}

.palette-system-label {
  flex: 0 0 140px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.palette-system-row-item select {
  flex: 1;
  height: 32px;
  padding: 0 8px;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.palette-system-row-item select:focus { border-color: var(--input-focus); }

/* When system mode is on, dim the manual swatches to signal they're inactive */
.palette-system-row.is-on ~ .palette-grid .palette-swatch {
  opacity: 0.5;
}

@media (max-width: 540px) {
  .palette-system-row-item { flex-wrap: wrap; }
  .palette-system-label { flex: 1 1 100%; }
  .palette-system-row-item select { flex: 1 1 100%; }
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 540px) {
  .palette-grid { grid-template-columns: repeat(2, 1fr); }
}

.palette-swatch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  outline: none;
  font-family: inherit;
}

.palette-swatch:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.palette-swatch.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--input-focus-light);
}

.palette-preview {
  position: relative;
  display: block;
  width: 100%;
  height: 46px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.palette-preview .palette-bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 26%;
}

.palette-preview .palette-card {
  position: absolute;
  top: 8px;
  left: calc(26% + 8px);
  right: 8px;
  bottom: 8px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.06);
}

.palette-preview-default { background-color: #FAF8F5; }
.palette-preview-default .palette-bar { background-color: #0F1311; }
.palette-preview-default .palette-card { background-color: #FFFFFF; }

.palette-preview-dark { background-color: #064D44; }
.palette-preview-dark .palette-bar { background-color: #00120D; }
.palette-preview-dark .palette-card { background-color: #0E1210; }

.palette-preview-blueprint { background-color: #EEF3F8; }
.palette-preview-blueprint .palette-bar { background-color: #0E2030; }
.palette-preview-blueprint .palette-card { background-color: #FFFFFF; }

.palette-preview-onyx { background-color: #0F0F11; }
.palette-preview-onyx .palette-bar { background-color: #050507; }
.palette-preview-onyx .palette-card { background-color: #16161A; }

.palette-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-main);
  text-align: center;
}

/* Note author signature (rendered at the bottom of each journal entry) */
.note-author-stamp {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
  letter-spacing: 0.01em;
}
