:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0e1a2b;
  --surface-raised: #132238;
  --surface-soft: #0a1525;
  --border: #2a3d5c;
  --border-strong: #3d5b86;
  --text: #f4f7ff;
  --muted: #adbed8;
  --accent: #4f8cff;
  --accent-hover: #75a5ff;
  --success: #4adea3;
  --warning: #ffd166;
  --danger: #ff7474;
  --focus: #8cc8ff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 5% -10%, rgba(40, 94, 160, 0.25), transparent 34rem),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea {
  outline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
}

a {
  color: #9ac4ff;
}

code {
  overflow-wrap: anywhere;
  padding: 0.12rem 0.38rem;
  border: 1px solid rgba(122, 159, 211, 0.22);
  border-radius: 0.38rem;
  background: var(--surface-soft);
  color: #dce9ff;
  font-size: 0.88em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.28rem, 2vw, 1.65rem);
  line-height: 1.2;
}

h2 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.16rem, 2vw, 1.45rem);
  line-height: 1.25;
}

h3 {
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.55rem;
  background: white;
  color: #07111f;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.9);
}

.header-meta,
.muted {
  color: var(--muted);
}

.header-meta {
  margin: 0;
  font-size: 0.88rem;
}

.header-actions,
.button-row,
.item-toolbar,
.toggle-group,
.call-status {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.version-chip {
  padding: 0.42rem 0.72rem;
  border: 1px solid rgba(74, 222, 163, 0.38);
  border-radius: 999px;
  background: rgba(74, 222, 163, 0.1);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 750;
}

.section-nav {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.65rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 17, 31, 0.96);
  backdrop-filter: blur(12px);
}

