/* =========================================================================
   sopslop · the wow layer
   ------------------------------------------------------------------------- */

:root {
  --bg: #08080f;
  --bg-soft: #0d0d18;
  --surface: rgba(22, 22, 36, 0.62);
  --surface-2: rgba(28, 28, 46, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ecedf5;
  --text-soft: #b6b8cc;
  --text-mute: #7e8199;
  --text-faint: #5b5e74;
  --accent-1: #7c5cff;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --accent-warn: #f5a524;
  --accent-danger: #f87171;
  --accent-success: #34d399;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px rgba(124, 92, 255, 0.18), 0 30px 60px -20px rgba(124, 92, 255, 0.35);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font-sans: "Inter", "SF Pro Text", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
  --grad: linear-gradient(120deg, var(--accent-1), var(--accent-2) 55%, var(--accent-3));
  --grad-soft: linear-gradient(120deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.14) 60%, rgba(244, 114, 182, 0.18));
}

[data-theme="light"] {
  --bg: #f6f6fb;
  --bg-soft: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-2: rgba(255, 255, 255, 0.92);
  --border: rgba(15, 18, 40, 0.08);
  --border-strong: rgba(15, 18, 40, 0.16);
  --text: #14162a;
  --text-soft: #44475e;
  --text-mute: #6c708a;
  --text-faint: #9094ad;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 50px rgba(20, 22, 60, 0.12);
  --shadow-glow: 0 0 0 1px rgba(124, 92, 255, 0.18), 0 24px 50px -22px rgba(124, 92, 255, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; }
::selection { background: rgba(124, 92, 255, 0.45); color: #fff; }

/* ---------- Animated mesh background ----------------------------------- */

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-blob {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.55;
  mix-blend-mode: screen;
  animation: blob-float 26s ease-in-out infinite alternate;
}

.bg-blob-1 { background: radial-gradient(circle at 30% 30%, #7c5cff, transparent 60%); top: -20%; left: -15%; }
.bg-blob-2 { background: radial-gradient(circle at 60% 40%, #22d3ee, transparent 60%); top: 20%; right: -20%; animation-delay: -8s; }
.bg-blob-3 { background: radial-gradient(circle at 50% 50%, #f472b6, transparent 60%); bottom: -25%; left: 30%; animation-delay: -16s; }

[data-theme="light"] .bg-blob { opacity: 0.45; mix-blend-mode: multiply; filter: blur(140px); }

@keyframes blob-float {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(6vw, -4vh) scale(1.08); }
  100% { transform: translate(-4vw, 5vh) scale(0.96); }
}

.bg-grain {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 1px;
  mix-blend-mode: overlay;
  opacity: 0.25;
}

[data-theme="light"] .bg-grain { opacity: 0.5; mix-blend-mode: multiply; }

/* ---------- Glass primitive ------------------------------------------- */

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-1);
}

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 220% 220%;
  animation: grad-pan 14s ease-in-out infinite;
  display: inline-block;
}

@keyframes grad-pan {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ---------- Topbar ----------------------------------------------------- */

.topbar {
  position: sticky;
  top: 12px;
  z-index: 50;
  margin: 12px 18px 0;
  padding: 10px 16px;
  border-radius: 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  transition: transform 0.18s ease;
}
.brand:hover { transform: translateY(-1px); }

.brand-mark {
  display: inline-flex;
  filter: drop-shadow(0 4px 16px rgba(124, 92, 255, 0.35));
}

.brand-name-1 { color: var(--text); }
.brand-name-2 {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search {
  position: relative;
  width: min(100%, 560px);
  justify-self: center;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(10, 12, 26, 0.55);
  border: 1px solid var(--border);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
[data-theme="light"] .search-shell { background: rgba(255, 255, 255, 0.7); }

.search-shell:focus-within {
  border-color: rgba(124, 92, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18);
}

.search-icon { color: var(--text-mute); flex: none; }
.search-shell input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0.01em;
}

.search-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  color: var(--text-mute);
  border: 1px solid var(--border);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 70vh;
  overflow: auto;
  background: var(--surface-2);
  backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  padding: 8px;
  display: none;
}
.search-results.is-open:not(:empty) { display: block; }

.search-empty {
  padding: 16px 14px;
  color: var(--text-mute);
  font-size: 13px;
}
.search-empty-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 4px;
}

.search-list { display: flex; flex-direction: column; }
.search-hit {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.search-hit:hover, .search-hit:focus-visible {
  background: rgba(124, 92, 255, 0.12);
  outline: none;
  transform: translateX(2px);
}
.search-hit-top {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.search-hit-title {
  font-weight: 600;
  color: var(--text);
}
.search-hit-snippet {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.5;
}
.search-hit-snippet mark {
  background: rgba(244, 114, 182, 0.22);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.top-actions { display: flex; align-items: center; gap: 8px; }
.top-link {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-mute);
  background: rgba(255,255,255,0.02);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.top-link:hover { color: var(--text); border-color: var(--border-strong); }

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-soft);
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.icon-btn:hover { color: var(--text); transform: translateY(-1px); }
.icon-sun { display: none; }
.icon-moon { display: inline-block; }
[data-theme="light"] .icon-sun { display: inline-block; }
[data-theme="light"] .icon-moon { display: none; }

.icon-sound-off { display: none; }
.icon-sound-on { display: inline-block; }
.icon-btn[data-muted="true"] .icon-sound-on { display: none; }
.icon-btn[data-muted="true"] .icon-sound-off { display: inline-block; }
.icon-btn[data-muted="true"] { color: var(--text-faint); }

/* ---------- User menu ------------------------------------------------- */

.user-menu { position: relative; }
.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.user-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
}
.user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  background: var(--grad);
  border-color: transparent;
}
.user-name {
  font-size: 13px;
  font-weight: 500;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  border-radius: 14px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  display: none;
  z-index: 60;
}
.user-menu.is-open .user-pop { display: block; }
.user-pop-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-pop-head strong { font-size: 13.5px; }
.user-pop-head span { font-size: 12px; color: var(--text-mute); font-family: var(--font-mono); }
.user-pop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-soft);
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
.user-pop-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* ---------- Welcome overlay (post-login fallback) --------------------- */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 4, 10, 0.78);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.32s ease;
  cursor: pointer;
}
.welcome-overlay.is-visible { opacity: 1; }
.welcome-overlay-card {
  text-align: center;
  padding: 36px 48px;
  border-radius: 22px;
  background: rgba(15, 15, 26, 0.7);
  border: 1px solid rgba(124, 92, 255, 0.4);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 60px rgba(124, 92, 255, 0.25);
  transform: translateY(8px) scale(0.97);
  transition: transform 0.4s cubic-bezier(.22,1,.36,1);
}
.welcome-overlay.is-visible .welcome-overlay-card { transform: translateY(0) scale(1); }
.welcome-overlay-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.welcome-overlay-title {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome-overlay-sub { margin: 0; color: var(--text-mute); font-size: 13px; }

/* ---------- Layout ----------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  padding: 22px 22px 40px;
  flex: 1;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  padding: 16px 14px 14px;
  overflow: hidden;
}

.sidebar-head { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.seg-control {
  display: flex;
  background: rgba(10, 12, 26, 0.55);
  border-radius: 12px;
  padding: 4px;
  border: 1px solid var(--border);
}
[data-theme="light"] .seg-control { background: rgba(0,0,0,0.04); }

.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--text-mute);
  transition: color 0.18s ease, background 0.18s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active {
  background: var(--grad);
  color: white;
  box-shadow: 0 6px 18px -8px rgba(124, 92, 255, 0.7);
}
.seg-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
  color: inherit;
}
.seg-btn:not(.is-active) .seg-count { background: rgba(255,255,255,0.06); color: var(--text-faint); }

.sidebar-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-mute);
}
.sidebar-filter input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.doc-list {
  list-style: none;
  margin: 0;
  padding: 8px 2px 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.doc-list::-webkit-scrollbar { width: 8px; }
.doc-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 8px; }

.doc-list-item { padding: 0; margin: 0; }

.doc-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "kind title"
    "kind area";
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 12px;
  margin: 3px 0;
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.doc-card:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
  transform: translateX(2px);
}
.doc-card.is-active {
  background: linear-gradient(120deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.10));
  border-color: rgba(124, 92, 255, 0.45);
  box-shadow: 0 8px 30px -16px rgba(124, 92, 255, 0.7);
}
.doc-kind {
  grid-area: kind;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 4px 7px;
  border-radius: 6px;
  text-transform: uppercase;
}
.doc-kind-sop { background: rgba(124, 92, 255, 0.15); color: #c4b5fd; border: 1px solid rgba(124, 92, 255, 0.3); }
.doc-kind-kb  { background: rgba(34, 211, 238, 0.13); color: #67e8f9; border: 1px solid rgba(34, 211, 238, 0.3); }
[data-theme="light"] .doc-kind-sop { color: #5b3df0; }
[data-theme="light"] .doc-kind-kb  { color: #0891b2; }

.doc-title {
  grid-area: title;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}
.doc-area {
  grid-area: area;
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.01em;
  text-transform: capitalize;
}

/* ---------- Content area ----------------------------------------------- */

.content-wrap {
  min-width: 0;
  view-transition-name: content;
}

::view-transition-old(content) { animation: vt-out 240ms ease forwards; }
::view-transition-new(content) { animation: vt-in 320ms ease forwards; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Landing ---------------------------------------------------- */

.landing { display: flex; flex-direction: column; gap: 22px; }

.hero {
  border-radius: var(--radius-lg);
  padding: 42px 44px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: var(--grad-soft);
  opacity: 0.6;
  z-index: -1;
}

.hero-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 18px 0 16px;
  display: flex;
  flex-direction: column;
}
.hero-title .grad-text { display: block; }

.hero-sub {
  max-width: 64ch;
  color: var(--text-soft);
  font-size: 16.5px;
  line-height: 1.6;
  margin: 0 0 26px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--grad);
  color: white;
  border-color: transparent;
  box-shadow: 0 12px 32px -12px rgba(124, 92, 255, 0.7);
}
.btn-primary:hover { box-shadow: 0 16px 40px -12px rgba(124, 92, 255, 0.85); }
.btn-ghost {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--border-strong); background: rgba(255,255,255,0.07); }

