:root {
  /* Surfaces */
  --bg: #0a0c12;
  --bg-elev: #11141c;
  --bg-elev-2: #171b26;
  --bg-hover: #1b2030;

  /* Strokes */
  --border: #1f2330;
  --border-strong: #2a2f3e;
  --border-accent: rgba(91, 143, 255, 0.35);

  /* Text */
  --text: #e8eaf0;
  --text-dim: #8b92a5;
  --text-muted: #5e6475;

  /* Accent */
  --accent: #5b8fff;
  --accent-soft: rgba(91, 143, 255, 0.12);
  --accent-glow: rgba(91, 143, 255, 0.22);
  --accent-2-glow: rgba(124, 92, 255, 0.16);

  /* Status */
  --pilot: #f0a045;
  --planned: #5b8fff;
  --stable: #4ac27a;
  --flagship: #b884ff;

  /* Section accent palette (chosen per section in edit mode) */
  --accent-blue:        #5b8fff;
  --accent-blue-soft:   rgba(91, 143, 255, 0.12);
  --accent-amber:       #f0a045;
  --accent-amber-soft:  rgba(240, 160, 69, 0.13);
  --accent-green:       #4ac27a;
  --accent-green-soft:  rgba(74, 194, 122, 0.13);
  --accent-purple:      #b884ff;
  --accent-purple-soft: rgba(184, 132, 255, 0.13);
  --accent-rose:        #ff7a9c;
  --accent-rose-soft:   rgba(255, 122, 156, 0.14);
  --accent-teal:        #4fd1c5;
  --accent-teal-soft:   rgba(79, 209, 197, 0.13);

  /* Health dot */
  --health-up:      #4ac27a;
  --health-down:    #f56565;
  --health-unknown: #5e6475;

  /* Geometry */
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --maxw: 1180px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fb;
    --bg-elev: #ffffff;
    --bg-elev-2: #f1f3f8;
    --bg-hover: #eef1f6;
    --border: #e5e8ef;
    --border-strong: #ced3dd;
    --border-accent: rgba(74, 122, 255, 0.3);
    --text: #0f1320;
    --text-dim: #4d5468;
    --text-muted: #8389a0;
    --accent: #4a7aff;
    --accent-soft: rgba(74, 122, 255, 0.1);
    --accent-glow: rgba(74, 122, 255, 0.18);
    --accent-2-glow: rgba(124, 92, 255, 0.12);
    --pilot: #c97a15;
    --planned: #4a7aff;
    --stable: #2e8b4f;
    --flagship: #8a5bd5;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@supports (font-variation-settings: normal) {
  html, body { font-family: 'Inter var', 'Inter', system-ui, sans-serif; }
}

/* Honor user's motion preference. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }

code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
}

/* ---------- Hero ---------- */

.hero {
  position: sticky;
  top: 0;
  z-index: 10;
  overflow: hidden;
  background: var(--bg);
  /* No size transitions on the hero itself — animating its height while it's
   * sticky causes visible jitter as scroll-anchoring tries to compensate.
   * The compact-on-scroll change is instant. */
}

/* Stop the browser from auto-adjusting scroll position when the sticky
 * hero changes height. Without this, shrinking the hero can pull scrollY
 * past the threshold and the toggle fights the user. */
html { overflow-anchor: none; }

/* When the user scrolls past ~80px we shrink the hero to a slim bar so it
 * doesn't eat the viewport. Toggled by a scroll listener in app.js. */
