/* ============================================================
   Salesforce Pilot Requirements — Interactive Requirements Map
   Visual language inspired by the Salesforce deck:
   deep navy background, blue→purple gradient flow,
   generous whitespace, soft glassy cards.
   ============================================================ */

:root {
  /* Type */
  --text-xs:   clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  --text-lg:   clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  --text-xl:   clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem, 1.5rem + 2vw, 3rem);

  /* Spacing */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem;
  --s-5: 1.25rem; --s-6: 1.5rem; --s-8: 2rem; --s-10: 2.5rem;
  --s-12: 3rem; --s-16: 4rem; --s-20: 5rem;

  /* Radii */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 22px; --r-full: 9999px;

  /* Salesforce-inspired palette */
  --sf-navy-deep:   #061b4a;
  --sf-navy:        #0a2472;
  --sf-blue:        #1a52c9;
  --sf-blue-bright: #4096ff;
  --sf-cyan:        #3ccbf4;
  --sf-purple:      #6d3fd0;
  --sf-purple-deep: #4b1ea6;
  --sf-accent-green: #00d1b2;

  /* Dark (default) tokens */
  --bg:        #050f30;
  --bg-grad:   radial-gradient(1200px 700px at 10% -10%, #13306e 0%, transparent 55%),
               radial-gradient(900px 600px at 90% 10%, #3a1e82 0%, transparent 50%),
               linear-gradient(180deg, #050f30 0%, #030924 100%);
  --surface:   rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.06);
  --surface-3: rgba(255,255,255,0.09);
  --border:    rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.22);
  --text:      #eef2ff;
  --text-muted:#a9b4d3;
  --text-faint:#6e7aa0;
  --shadow-md: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.45);
  --ring:      0 0 0 2px rgba(64, 150, 255, 0.6);

  --transition: 220ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg: #f3f5fb;
  --bg-grad:
    radial-gradient(1200px 700px at 10% -10%, #d2dcff 0%, transparent 55%),
    radial-gradient(900px 600px at 90% 10%, #e1d3ff 0%, transparent 50%),
    linear-gradient(180deg, #f3f5fb 0%, #e9eefb 100%);
  --surface:   rgba(12, 24, 60, 0.04);
  --surface-2: rgba(12, 24, 60, 0.06);
  --surface-3: rgba(12, 24, 60, 0.09);
  --border:    rgba(12, 24, 60, 0.12);
  --border-strong: rgba(12, 24, 60, 0.24);
  --text:      #0a1a3d;
  --text-muted:#465682;
  --text-faint:#7c8aae;
  --shadow-md: 0 10px 30px rgba(10, 30, 90, 0.10);
  --shadow-lg: 0 20px 60px rgba(10, 30, 90, 0.15);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
}
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; background: none; border: none; color: inherit; font: inherit; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
a { color: var(--sf-blue-bright); }

/* ---------- Layout ---------- */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--s-8) clamp(var(--s-4), 4vw, var(--s-10)) var(--s-20);
}

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-6); margin-bottom: var(--s-8);
  position: sticky; top: 0; z-index: 20;
  /* Extend the bar to the full viewport so the blur/border span edge-to-edge,
     then pad generously inside so the logo and actions never sit on the edge. */
  margin-inline: calc(-1 * clamp(var(--s-4), 4vw, var(--s-10)));
  padding: var(--s-4) clamp(var(--s-6), 5vw, var(--s-12));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--s-3); }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--sf-blue-bright), var(--sf-purple));
  display: grid; place-items: center;
  box-shadow: 0 4px 20px rgba(64,150,255,0.35);
}
.brand-logo svg { width: 22px; height: 22px; color: white; }
.brand-title { font-weight: 700; font-size: var(--text-sm); letter-spacing: -0.01em; }
.brand-sub { font-size: var(--text-xs); color: var(--text-muted); }

.actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 0.55rem 0.95rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--sf-blue), var(--sf-purple));
  border-color: transparent; color: white; font-weight: 600;
  box-shadow: 0 6px 20px rgba(64,150,255,0.3);
}
.btn-primary:hover { box-shadow: 0 8px 28px rgba(64,150,255,0.45); }
.btn-ghost { background: transparent; }
.btn-icon { padding: 0.55rem; }

