:root {
  --bg: #f3f4f6;
  --fg: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --surface: #ffffff;
  --fill: #f9fafb;
  --fill-soft: #f3f4f6;
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef2ff;
  --brand-fg: #3730a3;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --added-bg: #ecfdf5;
  --added-fg: #047857;
  --added-line: #10b981;
  --removed-bg: #fef2f2;
  --removed-fg: #b91c1c;
  --removed-line: #ef4444;
  --modified-bg: #fffbeb;
  --modified-fg: #b45309;
  --modified-line: #f59e0b;
  --badge-draft-bg: #f3f4f6;
  --badge-draft-fg: #4b5563;
  --badge-published-bg: #ecfdf5;
  --badge-published-fg: #047857;
  --badge-deprecated-bg: #f5f3ff;
  --badge-deprecated-fg: #6d28d9;
  --badge-new-bg: #4f46e5;
  --badge-new-fg: #ffffff;
  --badge-pending-bg: #fffbeb;
  --badge-pending-fg: #b45309;
  --badge-pending-hot-bg: #fef2f2;
  --badge-pending-hot-fg: #b91c1c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--fg);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

a {
  color: var(--brand);
}

code,
.mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* ----- shell ----- */

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 16px 12px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 8px 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.role-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--fill-soft);
  border-radius: 999px;
}

.role-toggle-label {
  display: none;
}

.role-btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

.role-btn.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #c7d2fe;
  color: var(--brand-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

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

.nav-label {
  margin: 0 8px 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 550;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.nav a:hover {
  color: var(--fg);
  background: var(--fill);
}

.nav a.is-active {
  color: var(--brand-fg);
  background: var(--brand-soft);
}

.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--fill-soft);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.nav-label-2 {
  margin-top: 14px;
}

.main-flow {
  max-width: 1240px;
}

/* ----- spec document ----- */

.spec-board {
  display: grid;
  gap: 16px;
  align-items: start;
}

.spec-board.is-both {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
}

.spec-board.is-render,
.spec-board.is-raw {
  grid-template-columns: 1fr;
}

.spec-prose {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px 40px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.spec-prose h1 {
  margin: 0 0 12px;
  font-size: 26px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.spec-prose h2 {
  margin: 32px 0 10px;
  padding-top: 8px;
  font-size: 18px;
  letter-spacing: -0.02em;
  border-top: 1px solid var(--line);
}

.spec-prose h2:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.spec-prose h3 {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.spec-prose p {
  margin: 0 0 12px;
}

.spec-prose ul,
.spec-prose ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.spec-prose li {
  margin: 0 0 6px;
}

.spec-prose li ul,
.spec-prose li ol {
  margin: 6px 0 0;
}

.spec-prose code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 4px;
}

.spec-prose pre {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #111827;
  color: #e5e7eb;
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
}

.spec-prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

.spec-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 13px;
}

.spec-prose th,
.spec-prose td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.spec-prose th {
  background: var(--fill);
  font-weight: 650;
}

.spec-prose strong {
  font-weight: 650;
}

.spec-raw {
  margin: 0;
  padding: 16px 18px;
  background: #111827;
  color: #e5e7eb;
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 220px);
  font-size: 12px;
  line-height: 1.55;
  box-shadow: var(--shadow);
  position: sticky;
  top: 72px;
}

.spec-raw code {
  font-family: var(--mono);
  font-size: inherit;
  color: inherit;
  white-space: pre;
}

.spec-board.is-raw .spec-raw {
  max-height: none;
  position: static;
}

/* ----- flow explainer ----- */

.flow-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.flow-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 4px 0 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.flow-dot {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 99px;
  cursor: pointer;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.flow-dot.is-done {
  background: var(--brand-soft);
  border-color: #c7d2fe;
  color: var(--brand-fg);
}

.flow-dot.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.16);
}

.flow-dot-line {
  flex: 1;
  min-width: 8px;
  height: 2px;
  background: var(--line);
}

