:root {
  color-scheme: dark;
  --bg: #0d0e12;
  --panel: #15161b;
  --panel-2: #191a20;
  --line: rgba(255, 255, 255, 0.09);
  --muted: #858894;
  --text: #f4f1f3;
  --pink: #ef9eb5;
  --blush: #f6c3cf;
  --mint: #7ed0ba;
  --code-width: clamp(360px, 38vw, 560px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, input { font: inherit; }

button:focus-visible,
input:focus-visible,
.code-wrap:focus-visible {
  outline: 2px solid rgba(239, 158, 181, 0.8);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--code-width) minmax(0, 1fr);
  height: 100dvh;
  min-height: 560px;
  background: var(--bg);
}

.code-pane {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 34px;
  min-width: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.22);
}

.pane-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #18191e;
}

.window-dots { display: flex; gap: 7px; }
.window-dots i { width: 9px; height: 9px; border-radius: 50%; background: #53545b; }
.window-dots i:first-child { background: #d2747c; }
.window-dots i:nth-child(2) { background: #d5ad6c; }
.window-dots i:last-child { background: #73aa86; }

.file-name {
  overflow: hidden;
  color: #dad8dc;
  font: 12px/1.2 Consolas, "Cascadia Code", monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #777a84;
  font-size: 10px;
  white-space: nowrap;
}

.runtime i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 9px rgba(126, 208, 186, 0.7);
}

.code-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  padding: 18px 0 26px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025), transparent 18%),
    var(--panel);
}

.code-list {
  position: absolute;
  inset: 18px 0 auto;
  margin: 0;
  padding: 0 18px 0 56px;
  color: #989aa3;
  font: 11.5px/1.85 Consolas, "Cascadia Code", "SFMono-Regular", monospace;
  list-style-position: outside;
  transition: transform 650ms cubic-bezier(.2,.8,.2,1);
}

.code-list li {
  min-height: 21px;
  padding-left: 13px;
  white-space: pre;
  opacity: 0.58;
  transition: color 240ms ease, opacity 240ms ease, background 240ms ease;
}

.code-list li::marker { color: #494b54; font-size: 9px; }
.code-list li.active {
  color: #e9e4e7;
  opacity: 1;
  background: linear-gradient(90deg, rgba(239, 158, 181, 0.11), transparent);
}
.code-list li.active::marker { color: var(--pink); }
.code-list .kw { color: #c49bd5; }
.code-list .fn { color: #82bddd; }
.code-list .num { color: #d6b480; }
.code-list .str { color: #9ac79f; }
.code-list .cm { color: #636671; font-style: italic; }
.code-list .var { color: #d5acba; }

.code-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: #767983;
  font: 9px/1 Consolas, monospace;
  text-transform: uppercase;
}

.code-status span:last-child { color: #a88792; }

.stage {
  position: relative;
  isolation: isolate;
  min-width: 0;
  overflow: hidden;
  background: #0b0d12;
}

#lotusCanvas,
.stage-wash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#lotusCanvas { z-index: 0; display: block; }

.stage-wash {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(9, 10, 14, 0.62), transparent 28%),
    linear-gradient(180deg, rgba(10, 11, 15, 0.25), transparent 25%, transparent 72%, rgba(8, 9, 12, 0.68));
}

.stage::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.035);
  content: "";
  pointer-events: none;
}

.stage-header {
  position: absolute;
  z-index: 3;
  top: clamp(28px, 5vh, 62px);
  left: clamp(24px, 4vw, 64px);
  right: clamp(24px, 4vw, 64px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 9px;
  color: #9f838c;
  font: 9px/1.2 Consolas, monospace;
}

h1 {
  margin: 0;
  color: #f4f0f2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4.5vw, 62px);
  font-weight: 400;
  line-height: 0.95;
}

h1 span { color: var(--pink); }

.caption {
  margin: 2px 0 0;
  color: rgba(236, 229, 233, 0.54);
  font-size: 11px;
  line-height: 1.8;
  text-align: right;
}

.seed-readout {
  position: absolute;
  z-index: 3;
  right: clamp(24px, 4vw, 64px);
  bottom: clamp(92px, 13vh, 126px);
  display: grid;
  justify-items: end;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.seed-readout span { font: 8px/1.4 Consolas, monospace; }
.seed-readout strong { color: rgba(244, 195, 207, 0.62); font: 18px/1.2 Georgia, serif; font-weight: 400; }

.controls {
  position: absolute;
  z-index: 5;
  right: clamp(20px, 3vw, 44px);
  bottom: 30px;
  left: clamp(20px, 3vw, 44px);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(19, 20, 26, 0.78);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(14px);
}

.icon-btn {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #d7d2d5;
  cursor: pointer;
  font: 13px/1 Consolas, monospace;
  transition: background 150ms ease, color 150ms ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.icon-btn:active { background: rgba(239, 158, 181, 0.16); }

.slider-control {
  display: grid;
  grid-template-columns: auto minmax(64px, 1fr) 38px;
  align-items: center;
  flex: 1 1 180px;
  gap: 9px;
  min-width: 110px;
  padding: 0 8px;
  color: #888b94;
  font-size: 10px;
}

.slider-control output {
  color: #b8adb1;
  font: 9px/1 Consolas, monospace;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 3px;
  margin: 0;
  appearance: none;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  appearance: none;
  border: 2px solid #f3d1da;
  border-radius: 50%;
  background: #aa6679;
  box-shadow: 0 0 0 3px rgba(239, 158, 181, 0.1);
}

.progress-track {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--pink);
  box-shadow: 0 0 12px rgba(239, 158, 181, 0.8);
}

.mobile-only { display: none; }

@media (max-width: 860px) {
  body { overflow: hidden; }
  .app-shell { grid-template-columns: 1fr; min-height: 520px; }
  .stage { grid-column: 1; grid-row: 1; }
  .code-pane {
    position: absolute;
    z-index: 10;
    inset: auto 12px 88px 12px;
    height: min(52vh, 420px);
    border: 1px solid var(--line);
    border-radius: 6px;
    transform: translateY(calc(100% + 110px));
    transition: transform 320ms cubic-bezier(.2,.8,.2,1);
  }
  .code-pane.open { transform: translateY(0); }
  .mobile-only { display: grid; }
  .density-control { display: none; }
  .stage-header { top: 24px; left: 24px; right: 24px; }
  .caption { display: none; }
  .seed-readout { right: 24px; bottom: 96px; }
  .controls { right: 12px; bottom: 18px; left: 12px; }
}

@media (max-width: 520px) {
  .slider-control { grid-template-columns: auto minmax(50px, 1fr) 34px; padding: 0 3px; }
  .controls { gap: 2px; }
  .icon-btn { flex-basis: 32px; width: 32px; }
  .code-list { font-size: 10.5px; }
  .stage-header h1 { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .code-list, .code-pane { transition: none; }
}
