:root {
  --bg: #0a0a0a;
  --fg: #f4f4f4;
  --muted: #888;
  --accent: #4cc2ff;
  --bar: rgba(20, 20, 20, 0.85);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

input, button, textarea, select { touch-action: auto; }
input[type="range"] { touch-action: pan-x; }

.stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.has-host-bar .stage { bottom: 76px; }

button {
  font: inherit;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid #333;
  background: #1a1a1a; color: var(--fg);
  cursor: pointer;
}
button.primary { background: var(--accent); color: #001018; border-color: var(--accent); }
button:active { transform: scale(0.97); }

/* text */
.slide-text {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 5vmin;
}
.slide-text h1 { margin: 0 0 0.4em; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.slide-text p  { margin: 0; color: var(--muted); line-height: 1.5; max-width: 28em; font-size: 22px; }

/* image */
.slide-image { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.slide-image img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* color */
.slide-color { width: 100%; height: 100%; position: relative; }
.slide-color .swatch { width: 100%; height: 100%; }
.slide-color .controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: var(--bar);
  display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center;
  font-size: 14px;
}
.slide-color .controls label { color: var(--muted); }
.slide-color .controls .full { grid-column: 1 / -1; color: var(--fg); }

/* ────────── bytebeat (cream / editorial theme) ────────── */

body.theme-cream {
  background: #ebe8e1;
  color: #1a1a1a;
}
body.theme-cream .host-bar {
  background: rgba(255, 255, 255, 0.78);
  border-top: 1px solid #d8d4ca;
  color: #1a1a1a;
}
body.theme-cream .host-bar button {
  background: #fff;
  color: #1a1a1a;
  border-color: #d8d4ca;
}
body.theme-cream .host-bar .meta { color: #999; }

.bb {
  width: 100%;
  max-width: 720px;
  padding: 6vmin 5vmin;
  display: flex;
  flex-direction: column;
  gap: 28px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: #1a1a1a;
}

.bb-title {
  font-size: 13px;
  letter-spacing: 0.06em;
  color: #777;
  margin-bottom: -12px;
}

.bb-field { display: flex; flex-direction: column; gap: 10px; }

.bb-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #999;
  font-weight: 600;
}
.bb-label .bb-n {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  margin-left: 8px;
  color: #1a1a1a;
  letter-spacing: 0;
  font-weight: 700;
}

.bb-box {
  background: #fff;
  border: 1px solid #e0ddd5;
  border-radius: 6px;
  padding: 18px 20px;
  min-height: 120px;
}
.bb-box-readonly {
  display: flex;
  align-items: center;
  min-height: 80px;
}

.bb-expr {
  width: 100%;
  min-height: 84px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: #1a1a1a;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: clamp(14px, 2.4vw, 18px);
  line-height: 1.5;
}
.bb-expr-display {
  width: 100%;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: clamp(16px, 3vw, 22px);
  color: #1a1a1a;
}

.bb-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.bb-play {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  padding: 0;
  border-radius: 50%;
  background: #ee7c2b;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease;
}
.bb-play:hover { background: #f08838; }
.bb-play:active { transform: scale(0.94); }
.bb-play svg { width: 22px; height: 22px; }

.bb-vol {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* minimal range (used by VOLUME and N) */
.bb-vol-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  outline: none;
}
.bb-vol-range::-webkit-slider-runnable-track {
  height: 1px;
  background: #c9c5bb;
  border: none;
}
.bb-vol-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #1a1a1a;
  border: none;
  margin-top: -6.5px;
  cursor: pointer;
}
.bb-vol-range::-moz-range-track {
  height: 1px;
  background: #c9c5bb;
  border: none;
}
.bb-vol-range::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #1a1a1a;
  border: none;
  cursor: pointer;
}

.bb-counter {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 13px;
  color: #999;
  margin-top: 8px;
}
.bb-counter i {
  font-style: italic;
  font-family: "Times New Roman", Georgia, serif;
}
.bb-counter b {
  color: #1a1a1a;
  font-weight: 700;
}

.bb-editor-pad .bb-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bb-pad {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bb-pad-row {
  display: grid;
  gap: 6px;
}

.bb-pad-row-num {
  grid-template-columns: repeat(10, minmax(0, 1fr));
}

.bb-pad-row-op {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.bb-pad-key {
  min-height: 34px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid #dfdbd2;
  background: #f5f2ea;
  color: #1a1a1a;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 13px;
}

.bb-pad-key:active {
  transform: translateY(1px);
}

@media (max-width: 640px) {
  .bb-pad-row-num {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .bb-pad-row-op {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* mute bytebeat viewer */
.bb.bb-viewer {
  gap: 18px;
}

.bb-viewer .bb-row {
  justify-content: flex-start;
}

.bb-viz {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e0ddd5;
  border-radius: 6px;
  background: #fff;
}

.bb-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: #8d8678;
}

.bb-readout b {
  color: #1a1a1a;
  font-weight: 700;
  margin-left: 6px;
}

.bb-bits {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.bb-bit {
  height: clamp(22px, 3vw, 30px);
  border-radius: 4px;
  border: 1px solid #ddd8ce;
  background: #f8f6f1;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.bb-bit.on {
  background: #ee7c2b;
  border-color: #d87027;
}

.bb-history {
  width: 100%;
  height: 112px;
  display: block;
  border: 1px solid #ddd8ce;
  border-radius: 4px;
  background: #f8f6f1;
}

@media (max-width: 640px) {
  .bb-history {
    height: 96px;
  }
}

/* p5 */
.slide-p5 { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.slide-p5 canvas { display: block; max-width: 100%; max-height: 100%; }

/* host bar */
.host-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--bar);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}
.host-bar[hidden] { display: none; }
.host-bar .meta {
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 13px; color: var(--muted);
}
.host-bar .sep { margin: 0 4px; }
