/* ===================================================================
   FORGESTAR OS — Design system (Apple-aesthetic, dark mode)
   =================================================================== */

:root {
  /* Surfaces — light glassy grey */
  --bg: #E8E9EE;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-elev: rgba(255, 255, 255, 0.86);
  --surface-translucent: rgba(255, 255, 255, 0.58);
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.78);

  /* Text */
  --text: #14141B;
  --text-secondary: #4A4A55;
  --text-tertiary: #8C8C96;

  /* Borders */
  --border: rgba(20, 20, 27, 0.07);
  --border-strong: rgba(20, 20, 27, 0.13);
  --border-glow: rgba(255, 255, 255, 0.6);

  /* Accent (single accent — Forgestar ember) */
  --accent: #E8632B;
  --accent-soft: rgba(232, 99, 43, 0.10);
  --accent-strong: #C8531F;

  /* Tile accents (rotating gradient hues for the brief) */
  --hue-ember:  232, 99, 43;
  --hue-iris:   124, 99, 230;
  --hue-jade:   46, 175, 139;
  --hue-azure:  72, 142, 230;

  /* Semantic */
  --success: #1A9D4F;
  --warning: #D58400;
  --danger: #D8362F;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 20, 30, 0.07);
  --shadow-lg: 0 24px 60px rgba(20, 20, 30, 0.12);
  --shadow-glow: 0 0 0 1px rgba(20, 20, 30, 0.05), 0 24px 48px -12px rgba(20, 20, 30, 0.10);

  /* Layout */
  --sidebar-w: 240px;
  --inspector-w: 320px;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Menlo', 'Monaco', monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 8% 0%, rgba(232, 99, 43, 0.16), transparent 60%),
    radial-gradient(800px 600px at 92% 0%, rgba(124, 99, 230, 0.14), transparent 65%),
    radial-gradient(900px 700px at 50% 100%, rgba(72, 142, 230, 0.12), transparent 60%),
    radial-gradient(700px 500px at 95% 100%, rgba(46, 175, 139, 0.10), transparent 65%);
  filter: saturate(115%);
}

a { color: inherit; text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ===================================================================
   APP SHELL
   =================================================================== */

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

/* ===================================================================
   SIDEBAR
   =================================================================== */

.sidebar {
  background: var(--glass-strong);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 24px;
}
.sb-mark {
  width: 22px;
  height: 22px;
  background:
    linear-gradient(135deg, var(--accent), #FFB87A);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M50 8 L62 38 L94 42 L70 64 L78 96 L50 78 L22 96 L30 64 L6 42 L38 38 Z'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M50 8 L62 38 L94 42 L70 64 L78 96 L50 78 L22 96 L30 64 L6 42 L38 38 Z'/></svg>") center/contain no-repeat;
  flex-shrink: 0;
}
.sb-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

.sb-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sb-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: 4px 12px 6px;
  text-transform: uppercase;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 120ms ease-out, color 120ms ease-out;
  position: relative;
}
.sb-item:hover {
  background: rgba(20, 20, 30, 0.04);
  color: var(--text);
}
.sb-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.sb-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sb-icon {
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-tertiary);
  opacity: 0.85;
}

.sb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 4px;
}
.sb-dot.status-live { background: var(--success); box-shadow: 0 0 6px rgba(48, 209, 88, 0.6); }
.sb-dot.status-idle { background: var(--text-tertiary); }
.sb-dot.status-warn { background: var(--warning); }

.sb-pill {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
}
.sb-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sb-foot {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-newthread {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 8px);
  padding: 9px 12px;
  margin: 4px 4px 8px 4px;
  background: rgba(20, 20, 30, 0.07);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms ease-out, transform 120ms ease-out, border-color 120ms ease-out;
}
.sb-newthread:hover {
  background: rgba(20, 20, 30, 0.11);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.sb-newthread-icon {
  font-size: 13px;
  color: var(--text-secondary);
}

.sb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 8px);
  margin: 0 4px 12px 4px;
  padding: 8px 12px;
  background: rgba(20, 20, 30, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms ease-out;
}
.sb-search:hover { background: rgba(20, 20, 30, 0.07); color: var(--text-secondary); }
.sb-search-icon { font-size: 13px; }
.sb-search-label { flex: 1; text-align: left; }
.sb-search-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  background: rgba(20, 20, 30, 0.06);
  border-radius: 3px;
  color: var(--text-tertiary);
}

.sb-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 4px 10px;
}
.sb-section-btn {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.sb-section-btn:hover {
  background: rgba(20, 20, 30, 0.06);
  color: var(--text-secondary);
}

.sb-agent-list,
.sb-thread-list,
.sb-project-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-agent-item,
.sb-thread-item,
.sb-project-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  width: 100%;
  position: relative;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.sb-agent-item:hover,
.sb-thread-item:hover,
.sb-project-item:hover {
  background: rgba(20, 20, 30, 0.05);
  color: var(--text);
}
.sb-agent-item.active,
.sb-thread-item.active,
.sb-project-item.active {
  background: rgba(20, 20, 30, 0.06);
  color: var(--text);
}

.sb-agent-chip {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(var(--chip-hue, var(--hue-ember)), 0.85), rgba(var(--chip-hue, var(--hue-ember)), 0.55));
  color: white;
}