/* ---------- Connection + presence ---------- */
.conn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.conn-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #a0a8c0;
  box-shadow: 0 0 0 0 rgba(0,0,0,0);
  transition: background var(--transition), box-shadow var(--transition);
}
.conn[data-status="online"]     { color: var(--sf-accent-green); }
.conn[data-status="online"] .conn-dot { background: var(--sf-accent-green); box-shadow: 0 0 8px rgba(0,209,178,0.55); }
.conn[data-status="connecting"] { color: var(--text-muted); }
.conn[data-status="connecting"] .conn-dot { background: #ffa94d; animation: pulseDot 1s infinite ease-in-out; }
.conn[data-status="offline"] .conn-dot { background: #ff6b6b; }
.conn[data-status="offline"]    { color: #ff8a8a; }
@keyframes pulseDot { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

.presence { display: inline-flex; align-items: center; }
.presence .chip {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; color: white;
  border: 2px solid var(--bg);
  margin-left: -8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.presence .chip:first-child { margin-left: 0; }
.presence .chip[data-self="true"] { outline: 2px solid var(--sf-cyan); outline-offset: -2px; }
.presence .more {
  font-size: 10.5px; color: var(--text-muted); margin-left: 6px;
}

#name-btn { font-size: var(--text-xs); padding: 0.45rem 0.7rem; }
#name-btn svg { width: 13px; height: 13px; }

@media (max-width: 720px) {
  .conn-label { display: none; }
  #name-btn span { display: none; }
}

/* ---------- Field lock indicators ---------- */
.field.is-locked {
  position: relative;
}
.field.is-locked::before {
  content: attr(data-locked-by);
  position: absolute; top: 2px; right: 0;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--lock-color, var(--sf-cyan));
  letter-spacing: 0.02em;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px;
  border-radius: var(--r-full);
  background: color-mix(in oklab, var(--lock-color, var(--sf-cyan)) 16%, transparent);
  border: 1px solid color-mix(in oklab, var(--lock-color, var(--sf-cyan)) 40%, transparent);
  animation: lockPulse 1.6s infinite ease-in-out;
}
@keyframes lockPulse { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }
.field.is-locked textarea,
.field.is-locked input,
.field.is-locked .combo-toggle {
  border-color: var(--lock-color, var(--sf-cyan)) !important;
  background: color-mix(in oklab, var(--lock-color, var(--sf-cyan)) 8%, var(--surface)) !important;
  cursor: not-allowed;
}
.field.is-locked textarea,
.field.is-locked input {
  pointer-events: none;
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding: var(--s-8) 0 var(--s-12); }
.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: var(--s-3);
}
.hero h1 .accent {
  font-weight: 600;
  background: linear-gradient(135deg, var(--sf-accent-green), var(--sf-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  color: var(--text-muted);
  font-size: var(--text-lg);
  max-width: 70ch; margin: 0 auto;
}
.hero-meta {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  margin-bottom: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--surface);
}
.hero-meta::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sf-accent-green);
  box-shadow: 0 0 8px var(--sf-accent-green);
}

/* Progress bar */
.progress-wrap {
  max-width: 540px; margin: var(--s-6) auto 0;
  display: flex; align-items: center; gap: var(--s-3);
}
.progress-track {
  flex: 1; height: 6px; border-radius: var(--r-full);
  background: var(--surface-2); overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sf-cyan), var(--sf-purple));
  border-radius: var(--r-full);
  transition: width var(--transition);
}
.progress-label { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Phases ---------- */
.phases { display: flex; flex-direction: column; gap: var(--s-12); margin-top: var(--s-10); }

.phase { position: relative; }
.phase-header {
  display: flex; align-items: center; gap: var(--s-5);
  margin-bottom: var(--s-5);
}
.phase-badge {
  flex-shrink: 0;
  width: 132px; height: 132px; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  color: white;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
  padding: var(--s-5);
  line-height: 1.2;
}
.phase-badge > div { max-width: 90px; }
.phase-badge .label { font-size: 10.5px; font-weight: 500; opacity: 0.85; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.phase-badge .name  { font-size: 0.85rem; font-weight: 700; margin-top: 5px; word-break: keep-all; overflow-wrap: normal; hyphens: none; }

.phase[data-accent="deep-blue"]  .phase-badge { background: radial-gradient(circle at 30% 30%, #1a3a8a, #061645); }
.phase[data-accent="purple"]     .phase-badge { background: radial-gradient(circle at 30% 30%, #9464ff, #4b1ea6); }
.phase[data-accent="light-blue"] .phase-badge { background: radial-gradient(circle at 30% 30%, #62b6ff, #1a52c9); }

.phase-flowlabel {
  flex: 1;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0.65rem var(--s-4);
  border-radius: var(--r-full);
  background: linear-gradient(90deg, rgba(26,82,201,0.15), rgba(109,63,208,0.15));
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.phase-flowlabel::before {
  content: "◆"; color: var(--sf-cyan); font-size: 0.8rem;
}

/* ---------- Card grid ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-4);
}
@media (min-width: 900px) {
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: var(--transition);
  text-align: left;
  display: flex; flex-direction: column; gap: var(--s-3);
  min-height: 170px;
  overflow: hidden;
  width: 100%;
}
.card::before {
  /* Soft gradient glow on hover */
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(400px 200px at var(--mx,50%) var(--my,0%),
    rgba(64,150,255,0.12), transparent 60%);
  opacity: 0; transition: opacity var(--transition); pointer-events: none;
}
.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card:hover::before { opacity: 1; }

.card-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(64,150,255,0.2), rgba(109,63,208,0.2));
  color: var(--sf-cyan);
  border: 1px solid var(--border);
}
.card-icon svg { width: 20px; height: 20px; }
.card h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.card p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  flex: 1;
}
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.card-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
}
.card-status[data-filled="true"] {
  background: rgba(0, 209, 178, 0.12);
  color: var(--sf-accent-green);
}
.card-status[data-filled="true"]::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sf-accent-green);
}
.card-cta { color: var(--sf-blue-bright); font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.card-cta svg { width: 14px; height: 14px; transition: transform var(--transition); }
.card:hover .card-cta svg { transform: translateX(3px); }

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(3, 7, 25, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.drawer-overlay[data-open="true"] { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh;
  width: min(680px, 100%);
  z-index: 40;
  background: var(--bg);
  background-image:
    radial-gradient(600px 300px at 100% 0%, rgba(109,63,208,0.25), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg));
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--transition);
  display: flex; flex-direction: column;
}
.drawer[data-open="true"] { transform: translateX(0); }

.drawer-header {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: var(--s-4);
}
.drawer-header .card-icon { flex-shrink: 0; }
.drawer-title { flex: 1; }
.drawer-title .eyebrow {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.drawer-title h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.drawer-title .summary {
  margin-top: var(--s-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.drawer-close {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-close:hover { background: var(--surface-3); }

.drawer-body {
  flex: 1; overflow-y: auto;
  padding: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-5);
}
.drawer-body::-webkit-scrollbar { width: 10px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-full); }

.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--s-2);
  letter-spacing: -0.005em;
}
.field .hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: 6px;
}
.field textarea,
.field input,
.field select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 0.7rem 0.85rem;
  font-size: var(--text-sm);
  font-family: inherit;
  line-height: 1.5;
  transition: border-color var(--transition), background var(--transition);
  resize: vertical;
}
.field textarea { min-height: 90px; }
.field textarea:focus,
.field input:focus,
.field select:focus {
  border-color: var(--sf-blue-bright);
  background: var(--surface-2);
}
/* Custom combo (picklist) — themed to match the drawer inputs in dark + light */
.combo { position: relative; }
.combo-toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 0.7rem 0.85rem;
  font-size: var(--text-sm);
  line-height: 1.5;
  text-align: left;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.combo-toggle:hover { border-color: var(--border-strong); background: var(--surface-2); }