.kbd-inline {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.16);
}

.hero-stats {
  display: flex;
  gap: 36px;
  margin: 32px 0 0;
  padding: 0;
}
.hero-stats > div { display: flex; flex-direction: column; }
.hero-stats dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.hero-stats dd {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
}

.lane-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 6px 12px;
}
.lane-head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.lane-count {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  color: var(--text-mute);
  border: 1px solid var(--border);
}

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

.feature-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}
.feature-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--grad);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}
.feature-card:hover::before { opacity: 1; }

.feature-card-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.feature-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.feature-card-meta {
  margin: auto 0 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-mute);
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-soft);
  text-transform: capitalize;
}
.chip-muted { color: var(--text-mute); }
.chip-status { text-transform: uppercase; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; }
.chip-status-draft { background: rgba(245, 165, 36, 0.12); color: #fbbf24; border-color: rgba(245, 165, 36, 0.3); }
.chip-status-published { background: rgba(52, 211, 153, 0.12); color: var(--accent-success); border-color: rgba(52, 211, 153, 0.3); }

/* ---------- Article ---------------------------------------------------- */

.article { display: flex; flex-direction: column; gap: 18px; }

.article-head {
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  position: relative;
  overflow: hidden;
}
.article-head::after {
  content: "";
  position: absolute;
  inset: -1px;
  background: var(--grad-soft);
  opacity: 0.4;
  z-index: -1;
}

.article-head-top { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.article-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.022em;
  font-weight: 700;
  margin: 14px 0 6px;
  background: linear-gradient(180deg, var(--text) 60%, var(--text-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.article-id {
  margin: 6px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-mute);
  font-size: 12px;
}
.article-id-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.article-id code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-soft);
}

.article-source { color: var(--text-mute); font-size: 13px; margin: 10px 0 0; }
.article-source strong { color: var(--text); font-weight: 600; }

.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 22px;
  align-items: start;
}