.sb-thread-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-tertiary);
}
.sb-thread-status.active {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(26, 157, 79, 0.18);
  animation: thread-pulse 1.6s ease-in-out infinite;
}
.sb-thread-status.complete { background: var(--text-tertiary); }
@keyframes thread-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.sb-thread-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sb-thread-title {
  font-size: 12.5px;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-thread-sub {
  font-size: 10.5px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-loading,
.sb-empty {
  font-size: 11.5px;
  color: var(--text-tertiary);
  padding: 6px 12px;
}

.sb-cmdk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(20, 20, 30, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  transition: background 120ms ease-out;
}
.sb-cmdk:hover { background: rgba(20, 20, 30, 0.06); }

.sb-poweredby {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px 4px;
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: opacity 150ms ease-out;
}
.sb-poweredby:hover { opacity: 0.85; }
.sb-poweredby svg { display: block; flex-shrink: 0; }
.sb-poweredby .tk-name {
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: -0.005em;
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(20, 20, 30, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ===================================================================
   MAIN CONTENT
   =================================================================== */

.main {
  overflow-y: auto;
  padding: 0;
  height: 100vh;
}

.view {
  max-width: 920px;
  padding: 40px 48px 80px;
  margin: 0 auto;
}

.view-header {
  margin-bottom: 32px;
}
.view-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 4px;
}
.view-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.section-heading {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 32px 0 12px;
}

/* ===================================================================
   CARDS
   =================================================================== */

.card {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: background 150ms ease-out, transform 150ms ease-out, border-color 150ms ease-out, box-shadow 150ms ease-out;
  box-shadow: var(--shadow-sm);
}
.card.interactive {
  cursor: pointer;
}
.card.interactive:hover {
  background: var(--glass-strong);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.card-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

/* ===================================================================
   BUTTONS
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: all 150ms ease-out;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}
.btn-secondary {
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--surface-elev);
  border-color: rgba(20, 20, 30, 0.16);
}
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(20, 20, 30, 0.04); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ===================================================================
   INPUTS
   =================================================================== */

.input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 120ms ease-out, background 120ms ease-out;
  outline: none;
}
.input:focus {
  border-color: var(--accent);
}
.input::placeholder { color: var(--text-tertiary); }

textarea.input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  font-family: inherit;
}

/* ===================================================================
   STATUS / METADATA
   =================================================================== */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.status-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(20, 20, 30, 0.06);
  color: var(--text-secondary);
  letter-spacing: 0.005em;
}
.status-pill.live { background: rgba(48, 209, 88, 0.15); color: var(--success); }
.status-pill.warn { background: rgba(255, 159, 10, 0.15); color: var(--warning); }
.status-pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ===================================================================
   AGENT CHAT (used by Methodology agent + others)
   =================================================================== */

.chat {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 100px;
}
.chat-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 720px;
}
.chat-msg .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-elev);
  color: var(--text);
}
.chat-msg.user .avatar { background: var(--accent); color: #fff; }
.chat-msg.bot .avatar { background: linear-gradient(135deg, var(--accent), #FFB87A); color: #fff; }
.chat-msg .body {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  padding-top: 4px;
}
.chat-msg .body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface);
  padding: 2px 5px;
  border-radius: 3px;
}

.chat-input-wrap {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  padding: 32px 0 8px;
  margin-top: 24px;
}
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input-row .input {
  flex: 1;
}

/* ===================================================================
   LIST (used by inbox, audits, etc.)
   =================================================================== */

.list {
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.list-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  transition: background 120ms ease-out;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-elev); }
.list-row .row-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 14px;
  flex-shrink: 0;
}
.list-row .row-main {
  flex: 1;
  min-width: 0;
}
.list-row .row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row .row-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}
.list-row .row-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* ===================================================================
   COMMAND PALETTE
   =================================================================== */

.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
  animation: fadein 150ms ease-out;
}
.cmdk-backdrop[hidden] { display: none; }