.combo-toggle .combo-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-toggle.is-empty .combo-value { color: var(--text-faint); }
.combo-toggle svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; transition: transform var(--transition); }
.combo[data-open="true"] .combo-toggle { border-color: var(--sf-blue-bright); background: var(--surface-2); }
.combo[data-open="true"] .combo-toggle svg { transform: rotate(180deg); }

.combo-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg);
  background-image: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  margin: 0; list-style: none;
  display: none;
  z-index: 15;
  max-height: 260px; overflow-y: auto;
}
.combo[data-open="true"] .combo-menu { display: block; animation: comboIn 140ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes comboIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.combo-menu li {
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-2);
  transition: background var(--transition);
}
.combo-menu li:hover, .combo-menu li:focus-visible {
  background: var(--surface-3);
  outline: none;
}
.combo-menu li[aria-selected="true"] {
  background: color-mix(in oklab, var(--sf-blue-bright) 18%, transparent);
  color: var(--text);
}
.combo-menu li[aria-selected="true"]::after {
  content: "";
  width: 14px; height: 14px; flex-shrink: 0;
  background: currentColor;
  color: var(--sf-cyan);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.combo-menu::-webkit-scrollbar { width: 8px; }
.combo-menu::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-full); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.drawer-footer {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.save-indicator { display: inline-flex; align-items: center; gap: 6px; }
.save-indicator::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sf-accent-green); }

