:root {
  --bg: #0a0a0b;
  --bg-elevated: #121214;
  --bg-card: #151518;
  --border: rgba(245, 200, 110, 0.12);
  --border-strong: rgba(245, 200, 110, 0.28);
  --text: #f2efe8;
  --text-muted: #9a958a;
  --text-dim: #6e6a62;
  --gold: #e4b84a;
  --gold-soft: #c9a04a;
  --gold-dim: rgba(228, 184, 74, 0.14);
  --ok: #5ecf8e;
  --warn: #e4b84a;
  --idle: #7a7670;
  --err: #e07a6a;
  --radius: 10px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(228, 184, 74, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(228, 184, 74, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 120vw);
  height: 420px;
  background: radial-gradient(
    ellipse at center,
    rgba(228, 184, 74, 0.09),
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  padding: 1.75rem clamp(1.25rem, 4vw, 2.5rem) 1.25rem;
  border-bottom: 1px solid var(--border);
  animation: fade-down 0.55s ease both;
}

.brand {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand-block h1 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem 1.5rem;
}

.meta-stack {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.meta-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#generated-at,
#bot-count {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gold-dim);
  border-color: var(--border-strong);
  color: var(--gold);
}

.btn-primary:hover:not(:disabled) {
  background: rgba(228, 184, 74, 0.22);
}

.btn-trigger {
  width: 100%;
  text-align: left;
}

main {
  padding: 1.5rem clamp(1.25rem, 4vw, 2.5rem) 3rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: 1280px;
  margin: 0 auto;
}

.status-bar {
  animation: fade-up 0.5s ease 0.08s both;
}

.load-status {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.load-status.is-error {
  color: var(--err);
}

.source-note {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.section {
  animation: fade-up 0.55s ease both;
}

.section:nth-of-type(2) {
  animation-delay: 0.12s;
}
.section:nth-of-type(3) {
  animation-delay: 0.18s;
}
.section:nth-of-type(4) {
  animation-delay: 0.24s;
}
.section:nth-of-type(5) {
  animation-delay: 0.3s;
}

.section-head {
  margin-bottom: 1.1rem;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.section-sub {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  max-width: 42rem;
  font-size: 0.92rem;
}

.section-sub code {
  font-size: 0.82em;
  color: var(--gold-soft);
}

.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
}

.bot-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.2s ease;
}

.bot-card:hover {
  border-color: var(--border-strong);
}

.bot-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.bot-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.bot-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gold-soft);
  letter-spacing: 0.02em;
}

.bot-role {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

.chip-brain {
  color: var(--gold);
  background: var(--gold-dim);
  border-color: transparent;
}

.field-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.busy {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
}

.busy.is-unknown {
  color: var(--text-dim);
  font-style: italic;
}

.outputs {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.outputs li + li {
  margin-top: 0.2rem;
}

.muted-empty {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.routines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.routines-table th,
.routines-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.routines-table th {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
}

.routines-table tbody tr:last-child td {
  border-bottom: none;
}

.routines-table td:first-child {
  font-weight: 600;
  white-space: normal;
  min-width: 10rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-succeeded {
  color: var(--ok);
  background: rgba(94, 207, 142, 0.12);
}

.badge-never_run {
  color: var(--idle);
  background: rgba(122, 118, 112, 0.15);
}

.badge-failed {
  color: var(--err);
  background: rgba(224, 122, 106, 0.12);
}

.badge-running {
  color: var(--warn);
  background: var(--gold-dim);
}

.triggers-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 0.75rem;
}

.trigger-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.trigger-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.wire-note {
  margin: 1rem 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 40rem;
}

.wire-note code {
  color: var(--gold-soft);
  font-size: 0.82em;
}

.secret-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 24rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.secret-field input {
  appearance: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
}

.secret-field input:focus {
  outline: none;
  border-color: var(--gold);
}

.trigger-result {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  overflow-x: auto;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 48rem;
}

.notes-list li + li {
  margin-top: 0.45rem;
}

.site-footer {
  padding: 1.25rem clamp(1.25rem, 4vw, 2.5rem) 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--gold-soft);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@keyframes fade-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .routines-table th:nth-child(2),
  .routines-table td:nth-child(2) {
    display: none;
  }
}
