:root {
  --bg: #04161a;
  --bg-2: #06222a;
  --teal: #2ff3e0;
  --teal-deep: #00b8a9;
  --cyan: #38d6ff;
  --magenta: #ff5cc8;
  --gold: #ffd76a;
  --ink: #e7fbf7;
  --muted: #84b3ad;
  --line: rgba(47, 243, 224, 0.18);
  --line-strong: rgba(47, 243, 224, 0.42);
  --card: rgba(8, 38, 44, 0.62);
  --card-strong: rgba(8, 38, 44, 0.86);
  --danger: #ff6b8a;
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  letter-spacing: 0.01em;
}

body {
  position: relative;
  min-height: 100vh;
}

/* ---------- ambient background (matches kunst-generator) ---------- */
.grid-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(47, 243, 224, 0.08), transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 90%, rgba(56, 214, 255, 0.06), transparent 75%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  z-index: 0;
  pointer-events: none;
}
.grid-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(47, 243, 224, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(47, 243, 224, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 80%);
}
.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}
.glow--1 { width: 480px; height: 480px; top: -120px; left: -120px; background: var(--teal); }
.glow--2 { width: 520px; height: 520px; bottom: -160px; right: -160px; background: var(--cyan); opacity: 0.25; }

/* ---------- the disk canvas takes the whole stage ---------- */
#disk-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  display: block;
  cursor: grab;
}
#disk-canvas:active { cursor: grabbing; }

/* ---------- side panel (collapsible) ---------- */
.panel {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 360px;
  max-height: calc(100vh - 48px);
  padding: 22px 22px 18px;
  background: var(--card-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(47, 243, 224, 0.04) inset;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.55s var(--ease), opacity 0.35s var(--ease);
  scrollbar-width: thin;
  scrollbar-color: var(--teal-deep) transparent;
}
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: var(--teal-deep); border-radius: 3px; }

.panel--hidden {
  transform: translateX(calc(-100% - 32px));
  opacity: 0;
  pointer-events: none;
}

.panel-toggle {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 40px;
  height: 40px;
  background: var(--card-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  z-index: 11;
  transition: left 0.55s var(--ease), border-color 0.2s;
}
.panel-toggle:hover { border-color: var(--line-strong); }
.panel-toggle__bar {
  width: 18px;
  height: 1.5px;
  background: var(--teal);
  border-radius: 1px;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.panel--hidden ~ .panel-toggle { left: 24px; }
.panel-toggle--detached { display: flex; }

.panel__head { margin-bottom: 20px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 500;
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 10px var(--teal);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.panel__title {
  font-size: 32px;
  font-weight: 700;
  margin: 10px 0 8px;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, var(--teal) 0%, var(--cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.panel__sep { opacity: 0.55; }
.panel__sub {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
}
.panel__sub strong { color: var(--ink); font-weight: 500; }

.panel__section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.panel__section:last-of-type { border-bottom: 0; padding-bottom: 0; }
.panel__section--row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.panel__section--actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 0;
  padding-bottom: 0;
}
.panel__section--status { border-bottom: 0; padding-bottom: 0; }

.section__h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--teal);
  margin: 0 0 6px;
  font-weight: 500;
}
.section__hint {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 8px;
}
.section__hint code {
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  background: rgba(47, 243, 224, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--teal);
}

/* ---------- form controls ---------- */
.program {
  width: 100%;
  min-height: 130px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: 11.5px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.program:focus { border-color: var(--teal-deep); }

.tape {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.2em;
  outline: none;
  transition: border-color 0.2s;
}
.tape:focus { border-color: var(--teal-deep); }

.control { display: flex; flex-direction: column; gap: 4px; }
.control__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.control__readout {
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  color: var(--teal);
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px var(--teal);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg);
  cursor: pointer;
}

/* ---------- buttons ---------- */
.btn {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { border-color: var(--teal); color: var(--teal); }
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: linear-gradient(120deg, var(--teal-deep) 0%, var(--teal) 100%);
  color: var(--bg);
  border-color: var(--teal);
  font-weight: 700;
  flex: 1 1 100%;
}
.btn--primary:hover {
  color: var(--bg);
  box-shadow: 0 0 18px rgba(47, 243, 224, 0.4);
  border-color: var(--teal);
}

/* ---------- status panel ---------- */
.status {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
}
.status__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(47, 243, 224, 0.08);
}
.status__row:last-of-type { border-bottom: 0; }
.status__row span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }
.status__row strong {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--teal);
  font-weight: 700;
}
.status__tape {
  font-size: 13px;
  letter-spacing: 0.18em;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status__info {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.panel__foot {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.06em;
}

/* ---------- legend (bottom right) ---------- */
.legend {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  z-index: 5;
}
.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.swatch--cyan    { background: var(--cyan);    box-shadow: 0 0 8px var(--cyan); }
.swatch--magenta { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }
.swatch--gold    { background: var(--gold);    box-shadow: 0 0 8px var(--gold); }

/* ---------- tutorial popover ---------- */
.tutorial {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 240px;
  padding: 16px 18px;
  background: var(--card-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 6;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.tutorial h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--teal);
  margin: 0 0 8px;
  font-weight: 500;
}
.tutorial ol { padding-left: 18px; margin: 0; }
.tutorial li { margin-bottom: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .panel { width: calc(100vw - 32px); max-height: 60vh; }
  .panel--hidden { transform: translateY(calc(-100% - 32px)); }
  .legend { bottom: 12px; right: 12px; }
  .tutorial { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .eyebrow .dot { animation: none; }
  .panel, .panel-toggle__bar { transition: none; }
}
