:root {
  --bg: #060b16;
  --panel: #111827;
  --line: #243044;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --accent: #60a5fa;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Noto Sans TC", sans-serif;
  background: radial-gradient(circle at top, #0b1220, var(--bg) 65%);
  color: var(--text);
}

.app-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}
.tab-btn.active { border-color: var(--accent); box-shadow: 0 0 0 1px #60a5fa55 inset; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.topbar h1 { margin: 0 0 6px 0; font-size: 28px; }
.topbar p { margin: 0; color: var(--muted); }
.const-badge {
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  color: #bfdbfe;
}
.card h2, .card h3 { margin-top: 0; }

.tabs {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tab-btn {
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.tab-btn.active { border-color: var(--accent); box-shadow: 0 0 0 1px #60a5fa55 inset; }

.tab-panel { display: none; margin-top: 14px; }
.tab-panel.active { display: block; }

.card {
  background: linear-gradient(160deg, #0c1628, #0a1321);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.card h2, .card h3 { margin-top: 0; }

textarea, input, select {
  width: 100%;
  margin-top: 6px;
  margin-bottom: 10px;
  background: #0a1321;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
}

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.btn {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: 0;
  color: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}
.tab-btn.active { border-color: var(--accent); box-shadow: 0 0 0 1px #60a5fa55 inset; }

.pipeline { display: grid; gap: 10px; }
.pipeline-card {
  border: 1px solid var(--line);
  background: #0a1321;
  border-radius: 10px;
  padding: 10px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s ease, transform .22s ease;
}
.pipeline-card.show {
  opacity: 1;
  transform: translateY(0);
}
.pipeline-title { font-weight: 700; margin-bottom: 6px; }
.pipeline-body { color: #d1d5db; font-size: 14px; }

.scbkr-dots { display: flex; gap: 8px; flex-wrap: wrap; }
.scbkr-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid #4b5563;
  color: #d1d5db;
  background: #1f2937;
  transition: background .3s ease, border-color .3s ease;
}
.scbkr-dot.ok { background: #14532d; border-color: var(--ok); }
.scbkr-dot.warn { background: #7c2d12; border-color: var(--warn); }

.decision { padding: 3px 8px; border-radius: 999px; font-weight: 700; display: inline-block; }
.decision.allow { background: #14532d; color: #bbf7d0; }
.decision.rewrite { background: #713f12; color: #fde68a; }
.decision.escalate { background: #7c2d12; color: #fdba74; }
.decision.block { background: #7f1d1d; color: #fecaca; }

.list { display: grid; gap: 8px; }
.list-item {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #0a1321;
  color: var(--text);
  cursor: pointer;
}
.list-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.5fr 1fr 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}
.list-row.header { font-weight: 700; background: #1f2937; }

.message {
  min-height: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  color: #cbd5e1;
  line-height: 1.5;
}
.message.ok { border-color: #166534; color: #bbf7d0; }
.message.err { border-color: #7f1d1d; color: #fecaca; }
.status.ok { color: #86efac; }
.status.err { color: #fca5a5; }
.muted { color: var(--muted); }

.saving-wrap {
  margin-top: 12px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #1f2937;
  overflow: hidden;
}
.saving-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  transition: width .22s ease;
}
.saving-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  transition: width .22s ease;
}
.saving-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  transition: width .22s ease;
}
.saving-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  transition: width .22s ease;
}
.saving-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  transition: width .22s ease;
}
.list-row.header { font-weight: 700; background: #1f2937; }

.blink-block {
  animation: blinkBlock .6s ease;
}
@keyframes blinkBlock {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .7); border-color: var(--bad); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); border-color: var(--line); }
}
.message.ok { border-color: #166534; color: #bbf7d0; }
.message.err { border-color: #7f1d1d; color: #fecaca; }
.status.ok { color: #86efac; }
.status.err { color: #fca5a5; }
.muted { color: var(--muted); }

@media (max-width: 1100px) {
  .split-3 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}


.ritual-card input { font-size: 13px; }
.mother-mode body, body.mother-mode {
  background: radial-gradient(circle at top, #1b1033, #07050f 70%);
}
body.mother-mode .card {
  border-color: #6d28d9;
  box-shadow: 0 0 0 1px rgba(168,85,247,.25) inset, 0 0 20px rgba(168,85,247,.15);
}
body.mother-mode .btn {
  background: linear-gradient(135deg, #7c3aed, #c084fc);
}


.nav { margin-top: 10px; }
.nav a { color: #93c5fd; text-decoration: none; font-weight: 600; }
.law-block {
  white-space: pre-wrap;
  background: #090f1a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.65;
  color: #e2e8f0;
  margin-top: 10px;
}

.provider-quick-connect input[readonly] {
  opacity: 0.9;
  cursor: not-allowed;
}

.hint-text {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: #cbd5e1;
}

.api-snippet-wrap {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 12px;
  background: #0a1321;
}

.api-snippet-wrap summary {
  cursor: pointer;
  font-weight: 700;
  color: #bfdbfe;
}


.accent-governance {
  color: #ff8a3c;
}

.accent-governance-badge {
  border-color: #ff8a3c !important;
}

.app-shell {
  position: relative;
  overflow: hidden;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  background: radial-gradient(circle at 20% 20%, rgba(255,138,60,0.08), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(96,165,250,0.08), transparent 45%),
    radial-gradient(circle at 50% 80%, rgba(99,102,241,0.08), transparent 45%);
  animation: governanceAmbient 36s ease-in-out infinite alternate;
}

@keyframes governanceAmbient {
  0% { transform: translate3d(-1%, -1%, 0) scale(1); }
  100% { transform: translate3d(1%, 1%, 0) scale(1.04); }
}

.governance-panel-wrap {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.governance-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #0a1321;
}
.pipeline-title { font-weight: 700; margin-bottom: 6px; }
.pipeline-body { color: #d1d5db; font-size: 14px; }

.governance-panel h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
}
.message.ok { border-color: #166534; color: #bbf7d0; }
.message.err { border-color: #7f1d1d; color: #fecaca; }
.status.ok { color: #86efac; }
.muted { color: var(--muted); }

.governance-panel .small {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 960px) {
  .governance-panel-wrap {
    grid-template-columns: 1fr;
  }
}
