:root {
  color-scheme: dark;
  --bg: #070812;
  --panel: rgba(255, 255, 255, .072);
  --panel2: rgba(255, 255, 255, .035);
  --ink: #fbf7ff;
  --muted: #c8c1d7;
  --soft: #938ca5;
  --line: rgba(255, 255, 255, .15);
  --cyan: #8de5ff;
  --violet: #cda4fd;
  --gold: #f7d982;
  --green: #b6ffd5;
  --rose: #ffb8dd;
  --orange: #ffb86b;
  --focus: 0 0 0 3px rgba(141, 229, 255, .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 {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 6% 0, rgba(205, 164, 253, .24), transparent 31rem),
    radial-gradient(circle at 96% 4%, rgba(141, 229, 255, .18), transparent 29rem),
    linear-gradient(180deg, #05060d, var(--bg) 58%, #090b15);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; }
button:focus-visible, textarea:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.shell { width: min(1240px, calc(100% - 22px)); margin: auto; padding: 12px 0 80px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; }
.brand { font-weight: 900; letter-spacing: -.04em; }
.brand span { color: var(--cyan); }
.nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav a, .pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, .045);
  font-size: .82rem;
}
.nav a[aria-current="page"] { color: var(--cyan); border-color: rgba(141, 229, 255, .42); }

.panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  padding: 18px;
  margin: 12px 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}
.hero { padding: 28px; }
.kicker { color: var(--cyan); letter-spacing: .15em; text-transform: uppercase; font-weight: 850; font-size: .72rem; }
h1 { font-size: clamp(2.45rem, 7vw, 5.4rem); line-height: .93; letter-spacing: -.06em; margin: .18em 0; }
.lead { font-size: clamp(1.04rem, 2.2vw, 1.38rem); max-width: 900px; color: var(--muted); line-height: 1.56; }
h2 { margin: .1rem 0 .55rem; font-size: 1.46rem; }
h3 { margin: .1rem 0 .35rem; font-size: 1rem; }
h4 { margin: .2rem 0 .45rem; }
p, li, label { color: var(--muted); line-height: 1.56; }
.small { font-size: .82rem; color: var(--soft); }

.statusrow, .chips, .actions, .quick-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { margin-top: 14px; }
.badge, .chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .76rem;
  color: var(--muted);
  background: rgba(255, 255, 255, .04);
}
.green { color: var(--green); border-color: rgba(182, 255, 213, .36); }
.gold { color: var(--gold); border-color: rgba(247, 217, 130, .36); }
.rose { color: var(--rose); border-color: rgba(255, 184, 221, .36); }
.violet { color: var(--violet); border-color: rgba(205, 164, 253, .36); }
.cyan { color: var(--cyan); border-color: rgba(141, 229, 255, .36); }

.grid { display: grid; gap: 12px; }
.grid.main { align-items: start; }
.world-layout { display: grid; gap: 12px; }
.owner-card { border-left: 4px solid var(--green); }
.instruction-card { border-left: 4px solid var(--cyan); }
.candidate-card { border-left: 4px solid var(--violet); }
.world-card { border-left: 4px solid var(--cyan); }
.boundary-card { border-left: 4px solid var(--gold); }
.timeline-card { border-left: 4px solid var(--cyan); }

input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #080b19;
  color: var(--ink);
  padding: 12px;
}
textarea { min-height: 112px; resize: vertical; }
.field { display: grid; gap: 7px; margin-top: 12px; }

.primary, .secondary, .danger, .quick, .icon-button, .text-button, .button-link {
  border: 1px solid transparent;
  border-radius: 15px;
  padding: 11px 14px;
  font-weight: 760;
}
.primary { background: linear-gradient(135deg, var(--cyan), var(--violet)); color: #080913; }
.secondary, .button-link { border-color: var(--line); background: rgba(255, 255, 255, .055); color: var(--ink); }
.secondary.accept { border-color: rgba(182, 255, 213, .36); }
.danger { border-color: rgba(255, 184, 221, .38); background: rgba(255, 184, 221, .075); color: var(--rose); }
.button-link { display: inline-flex; align-items: center; justify-content: center; }
.text-button { padding: 4px 8px; border-color: transparent; background: transparent; color: var(--cyan); }

.quick-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick {
  min-height: 72px;
  border-color: rgba(141, 229, 255, .22);
  background: rgba(141, 229, 255, .055);
  color: var(--muted);
  font-weight: 650;
  text-align: left;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
}
.quick:hover, .secondary:hover, .button-link:hover { border-color: var(--cyan); }
.quick.selected {
  border-color: rgba(205, 164, 253, .7);
  background: linear-gradient(135deg, rgba(141, 229, 255, .09), rgba(205, 164, 253, .13));
  color: var(--ink);
}
.selection-mark {
  width: 26px;
  height: 26px;
  border: 1px solid currentColor;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--cyan);
}
.quick.selected .selection-mark { color: var(--violet); }