.section-nav a {
  flex: 0 0 auto;
  padding: 0.5rem 0.72rem;
  border-radius: 0.55rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.section-nav a:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(17rem, 0.9fr);
  gap: 1rem;
  width: min(92rem, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(14, 26, 43, 0.97);
  box-shadow: var(--shadow);
}

.editor-card,
.guardrail-card,
.full-width,
.status-grid .card {
  padding: clamp(1rem, 2.5vw, 1.45rem);
}

.full-width {
  grid-column: 1 / -1;
}

.hero {
  border-color: rgba(79, 140, 255, 0.68);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading > div:first-child {
  max-width: 52rem;
}

.section-heading-standalone {
  margin: 0 0 0.75rem;
}

.eyebrow {
  margin-bottom: 0.3rem;
  color: #8eb9f6;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.muted {
  margin-bottom: 0.7rem;
  font-size: 0.91rem;
}

.compact {
  margin: 0.4rem 0 0;
}

.publish-state {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-dot {
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
  background: var(--muted);
}

.publish-state.dirty .status-dot {
  background: var(--warning);
}

.publish-state.saved .status-dot {
  background: var(--success);
}

.notice {
  margin: 0 0 1rem;
  padding: 0.82rem 0.95rem;
  border: 1px solid rgba(79, 140, 255, 0.45);
  border-radius: 0.7rem;
  background: rgba(79, 140, 255, 0.12);
  color: #dbeaff;
}

.notice.error {
  border-color: rgba(255, 116, 116, 0.55);
  background: rgba(255, 116, 116, 0.12);
  color: #ffd5d5;
}

.notice.success {
  border-color: rgba(74, 222, 163, 0.45);
  background: rgba(74, 222, 163, 0.1);
  color: #c9ffe8;
}

.hidden {
  display: none;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 1.15rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

legend {
  padding: 0;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 780;
}

.fieldset-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.field-help {
  margin: 0.35rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.86rem;
}

label {
  display: block;
  margin: 0.72rem 0 0.35rem;
  color: #d8e5fa;
  font-size: 0.86rem;
  font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 0.65rem;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0.72rem 0.8rem;
}

textarea {
  min-height: 3rem;
  line-height: 1.45;
  resize: vertical;
}

input:hover,
textarea:hover {
  border-color: #587caf;
}

input:focus,
textarea:focus {
  border-color: var(--focus);
}

.character-count {
  margin-top: 0.32rem;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

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

.editor-item {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-soft);
}

.editor-item.disabled-item {
  opacity: 0.68;
}

.item-toolbar {
  justify-content: space-between;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin: 0;
  cursor: pointer;
  font-size: 0.82rem;
}

.check-control input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(10rem, 0.65fr) minmax(15rem, 1.35fr);
  gap: 0.75rem;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 0.62rem;
  cursor: pointer;
  font-weight: 760;
}

.button {
  min-height: 2.6rem;
  padding: 0.65rem 0.9rem;
}

.button.primary {
  background: var(--accent);
  color: white;
}

.button.primary:hover {
  background: var(--accent-hover);
  color: #07111f;
}

.button.secondary {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.button.secondary:hover,
.icon-button:hover {
  border-color: #6c91c5;
  background: #1a2c47;
}

.button.danger {
  background: #b93c4a;
  color: white;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-button {
  min-height: 2.15rem;
  padding: 0.42rem 0.58rem;
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 0.78rem;
}

.publish-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.3rem;
  padding: 1rem;
  border: 1px solid rgba(79, 140, 255, 0.4);
  border-radius: 0.8rem;
  background: rgba(79, 140, 255, 0.08);
}

.guardrail-card {
  align-self: start;
  position: sticky;
  top: 4.2rem;
}

.check-list,
.plain-list {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.check-list li,
.plain-list li {
  margin: 0.48rem 0;
}

.check-list li::marker {
  color: var(--success);
}

.version-list {
  display: grid;
  gap: 0.55rem;
}

.version-row {
  display: grid;
  grid-template-columns: minmax(6rem, 0.45fr) minmax(12rem, 1.5fr) minmax(10rem, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface-soft);
}

.version-title {
  font-weight: 800;
}

.version-detail {
  color: var(--muted);
  font-size: 0.8rem;
}

.call-status {
  margin: 0.75rem 0;
}

.pulse {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: #60708a;
}

.pulse.on {
  background: var(--success);
  box-shadow: 0 0 0 0.28rem rgba(74, 222, 163, 0.16);
}

.pulse.live {
  background: var(--danger);
  box-shadow: 0 0 0 0.28rem rgba(255, 116, 116, 0.16);
  animation: pulse 1.25s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.52;
  }
}

.call-log {
  min-height: 8rem;
  max-height: 17rem;
  overflow: auto;
  margin-top: 0.9rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #07101d;
  color: #c4d5ed;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.79rem;
  white-space: pre-wrap;
}

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

.status-grid .card {
  box-shadow: none;
}

.badge {
  display: inline-flex;
  padding: 0.3rem 0.62rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.badge.ok {
  background: rgba(74, 222, 163, 0.12);
  color: var(--success);
}

.badge.bad {
  background: rgba(255, 116, 116, 0.13);
  color: var(--danger);
}

.badge.warn {
  background: rgba(255, 209, 102, 0.12);
  color: var(--warning);
}

.text-link {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.86rem;
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(28rem, 100%);
  padding: clamp(1.35rem, 5vw, 2rem);
}

.login-card label {
  margin-top: 1rem;
}

.full-button {
  width: 100%;
  margin-top: 1.2rem;
}

@media (max-width: 900px) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .guardrail-card {
    position: static;
  }

  .full-width {
    grid-column: auto;
  }

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

  .version-row {
    grid-template-columns: 1fr 1fr;
  }

  .version-row .version-action {
    grid-column: 2;
    justify-self: end;
  }
}

@media (max-width: 620px) {
  .site-header,
  .section-heading,
  .fieldset-heading,
  .publish-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: space-between;
  }

  .two-column,
  .version-row {
    grid-template-columns: 1fr;
  }

  .version-row .version-action {
    grid-column: auto;
    justify-self: stretch;
  }

  .version-action .button {
    width: 100%;
  }

  .button-row .button {
    flex: 1 1 9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .pulse.live {
    animation: none;
  }
}