body.scrolled .hero-inner {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
body.scrolled .brand-row { margin-bottom: 0; }
body.scrolled .brand-mark { width: 32px; height: 32px; }
body.scrolled .hero h1 { font-size: 1.4rem; }
body.scrolled .tagline { display: none; }
body.scrolled .account-menu { top: 0.6rem; }

/* If the editing top-bar is present, push the hero below it. */
body.edit-mode .hero { top: 49px; }

/* Mesh-gradient hero — four overlapping radial bursts produce a soft,
 * non-uniform colored glow that's noticeably more interesting than the
 * old two-blob effect, with no SVG required. */
.hero {
  background:
    radial-gradient(45rem at 78% -10%,  rgba(91, 143, 255, 0.22), transparent 55%),
    radial-gradient(40rem at 100% 90%,  rgba(184, 132, 255, 0.18), transparent 55%),
    radial-gradient(50rem at 0% 110%,   rgba(79, 209, 197, 0.16), transparent 60%),
    radial-gradient(28rem at 28% 50%,   rgba(255, 122, 156, 0.10), transparent 50%),
    var(--bg);
}

@media (prefers-color-scheme: light) {
  .hero {
    background:
      radial-gradient(45rem at 78% -10%, rgba(91, 143, 255, 0.16), transparent 55%),
      radial-gradient(40rem at 100% 90%, rgba(184, 132, 255, 0.13), transparent 55%),
      radial-gradient(50rem at 0% 110%,  rgba(79, 209, 197, 0.12), transparent 60%),
      radial-gradient(28rem at 28% 50%,  rgba(255, 122, 156, 0.07), transparent 50%),
      var(--bg);
  }
}

.hero-inner {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 5rem 1.5rem 4rem;
  z-index: 1;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand-mark {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 16px rgba(91, 143, 255, 0.25));
}

@media (max-width: 600px) {
  .brand-mark { width: 44px; height: 44px; }
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  background: linear-gradient(180deg, var(--text) 0%, var(--text-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.tagline {
  margin: 0;
  font-size: 1.125rem;
  color: var(--text-dim);
  max-width: 46rem;
  letter-spacing: -0.005em;
}

/* ---------- Account menu ---------- */

.account-menu {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  z-index: 2;
}

.account-menu form { margin: 0; }

.account-link,
.account-menu button {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.9rem;
  font-size: 0.825rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  line-height: 1.4;
}

.account-link:hover,
.account-menu button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
}

@media (prefers-color-scheme: light) {
  .account-link,
  .account-menu button {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.10);
  }
  .account-link:hover,
  .account-menu button:hover {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.18);
  }
}

@media (max-width: 600px) {
  .account-menu {
    position: static;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
  }
  .hero-inner { padding-top: 2rem; }
}

/* ---------- Main + sections ---------- */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

section + section { margin-top: 4.5rem; }

.section-head { margin-bottom: 1.75rem; }

.section-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}

.section-head h2 {
  margin: 0 0 0.4rem;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.section-head p {
  margin: 0;
  color: var(--text-dim);
  max-width: 46rem;
  font-size: 0.95rem;
}

/* ---------- Grid ---------- */

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

/* ---------- Cards ---------- */

.card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(180deg, var(--section-accent-soft, var(--accent-glow)) 0%, transparent 50%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--section-accent, var(--border-accent));
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.4);
}

.card:hover::after { opacity: 1; }

.card-muted { background: transparent; }

.card-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--section-accent-soft, var(--accent-soft));
  color: var(--section-accent, var(--accent));
  margin-bottom: 1.1rem;
}

.card-icon svg {
  width: 22px;
  height: 22px;
}

/* Health dot — small notification-style indicator on the icon corner */
.health-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-elev);
  background: var(--health-unknown);
  transition: background 200ms ease, box-shadow 200ms ease;
}
.health-dot.health-ok      { background: var(--health-up); box-shadow: 0 0 6px rgba(74, 194, 122, 0.6); }
.health-dot.health-down    { background: var(--health-down); box-shadow: 0 0 6px rgba(245, 101, 101, 0.6); }
.health-dot.health-unknown { background: var(--health-unknown); }
.card-muted .health-dot { border-color: var(--bg); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.card-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card p {
  margin: 0 0 1.25rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  flex-grow: 1;
  line-height: 1.55;
}

/* ---------- Badges (dot + label) ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem 0.27rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1.1;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.badge-pilot { color: var(--pilot); }
.badge-planned { color: var(--planned); }
.badge-stable { color: var(--stable); }
.badge-flagship { color: var(--flagship); }

/* ---------- Meta (URL row) ---------- */

.meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.meta-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 3rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.meta-value {
  color: var(--text-dim);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.78rem;
  background: var(--bg-elev-2);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
  transition: color 140ms ease, border-color 140ms ease;
}

a.meta-value:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ---------- Card link ---------- */

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-start;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--accent);
  padding: 0.35rem 0;
  transition: gap 160ms ease, color 140ms ease;
}