.selection-tray {
  margin-top: 12px;
  border: 1px solid rgba(205, 164, 253, .3);
  border-radius: 18px;
  padding: 12px;
  background: rgba(205, 164, 253, .055);
}
.selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.selected-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.selected-instruction {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  padding: 9px;
  background: rgba(8, 11, 25, .64);
}
.selection-order, .step-number {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--cyan);
  border: 1px solid rgba(141, 229, 255, .35);
  font-size: .75rem;
  font-weight: 850;
}
.selection-text { color: var(--muted); overflow-wrap: anywhere; }
.selection-controls { display: flex; gap: 4px; }
.icon-button { width: 34px; height: 34px; padding: 0; border-color: var(--line); background: rgba(255, 255, 255, .045); color: var(--muted); }
.icon-button.remove { color: var(--rose); }

.world-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.world-header h2 { margin-bottom: .15rem; }
.revision { white-space: nowrap; }
.node-groups { display: grid; gap: 10px; }
.node-group { border: 1px solid rgba(255, 255, 255, .09); border-radius: 18px; padding: 12px; background: rgba(255, 255, 255, .025); }
.node-group h3 { display: flex; justify-content: space-between; color: var(--muted); }
.node-group h3 span { color: var(--cyan); }
.world-node { border-top: 1px solid rgba(255, 255, 255, .08); padding: 10px 0; }
.world-node:first-of-type { border-top: 0; }
.world-node p { margin: .25rem 0 0; font-size: .86rem; }
.node-type { text-transform: uppercase; letter-spacing: .12em; font-size: .64rem; color: var(--violet); font-weight: 800; }

.candidate { min-height: 310px; border: 1px solid var(--line); border-radius: 20px; background: #080b18; padding: 16px; }
.candidate.empty { display: grid; place-items: center; text-align: center; color: var(--soft); }
.candidate-status { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.binding-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 13px 0; }
.binding-grid > div { border: 1px solid rgba(255, 255, 255, .1); border-radius: 15px; padding: 11px; background: rgba(255, 255, 255, .025); display: grid; gap: 4px; }
.binding-grid span { font-size: .75rem; color: var(--soft); }
.binding-grid strong { color: var(--ink); }
code { display: block; color: var(--gold); overflow-wrap: anywhere; font-size: .72rem; }
.delta-list { padding-left: 1.15rem; }
.delta-list li { margin: .4rem 0; }

.plan-steps { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 10px; }
.plan-step {
  border: 1px solid rgba(205, 164, 253, .22);
  border-radius: 17px;
  padding: 12px;
  background: rgba(205, 164, 253, .04);
}
.subset-choice { display: grid; grid-template-columns: auto 30px 1fr; align-items: start; gap: 9px; cursor: pointer; }
.subset-choice input { margin-top: 7px; accent-color: var(--violet); }
.subset-choice strong { display: block; color: var(--ink); }
.subset-choice small { display: block; color: var(--soft); margin-top: 3px; }
.step-binding { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin: 9px 0 0 64px; color: var(--soft); font-size: .76rem; }
.step-binding code { margin-left: auto; }
.combined-delta { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }

.review-note { display: grid; gap: 5px; border: 1px solid rgba(205, 164, 253, .32); border-radius: 16px; padding: 12px; margin-top: 14px; background: rgba(205, 164, 253, .06); }
.review-note span { color: var(--muted); font-size: .84rem; }
.record-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; }
.record-grid dt { color: var(--soft); }
.record-grid dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.notice { border: 1px solid currentColor; border-radius: 16px; padding: 12px 14px; margin: 12px 0; background: rgba(255, 255, 255, .035); }
.timeline { display: grid; gap: 8px; max-height: 520px; overflow: auto; padding-right: 3px; }
.timeline-record { display: grid; grid-template-columns: minmax(105px, .35fr) 1fr; gap: 12px; border: 1px solid rgba(255, 255, 255, .09); border-radius: 16px; padding: 11px; background: rgba(255, 255, 255, .025); }
.timeline-record time { color: var(--soft); font-size: .72rem; }
.timeline-record div { display: grid; gap: 2px; }
.timeline-record span { color: var(--cyan); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.timeline-record strong { font-size: .9rem; }
.empty-note { color: var(--soft); font-style: italic; }
.boundary-list { padding-left: 1.2rem; }
.boundary-list li { margin: .45rem 0; }
.footer { text-align: center; color: var(--soft); font-size: .78rem; padding-top: 18px; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--cyan); }
[hidden] { display: none !important; }

@media (min-width: 920px) {
  .grid.main { grid-template-columns: 1.08fr .92fr; }
  .grid.two { grid-template-columns: 1fr 1fr; }
  .world-layout { grid-template-columns: .9fr 1.1fr; }
}

@media (max-width: 680px) {
  .hero { padding: 21px; }
  .panel { padding: 15px; }
  .binding-grid { grid-template-columns: 1fr; }
  .timeline-record { grid-template-columns: 1fr; }
  .actions button, .actions .button-link { flex: 1 1 42%; }
  .quick-grid { grid-template-columns: 1fr; }
  .quick { width: 100%; min-height: 66px; }
  .selected-instruction { grid-template-columns: 28px minmax(0, 1fr); }
  .selection-controls { grid-column: 2; }
  .step-binding { margin-left: 0; }
  .step-binding code { width: 100%; margin-left: 0; }
  .record-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
