:root {
  --bg: #1a1a1a;
  --panel: rgba(18, 18, 18, 0.78);
  --fg: #e6e6e6;
  --dim: #8c8c8c;
  --line: #3c3c3c;
  --accent: #ff6fae;
  --px: 40px;
  --font: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 48px;
  overflow: hidden;
}

button, select { font: inherit; color: inherit; }

/* ---------- phone column ---------- */

.phone {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* all touch on the canvas orbits the model */
}

/* Overlays let touches through to the canvas except on their controls. */
.bar, .info, .status { pointer-events: none; }
.bar button, .info button, .info .wheel, .info .caption { pointer-events: auto; }

/* ---------- top bar ---------- */

.bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 12px 0;
}

.controls {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.px {
  width: var(--px);
  height: var(--px);
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  image-rendering: pixelated;
}
.px svg { width: 18px; height: 18px; display: block; }
.px:active { transform: translateY(1px); border-color: var(--fg); }
.px:disabled { opacity: 0.35; cursor: default; transform: none; }
.px.on { border-color: var(--accent); color: var(--accent); }
.px.small { --px: 32px; }
.px.small svg { width: 14px; height: 14px; }

/* Prev / next: slim tabs on the screen edges, halfway down, for thumbs. */
.edge {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 56px;
  transform: translateY(-50%);
  z-index: 1;
}
.edge.left { left: 0; border-left: 0; }
.edge.right { right: 0; border-right: 0; }
.edge:active { transform: translateY(calc(-50% + 1px)); }
.edge svg { width: 14px; height: 14px; }

/* While orbiting: overlay drops to 10%, then fully hidden after 5s (see app.js). */
.ui { transition: opacity 0.2s ease; }
.phone.orbiting .ui { opacity: 0.1; }
.phone.orbiting.orbit-long .ui { opacity: 0; }

.chip {
  height: var(--px);
  max-width: 45%;
  padding: 0 10px;
  background: var(--panel);
  border: 2px solid var(--accent);
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* ---------- status / loading ---------- */

.status {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  color: var(--dim);
  text-align: center;
  white-space: nowrap;
}

/* ---------- info panel ---------- */

.info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 48px 14px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(10, 10, 10, 0.88) 55%, transparent);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.date { margin: 2px 0 0; color: var(--dim); font-size: 11px; }

.caption {
  margin: 8px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.caption.open { -webkit-line-clamp: unset; }
.caption:empty { display: none; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.tags:empty { display: none; }
.tags button {
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  cursor: pointer;
}
.tags button.on { border-color: var(--accent); color: var(--accent); }

.action {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--dim);
  pointer-events: auto;
}
/* ---------- action picker wheel (see wheel.js) ---------- */

.wheel {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 76px;
  perspective: 300px;
  font-size: 15px;
  letter-spacing: 0.12em;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  outline: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 32%, #000 68%, transparent);
}
.wheel:active { cursor: grabbing; }

.wheel-drum {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.wheel-item,
.wheel-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: var(--row);
  margin-top: calc(var(--row) / -2);
}

.wheel-item {
  padding: 0 8px;
  line-height: var(--row);
  text-align: center;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.wheel-item.sel { color: var(--fg); }

.wheel-band {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
.wheel:focus-visible .wheel-band { border-color: var(--accent); }

/* ---------- tag index sheet ---------- */

.sheet {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: rgba(14, 14, 14, 0.96);
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  z-index: 2;
}
.sheet[hidden] { display: none; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.tag-list {
  list-style: none;
  margin: 0;
  padding: 6px 0 0;
  overflow-y: auto;
}
.tag-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 12px 4px;
  background: none;
  border: 0;
  border-bottom: 1px solid #262626;
  text-align: left;
  cursor: pointer;
}
.tag-list button span:last-child { color: var(--dim); }
.tag-list button.on { color: var(--accent); }

/* ---------- toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 30%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: var(--fg);
  color: var(--bg);
  z-index: 3;
}

/* ---------- desktop: phone column + QR ---------- */

.desk { display: none; }

@media (min-width: 900px) and (hover: hover) {
  .phone {
    width: min(460px, calc(100dvh * 9 / 16));
    height: 100dvh;
    border-left: 2px solid var(--line);
    border-right: 2px solid var(--line);
  }
  .desk {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 180px;
    color: var(--dim);
    text-align: center;
  }
  .desk p { margin: 0; }
  .qr {
    width: 160px;
    height: 160px;
    padding: 10px;
    background: #fff;
  }
  .qr svg { width: 100%; height: 100%; display: block; }
  .qr-url { font-size: 11px; overflow-wrap: anywhere; }
}
