:root {
  --ink: #e8edf6;
  --dim: #8a94a8;
  --bg: #0a0d14;
  --panel: #141926;
  --line: #232a3b;
  --accent: #8fb2e0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.is-immersive {
  overflow: hidden;
  height: 100dvh;
  touch-action: none;
}

/* ---- gallery viewport ------------------------------------------------- */

.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.viewport__stage {
  position: absolute;
  inset: 0;
}

.viewport__stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  padding: 1.4rem 1.6rem;
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.7);
}

.hud__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.hud__caption {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--dim);
}

.viewport__hint {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  color: var(--dim);
  pointer-events: none;
  text-align: center;
}

/* Show the touch hint on coarse-pointer devices, desktop hint otherwise. */
.viewport__hint-touch { display: none; }
@media (pointer: coarse) {
  .viewport__hint-desktop { display: none; }
  .viewport__hint-touch { display: inline; }
}

/* Grid overlay — a flat data-sigil per day. */
.viewport__grid-toggle {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.6rem;
  border: 1px solid var(--line);
  background: rgba(20, 25, 38, 0.65);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  z-index: 5;
  transition: background 0.15s, border-color 0.15s;
}
.viewport__grid-toggle:hover { background: rgba(30, 38, 58, 0.85); border-color: var(--accent); }

/* The sound toggle sits just left of the grid toggle, sharing its chrome. */
.viewport__sound-toggle {
  position: absolute;
  top: 1.2rem;
  right: 4.2rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.6rem;
  border: 1px solid var(--line);
  background: rgba(20, 25, 38, 0.65);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  z-index: 5;
  transition: background 0.15s, border-color 0.15s;
}
.viewport__sound-toggle:hover { background: rgba(30, 38, 58, 0.85); border-color: var(--accent); }
.viewport__sound-toggle[aria-pressed="true"] { border-color: var(--accent); }

/* A horizontal reel of day-stills along the bottom — the room stays visible
   above it. Slide sideways through every day; tap a card to fly there. */
.reel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(6, 8, 14, 0.96), rgba(6, 8, 14, 0.82));
  backdrop-filter: blur(4px);
  z-index: 10;
  border-top: 1px solid var(--line);
}
.reel[hidden] { display: none; }
.reel__viewport { overflow: hidden; }

.reel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem 0.2rem;
}
.reel__title { font-size: 0.85rem; color: var(--dim); letter-spacing: 0.03em; }
.reel__close {
  width: 2rem; height: 2rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: transparent; color: var(--ink);
  font-size: 1rem; cursor: pointer;
}
.reel__close:hover { border-color: var(--accent); }

.reel__viewport {
  overflow: hidden;
  padding: 0.6rem 1rem 1rem;
}
.reel__track {
  display: flex;
  gap: 0.8rem;
  width: max-content;
  cursor: grab;
  will-change: transform;
}
.reel__track:active { cursor: grabbing; }

.reel__card {
  flex: 0 0 auto;
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: #05070b;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s, border-color 0.12s;
}
.reel__card:hover { transform: translateY(-4px); border-color: var(--accent); }

.reel__canvas {
  display: block;
  width: 100%;
  height: auto;      /* intrinsic 300×300 backing store gives a square box */
  pointer-events: none;
}
.reel__date {
  display: block;
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  color: var(--dim);
  border-top: 1px solid var(--line);
  pointer-events: none;
}

/* Travel controls — step between days along the helix. */
.viewport__nav {
  position: absolute;
  bottom: 3.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
}

.viewport__nav-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(20, 25, 38, 0.65);
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s;
}

.viewport__nav-btn:hover {
  background: rgba(30, 38, 58, 0.85);
  border-color: var(--accent);
}

.viewport__nav-btn:active { transform: scale(0.94); }

/* ---- studio ----------------------------------------------------------- */

.studio {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem;
}

.studio__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.studio__title { margin: 0; font-size: 1.2rem; }
.studio__links { display: flex; gap: 0.75rem; align-items: center; }

.studio__link,
.studio__link button,
.studio__link--plain button {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.studio__panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.studio__heading { margin: 0 0 1rem; font-size: 1rem; }

.studio__form { display: flex; flex-direction: column; gap: 1rem; }

.studio__field { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--dim); }

.studio__field input {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.studio__submit {
  align-self: flex-start;
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: rgba(143, 178, 224, 0.12);
  color: var(--ink);
  cursor: pointer;
}

.studio__list { list-style: none; margin: 0; padding: 0; }

.studio__row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.studio__date { font-variant-numeric: tabular-nums; }
.studio__meta { color: var(--dim); font-size: 0.85rem; margin-left: auto; }

.studio__remove button,
.studio__remove {
  background: none;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.studio__flash { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.9rem; }
.studio__flash--ok { background: rgba(120, 200, 160, 0.15); color: #9fe0c0; }
.studio__flash--warn { background: rgba(224, 143, 143, 0.15); color: #e0a0a0; }
.studio__empty { color: var(--dim); }