.article-body {
  border-radius: var(--radius-lg);
  padding: 32px 38px 36px;
}

.toc-rail { position: sticky; top: 92px; }

.toc {
  border-radius: var(--radius-md);
  padding: 16px 16px 18px;
}
.toc-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.toc-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 2px; }
.toc-item a {
  display: block;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-mute);
  border-left: 2px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  line-height: 1.4;
}
.toc-item a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.toc-l3 a { padding-left: 22px; font-size: 12px; }
.toc-item a.is-active {
  color: var(--text);
  background: rgba(124, 92, 255, 0.08);
  border-left-color: var(--accent-1);
}
.toc-empty { color: var(--text-faint); font-size: 12px; }

/* ---------- Markdown body --------------------------------------------- */

.markdown { color: var(--text); font-size: 15.5px; line-height: 1.72; }
.markdown > *:first-child { margin-top: 0; }
.markdown h2, .markdown h3, .markdown h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--text);
  scroll-margin-top: 92px;
}
.markdown h2 {
  margin: 38px 0 14px;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.markdown h2::before {
  content: "";
  width: 4px;
  height: 22px;
  border-radius: 4px;
  background: var(--grad);
  flex: none;
}
.markdown h3 { margin: 26px 0 10px; font-size: 17px; }
.markdown h4 { margin: 20px 0 8px; font-size: 15px; }

.markdown p { margin: 0 0 14px; color: var(--text-soft); }
.markdown strong { color: var(--text); font-weight: 600; }
.markdown em { color: var(--text-soft); }
.markdown a { color: var(--accent-2); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.markdown a:hover { color: var(--accent-1); }
.markdown ul, .markdown ol { margin: 6px 0 16px; padding-left: 22px; color: var(--text-soft); }
.markdown li { margin: 4px 0; }
.markdown li::marker { color: var(--text-faint); }
.markdown blockquote {
  margin: 16px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--accent-1);
  background: rgba(124, 92, 255, 0.06);
  border-radius: 0 10px 10px 0;
  color: var(--text-soft);
}
.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 16px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.markdown th, .markdown td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.markdown th { background: rgba(255,255,255,0.04); font-weight: 600; color: var(--text); }

.markdown code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.markdown pre {
  margin: 14px 0;
  padding: 16px 18px;
  border-radius: 12px;
  background: rgba(8, 8, 16, 0.7);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}
.markdown pre code { background: transparent; border: 0; padding: 0; }

/* ---------- Step blocks ------------------------------------------------ */

.step {
  display: grid;
  grid-template-columns: 48px 1fr;
  column-gap: 16px;
  row-gap: 0;
  margin: 10px 0;
  padding: 14px 16px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: 14px;
  position: relative;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.step + .step { margin-top: 8px; }
.step:hover { border-color: rgba(124, 92, 255, 0.35); background: rgba(124, 92, 255, 0.04); }

.step-head {
  grid-column: 1 / span 2;
  display: contents;
}
.step-num {
  grid-column: 1;
  grid-row: 1 / -1;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  background: var(--grad);
  color: white;
  border-radius: 12px;
  align-self: start;
  box-shadow: 0 10px 22px -12px rgba(124, 92, 255, 0.7);
}

.step-titles {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 22px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-mute);
}
.pill-actor { color: #c4b5fd; border-color: rgba(124, 92, 255, 0.35); background: rgba(124, 92, 255, 0.10); }
.pill-confidence { color: var(--accent-success); border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.10); }

.step-body {
  grid-column: 2;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  margin-top: 6px;
}

.step-meta {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 4px;
}
.step-body + .step-meta {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.step-meta-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-right: 6px;
  flex: none;
}
.step-meta-value { color: var(--text-soft); }

/* ---------- Decision tiles -------------------------------------------- */

.decision-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 16px;
  display: grid;
  gap: 14px;
}
.decision-list .decision-item {
  list-style: none;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  margin: 0;
}
.decision-q {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-3);
  padding: 2px 8px;
  background: rgba(244, 114, 182, 0.12);
  border: 1px solid rgba(244, 114, 182, 0.3);
  border-radius: 6px;
  margin-right: 10px;
}