.flow-caption {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.flow-caption-k {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.flow-step-n {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.flow-actor-now {
  font-size: 11px;
  font-weight: 650;
  color: var(--brand-fg);
  background: var(--brand-soft);
  padding: 2px 8px;
  border-radius: 99px;
}

.flow-caption h2 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.flow-caption p {
  margin: 0 0 12px;
  color: var(--muted);
  max-width: 72ch;
}

.flow-actors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.flow-actor {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--fill-soft);
}

.flow-actor.is-active {
  color: var(--brand-fg);
  background: var(--brand-soft);
  font-weight: 650;
}

.flow-scene {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    radial-gradient(circle at 1px 1px, #e5e7eb 1px, transparent 0) 0 0 / 18px 18px,
    var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.flow-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr) 22px minmax(0, 1fr) 22px minmax(0, 1fr) 22px minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
  overflow-x: auto;
}

.flow-node {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  min-height: 156px;
  opacity: 0.55;
  transform: translateY(0);
  transition: opacity 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.flow-node.is-done {
  opacity: 0.92;
}

.flow-node.is-active {
  opacity: 1;
  border-color: #c7d2fe;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12), var(--shadow);
  transform: translateY(-2px);
}

.flow-node.is-live {
  border-color: #6ee7b7;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16), var(--shadow);
}

.flow-node-k {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.flow-placeholder {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.flow-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.flow-token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: 99px;
  background: var(--fill);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 550;
  animation: flowPop 0.4s ease both;
  animation-delay: calc(var(--i) * 90ms);
}

.flow-token b {
  width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}

.flow-tokens.is-ingest .flow-token {
  animation: flowIngest 0.85s ease forwards;
  animation-delay: calc(var(--i) * 70ms);
}

.flow-sop-title {
  font-weight: 650;
  font-size: 13px;
  line-height: 1.3;
  margin-bottom: 2px;
}

.flow-sop-id {
  color: var(--muted);
  margin-bottom: 8px;
}

.flow-mini-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.flow-file {
  border: 1px dashed #c7d2fe;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  padding: 8px;
  animation: flowPop 0.45s ease both;
}

.flow-file-h {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-fg);
  margin-bottom: 4px;
}

.flow-chat {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 8px;
  animation: flowPop 0.45s ease both;
}

.flow-chat-meta {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--added-fg);
  margin-bottom: 4px;
}

.flow-chat p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  animation: flowType 0.9s ease both;
}

.flow-pipe {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-pipe-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--line);
  border-radius: 99px;
}

.flow-pipe.is-live .flow-pipe-line {
  background: var(--brand);
}

.flow-packet {
  display: none;
}

.flow-pipe.is-live .flow-packet {
  display: block;
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 99px;
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
  animation: flowPacket 1.15s linear infinite;
}