.cmdk-panel {
  width: 100%;
  max-width: 560px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cmdkenter 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cmdk-input {
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 16px;
  border-bottom: 1px solid var(--border);
}
.cmdk-input::placeholder { color: var(--text-tertiary); }

.cmdk-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.cmdk-item:hover, .cmdk-item.selected {
  background: var(--accent-soft);
  color: var(--text);
}
.cmdk-item .cmdk-cat {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
}
.cmdk-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.cmdk-foot {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  gap: 12px;
}

@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes cmdkenter {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===================================================================
   DAILY BRIEF
   =================================================================== */

.brief-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.brief-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
@media (max-width: 720px) {
  .brief-stats { grid-template-columns: repeat(2, 1fr); }
}
.brief-stat {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.brief-stat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(var(--tile-hue, var(--hue-ember)), 0.18), transparent 60%);
  pointer-events: none;
}
.brief-stat > * { position: relative; }
.brief-stat:nth-child(1) { --tile-hue: var(--hue-ember); }
.brief-stat:nth-child(2) { --tile-hue: var(--hue-iris); }
.brief-stat:nth-child(3) { --tile-hue: var(--hue-jade); }
.brief-stat:nth-child(4) { --tile-hue: var(--hue-azure); }
.brief-stat.interactive {
  cursor: pointer;
}
.brief-stat.interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.brief-stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}
.brief-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.brief-stat-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}
.brief-stat-skel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 92px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.85; }
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 720px) {
  .brief-grid { grid-template-columns: 1fr; }
}
.brief-section {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.brief-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.brief-section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.brief-section-body {
  flex: 1;
}
.brief-loading,
.brief-empty,
.brief-error {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 8px 0;
}
.brief-empty a {
  color: var(--accent);
  text-decoration: none;
}
.brief-error { color: #FF6B6B; }
.brief-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brief-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  margin: 0 -8px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  width: calc(100% + 16px);
}
.brief-row:hover {
  background: var(--surface-elev);
}
.brief-row-static {
  cursor: default;
}
.brief-row-static:hover {
  background: transparent;
}
.brief-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-tertiary);
}
.brief-row-dot.dot-ok    { background: #4ADE80; }
.brief-row-dot.dot-warn  { background: #FFC857; }
.brief-row-dot.dot-fail  { background: #FF6B6B; }
.brief-row-dot.dot-mute  { background: var(--text-tertiary); }
.brief-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brief-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brief-row-sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brief-row-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.brief-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brief-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 150ms ease-out, transform 120ms ease-out;
}
.brief-action-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.brief-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.brief-action-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.brief-action-sub {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ===================================================================
   CUSTOMERS
   =================================================================== */

.customers-search {
  width: 240px;
}
.customers-search input {
  width: 100%;
}

.customers-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 720px) {
  .customers-stats { grid-template-columns: repeat(2, 1fr); }
}

.customers-list {
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.customer-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease-out;
}
.customer-row:last-child { border-bottom: 0; }
.customer-row:hover {
  background: rgba(20, 20, 30, 0.04);
}

.customer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(var(--hue-iris), 0.85), rgba(var(--hue-azure), 0.65));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.customer-main {
  flex: 1;
  min-width: 0;
}
.customer-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.customer-star { color: var(--accent); font-size: 11px; }
.customer-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.customer-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.customer-count {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(20, 20, 30, 0.05);
  color: var(--text-secondary);
}
.customer-count.audit {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.customer-count.revenue {
  background: rgba(46, 175, 139, 0.14);
  color: var(--success);
  font-weight: 600;
}

.customer-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  width: 70px;
  text-align: right;
  flex-shrink: 0;
}

.customer-notes {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.customer-notes-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}
.customer-notes-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}

