:root {
  color-scheme: dark;
  --ink: rgba(244, 240, 255, 0.92);
  --dim: rgba(226, 214, 245, 0.58);
  --line: rgba(226, 214, 245, 0.28);
  --sans: "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body.cursor-hidden,
body.cursor-hidden * {
  cursor: none !important;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #07040d;
}

body.cover-mode .chrome,
body.cover-mode #composer {
  display: none !important;
}

body.cover-mode:not(.cover-tune) #controls {
  display: none !important;
}

body.cover-mode:not(.cover-tune) {
  pointer-events: none;
}

body.cover-tune {
  background: #07070a;
}

body.cover-tune #stage {
  inset: auto;
  top: 48px;
  left: 40px;
  width: min(36vw, 420px);
  height: min(36vw, 420px);
  background: #000;
}

body.cover-tune #stage::after {
  content: "FUTURE";
  position: absolute;
  left: 24px;
  bottom: 22px;
  z-index: 3;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.24px;
  pointer-events: none;
}

body.cover-tune #controls {
  display: block !important;
  position: fixed;
  top: 48px;
  right: 24px;
  left: auto;
  width: min(420px, calc(100vw - min(36vw, 420px) - 88px));
  max-height: calc(100% - 72px);
}

body.cover-tune #controls label:not(.is-cover-knob),
body.cover-tune #controls .controls-title:not(.is-cover-knob),
body.cover-tune #controls .led-note,
body.cover-tune #controls #led-status,
body.cover-tune #controls #led-scan,
body.cover-tune #controls .source-box {
  display: none;
}

.cover-color,
body:not(.cover-tune) label.cover-only {
  display: none;
}

body.cover-tune .cover-color {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px 10px;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.cover-color-head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--dim);
}

#controls #cover-color {
  grid-column: auto;
  width: 84px;
  height: 64px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  cursor: pointer;
}

#controls #cover-hex {
  grid-column: auto;
  width: 100%;
  height: 64px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: 16px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cover-swatches {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cover-swatches button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
}

.cover-swatches button.is-on {
  box-shadow: 0 0 0 2px #07070a, 0 0 0 4px #fff;
}

body.cover-tune #controls input[data-range="hue"] {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff2a2a, #ffe14a, #4dff6a, #3dfff2, #4d7dff, #d24dff, #ff2a2a);
}

body.cover-tune #controls input[data-range="hue"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #111;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 14px 12px 10px;
}

.top, .copy, .hint, .bottom, #composer, #controls, #minus {
  pointer-events: auto;
}

.brand, #shader-line, .copy, .hint, .bottom {
  display: none;
}

.top {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
}

.brand {
  display: none;
  gap: 12px;
  align-items: center;
}

.mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.brand p, .top-right p, .index, .hint, .bottom p, #status {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

#status { margin-top: 4px; }

.top-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-right i {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 8px;
  border-radius: 50%;
  background: #d7c6ff;
  box-shadow: 0 0 8px #d7c6ff;
}

#menu, #tune {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: transparent;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  cursor: pointer;
}

#menu:hover, #tune:hover, body.panel-open #menu, body.controls-open #tune {
  color: transparent;
  border-color: transparent;
}

.copy {
  position: absolute;
  left: 12px;
  bottom: 48px;
  width: calc(100% - 24px);
}

body.panel-open .copy { bottom: 360px; }

.index { margin-bottom: 14px; }

h1 {
  margin: 0 0 10px;
  font-weight: 360;
  font-size: 42px;
  line-height: 0.88;
  letter-spacing: 0.01em;
}

#data-line {
  margin: 0 0 12px;
  max-width: 36ch;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(244, 240, 255, 0.55);
  white-space: pre-wrap;
}

#minus {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--minus-w, 77%);
  height: var(--minus-h, 23%);
  border-radius: var(--minus-r, 0.4vmin);
  border: 1px solid rgba(243, 168, 92, 0.8);
  background: rgba(12, 6, 4, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#log {
  width: calc(100% - 28px);
  max-height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: clamp(12px, 1.7vmin, 18px);
  line-height: 1.45;
  color: rgba(255, 236, 214, 0.92);
}

#log::-webkit-scrollbar { width: 0; }

.line { margin: 0; }
.line.user { color: rgba(244, 240, 255, 0.45); }
.line.bot.thinking { opacity: 0.45; }