.decision-branches {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.decision-branch {
  list-style: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-soft);
  display: flex;
  gap: 8px;
  border: 1px solid var(--border);
}
.decision-yes { background: rgba(52, 211, 153, 0.07); border-color: rgba(52, 211, 153, 0.25); }
.decision-no  { background: rgba(248, 113, 113, 0.07); border-color: rgba(248, 113, 113, 0.25); }

/* ---------- Callout (warnings / SME review) --------------------------- */

.callout-warning {
  position: relative;
  padding: 22px 24px 18px;
  margin: 28px 0;
  border-radius: 16px;
  background: rgba(245, 165, 36, 0.06);
  border: 1px solid rgba(245, 165, 36, 0.25);
}
.callout-warning > h2 {
  margin-top: 0;
  color: var(--accent-warn);
}
.callout-warning > h2::before { background: linear-gradient(180deg, var(--accent-warn), #f97316); }

/* ---------- Related ---------------------------------------------------- */

.related { margin-top: 36px; }
.related h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.related-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.025);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.related-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.related-title { font-weight: 600; font-size: 14px; }

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

.footer {
  margin-top: auto;
  padding: 22px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  background: rgba(0,0,0,0.18);
}
[data-theme="light"] .footer { background: rgba(255,255,255,0.4); }

/* ---------- Responsive ------------------------------------------------- */

@media (max-width: 1100px) {
  .article-grid { grid-template-columns: minmax(0, 1fr); }
  .toc-rail { position: relative; top: 0; order: -1; }
}

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { position: relative; top: 0; max-height: 360px; }
  .topbar { grid-template-columns: auto 1fr; gap: 10px; }
  .top-actions { display: none; }
  .search { grid-column: 1 / -1; order: 3; }
  .hero { padding: 28px 22px; }
  .article-body { padding: 22px 20px; }
  .step { grid-template-columns: 40px 1fr; column-gap: 12px; padding: 12px 14px; }
  .step-num { width: 40px; height: 40px; font-size: 17px; border-radius: 10px; }
  .decision-branches { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation: none !important; transition: none !important; }
}
