:root {
  --bg: #07101d;
  --bg-soft: #0c1627;
  --panel: rgba(12, 22, 39, 0.86);
  --panel-strong: rgba(14, 24, 43, 0.96);
  --panel-muted: rgba(18, 30, 52, 0.78);
  --surface: #122036;
  --surface-soft: #162741;
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #edf4ff;
  --muted: #8ea1be;
  --muted-strong: #afc0db;
  --accent: #62e8d7;
  --accent-soft: rgba(98, 232, 215, 0.12);
  --accent-strong: #74f7e4;
  --warm: #f59e0b;
  --warm-soft: rgba(245, 158, 11, 0.12);
  --danger: #ff7a7a;
  --danger-soft: rgba(255, 122, 122, 0.12);
  --create: #76e39a;
  --create-soft: rgba(118, 227, 154, 0.12);
  --assign: #7cc9ff;
  --assign-soft: rgba(124, 201, 255, 0.12);
  --update: #ffbf69;
  --update-soft: rgba(255, 191, 105, 0.12);
  --remove: #ff8b99;
  --remove-soft: rgba(255, 139, 153, 0.12);
  --shadow: 0 28px 80px rgba(1, 6, 18, 0.46);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 10% 10%, rgba(98, 232, 215, 0.12), transparent 24%),
    radial-gradient(circle at 90% 6%, rgba(245, 158, 11, 0.12), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(124, 201, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #040915 0%, #07101d 38%, #09111f 100%);
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Manrope", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.6), transparent 88%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(14, 24, 43, 0.9);
  color: var(--text);
  padding: 0.9rem 1rem;
}

textarea {
  resize: vertical;
}

code {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

.app-shell,
.loading-shell {
  width: min(1520px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 26px 0 40px;
}

.workspace-card {
  background: linear-gradient(180deg, rgba(16, 28, 47, 0.92), rgba(10, 19, 33, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-shell {
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  align-items: flex-start;
  padding: 1.4rem 1.5rem 1.2rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, rgba(14, 24, 43, 0.94), rgba(10, 19, 33, 0.82));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hero-kicker,
.mini-kicker {
  margin: 0 0 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
}

.hero-copy h1,
.panel-heading h2,
.detail-header h3,
.modal-header h3,
.detail-body h3,
.loading-card h1,
.algorithm-hero h2,
.schema-card h3 {
  margin: 0;
  font-family: "Sora", sans-serif;
  letter-spacing: -0.045em;
}

.hero-copy h1 {
  font-size: clamp(2.1rem, 3.6vw, 4rem);
  max-width: 980px;
}

.hero-copy p:last-child,
.detail-header p,
.modal-header p,
.panel-heading p,
.pending-box p,
.detail-object-card p,
.algorithm-hero p,
.loading-card p {
  color: var(--muted);
  line-height: 1.65;
}

.hero-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  background: rgba(98, 232, 215, 0.1);
  border: 1px solid rgba(98, 232, 215, 0.22);
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.tab-chip,
.prompt-chip,
.view-chip,
.flow-card,
.ghost-button,
.primary-button {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.tab-chip {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.85rem 1.1rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
  font-weight: 700;
}

.tab-chip.is-active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(98, 232, 215, 0.16), rgba(124, 201, 255, 0.14));
  border-color: rgba(98, 232, 215, 0.2);
}

.tab-chip:hover,
.prompt-chip:hover,
.view-chip:hover,
.flow-card:hover,
.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.workspace-single {
  display: block;
}

.chat-pane {
  padding: 1.2rem;
  width: min(1180px, 100%);
  margin: 0 auto;
}

.panel-heading,
.detail-header,
.compact-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.panel-heading h2,
.detail-header h3,
.modal-header h3 {
  font-size: 1.35rem;
}

.panel-heading p,
.detail-header p,
.modal-header p {
  margin: 0.4rem 0 0;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
  align-items: center;
}

.count-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 0.84rem;
  white-space: nowrap;
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.prompt-chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.72rem 0.92rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.chat-row {
  display: flex;
}

.chat-row.is-user {
  justify-content: flex-end;
}

.chat-row.is-assistant {
  justify-content: flex-start;
}

.chat-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: min(84%, 760px);
}

.chat-row.is-user .chat-stack {
  align-items: flex-end;
}

.chat-row.is-assistant .chat-stack {
  align-items: flex-start;
}

.chat-bubble {
  position: relative;
  padding: 1rem 1.05rem 1.05rem;
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.chat-bubble::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  bottom: 16px;
  transform: rotate(45deg);
}

.assistant-bubble {
  background: linear-gradient(180deg, rgba(18, 32, 54, 0.98), rgba(14, 25, 43, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.assistant-bubble::after {
  left: -6px;
  background: rgba(16, 28, 47, 0.98);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.user-bubble {
  background: linear-gradient(135deg, rgba(34, 197, 182, 0.24), rgba(59, 130, 246, 0.28));
  border: 1px solid rgba(98, 232, 215, 0.24);
}

.user-bubble::after {
  right: -6px;
  background: linear-gradient(135deg, rgba(34, 197, 182, 0.24), rgba(59, 130, 246, 0.28));
  border-top: 1px solid rgba(98, 232, 215, 0.24);
  border-right: 1px solid rgba(98, 232, 215, 0.24);
}

.bubble-kicker {
  display: inline-flex;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.bubble-text {
  line-height: 1.72;
  white-space: pre-wrap;
}

.user-bubble .bubble-kicker {
  color: #cffef7;
}

.change-summary {
  width: 100%;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.change-summary.is-selected {
  border-color: rgba(98, 232, 215, 0.24);
  box-shadow: 0 0 0 1px rgba(98, 232, 215, 0.08) inset;
}

.summary-surface {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.95rem 1rem 0.85rem;
}

.summary-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.summary-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 800;
}

.summary-selected {
  font-size: 0.8rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(98, 232, 215, 0.12);
  border: 1px solid rgba(98, 232, 215, 0.2);
}

.change-summary h4 {
  margin: 0.75rem 0 0;
  font-size: 1rem;
  line-height: 1.45;
}

.summary-picker {
  display: grid;
  gap: 0.65rem;
  padding: 0 1rem 1rem;
}

.summary-picker-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.summary-pill-row,
.impact-note-row,
.detail-chip-row,
.impact-list,
.detail-stat-row,
.checkbox-grid,
.editor-actions,
.pending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.summary-token-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.summary-pill,
.impact-note,
.detail-chip,
.impact-token {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.65rem;
  border-radius: 999px;
  font-size: 0.84rem;
  border: 1px solid transparent;
}

.tone-create {
  background: var(--create-soft);
  color: var(--create);
}

.tone-assign {
  background: var(--assign-soft);
  color: var(--assign);
}

.tone-update {
  background: var(--update-soft);
  color: var(--update);
}

.tone-remove {
  background: var(--remove-soft);
  color: var(--remove);
}

.tone-muted {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
}

.summary-token,
.impact-token {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.58rem 0.7rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 0.82rem;
  line-height: 1.45;
}

.summary-token-tag {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.96;
}

.summary-token-text {
  min-width: 0;
  word-break: break-word;
}

.summary-token.tone-create,
.impact-token.tone-create {
  border-color: rgba(116, 255, 182, 0.28);
}

.summary-token.tone-assign,
.impact-token.tone-assign {
  border-color: rgba(124, 201, 255, 0.3);
}

.summary-token.tone-update,
.impact-token.tone-update {
  border-color: rgba(255, 214, 102, 0.3);
}

.summary-token.tone-remove,
.impact-token.tone-remove {
  border-color: rgba(255, 122, 122, 0.32);
}

.summary-token.tone-muted,
.impact-token.tone-muted {
  border-color: rgba(255, 255, 255, 0.08);
}

.view-chip,
.ghost-button,
.primary-button {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.72rem 0.92rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 700;
}

.primary-button,
.accent-button {
  background: linear-gradient(135deg, rgba(98, 232, 215, 0.22), rgba(124, 201, 255, 0.24));
  border-color: rgba(98, 232, 215, 0.24);
}

.danger-button {
  color: var(--danger);
  border-color: rgba(255, 122, 122, 0.22);
}

.pending-box,
.detail-body,
.detail-header,
.loading-card {
  padding: 1.15rem 1.2rem;
}

.pending-box {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  background: linear-gradient(135deg, rgba(255, 122, 122, 0.1), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 122, 122, 0.18);
  border-radius: var(--radius-lg);
}

.privacy-box {
  margin-top: 1rem;
  background: linear-gradient(135deg, rgba(98, 232, 215, 0.12), rgba(255, 255, 255, 0.03));
  border-color: rgba(98, 232, 215, 0.2);
}

.pending-box h3 {
  margin: 0;
}

.composer {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.composer-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: flex-end;
}

.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 6, 16, 0.72);
  backdrop-filter: blur(16px);
}

.modal-card {
  position: relative;
  width: min(1400px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.2rem 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  display: grid;
  gap: 0.75rem;
  justify-items: end;
}

.modal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0 1.25rem 1rem;
}

.modal-content {
  overflow: auto;
  padding: 0 1rem 1rem;
}

.modal-content > .workspace-card {
  box-shadow: none;
  background: rgba(255, 255, 255, 0.03);
}

.relation-tree-wrap {
  overflow-x: auto;
}

.relation-tree,
.tree-children {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.tree-children {
  margin-left: 1.25rem;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
}

.tree-node + .tree-node {
  margin-top: 0.7rem;
}

.tree-node-card {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.tree-node-card span {
  color: var(--accent-strong);
  font-weight: 800;
}

.relation-tree-empty,
.database-note p:last-child {
  color: var(--muted);
}

.view-chip.is-active {
  background: var(--accent-soft);
  border-color: rgba(98, 232, 215, 0.22);
  color: var(--accent-strong);
}

.impact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.impact-block {
  border-radius: var(--radius-md);
  padding: 0.95rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.impact-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-weight: 800;
}

.detail-section + .detail-section {
  margin-top: 1rem;
}

.detail-copy {
  margin: 0 0 0.85rem;
  color: var(--muted);
  max-width: 760px;
}

.detail-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.detail-object-card,
.schema-card,
.mcp-card,
.editor-item {
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding: 0.95rem;
}

.detail-object-card h4,
.schema-card h3,
.mcp-card h3 {
  margin: 0 0 0.35rem;
  font-family: "Sora", sans-serif;
}

.detail-list {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.8rem;
  color: var(--muted-strong);
}

.muted-chip {
  color: var(--muted);
}

.matrix-wrap {
  overflow-x: auto;
}

.matrix {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
}

.matrix th,
.matrix td {
  padding: 0.8rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.matrix th {
  font-size: 0.86rem;
  color: var(--muted-strong);
}

.matrix th small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
}

.cell-allow,
.cell-deny {
  border-radius: 14px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
}

.cell-allow {
  background: var(--create-soft);
  color: var(--create);
}

.cell-deny {
  background: var(--danger-soft);
  color: var(--danger);
}

.graph-scroll {
  overflow-x: auto;
  padding-bottom: 0.4rem;
}

.graph-shell {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 220px));
  justify-content: center;
  gap: clamp(36px, 4vw, 72px);
  min-height: 520px;
  padding: 0 12px;
}

.graph-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.graph-edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 2;
}

.graph-edge.is-linked {
  stroke: rgba(98, 232, 215, 0.72);
  stroke-width: 3;
}

.graph-edge.is-descendant {
  stroke: rgba(255, 214, 102, 0.82);
  stroke-width: 3;
}

.graph-edge.is-ancestor {
  stroke: rgba(124, 201, 255, 0.82);
  stroke-width: 3;
}

.graph-edge.is-negative {
  stroke: rgba(255, 122, 122, 0.88);
  stroke-width: 3;
  stroke-dasharray: 6 8;
}

.graph-edge.is-excluded {
  stroke: rgba(255, 122, 122, 0.68);
  stroke-dasharray: 6 8;
}

.graph-column {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
  align-items: flex-start;
}

.graph-heading {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  font-weight: 800;
}

.graph-node {
  position: relative;
  width: min(220px, 100%);
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  min-height: 86px;
}

.graph-node strong {
  display: block;
  line-height: 1.35;
}

.graph-node small {
  color: var(--muted);
  display: block;
  margin-top: 0.35rem;
  line-height: 1.45;
}

.graph-lock {
  border-left: 4px solid var(--node-accent, var(--accent));
  cursor: pointer;
}

.graph-node.is-focus {
  border-color: rgba(98, 232, 215, 0.24);
  box-shadow: 0 0 0 1px rgba(98, 232, 215, 0.08) inset;
}

.graph-node.is-hover-lock,
.graph-node.is-linked {
  border-color: rgba(98, 232, 215, 0.34);
  box-shadow: 0 0 0 1px rgba(98, 232, 215, 0.12) inset, 0 0 28px rgba(98, 232, 215, 0.12);
}

.graph-node.is-descendant-lock,
.graph-node.is-descendant-info {
  border-color: rgba(255, 214, 102, 0.42);
  box-shadow: 0 0 0 1px rgba(255, 214, 102, 0.12) inset, 0 0 28px rgba(255, 214, 102, 0.12);
}

.graph-node.is-ancestor-lock {
  border-color: rgba(124, 201, 255, 0.42);
  box-shadow: 0 0 0 1px rgba(124, 201, 255, 0.12) inset, 0 0 28px rgba(124, 201, 255, 0.12);
}

.graph-node.is-negative-lock,
.graph-node.is-negative-info,
.graph-node.is-negative-person {
  border-color: rgba(255, 122, 122, 0.42);
  box-shadow: 0 0 0 1px rgba(255, 122, 122, 0.12) inset, 0 0 28px rgba(255, 122, 122, 0.12);
}

.mcp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.wide-card {
  grid-column: 1 / -1;
}

.entity-form {
  display: grid;
  gap: 0.75rem;
}

.checkbox-grid {
  gap: 0.45rem;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.48rem 0.68rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 0.84rem;
}

.checkbox-pill input {
  width: auto;
  margin: 0;
}

.editor-block {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.editor-block > summary,
.editor-item > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 800;
}

.editor-block > summary::-webkit-details-marker,
.editor-item > summary::-webkit-details-marker {
  display: none;
}

.editor-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.9rem;
}

.editor-item {
  padding: 0.85rem;
}

.editor-item form {
  margin-top: 0.85rem;
}

.database-form {
  display: grid;
  gap: 1rem;
}

.database-note h3,
.database-head h4 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.database-section {
  display: grid;
  gap: 0.65rem;
}

.database-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.database-head span {
  color: var(--muted);
  font-size: 0.86rem;
}

.database-wrap {
  overflow-x: auto;
}

.database-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
}

.database-table th,
.database-table td {
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.database-table th {
  color: var(--muted-strong);
  font-size: 0.82rem;
}

.database-table input,
.database-table textarea,
.database-table select {
  min-width: 140px;
}

.database-table textarea {
  min-height: 90px;
}

.database-actions {
  display: flex;
  justify-content: flex-end;
}

.algorithm-shell {
  display: grid;
  gap: 1rem;
}

.algorithm-hero,
.algorithm-flow {
  padding: 1.2rem;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.8rem;
}

.flow-card {
  text-align: left;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 1rem;
  display: grid;
  gap: 0.5rem;
}

.flow-card.is-active {
  border-color: rgba(98, 232, 215, 0.22);
  background: linear-gradient(135deg, rgba(98, 232, 215, 0.12), rgba(124, 201, 255, 0.08));
}

.flow-count {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.algorithm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 1rem;
}

.schema-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.schema-list {
  margin: 0.75rem 0 0;
  padding-left: 1rem;
  color: var(--muted-strong);
  display: grid;
  gap: 0.45rem;
}

.loading-card {
  max-width: 640px;
  margin: 12vh auto 0;
}

.error-banner {
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 122, 122, 0.18);
  background: var(--danger-soft);
  color: var(--danger);
}

.app-shell.is-busy {
  opacity: 0.95;
}

.ghost-button:disabled,
.primary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 1240px) {
  .algorithm-grid,
  .mcp-grid {
    grid-template-columns: 1fr;
  }

  .flow-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 880px) {
  .app-shell,
  .loading-shell {
    width: min(100vw - 18px, 100%);
    padding-top: 16px;
  }

  .hero-shell,
  .panel-heading,
  .detail-header,
  .modal-header,
  .pending-box {
    flex-direction: column;
  }

  .modal-shell {
    padding: 12px;
  }

  .modal-card {
    width: min(100vw - 12px, 100%);
    max-height: calc(100vh - 24px);
  }

  .modal-actions {
    justify-items: stretch;
  }

  .chat-stack {
    max-width: 100%;
  }

  .impact-grid,
  .detail-card-row {
    grid-template-columns: 1fr;
  }

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