.hint {
  position: absolute;
  right: 12px;
  bottom: 64px;
}

.bottom {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  display: none;
  justify-content: space-between;
  border-top: 1px solid rgba(226, 214, 245, 0.16);
  padding-top: 10px;
}

#fit-readout,
#bodies {
  display: none;
}

#bed-name {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(243, 168, 92, 0.85);
}

#composer {
  display: none;
  position: absolute;
  left: 8px;
  bottom: 48px;
  width: min(720px, calc(100% - 16px));
  flex-direction: column;
  gap: 8px;
}

body.panel-open #composer {
  display: flex;
  max-height: 46vh;
  overflow: auto;
}

.composer-row { display: flex; gap: 8px; }

#text, #reply-voice {
  border: 1px solid var(--line);
  background: rgba(8, 4, 16, 0.72);
  color: white;
  font: 13px/1.4 var(--sans);
  border-radius: 999px;
  padding: 10px 14px;
}

#text { flex: 1; outline: none; }
#reply-voice {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

#beds { display: flex; flex-wrap: wrap; gap: 6px; }

#beds button {
  border: 1px solid var(--line);
  background: rgba(8, 4, 16, 0.72);
  color: rgba(255, 236, 214, 0.78);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}

#beds button.active {
  border-color: rgba(243, 168, 92, 0.9);
  color: rgba(255, 220, 180, 0.96);
}

#controls {
  display: none;
  position: absolute;
  z-index: 4;
  top: 56px;
  right: 8px;
  width: min(420px, calc(100% - 16px));
  max-height: calc(100% - 70px);
  overflow: auto;
  padding: 14px 14px 16px;
  background: rgba(8, 4, 16, 0.82);
  border: 1px solid var(--line);
  color: var(--ink);
}

body.controls-open #controls { display: block; }

.controls-title, #field-note {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--dim);
}

#controls label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--dim);
}

#controls input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: #d7c6ff; }

#controls input[type="text"],
#controls input:not([type="range"]),
#controls textarea {
  grid-column: 1 / -1;
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: white;
  font: 13px/1.4 var(--sans);
  padding: 7px 8px;
}

#controls textarea { resize: vertical; min-height: 72px; }

.composer-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(243, 168, 92, 0.85);
}

#model-list { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.model-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(255, 236, 214, 0.9);
}
.model-choice input { accent-color: rgba(243, 168, 92, 0.95); }

.design-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(255, 236, 214, 0.72);
}
.design-field textarea,
.design-field input[type="range"] { grid-column: 1 / -1; width: 100%; }
.design-field textarea {
  border: 1px solid var(--line);
  background: rgba(8, 4, 16, 0.72);
  color: white;
  font: 13px/1.45 var(--sans);
  letter-spacing: 0;
  padding: 8px 10px;
  resize: vertical;
  min-height: 64px;
}
.design-field input[type="range"] { accent-color: rgba(243, 168, 92, 0.95); }
#dialogue-save {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: rgba(8, 4, 16, 0.72);
  color: rgba(255, 236, 214, 0.9);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}
#dialogue-note,
#autostart-note {
  margin: 0;
  min-height: 1em;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(243, 168, 92, 0.85);
}

.source-box { margin: 14px 0 12px; }
.source-box .controls-title { margin-bottom: 8px; }
#controls label.check {
  align-items: center;
}
#controls label.check input {
  grid-column: auto;
  width: auto;
  justify-self: end;
  accent-color: #d7c6ff;
}
.led-note, #led-status {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.5;
  color: var(--dim);
}
#source-add, #led-scan {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: white;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 8px 0;
  cursor: pointer;
}
#source-list { list-style: none; margin: 8px 0 0; padding: 0; }
#source-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}
#source-list button {
  border: 0;
  background: transparent;
  color: rgba(243, 168, 92, 0.9);
  cursor: pointer;
}

.controls-actions { display: flex; gap: 8px; margin-top: 4px; }

.controls-actions button {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  color: white;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 8px 0;
  cursor: pointer;
}

#field-note { margin-top: 10px; margin-bottom: 0; }

@media (max-width: 800px) {
  .copy { width: calc(100% - 56px); }
  h1 { font-size: 48px; }
  .hint { display: none; }
}