.card-link::after {
  content: '→';
  display: inline-block;
  transition: transform 160ms ease;
}

.card-link:hover {
  color: var(--text);
  gap: 0.55rem;
}

.card-link:hover::after { transform: translateX(2px); }

.card-link[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.4;
}

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.825rem;
}

footer p { margin: 0; }

/* ===========================================================
 * Auth pages (login, change-password)
 * =========================================================== */

body.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  position: relative;
  overflow: hidden;
}

body.auth-page::before,
body.auth-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}

body.auth-page::before {
  top: -30%;
  right: -20%;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
}

body.auth-page::after {
  bottom: -30%;
  left: -20%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, var(--accent-2-glow) 0%, transparent 60%);
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-brand span {
  background: linear-gradient(180deg, var(--text) 0%, var(--text-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 16px rgba(91, 143, 255, 0.25));
}

.auth-card {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.5);
}

.auth-card h2 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-card .sub {
  margin: 0 0 1.5rem;
  color: var(--text-dim);
  font-size: 0.875rem;
}

.auth-card label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.auth-card input {
  display: block;
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  margin-bottom: 1rem;
  box-sizing: border-box;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.auth-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-card button {
  width: 100%;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #0a0c12;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition: filter 140ms ease, transform 80ms ease;
}

.auth-card button:hover { filter: brightness(1.08); }
.auth-card button:active { transform: translateY(1px); }

.auth-card .error,
.auth-card .success {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.auth-card .error {
  background: rgba(245, 101, 101, 0.08);
  border-color: rgba(245, 101, 101, 0.25);
  color: #ff8a8a;
}

.auth-card .success {
  background: rgba(74, 194, 122, 0.08);
  border-color: rgba(74, 194, 122, 0.25);
  color: #7dd48f;
}

.auth-card .links {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
}

/* ===========================================================
 * Edit mode (CMS overlay)
 * =========================================================== */

.load-error { color: var(--text-dim); text-align: center; padding: 4rem 1rem; }

#edit-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border-accent);
  font-size: 0.875rem;
  color: var(--text-dim);
  backdrop-filter: blur(8px);
}

#edit-bar > div { display: flex; gap: 0.5rem; }

.btn-primary,
.btn-secondary {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: filter 120ms ease, background 120ms ease, border-color 120ms ease;
}
.btn-primary  { background: var(--accent); color: #0a0c12; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-elev-2); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-strong); }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-hover); }
.btn-icon.btn-danger:hover { color: #ff8a8a; border-color: rgba(245, 101, 101, 0.4); }

/* Section editing */
body.edit-mode .section-head {
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  gap: 0.5rem;
}
.section-label-input,
.section-title-input,
.section-blurb-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
  resize: vertical;
}
.section-label-input { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); }
.section-title-input { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.section-blurb-input { font-size: 0.9rem; color: var(--text-dim); }
.section-controls {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

/* Cards in edit mode */
body.edit-mode .card-editable { cursor: grab; }
body.edit-mode .card-editable:active { cursor: grabbing; }
body.edit-mode .card-editable.dragging { opacity: 0.4; }
body.edit-mode .card-editable.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.card-controls {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: flex;
  gap: 0.3rem;
  opacity: 0;
  transition: opacity 140ms ease;
}
body.edit-mode .card-editable:hover .card-controls,
body.edit-mode .card-editable:focus-within .card-controls,
/* Pinned (virtual-section) cards aren't draggable so they never get the
 * card-editable class — show their controls by default so the unpin
 * star is discoverable in edit mode. */
body.edit-mode .section-virtual .card-controls { opacity: 1; }
.card-controls .btn-icon { background: var(--bg-elev-2); }

/* "+" Add buttons */
.card-add {
  background: transparent;
  border: 1.5px dashed var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: border-color 140ms ease, color 140ms ease;
}
.card-add:hover { border-color: var(--accent); color: var(--accent); }

.btn-add-section {
  display: block;
  width: 100%;
  margin-top: 3rem;
  padding: 1rem;
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}
.btn-add-section:hover { border-color: var(--accent); color: var(--accent); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 50;
}

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 36rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}

.modal h3 {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.form { display: grid; gap: 1rem; }
.form-row { display: grid; gap: 0.4rem; }
.form-row > label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.form-row input[type="text"],
.form-row input:not([type]),
.form-row textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Badge picker */
.badge-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge-option {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 140ms ease, color 140ms ease;
}
.badge-option.selected { border-color: currentColor; }
.badge-option.badge-pilot { color: var(--pilot); }
.badge-option.badge-stable { color: var(--stable); }
.badge-option.badge-planned { color: var(--planned); }
.badge-option.badge-flagship { color: var(--flagship); }

/* Icon picker */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 0.4rem;
}
.icon-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  padding: 0;
}
.icon-cell svg { width: 22px; height: 22px; }
.icon-cell:hover { color: var(--text); border-color: var(--border-strong); }
.icon-cell.selected {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Links list inside card editor */
.links-list { display: grid; gap: 0.4rem; margin-bottom: 0.5rem; }
.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto auto auto;
  gap: 0.35rem;
  align-items: center;
}
.link-row input { min-width: 0; }
.link-row .link-url { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.85rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ===========================================================
 * Search bar
 * =========================================================== */
.search-shell {
  max-width: var(--maxw);
  margin: 1.5rem auto -1rem;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
#search-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#search-input::placeholder { color: var(--text-muted); }
#search-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Hide cards / sections that don't match the search filter. */
.filtered-out { display: none !important; }

/* ===========================================================
 * Section accent picker (in edit mode)
 * =========================================================== */
.accent-picker {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  margin-right: 0.4rem;
}
.accent-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: currentColor;
  cursor: pointer;
  padding: 0;
  transition: border-color 120ms ease, transform 120ms ease;
}
.accent-swatch:hover { transform: scale(1.1); }
.accent-swatch.selected { border-color: var(--text); transform: scale(1.1); }
.accent-blue   { color: var(--accent-blue); }
.accent-amber  { color: var(--accent-amber); }
.accent-green  { color: var(--accent-green); }
.accent-purple { color: var(--accent-purple); }
.accent-rose   { color: var(--accent-rose); }
.accent-teal   { color: var(--accent-teal); }

/* ===========================================================
 * Help overlay (keyboard shortcuts)
 * =========================================================== */
.shortcuts-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6rem 1.25rem;
  margin: 0;
}
.shortcuts-list dt {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
}
.shortcuts-list dd {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

/* ===========================================================
 * Pinned (virtual) section
 * =========================================================== */
.section-virtual .section-head { margin-bottom: 1.25rem; }
.section-virtual .section-label { color: var(--section-accent, var(--accent)); }
.section-virtual .section-head h2 { font-size: 1.4rem; }

/* The star toggle in the card-controls */
.btn-icon.btn-pinned { color: var(--accent-amber); border-color: rgba(240, 160, 69, 0.4); }

/* ===========================================================
 * List view (compact rows instead of card grid)
 * =========================================================== */
body.view-list .grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

body.view-list .card {
  flex-direction: row;
  align-items: center;
  padding: 0.55rem 1rem;
  gap: 1rem;
  min-height: 48px;
}

body.view-list .card:hover { transform: none; }
body.view-list .card::after { display: none; }

body.view-list .card-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 0;
  border-radius: 8px;
  flex-shrink: 0;
}
body.view-list .card-icon svg { width: 16px; height: 16px; }
body.view-list .health-dot { width: 8px; height: 8px; border-width: 1.5px; }

body.view-list .card-head {
  margin: 0;
  flex: 0 1 auto;
  align-items: center;
  min-width: 0;
}
body.view-list .card-head h3 {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.view-list .card p { display: none; }

body.view-list .meta {
  flex: 1;
  flex-direction: row;
  flex-wrap: wrap;
  margin: 0 0 0 auto;
  gap: 0.35rem;
  justify-content: flex-end;
}
body.view-list .meta-row { gap: 0.35rem; }
body.view-list .meta-label {
  font-size: 0.62rem;
  min-width: 0;
}
body.view-list .meta-value {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
}

body.view-list .badge { padding: 0.15rem 0.55rem 0.17rem 0.45rem; font-size: 0.65rem; }
body.view-list .badge::before { width: 5px; height: 5px; }

@media (max-width: 700px) {
  body.view-list .meta { display: none; }
  body.view-list .card-head { flex: 1; }
}

/* ===========================================================
 * Toast notifications
 * =========================================================== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: calc(100vw - 3rem);
}
.toast {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: auto;
  cursor: pointer;
  min-width: 200px;
  max-width: 360px;
}
.toast.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { border-color: rgba(74, 194, 122, 0.45); }
.toast-success::before { content: "✓ "; color: var(--stable); font-weight: 700; }
.toast-error   { border-color: rgba(245, 101, 101, 0.45); }
.toast-error::before   { content: "✕ "; color: #f56565; font-weight: 700; }
.toast-info::before    { content: "· "; color: var(--accent); }

/* ===========================================================
 * Stagger fade-in on first paint
 * =========================================================== */
@keyframes card-stagger-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
main.first-paint .card[data-card-id] {
  animation: card-stagger-in 320ms ease-out backwards;
  animation-delay: calc(var(--stagger-i, 0) * 30ms);
}

/* ===========================================================
 * Skeleton placeholders
 * =========================================================== */
@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton {
  background:
    linear-gradient(90deg,
      var(--bg-elev) 0%,
      var(--bg-elev-2) 50%,
      var(--bg-elev) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}
.skeleton-section .section-head { display: block; margin-bottom: 1.75rem; }
.skeleton-label   { display: block; width: 6rem;  height: 0.7rem; margin-bottom: 0.5rem; }
.skeleton-title   { display: block; width: 18rem; max-width: 80%; height: 1.6rem; }
.skeleton-card    { gap: 0.5rem; }
.skeleton-icon    { width: 40px; height: 40px; border-radius: 10px; margin-bottom: 1.1rem; }
.skeleton-line    { height: 0.65rem; margin-bottom: 0.55rem; }
.skeleton-line-heading { width: 60%; height: 1.05rem; margin-bottom: 0.85rem; }
.skeleton-line-short { width: 35%; }
.skeleton-card .skeleton-line:last-child { margin-bottom: 0; }

/* ===========================================================
 * Light-mode polish pass
 * =========================================================== */
@media (prefers-color-scheme: light) {
  /* Slightly stronger borders to compensate for the much lighter surfaces */
  :root {
    --border: #e1e5ec;
    --border-strong: #c0c5d0;
  }
  /* Cards need a soft shadow in light mode to look elevated */
  .card { box-shadow: 0 1px 2px rgba(15, 19, 32, 0.04); }
  .card:hover { box-shadow: 0 12px 28px -14px rgba(15, 19, 32, 0.18); }

  /* Hero gradient text needs higher contrast (prev value too washed-out) */
  .hero h1 {
    background: linear-gradient(180deg, #0f1320 0%, #4d5468 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .auth-brand span {
    background: linear-gradient(180deg, #0f1320 0%, #4d5468 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  /* The mesh gradient needs a tad more punch on light backgrounds */
  .hero {
    background:
      radial-gradient(45rem at 78% -10%, rgba(74, 122, 255, 0.20), transparent 55%),
      radial-gradient(40rem at 100% 90%, rgba(124, 92, 255, 0.16), transparent 55%),
      radial-gradient(50rem at 0% 110%,  rgba(79, 209, 197, 0.16), transparent 60%),
      radial-gradient(28rem at 28% 50%,  rgba(255, 122, 156, 0.10), transparent 50%),
      var(--bg);
  }

  /* Toast surface */
  .toast { box-shadow: 0 12px 32px -12px rgba(15, 19, 32, 0.18); }

  /* Skeleton needs a darker shimmer on light surfaces to be visible */
  .skeleton {
    background:
      linear-gradient(90deg,
        #eef1f7 0%,
        #dde2eb 50%,
        #eef1f7 100%);
    background-size: 200% 100%;
  }

  /* Modal overlay can be lighter on a light page so it doesn't go pitch-black */
  .modal-overlay { background: rgba(15, 19, 32, 0.35); }

  /* Health dot border picks up the light card background */
  .health-dot { border-color: var(--bg-elev); }
}

/* ===========================================================
 * Section collapse + sort
 * =========================================================== */
.section-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.section-toggle {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7rem;
  line-height: 1;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 200ms ease, color 140ms ease;
}
.section-toggle:hover { color: var(--text); }
.section-toggle.collapsed { transform: rotate(-90deg); }

.section-collapsed .grid { display: none; }
.section-collapsed .section-head { margin-bottom: 0; }
.section-collapsed .section-head h2 { opacity: 0.7; }

/* Sort dropdown that sits at the right side of the section header */
.section-sort {
  margin-top: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.section-sort-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sort-select {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.sort-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===========================================================
 * Undo button (in edit-bar) — disabled state styling
 * =========================================================== */
#undo-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===========================================================
 * Tag chips + filter bar
 * =========================================================== */
.tag-bar {
  max-width: var(--maxw);
  margin: 0.5rem auto -1.25rem;
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}
.tag-bar.empty { display: none; }
.tag-bar-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 0.25rem;
}
.tag-clear {
  margin-left: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
}
.tag-clear:hover { color: var(--text); }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.18rem 0.55rem 0.2rem;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.tag-chip:hover { color: var(--text); border-color: var(--border-strong); }
.tag-chip.selected {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tag-count { color: var(--text-muted); font-size: 0.68rem; }
.tag-chip.selected .tag-count { color: var(--accent); }
.tag-chip-bar { /* inside the global tag bar — slightly larger */
  font-size: 0.76rem;
  padding: 0.22rem 0.65rem 0.24rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: -0.5rem 0 0.75rem;
}

.card-notes {
  margin: 0 0 1rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg-elev-2);
  border-left: 3px solid var(--section-accent, var(--accent));
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
  white-space: pre-wrap;
}

/* Tag preview inside the card editor modal */
.tag-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
  min-height: 1.2rem;
}

/* ===========================================================
 * Bulk select (edit mode)
 * =========================================================== */
.card-select {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  width: 17px;
  height: 17px;
  cursor: pointer;
  z-index: 1;
  margin: 0;
  opacity: 0;
  transition: opacity 140ms ease;
  accent-color: var(--accent);
}
body.edit-mode .card-editable .card-select { opacity: 0.55; }
body.edit-mode .card-editable:hover .card-select,
body.edit-mode .card-editable.card-selected .card-select,
body.edit-mode .card-editable .card-select:focus { opacity: 1; }

.card-selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Edit-bar layout */
#edit-bar { padding: 0; }
.edit-bar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
}
.edit-bar-actions { display: flex; gap: 0.5rem; }

.edit-bar-bulk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.5rem;
  border-top: 1px dashed var(--border-accent);
  background: var(--accent-soft);
}
.edit-bar-bulk[hidden] { display: none; }
.bulk-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}
.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.bulk-badge-select {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-secondary.btn-danger-outline {
  color: #ff8a8a;
  border-color: rgba(245, 101, 101, 0.4);
}
.btn-secondary.btn-danger-outline:hover {
  background: rgba(245, 101, 101, 0.12);
  border-color: rgba(245, 101, 101, 0.6);
}

/* When the bulk row is visible, the edit-bar is taller — push the sticky
 * hero down accordingly. The .edit-mode + .has-bulk combo lets us bump
 * the offset without measuring the DOM. */
body.edit-mode.has-bulk .hero { top: 92px; }