.flow-gate {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.flow-gate.is-idle {
  color: var(--muted);
  font-size: 12px;
}

.flow-gate-h {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 8px;
}

.flow-meter {
  position: relative;
  height: 10px;
  background: var(--fill-soft);
  border-radius: 99px;
}

.flow-meter-fill {
  display: block;
  height: 100%;
  width: var(--p);
  border-radius: 99px;
  background: linear-gradient(90deg, #f59e0b 0%, #f59e0b 90%, #10b981 90%);
  transform: scaleX(0);
  transform-origin: left center;
  animation: flowFill 0.85s ease forwards;
}

.flow-meter-mark {
  position: absolute;
  left: 90%;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--fg);
  border-radius: 99px;
}

.flow-gate-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.flow-doc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.flow-doc.is-empty {
  padding-bottom: 8px;
}

.flow-doc-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--fill);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.flow-doc-line {
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.flow-doc-line.is-add {
  background: var(--added-bg);
  color: var(--added-fg);
  animation: flowLineIn 0.45s ease both;
}

.flow-doc-line.is-mod {
  background: var(--modified-bg);
  color: var(--modified-fg);
  animation: flowLineIn 0.45s ease both;
}

.flow-doc-line.is-del {
  background: var(--removed-bg);
  color: var(--removed-fg);
  text-decoration: line-through;
  animation: flowLineIn 0.45s ease both;
}

.flow-doc-line.is-pending {
  background: repeating-linear-gradient(
    -45deg,
    var(--added-bg),
    var(--added-bg) 8px,
    #fff 8px,
    #fff 12px
  );
  color: var(--added-fg);
  outline: 1px dashed var(--added-line);
  outline-offset: -1px;
  animation: flowLineIn 0.45s ease both;
}

.flow-doc-line.is-ghost {
  color: var(--muted);
  opacity: 0.7;
}

.flow-legend {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

@keyframes flowPop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes flowIngest {
  to {
    opacity: 0.25;
    transform: translateX(16px) scale(0.9);
  }
}

@keyframes flowFill {
  to {
    transform: scaleX(1);
  }
}

@keyframes flowPacket {
  from {
    left: 0;
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  to {
    left: calc(100% - 8px);
    opacity: 0.15;
  }
}

@keyframes flowPacketY {
  from {
    top: 0;
    left: 50%;
    margin-left: -4px;
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  to {
    top: calc(100% - 8px);
    left: 50%;
    margin-left: -4px;
    opacity: 0.15;
  }
}

@keyframes flowType {
  from {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
  }
  to {
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes flowLineIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-token,
  .flow-tokens.is-ingest .flow-token,
  .flow-file,
  .flow-chat,
  .flow-chat p,
  .flow-meter-fill,
  .flow-pipe.is-live .flow-packet,
  .flow-doc-line.is-add,
  .flow-doc-line.is-mod,
  .flow-doc-line.is-del,
  .flow-doc-line.is-pending,
  .flow-node {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    clip-path: none !important;
    opacity: 1 !important;
  }

  .flow-meter-fill {
    transform: scaleX(1) !important;
  }

  .flow-pipe.is-live .flow-packet {
    display: none !important;
  }
}

.main {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.note {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-fg);
  font-size: 13px;
}

/* ----- controls ----- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--fill-soft);
  border-radius: 999px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 550;
  font-size: 13px;
}

.tab.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.tab .count {
  margin-left: 6px;
  color: inherit;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

input[type="text"],
input[type="search"],
select,
textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 10px;
  width: 100%;
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
}

input[type="search"] {
  width: 240px;
}

select {
  width: 160px;
  background: var(--surface);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
  border-radius: var(--radius-sm);
  font-weight: 550;
  font-size: 13px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--fill);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--surface);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #fff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ----- table ----- */

.table {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-row,
.table-head {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
}

.table-head {
  border-bottom: 1px solid var(--line);
  background: var(--fill);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sop-grid {
  grid-template-columns: minmax(160px, 1.5fr) minmax(110px, 0.9fr) 100px 64px 90px 88px minmax(140px, 1.2fr);
}

.skill-grid {
  grid-template-columns: minmax(160px, 1.4fr) minmax(150px, 1.2fr) 88px 88px 100px minmax(160px, 1.3fr);
}

.member-grid {
  grid-template-columns: minmax(140px, 1.2fr) minmax(160px, 1.3fr) 100px 90px 90px;
}

.index-grid {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(200px, 1.6fr);
}

.table-row {
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.12s ease;
}

.table-head + .table-row {
  border-top: 0;
}

.table-row.is-static,
.table-row.is-static:hover {
  cursor: default;
  background: var(--surface);
}

a.table-row:hover,
.table-row.is-clickable:hover {
  background: #f8fafc;
}

.table-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.cell-title {
  font-weight: 600;
  color: var(--fg);
}

.cell-muted {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 0;
}

.badge-draft {
  background: var(--badge-draft-bg);
  color: var(--badge-draft-fg);
}

.badge-published {
  background: var(--badge-published-bg);
  color: var(--badge-published-fg);
}

.badge-deprecated {
  background: var(--badge-deprecated-bg);
  color: var(--badge-deprecated-fg);
}

.badge-skill {
  background: var(--brand-soft);
  color: var(--brand-fg);
}

.badge-will {
  background: var(--fill);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.badge-new {
  background: var(--badge-new-bg);
  color: var(--badge-new-fg);
}

.badge-pending {
  background: var(--badge-pending-bg);
  color: var(--badge-pending-fg);
}

.badge-pending-hot {
  background: var(--badge-pending-hot-bg);
  color: var(--badge-pending-hot-fg);
}

.badge-active {
  background: var(--badge-published-bg);
  color: var(--badge-published-fg);
}

.badge-removed {
  background: var(--badge-pending-hot-bg);
  color: var(--badge-pending-hot-fg);
  text-decoration: line-through;
}

/* ----- panels / cards ----- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.stack .panel,
.stack > .source-block {
  margin-bottom: 0;
}

.panel > .table {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--fill);
  font-weight: 600;
  font-size: 13px;
}

.panel-b {
  padding: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.meta-item {
  color: var(--muted);
  font-size: 13px;
}

.meta-item strong {
  color: var(--fg);
  font-weight: 600;
}

.body-preview {
  border: 1px solid var(--line);
  background: var(--fill);
  padding: 12px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.55;
  border-radius: var(--radius-sm);
}

.body-preview.is-editable {
  background: var(--surface);
}

.body-section + .body-section {
  margin-top: 14px;
}

.body-section h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.body-section p,
.body-section ol {
  margin: 0;
}

.body-section ol {
  padding-left: 18px;
}

/* ----- wizard ----- */

.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 20px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--fill-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

.step.is-active {
  background: var(--brand-soft);
  color: var(--brand-fg);
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.step.is-active .step-num {
  background: var(--brand);
  color: #fff;
}

.step-join {
  width: 28px;
  height: 2px;
  background: var(--line);
  margin: 0 6px;
}

.source-block {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.source-block.has-value {
  border-color: #c7d2fe;
  box-shadow: 0 0 0 1px #c7d2fe, var(--shadow);
}

.source-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
}

.source-b {
  padding: 16px;
}

.file-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.file-name {
  font-family: var(--mono);
  font-size: 12px;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.error {
  margin: 6px 0 0;
  color: var(--removed-fg);
  font-size: 12px;
}

.picker-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--fill-soft);
  border-radius: 999px;
  width: fit-content;
  margin-bottom: 10px;
}

.picker-tab {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 550;
  font-size: 13px;
}

.picker-tab.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.picker-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 180px;
  overflow: auto;
}

.picker-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.picker-item:first-child {
  border-top: 0;
}

.picker-item:hover {
  background: var(--fill);
}

.picker-item input {
  margin-top: 3px;
}

.selected-count {
  color: var(--muted);
  font-size: 12px;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
}

/* ----- skill detail ----- */

.diff-note {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-weight: 550;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.diff-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.diff-block:last-child {
  margin-bottom: 0;
}

.diff-h {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.diff-added {
  background: var(--added-bg);
  box-shadow: inset 3px 0 0 var(--added-line);
}

.diff-removed {
  background: var(--removed-bg);
  box-shadow: inset 3px 0 0 var(--removed-line);
}

.diff-modified {
  background: var(--modified-bg);
  box-shadow: inset 3px 0 0 var(--modified-line);
}

.diff-title {
  font-weight: 700;
  font-size: 14px;
}

.diff-cause {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.diff-b {
  padding: 12px 14px;
  background: var(--surface);
  color: var(--fg);
}

.diff-removed .diff-b {
  text-decoration: line-through;
  color: var(--removed-fg);
  background: #fff7f7;
}

.diff-added .diff-b {
  background: #f7fef9;
}

.line-diff {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.line-del {
  background: var(--removed-bg);
  color: var(--removed-fg);
  text-decoration: line-through;
  padding: 1px 4px;
}

.line-add {
  background: var(--added-bg);
  color: var(--added-fg);
  padding: 1px 4px;
}

.line-ctx {
  padding: 1px 4px;
  color: var(--muted);
}

.editor-textarea {
  min-height: 220px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.editor {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--fill);
  border-bottom: 1px solid var(--line);
}

.editor-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.lg {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lg-add {
  background: var(--added-bg);
  color: var(--added-fg);
}

.lg-mod {
  background: var(--modified-bg);
  color: var(--modified-fg);
}

.lg-del {
  background: var(--removed-bg);
  color: var(--removed-fg);
}

.md-doc {
  padding: 24px 28px 36px;
  font-size: 15px;
  line-height: 1.65;
  overflow: auto;
  max-height: 72vh;
}

.md-doc h2 {
  margin: 32px 0 10px;
  padding: 6px 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
}

.md-doc h2:first-of-type {
  margin-top: 8px;
}

.md-doc h3 {
  margin: 18px 0 6px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.md-doc p,
.md-doc li {
  margin: 0 0 8px;
  padding: 4px 10px;
  border-radius: 6px;
}

.md-doc ul,
.md-doc ol {
  margin: 0 0 14px;
  padding-left: 32px;
}

.md-doc li {
  margin: 0 0 4px;
}

.md-doc code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 4px;
}

.md-front {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 16px;
  margin: 0 0 24px;
  padding: 14px 16px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.md-front div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.md-front dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.md-front dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
}

.md-tag {
  margin: 20px 0 8px;
  padding: 2px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.md-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 0 18px;
  font-size: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.md-table th,
.md-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.md-table tr:last-child td {
  border-bottom: 0;
}

.md-table th {
  background: var(--fill);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.md-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
  text-transform: none;
  text-decoration: none;
}

.md-added {
  background: var(--added-bg);
  box-shadow: inset 3px 0 0 var(--added-line);
}

.md-removed {
  background: var(--removed-bg);
  box-shadow: inset 3px 0 0 var(--removed-line);
  text-decoration: line-through;
  color: var(--removed-fg);
}

.md-modified {
  background: var(--modified-bg);
  box-shadow: inset 3px 0 0 var(--modified-line);
}

.md-chip-added {
  background: #d1fae5;
  color: var(--added-fg);
  text-decoration: none;
}

.md-chip-removed {
  background: #fee2e2;
  color: var(--removed-fg);
  text-decoration: none;
}

.md-chip-modified {
  background: #fde68a;
  color: var(--modified-fg);
  text-decoration: none;
}

.banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.banner-added {
  background: var(--added-bg);
  border-color: #a7f3d0;
}

.banner-changed {
  background: var(--modified-bg);
  border-color: #fde68a;
}

.banner a {
  font-weight: 600;
}

.locked {
  border: 1px dashed var(--line);
  background: var(--fill);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.score-bar {
  display: inline-block;
  width: 44px;
  height: 6px;
  border-radius: 999px;
  background: var(--fill-soft);
  overflow: hidden;
}

.score-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.score-n {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 650;
}

.score-high .score-bar > span {
  background: #10b981;
}

.score-high .score-n {
  color: var(--added-fg);
}

.score-mid .score-bar > span {
  background: #f59e0b;
}

.score-mid .score-n {
  color: var(--modified-fg);
}

.score-low .score-bar > span {
  background: #ef4444;
}

.score-low .score-n {
  color: var(--removed-fg);
}

.conf {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conf-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  font-size: 13px;
}

.conf-h-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.conf-reason {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.conf-policy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.merge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.match-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--fill);
}

.match-card-h {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.match-card .conf {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.modal p {
  margin: 0 0 16px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .spec-board.is-both {
    grid-template-columns: 1fr;
  }

  .spec-raw {
    position: static;
    max-height: 420px;
  }
}

@media (max-width: 800px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
  }

  .nav-label {
    display: none;
  }

  .flow-controls {
    margin-left: 0;
    width: 100%;
  }

  .flow-rail {
    grid-template-columns: 1fr;
  }

  .flow-pipe {
    height: 22px;
  }

  .flow-pipe-line {
    width: 2px;
    height: 100%;
    margin: 0 auto;
  }

  .flow-pipe.is-live .flow-packet {
    animation: flowPacketY 1.15s linear infinite;
  }

  .sop-grid,
  .skill-grid,
  .member-grid,
  .index-grid {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .table-head {
    display: none;
  }

  .header {
    height: auto;
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  input[type="search"] {
    width: 100%;
  }

  .filters {
    margin-left: 0;
    width: 100%;
  }
}
