:root {
  --bg: #06080c;
  --chassis-top: #262a32;
  --chassis-mid: #16191f;
  --chassis-bot: #0c0e13;
  --line: rgba(255, 255, 255, 0.09);
  --ink: #eef2f5;
  --mute: #8e97a3;
  --amber: #ffbe5c;
  --cyan: #38f6e8;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 35%, #101620 0%, #06080c 68%, #030407 100%);
  color: var(--ink);
  font-family: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.desk {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 40px);
}

.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 48%, rgba(44, 224, 218, 0.14), transparent 56%);
  transition: background 0.8s ease;
}
.ambient-glow[data-world="cosmos"] {
  background: radial-gradient(circle at 50% 48%, rgba(164, 82, 232, 0.16), transparent 56%);
}
.ambient-glow[data-world="shrine"] {
  background: radial-gradient(circle at 50% 48%, rgba(46, 232, 168, 0.14), transparent 56%);
}

.minitv {
  position: relative;
  width: min(1060px, 94vw);
  max-height: 88vh;
  z-index: 2;
}

.chassis {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  background: linear-gradient(160deg, var(--chassis-top) 0%, var(--chassis-mid) 44%, var(--chassis-bot) 100%);
  border-radius: 20px;
  padding: 16px 14px 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.78),
    0 8px 24px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -2px 6px rgba(0, 0, 0, 0.65);
}

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

.screen-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  background: #02050a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 2px #05070b,
    inset 0 8px 26px rgba(0, 0, 0, 0.75);
  cursor: crosshair;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.glass-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(128deg, rgba(255, 255, 255, 0.055) 0%, transparent 32%, transparent 78%, rgba(255, 255, 255, 0.025) 100%),
    radial-gradient(circle at 50% 50%, transparent 65%, rgba(0, 0, 0, 0.36) 100%);
}

.osd {
  position: absolute;
  left: 16px;
  bottom: 14px;
  padding: 5px 11px;
  border-radius: 4px;
  background: rgba(6, 10, 16, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  font: 500 11px/1.3 "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.1em;
  color: rgba(235, 245, 248, 0.92);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.osd.show {
  opacity: 1;
  transform: translateY(0);
}

.led-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.chassis-mark {
  font: 600 10px/1 "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.26);
}

.power-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 190, 92, 0.9), 0 0 18px rgba(255, 190, 92, 0.45);
}

/* Right-edge tactile hardware dials */
.side-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding-left: 14px;
  border-left: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.05);
}

.dial, .knob, .sound-dot {
  appearance: none;
  background: none;
  border: 0;
  padding: 4px;
  color: var(--mute);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.12s ease;
}
.dial:hover, .knob:hover, .sound-dot:hover { color: var(--ink); }
.dial:active, .knob:active, .sound-dot:active { transform: scale(0.94); }

.wheel {
  width: 14px;
  height: 44px;
  border-radius: 7px;
  background: repeating-linear-gradient(
    0deg,
    #1c2026 0px,
    #1c2026 2px,
    #353b45 3px,
    #0e1014 4px
  );
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.knob-cap {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a404b, #171a20 72%, #0c0e12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.65), inset 0 1px 1px rgba(255, 255, 255, 0.22);
  position: relative;
}
.knob-cap::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 2px;
  height: 8px;
  transform: translateX(-50%);
  border-radius: 1px;
  background: var(--amber);
}

.sound-dot .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #141820;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.sound-dot[aria-pressed="true"] .dot {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(56, 246, 232, 0.7);
}

.dial-label {
  font: 500 10px/1 "SFMono-Regular", Menlo, "PingFang SC", sans-serif;
  letter-spacing: 0.08em;
}

/* Discreet slide-out drawer (hidden by default) */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 92vw);
  height: 100%;
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(22px);
  border-left: 1px solid rgba(255, 255, 255, 0.11);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateX(102%);
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 20;
  overflow-y: auto;
}
.drawer[aria-hidden="false"] {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.kicker {
  display: block;
  font: 500 10px/1.4 "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.14em;
  color: var(--amber);
}
.drawer h2 { margin: 4px 0 0; font-size: 20px; font-weight: 550; }
.drawer h3 { margin: 4px 0 6px; font-size: 15px; font-weight: 550; }
.close-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.drawer-section {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.world-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.world-pills button {
  appearance: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--mute);
  padding: 8px 6px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.world-pills button[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--cyan);
  background: rgba(56, 246, 232, 0.1);
}

.presence-line {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #cfd8e0;
}

.diary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: var(--mute);
}
.diary-list li {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-copy {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--mute);
}

.sketch-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
#sketch-pad {
  width: 120px;
  height: 120px;
  flex: none;
  image-rendering: pixelated;
  background: #060a10;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}
.sketch-tools {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.swatches button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.swatches button[aria-pressed="true"] {
  border-color: #fff;
  transform: scale(1.1);
}
.sketch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sketch-actions button, .upload-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
}
.sketch-actions .primary-btn {
  background: var(--cyan);
  color: #031518;
  border-color: var(--cyan);
  font-weight: 600;
  width: 100%;
}

.drawer-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.drawer-foot a {
  color: var(--mute);
  text-decoration: none;
}
.drawer-foot a:hover { color: var(--ink); }

@media (max-width: 720px) {
  .chassis {
    grid-template-columns: 1fr;
    padding: 10px;
    border-radius: 16px;
  }
  .side-panel {
    flex-direction: row;
    justify-content: space-around;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: none;
    padding: 12px 4px 4px;
    margin-top: 8px;
  }
  .wheel { width: 38px; height: 14px; }
}