.customer-tl {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tl-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(20, 20, 30, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.tl-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.tl-audit .tl-icon { background: var(--accent-soft); color: var(--accent); }
.tl-sent .tl-icon  { background: rgba(46, 175, 139, 0.14); color: var(--success); }
.tl-inbox .tl-icon { background: rgba(72, 142, 230, 0.14); color: #2A5FA0; }
.tl-main {
  flex: 1;
  min-width: 0;
}
.tl-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.tl-time {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* ===================================================================
   PIPELINE — FANTASY MAP
   =================================================================== */

.pipeline-view {
  max-width: none;
  padding: 32px 40px 56px;
  margin: 0;
  width: 100%;
  position: relative;
}
@media (max-width: 720px) {
  .pipeline-view { padding: 24px 20px 40px; }
}

.pipeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding: 0 8px;
}
.pipeline-title {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 4px 0;
}
.pipeline-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.quest-region {
  width: 100%;
}

.quest-canvas {
  position: relative;
  width: 100%;
  border-radius: 24px;
  background: var(--glass-strong);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  padding: 60px 40px 60px;
}
.quest-canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 8% 10%, rgba(var(--hue-iris), 0.12), transparent 60%),
    radial-gradient(800px 500px at 95% 90%, rgba(var(--hue-ember), 0.10), transparent 60%),
    radial-gradient(700px 400px at 50% 50%, rgba(var(--hue-azure), 0.06), transparent 70%);
}
.quest-canvas > * { position: relative; }

.quest-empty {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.quest-empty-content {
  text-align: center;
  max-width: 460px;
}
.quest-empty-icon {
  font-size: 36px;
  color: var(--accent);
  margin-bottom: 14px;
}
.quest-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.quest-empty-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.quest-track-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* The track line */
.quest-track-line {
  fill: none;
  stroke: url(#track-grad);
  stroke-width: 4;
  stroke-linecap: round;
}
.quest-track-shadow {
  fill: none;
  stroke: url(#track-shadow-grad);
  stroke-width: 14;
  stroke-linecap: round;
  filter: blur(8px);
}

/* Stations */
.quest-station { cursor: pointer; }

.quest-station .station-glow {
  fill: rgba(var(--station-hue, var(--hue-ember)), 0.18);
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.quest-station:hover .station-glow { opacity: 1; }
.quest-station.occupied .station-glow {
  opacity: 1;
  animation: station-pulse 2.4s ease-in-out infinite;
}
@keyframes station-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.12); }
}

.quest-station .station-outer {
  fill: white;
  stroke: rgba(var(--station-hue, var(--hue-ember)), 0.5);
  stroke-width: 2;
  filter: drop-shadow(0 6px 12px rgba(20, 20, 30, 0.06));
}
.quest-station.occupied .station-outer {
  stroke: rgb(var(--station-hue, var(--hue-ember)));
  stroke-width: 2.5;
}
.quest-station .station-inner {
  fill: rgba(var(--station-hue, var(--hue-ember)), 0.15);
}
.quest-station.occupied .station-inner {
  fill: rgb(var(--station-hue, var(--hue-ember)));
}
.quest-station .station-num {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  fill: rgb(var(--station-hue, var(--hue-ember)));
}
.quest-station.occupied .station-num {
  fill: white;
}

.quest-station .station-name {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  fill: var(--text);
  letter-spacing: -0.005em;
}
.quest-station .station-tag {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 11px;
  fill: var(--text-tertiary);
  font-weight: 500;
}

.quest-station .station-avatar-bg {
  fill: rgb(var(--station-hue, var(--hue-ember)));
  stroke: white;
  stroke-width: 2;
  filter: drop-shadow(0 2px 4px rgba(20, 20, 30, 0.18));
}
.quest-station .station-avatar-bg.more {
  fill: var(--text);
}
.quest-station .station-avatar-text {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  fill: white;
}

.quest-station .station-hit {
  fill: transparent;
  pointer-events: all;
}

.quest-trophy {
  background: linear-gradient(135deg, rgba(232, 180, 82, 0.22), rgba(200, 130, 40, 0.22));
  border: 1px solid rgba(160, 122, 48, 0.45);
  color: #5C4527;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
}

/* ===== Upsell map (per-customer drawer) ===== */
.upsell-section {
  margin-bottom: 24px;
}
.upsell-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.upsell-minitrack {
  width: 100%;
  height: 80px;
  display: block;
}
.upsell-track-line {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 2;
  stroke-linecap: round;
}
.upsell-station-bg {
  fill: white;
  stroke: var(--border-strong);
  stroke-width: 2;
}
.upsell-station.done .upsell-station-bg {
  fill: var(--accent);
  stroke: var(--accent-strong);
}
.upsell-station.current .upsell-station-bg {
  fill: white;
  stroke: var(--accent);
  stroke-width: 3;
}
.upsell-station-pulse {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  opacity: 0.4;
  animation: upsell-pulse 1.6s ease-out infinite;
}
@keyframes upsell-pulse {
  0%   { r: 9;  stroke-opacity: 0.6; }
  100% { r: 18; stroke-opacity: 0;   }
}
.upsell-station-mark {
  font-size: 10px;
  font-weight: 700;
  fill: white;
}
.upsell-station-label {
  font-size: 9.5px;
  font-weight: 500;
  fill: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.upsell-station.current .upsell-station-label,
.upsell-station.done .upsell-station-label {
  fill: var(--text);
}

.upsell-branches {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upsell-branch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all 150ms ease-out;
}
.upsell-branch:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.85);
  transform: translateX(2px);
}
.upsell-branch-primary {
  border-color: rgba(232, 99, 43, 0.30);
  background: linear-gradient(135deg, rgba(232, 99, 43, 0.07), rgba(232, 99, 43, 0.02));
}
.upsell-branch-primary:hover {
  border-color: var(--accent);
}
.upsell-branch-gold {
  border-color: rgba(160, 122, 48, 0.30);
  background: linear-gradient(135deg, rgba(232, 180, 82, 0.10), rgba(232, 180, 82, 0.02));
}
.upsell-branch-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(20, 20, 30, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.upsell-branch-primary .upsell-branch-icon {
  background: var(--accent-soft);
  color: var(--accent);
}
.upsell-branch-gold .upsell-branch-icon {
  background: rgba(232, 180, 82, 0.18);
  color: #8B5A1C;
}
.upsell-branch-main {
  flex: 1;
  min-width: 0;
}
.upsell-branch-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.upsell-branch-sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.upsell-branch-arrow {
  font-size: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.upsell-branch:hover .upsell-branch-arrow { color: var(--accent); }

.pipeline-totals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pipeline-pill {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20, 20, 30, 0.05);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: inherit;
}
.pipeline-pill strong {
  color: var(--text);
  font-weight: 600;
  margin-right: 4px;
}
.pipeline-pill.champion {
  background: linear-gradient(135deg, rgba(232, 180, 82, 0.20), rgba(200, 130, 40, 0.20));
  border-color: rgba(160, 122, 48, 0.45);
  color: #6E5331;
}
.pipeline-pill.champion strong { color: #5C4527; }

.forgequest-eyebrow {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #C8531F;
  font-weight: 700;
  margin-bottom: 6px;
}
.forgequest-title {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif !important;
  letter-spacing: -0.005em;
}

.map-row.has-won {
  background: linear-gradient(135deg, rgba(255, 235, 180, 0.65), rgba(232, 180, 82, 0.30));
  border-color: rgba(160, 122, 48, 0.40);
  box-shadow: 0 0 0 1px rgba(232, 180, 82, 0.30) inset, var(--shadow-sm);
}
.map-row-crown {
  font-size: 12px;
  margin-left: 4px;
  filter: drop-shadow(0 1px 2px rgba(120, 80, 30, 0.4));
}
.map-row-victory {
  margin-top: 4px;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  color: #8B5A1C;
  letter-spacing: 0.05em;
}

.map-region { margin-top: 8px; }

.map-parchment {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--glass-strong);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  box-shadow: var(--shadow-md);
  padding: 32px 24px 28px 24px;
}
.map-parchment::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(800px 500px at 12% 12%, rgba(var(--hue-iris), 0.10), transparent 60%),
    radial-gradient(800px 500px at 88% 88%, rgba(var(--hue-jade), 0.10), transparent 60%),
    radial-gradient(700px 400px at 50% 50%, rgba(var(--hue-azure), 0.06), transparent 70%);
}

.map-decor {
  position: absolute;
  pointer-events: none;
  opacity: 0.18;
}
.map-decor-mountain {
  top: 12px;
  right: 24px;
  width: 110px;
  height: 60px;
  background:
    linear-gradient(160deg, transparent 50%, #5C4527 50.5%, #5C4527 60%, transparent 60.5%) 0 0 / 60px 60px no-repeat,
    linear-gradient(160deg, transparent 50%, #6E5331 50.5%, #6E5331 62%, transparent 62.5%) 38px 0 / 70px 60px no-repeat;
}
.map-decor-trees {
  bottom: 10px;
  left: 16px;
  width: 140px;
  height: 32px;
  background:
    radial-gradient(circle at 12px 16px, #527245 8px, transparent 9px),
    radial-gradient(circle at 32px 12px, #4F6E42 10px, transparent 11px),
    radial-gradient(circle at 56px 18px, #527245 7px, transparent 8px),
    radial-gradient(circle at 80px 14px, #4F6E42 9px, transparent 10px),
    radial-gradient(circle at 110px 16px, #527245 8px, transparent 9px);
}
.map-decor-compass {
  top: 18px;
  left: 22px;
  width: 64px;
  height: 64px;
  opacity: 0.34;
}
.map-compass-rose {
  position: relative;
  width: 100%;
  height: 100%;
  border: 2px solid #6E5331;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, transparent 60%, rgba(110, 83, 49, 0.18) 100%);
}
.map-compass-rose > div {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  color: #5C4527;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
}
.map-compass-n { top: 2px; left: 50%; transform: translateX(-50%); }
.map-compass-s { bottom: 2px; left: 50%; transform: translateX(-50%); }
.map-compass-e { right: 4px; top: 50%; transform: translateY(-50%); }
.map-compass-w { left: 4px; top: 50%; transform: translateY(-50%); }
.map-compass-needle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 36px;
  margin-top: -18px;
  margin-left: -1px;
  background: linear-gradient(to bottom, #B33A20 0%, #B33A20 50%, #5C4527 50%, #5C4527 100%);
  border-radius: 2px;
  transform-origin: 50% 50%;
  animation: compass-spin 12s linear infinite;
}
@keyframes compass-spin {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(8deg); }
}

.adventure-map {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

/* Coastline (the realm outline) */
.coast-line {
  fill: rgba(255, 255, 255, 0.55);
  stroke: rgba(20, 20, 30, 0.18);
  stroke-width: 1;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 2 4;
}
.coast-line-shadow {
  fill: none;
  stroke: rgba(20, 20, 30, 0.06);
  stroke-width: 6;
  filter: blur(3px);
}

/* The dashed quest route between landmarks */
.quest-route {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 4 6;
  stroke-linecap: round;
  opacity: 0.55;
}

/* Modern outline-style fills for every landmark drawing */
.ink {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ink-fill {
  fill: rgba(255, 255, 255, 0.95);
  stroke: var(--text);
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.ink-fill-bg {
  fill: var(--text);
}
.ink-fill-window {
  fill: var(--accent);
  stroke: var(--text);
  stroke-width: 1.1;
}
.ink-fill-flag {
  fill: var(--accent);
  stroke: var(--text);
  stroke-width: 1;
}
.ink-fill-yellow {
  fill: var(--accent);
  stroke: var(--text);
  stroke-width: 1;
}
.ink-fill-flame {
  fill: var(--accent);
  stroke: var(--text);
  stroke-width: 1;
}
.ink-fill-sail {
  fill: rgba(255, 255, 255, 0.95);
  stroke: var(--text);
  stroke-width: 1.3;
}
.ink-fill-snow {
  fill: rgba(255, 255, 255, 0.95);
  stroke: var(--text);
  stroke-width: 1.1;
}
.ink-fill-gold {
  fill: var(--accent);
  stroke: var(--text);
  stroke-width: 1.5;
}
.ink-fill-gem {
  fill: white;
  stroke: var(--text);
  stroke-width: 0.8;
}
.ink-smoke {
  fill: none;
  stroke: var(--text-tertiary);
  stroke-width: 1.1;
  stroke-linecap: round;
  opacity: 0.6;
}

/* Landmark groups */
.landmark {
  cursor: pointer;
  transition: transform 220ms ease-out;
}
.landmark:hover {
  transform: translate(var(--lx, 0), var(--ly, 0)) scale(1.06);
}
.landmark-hit {
  fill: transparent;
  pointer-events: all;
}
.landmark.empty .ink-fill,
.landmark.empty .ink-fill-bg,
.landmark.empty .ink-fill-window,
.landmark.empty .ink-fill-flag,
.landmark.empty .ink-fill-yellow,
.landmark.empty .ink-fill-flame,
.landmark.empty .ink-fill-sail,
.landmark.empty .ink-fill-snow,
.landmark.empty .ink-fill-gold,
.landmark.empty .ink-fill-gem {
  opacity: 0.55;
}
.landmark.empty .ink {
  opacity: 0.55;
}

.landmark-name {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  fill: var(--text);
  letter-spacing: -0.005em;
}
.landmark-sub {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 10px;
  fill: var(--text-tertiary);
  font-weight: 500;
}

.landmark-flagcluster .flagcluster-bg {
  fill: var(--accent);
  stroke: white;
  stroke-width: 2;
  filter: drop-shadow(0 2px 6px rgba(232, 99, 43, 0.32));
}
.landmark-flagcluster .flagcluster-count {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  fill: white;
}

/* Active landmark glow ring */
.landmark.occupied .ink-fill,
.landmark.occupied .ink-fill-bg,
.landmark.occupied .ink-fill-sail,
.landmark.occupied .ink-fill-snow {
  filter: drop-shadow(0 0 8px rgba(232, 99, 43, 0.18));
}

/* Compass on the map */
.map-compass-svg .compass-ring {
  fill: rgba(255, 255, 255, 0.65);
  stroke: var(--text);
  stroke-width: 1.2;
}
.map-compass-svg .compass-star {
  fill: var(--text);
  stroke: var(--text);
  stroke-width: 0.5;
  animation: compass-spin-svg 18s linear infinite;
  transform-origin: 0 0;
}
.map-compass-svg .compass-letter {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  fill: var(--text);
}
@keyframes compass-spin-svg {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Title banner */
.map-banner .banner-bg {
  fill: rgba(255, 255, 255, 0.95);
  stroke: var(--text);
  stroke-width: 1.2;
  filter: drop-shadow(0 4px 12px rgba(20, 20, 30, 0.10));
}
.map-banner .banner-fold {
  fill: var(--accent);
  stroke: var(--text);
  stroke-width: 1;
}
.map-banner .banner-text {
  font-family: -apple-system, 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  fill: var(--text);
  letter-spacing: 0.22em;
}

/* Sea decorations — subtle dots & marks */
.sea-wave {
  fill: none;
  stroke: var(--text-tertiary);
  stroke-width: 1;
  stroke-linecap: round;
  opacity: 0.35;
}
.sea-fish {
  fill: var(--text-tertiary);
  stroke: var(--text-tertiary);
  stroke-width: 0.8;
  opacity: 0.4;
}
.sea-monster {
  fill: none;
  stroke: var(--text-tertiary);
  stroke-width: 1;
  stroke-linecap: round;
  opacity: 0.4;
}

/* Cohort drawer list */
.cohort-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cohort-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(20, 20, 30, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.cohort-row:hover {
  background: rgba(20, 20, 30, 0.08);
}

.map-empty {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.map-empty-content {
  position: relative;
  z-index: 1;
}
.map-empty-icon {
  font-size: 40px;
  color: #8B6F47;
  margin-bottom: 12px;
}
.map-empty-title {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: #5C4527;
  margin-bottom: 6px;
}
.map-empty-sub {
  font-size: 13px;
  color: #7A5E38;
  max-width: 360px;
  line-height: 1.55;
}

.map-customers {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 247, 224, 0.45);
  border: 1px solid rgba(120, 90, 50, 0.16);
  border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(2px);
}
.map-row-left {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
}
.map-row-name {
  font-size: 14px;
  font-weight: 600;
  color: #3C2E18;
}
.map-row-sub {
  font-size: 11px;
  color: #7A5E38;
  font-family: var(--font-sans);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-row-pay {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  font-family: var(--font-sans);
  align-self: flex-start;
}
.map-row-pay.paid {
  background: rgba(46, 125, 50, 0.18);
  color: #2E5C2A;
}
.map-row-pay.unpaid {
  background: rgba(180, 90, 40, 0.18);
  color: #8B4A1F;
}
.map-row-canvas {
  flex: 1;
  min-width: 0;
}
.map-svg {
  width: 100%;
  height: 140px;
  display: block;
}

.map-path {
  fill: none;
  stroke: #8B6F47;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.7;
}
.map-path-shadow {
  fill: none;
  stroke: rgba(80, 50, 20, 0.20);
  stroke-width: 4;
  stroke-linecap: round;
  filter: blur(1.5px);
  transform: translate(0, 1.5px);
}

.map-milestone {
  cursor: pointer;
  transition: transform 200ms ease-out;
}
.map-milestone:hover {
  transform: translate(var(--mx, 0), var(--my, 0)) scale(1.08);
}
.map-milestone .map-milestone-bg {
  fill: #F4E5C0;
  stroke: #8B6F47;
  stroke-width: 2;
}
.map-milestone .map-milestone-ring {
  fill: none;
  stroke: transparent;
  stroke-width: 2;
}
.map-milestone .map-milestone-glyph {
  font-size: 18px;
  fill: #6E5331;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  pointer-events: none;
}
.map-milestone .map-milestone-label {
  font-size: 9px;
  fill: #7A5E38;
  font-family: var(--font-sans);
  font-weight: 500;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.map-milestone.done .map-milestone-bg {
  fill: url(#mile-gradient-done);
  fill: #E8B452;
  stroke: #A07A30;
}
.map-milestone.done .map-milestone-glyph {
  fill: #3C2E18;
  font-weight: 700;
}
.map-milestone.done .map-milestone-label {
  fill: #5C4527;
}

.map-milestone.current .map-milestone-bg {
  fill: #FFE5C7;
  stroke: #E8632B;
  stroke-width: 2.5;
}
.map-milestone.current .map-milestone-ring {
  stroke: rgba(232, 99, 43, 0.45);
  stroke-width: 3;
  animation: milestone-pulse 1.6s ease-out infinite;
}
.map-milestone.current .map-milestone-glyph {
  fill: #E8632B;
  font-weight: 700;
}
.map-milestone.current .map-milestone-label {
  fill: #C8531F;
  font-weight: 700;
}
@keyframes milestone-pulse {
  0%   { stroke-opacity: 0.65; r: 20; }
  100% { stroke-opacity: 0; r: 30; }
}

.map-milestone.pending .map-milestone-bg {
  fill: rgba(230, 215, 180, 0.55);
  stroke: rgba(120, 90, 50, 0.40);
  stroke-dasharray: 3 3;
}
.map-milestone.pending .map-milestone-glyph,
.map-milestone.pending .map-milestone-label {
  opacity: 0.5;
}

.map-flag {
  pointer-events: none;
}
.map-flag-pole {
  stroke: #5C4527;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}
.map-flag-cloth {
  fill: #E8632B;
  stroke: #A0421C;
  stroke-width: 1;
}
.map-flag-name {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  fill: white;
}

.md-step-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
}
.md-step-glyph {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

/* ===================================================================
   AGENTS GRID
   =================================================================== */

.agents-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
@media (max-width: 720px) {
  .agents-stats { grid-template-columns: repeat(2, 1fr); }
}
.agents-stats .brief-stat::before {
  background: radial-gradient(circle at 100% 0%, rgba(20, 20, 30, 0.04), transparent 60%);
}

.agents-filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.agents-chips {
  display: flex;
  gap: 6px;
}
.agents-chip {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: all 120ms ease-out;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.agents-chip:hover { border-color: var(--border-strong); color: var(--text); }
.agents-chip.active {
  background: rgba(20, 20, 30, 0.10);
  color: var(--text);
  border-color: rgba(20, 20, 30, 0.16);
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.agent-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  padding: 0;
  overflow: hidden;
  min-height: 180px;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}
.agent-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.agent-card-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(80% 80% at 0% 0%, rgba(var(--card-hue, var(--hue-ember)), 0.30), transparent 60%),
    radial-gradient(80% 80% at 100% 100%, rgba(var(--card-hue, var(--hue-ember)), 0.18), transparent 60%);
  pointer-events: none;
}
.agent-card-content {
  position: relative;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 180px;
}
.agent-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.agent-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: linear-gradient(135deg, rgba(var(--card-hue, var(--hue-ember)), 0.95), rgba(var(--card-hue, var(--hue-ember)), 0.65));
  color: white;
  flex-shrink: 0;
}
.agent-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  flex: 1;
}
.agent-card-tag {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.agent-card-tag.beta {
  background: var(--accent-soft);
  color: var(--accent);
}
.agent-card-tag.soon {
  background: rgba(20, 20, 30, 0.06);
  color: var(--text-tertiary);
}
.agent-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
}
.agent-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.agent-card-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.agent-card-dot.live {
  background: var(--success);
}
.agent-card-cost {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(20, 20, 30, 0.06);
  padding: 2px 7px;
  border-radius: 4px;
}

/* ===================================================================
   THREAD VIEW
   =================================================================== */

.thread-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - 32px);
}
.thread-head {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.thread-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.thread-head-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.thread-head-right {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.thread-head-loading {
  font-size: 12px;
  color: var(--text-tertiary);
}
.thread-title-input-wrap {
  margin-bottom: 2px;
}
.thread-title-input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.01em;
  padding: 0;
  width: 100%;
}
.thread-title-input:focus {
  background: rgba(20, 20, 30, 0.04);
  border-radius: 4px;
  padding: 2px 6px;
  margin: -2px -6px;
}
.thread-meta {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

/* ===================================================================
   DRAFTER AGENT
   =================================================================== */

.drafter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 980px) {
  .drafter-grid { grid-template-columns: 1fr; }
}

.drafter-form,
.drafter-preview {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
}
.drafter-preview {
  min-height: 600px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 0;
}
.drafter-section-title {
  margin: 0 0 12px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.drafter-section-title em {
  text-transform: none;
  letter-spacing: 0;
  font-style: normal;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-left: 6px;
  font-size: 10.5px;
}
.drafter-req {
  color: var(--accent);
}

.drafter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.drafter-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.drafter-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}
.drafter-label em {
  font-style: normal;
  color: var(--accent);
  margin-left: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.drafter-transcript {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  font-family: var(--font-sans);
  line-height: 1.55;
}
.drafter-notes {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  font-family: var(--font-sans);
  line-height: 1.55;
}
.drafter-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.drafter-status {
  font-size: 12px;
  color: var(--text-tertiary);
}
.drafter-status.ok  { color: var(--success); }
.drafter-status.err { color: var(--danger); }

.drafter-empty {
  height: 100%;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-tertiary);
}
.drafter-empty-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.drafter-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.drafter-empty-sub {
  font-size: 12.5px;
  max-width: 320px;
  line-height: 1.55;
}
.drafter-empty-sub code {
  font-family: var(--font-mono);
  background: rgba(20, 20, 30, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

.drafter-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 600px;
  gap: 14px;
}
.drafter-loading-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.drafter-loading-text {
  font-size: 13px;
  color: var(--text-secondary);
}
.drafter-error {
  padding: 24px;
  color: var(--danger);
  font-size: 13px;
}

.drafter-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  z-index: 1;
}
.drafter-preview-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.drafter-preview-meta code {
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--text-secondary);
}
.drafter-preview-actions {
  display: flex;
  gap: 6px;
}
.drafter-preview-body {
  padding: 24px 26px 40px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* Markdown styling inside drafter-preview-body */
.drafter-preview-body .md-h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 16px 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.drafter-preview-body .md-h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 10px 0;
  letter-spacing: -0.01em;
}
.drafter-preview-body .md-h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 8px 0;
}
.drafter-preview-body .md-h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.drafter-preview-body .md-p {
  margin: 0 0 12px 0;
}
.drafter-preview-body .md-list {
  margin: 0 0 14px 0;
  padding-left: 22px;
}
.drafter-preview-body .md-list li {
  margin-bottom: 4px;
}
.drafter-preview-body .md-quote {
  margin: 14px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-secondary);
}
.drafter-preview-body .md-hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}
.drafter-preview-body .md-code {
  background: rgba(20, 20, 30, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  margin: 12px 0;
  color: var(--text);
}
.drafter-preview-body .md-icode {
  font-family: var(--font-mono);
  background: rgba(20, 20, 30, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.drafter-preview-body .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 12.5px;
}
.drafter-preview-body .md-table th,
.drafter-preview-body .md-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.drafter-preview-body .md-table th {
  background: rgba(20, 20, 30, 0.04);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.drafter-preview-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===================================================================
   INBOX DRAWER
   =================================================================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease-out;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100vw);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.drawer-backdrop.open .drawer-panel {
  transform: translateX(0);
}
.drawer-loading {
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}
.drawer-head {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.drawer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  font-size: 14px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.drawer-close:hover {
  background: var(--surface);
  color: var(--text);
}
.drawer-meta {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.drawer-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 14px 0;
  padding-right: 36px;
  line-height: 1.3;
}
.drawer-from {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drawer-label {
  display: inline-block;
  width: 32px;
  color: var(--text-tertiary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 32px;
}
.drawer-body-text {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  word-wrap: break-word;
  margin: 0;
  letter-spacing: -0.005em;
}
.drawer-body-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.drawer-body-text a:hover {
  text-decoration: none;
}
.email-block {
  white-space: pre-wrap;
}
.email-block + .email-block {
  margin-top: 4px;
}
.email-quote {
  white-space: pre-wrap;
  color: var(--text-tertiary);
  border-left: 2px solid var(--border-strong);
  padding-left: 12px;
  margin: 12px 0;
  font-size: 13px;
}
.email-quote + .email-block,
.email-block + .email-quote {
  margin-top: 12px;
}
.drawer-body-iframe {
  width: 100%;
  min-height: 60vh;
  border: 0;
  background: white;
  border-radius: 8px;
}
.row-title.unread {
  font-weight: 600;
  color: var(--text);
}
.row-title.unread::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: middle;
}

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

.drawer-actions {
  margin-top: 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.drawer-danger:hover {
  color: #FF6B6B !important;
}

.inbox-tabs {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  border-bottom: 1px solid var(--border);
}
.inbox-tab {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}
.inbox-tab:hover {
  color: var(--text-secondary);
}
.inbox-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.inbox-tab-action {
  margin-left: auto;
  margin-bottom: 4px;
}

.compose-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tpl-menu {
  position: absolute;
  top: 52px;
  right: 16px;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
  padding: 6px;
}
.tpl-menu[hidden] { display: none; }
.tpl-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}
.tpl-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  gap: 2px;
}
.tpl-item:hover {
  background: var(--accent-soft);
}
.tpl-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.tpl-subject {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.compose-head { position: relative; }

/* ===================================================================
   COMPOSE MODAL
   =================================================================== */

.compose-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.36);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
  padding-bottom: 8vh;
}
.compose-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.compose-panel {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 16vh);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.97) translateY(8px);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.compose-backdrop.open .compose-panel {
  transform: scale(1) translateY(0);
}
.compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.compose-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.compose-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
}
.compose-field {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.compose-label {
  width: 56px;
  flex-shrink: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}
.compose-field input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 4px 0;
}
.compose-field input::placeholder { color: var(--text-tertiary); }
.compose-textarea {
  width: 100%;
  min-height: 220px;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
  padding: 8px 0;
}
.compose-textarea::placeholder { color: var(--text-tertiary); }

.placeholders {
  background: var(--accent-soft);
  border: 1px solid rgba(255, 138, 61, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 4px;
}
.placeholders[hidden] { display: none; }
.placeholders-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 10px;
  font-weight: 600;
}
.placeholders-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-left: 6px;
}
.placeholders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.placeholder-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.placeholder-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  font-weight: 500;
}
.placeholder-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: 0;
}
.placeholder-input:focus {
  border-color: var(--accent);
}
.placeholder-input::placeholder { color: var(--text-tertiary); }
.compose-status {
  font-size: 12px;
  color: var(--text-tertiary);
  min-height: 16px;
}
.compose-status.ok { color: var(--accent); }
.compose-status.err { color: #FF6B6B; }
.compose-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.compose-foot-spacer { flex: 1; }
.compose-select {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 4px 0;
  cursor: pointer;
}
.compose-select option {
  background: var(--surface-elev);
  color: var(--text);
}
.compose-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.compose-attachments:empty { display: none; }
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  color: var(--text);
  max-width: 240px;
}
.att-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.att-size {
  color: var(--text-tertiary);
  font-size: 11px;
  flex-shrink: 0;
}
.att-remove {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.att-remove:hover {
  background: var(--surface-elev);
  color: var(--text);
}

/* ===================================================================
   TOASTS
   =================================================================== */

.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 200ms ease-out;
  max-width: 320px;
}
.toast.error { border-left: 3px solid var(--danger); }
.toast.success { border-left: 3px solid var(--success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===================================================================
   EMPTY STATES
   =================================================================== */

.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}
.empty-icon {
  font-size: 32px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  opacity: 0.6;
}
.empty-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 320px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

/* ===================================================================
   SETTINGS / FORMS
   =================================================================== */

.settings-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.settings-row {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.settings-row:last-child { border-bottom: 0; }
.settings-row .label {
  flex: 0 0 200px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.settings-row .value {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */

@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none; /* TODO: mobile slide-out menu */
  }
  .view {
    padding: 24px 20px 80px;
  }
  .view-title { font-size: 22px; }
}