/* ---------- Export menu ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none; flex-direction: column;
  z-index: 25;
}
.menu[data-open="true"] { display: flex; }
.menu button {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  text-align: left;
  color: var(--text);
}
.menu button:hover { background: var(--surface-2); }
.menu button svg { width: 16px; height: 16px; color: var(--text-muted); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 0.7rem 1rem;
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--s-2);
  opacity: 0; pointer-events: none;
  z-index: 60;
  transition: opacity var(--transition), transform var(--transition);
}
.toast[data-show="true"] { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 16px; height: 16px; color: var(--sf-accent-green); }

/* ---------- Footer ---------- */
.sitefooter {
  margin-top: var(--s-16);
  padding: var(--s-5) 0;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s-4); flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.platform-strip {
  display: flex; gap: var(--s-2); flex-wrap: wrap;
}
.platform-strip span {
  padding: 3px 10px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .phase-header { flex-direction: column; align-items: flex-start; }
  .phase-badge { width: 112px; height: 112px; padding: var(--s-4); }
  .phase-badge > div { max-width: 78px; }
  .drawer { width: 100%; }
  .brand-sub { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* =========================================================
   Rich text editor (view / edit / save / cancel)
   ========================================================= */
.field .rich {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  display: flex; flex-direction: column;
  position: relative;
}
/* In view mode, the container is deliberately calm — no focus ring. */
.field .rich[data-mode="edit"]:focus-within {
  border-color: var(--sf-blue-bright);
  background: var(--surface-2);
}
/* Toolbar is only shown while editing. */
.rich-toolbar {
  display: none;
  flex-wrap: wrap; align-items: center;
  gap: 2px;
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 60%, transparent);
}
.field .rich[data-mode="edit"] .rich-toolbar {
  display: flex;
}
.rtb {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  padding: 5px 8px;
  min-width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.rtb b, .rtb i, .rtb u { font-size: var(--text-sm); }
.rtb:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.rtb:active { transform: translateY(1px); }
.rtb[aria-pressed="true"], .rtb.is-active {
  background: color-mix(in oklab, var(--sf-blue-bright) 18%, var(--surface-2));
  color: var(--text);
  border-color: color-mix(in oklab, var(--sf-blue-bright) 40%, var(--border));
}
.rtb-sep {
  display: inline-block;
  width: 1px; height: 16px;
  margin: 0 4px;
  background: var(--border);
}
.rich-editor {
  min-height: 120px;
  max-height: 480px;
  overflow-y: auto;
  padding: 0.7rem 0.85rem;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text);
  outline: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
  display: block;
}
/* View mode: no caret, no outline, subtly indicate read-only state */
.field .rich[data-mode="view"] .rich-editor {
  caret-color: transparent;
  cursor: default;
  user-select: text;
}
.field .rich[data-mode="view"] .rich-editor:empty::before {
  opacity: 0.75;
}

/* Actions bar (Edit | Save + Cancel) */
.rich-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 50%, transparent);
}
.rich-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}
/* Mode-scoped button visibility (drives Edit vs Save/Cancel) */
.rich[data-mode="view"] .rich-btn.rich-save,
.rich[data-mode="view"] .rich-btn.rich-cancel {
  display: none !important;
}
.rich[data-mode="edit"] .rich-btn.rich-edit {
  display: none !important;
}
/* Belt & suspenders: honor the [hidden] attribute too */
.rich-btn[hidden] {
  display: none !important;
}
.rich-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.rich-btn:active { transform: translateY(1px); }
.rich-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.rich-btn svg { flex-shrink: 0; }
/* Primary: Save */
.rich-btn.rich-save {
  background: color-mix(in oklab, var(--sf-blue-bright) 22%, var(--surface));
  color: var(--text);
  border-color: color-mix(in oklab, var(--sf-blue-bright) 55%, var(--border));
}
.rich-btn.rich-save:hover {
  background: color-mix(in oklab, var(--sf-blue-bright) 34%, var(--surface));
  border-color: color-mix(in oklab, var(--sf-blue-bright) 75%, var(--border));
}
.rich-editor > *:first-child { margin-top: 0; }
.rich-editor > *:last-child { margin-bottom: 0; }
.rich-editor p { margin: 0 0 0.6em; }
.rich-editor h3 {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0.6em 0 0.35em;
}
.rich-editor h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0.6em 0 0.3em;
  color: var(--text);
}
.rich-editor ul, .rich-editor ol {
  margin: 0 0 0.6em;
  padding-left: 1.4em;
}
.rich-editor li { margin: 0.15em 0; }
.rich-editor blockquote {
  margin: 0 0 0.6em;
  padding: 0.25em 0 0.25em 0.9em;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
  font-style: italic;
}
.rich-editor a {
  color: var(--sf-blue-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rich-editor code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}

/* Locked visual for rich editor */
.field.is-locked .rich {
  background: color-mix(in oklab, var(--lock-color, var(--sf-cyan)) 8%, var(--surface)) !important;
}

/* =========================================================
   Files section (bottom of every drawer card)
   ========================================================= */
.files-section {
  margin-top: var(--s-2);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.files-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
}
.files-title {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.005em;
}
/* Upload trigger — a <label for="drawer-file-input"> wrapping a hidden
   <input type="file">. Clicking anywhere on the label natively opens the
   file picker in every browser (no JS click() call needed). */
.files-upload-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.7rem;
  font-size: var(--text-xs);
  font-weight: 600;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.files-upload-label svg { width: 14px; height: 14px; }
.files-upload-label:focus-visible {
  outline: 2px solid var(--sf-blue-bright, #1b96ff);
  outline-offset: 2px;
}
.files-upload-input-hidden {
  /* Visually hidden but still clickable via the <label>. Do NOT use
     display:none — that would break the label-to-input association in
     some older browsers. */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.files-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s-4);
  background: var(--surface);
  transition: background var(--transition), border-color var(--transition);
  text-align: center;
  cursor: pointer;
}
.files-dropzone:hover { background: var(--surface-2); }
.files-dropzone[data-drag="over"] {
  background: color-mix(in oklab, var(--sf-blue-bright) 10%, var(--surface-2));
  border-color: var(--sf-blue-bright);
}
.files-dropzone-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.files-list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.files-empty {
  font-size: var(--text-xs);
  color: var(--text-faint);
  padding: var(--s-2) 0;
  text-align: center;
}
.file-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: background var(--transition), border-color var(--transition);
}
.file-item:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.file-item.is-pending { opacity: 0.7; }

.file-preview {
  display: block;
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-muted);
  flex-shrink: 0;
}
.file-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.file-thumb-ico {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.file-thumb-ico svg { width: 20px; height: 20px; }

.file-meta {
  min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.file-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-name:hover { color: var(--sf-blue-bright); text-decoration: underline; }
.file-sub {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-actions {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.file-action {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  cursor: pointer;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.file-action:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.file-action svg { width: 15px; height: 15px; }
.file-del:hover {
  color: #ff6b6b;
  border-color: color-mix(in oklab, #ff6b6b 40%, var(--border));
}

.file-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--sf-blue-bright);
  border-radius: 50%;
  animation: file-spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes file-spin { to { transform: rotate(360deg); } }

.files-note {
  font-size: var(--text-xs);
  color: var(--text-faint);
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
