/* ============================================
   SetKey — Design System
   Rendered Digital · setkey.app
   ============================================ */

/* --- Fonts --- */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Instrument Serif';
  src: url('/fonts/instrument-serif-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* --- Design Tokens --- */
:root {
  --bg: #141110;
  --surface: #1c1912;
  --surface-2: #3a3528;
  --border: #3a3528;
  --text: #f5f0e8;
  --muted: #9a9078;
  --accent: #D4943C;
  --accent-hover: #E0A448;
  --accent-glow: rgba(212, 148, 60, 0.35);
  --accent-dim: rgba(212, 148, 60, 0.15);
  --loop: #3d9e8f;
  --loop-glow: rgba(61, 158, 143, 0.35);
  --loop-dim: rgba(61, 158, 143, 0.18);
  --error: #d94040;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 100px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Reset & Global --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(212, 148, 60, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 50%, rgba(212, 148, 60, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(160, 120, 60, 0.025) 0%, transparent 45%);
  background-attachment: fixed;
  overscroll-behavior: none;
}

/* Grain texture — matte surface feel */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Edge vignette — focuses the eye on center controls */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(10, 8, 6, 0.45) 100%);
}

::selection {
  background: var(--accent-dim);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Accessibility --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius);
  z-index: 9999;
  font-weight: 600;
}

.skip-link:focus {
  top: 1rem;
}

kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75em;
  padding: 0.1em 0.4em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Layout --- */
.main {
  max-width: 520px;
  margin: 0 auto;
  padding: 2rem 1.25rem 2rem;
}

.page {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1.25rem 2rem;
  overflow-x: hidden;
}

/* --- Resonance Glow (plays when audio is active) --- */
.resonance-glow {
  position: fixed;
  top: 30%;
  left: 50%;
  width: 600px;
  height: 400px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(212, 148, 60, 0.07) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  will-change: opacity;
}

.resonance-glow.active {
  opacity: 1;
  animation: resonance 3s ease-in-out infinite;
}

@keyframes resonance {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.04); }
}

/* --- Empty State Fork --- */
.empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(ellipse at 50% 50%, rgba(212, 148, 60, 0.06) 0%, transparent 60%);
}

.empty-state.hidden {
  display: none;
}

.empty-state .fork-svg {
  width: 120px;
  height: 240px;
  color: var(--accent);
  opacity: 0.15;
  filter: drop-shadow(1px 2px 1px rgba(0, 0, 0, 0.6));
}

.empty-state.loading .fork-svg {
  opacity: 0.5;
  animation: fork-vibrate 0.08s linear infinite;
}

@keyframes fork-vibrate {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(0.5px); }
}

/* --- Wordmark Fork (rotated -90, underlines wordmark) --- */
.wordmark-fork {
  display: block;
  width: 200px;
  height: 68px;
  margin: -30px auto 0;
  color: var(--accent);
  opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
  .resonance-glow.active { animation: none; }
  .empty-state.loading .fork-svg { animation: none; }
}

/* --- App Header --- */
.app-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3), 0 0 30px var(--accent-glow);
}

.tagline {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

/* --- URL Form --- */
.url-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.url-input {
  flex: 1;
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.url-input::placeholder {
  color: var(--muted);
}

.url-input:disabled {
  opacity: 0.5;
}

.btn-load {
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--bg);
  background: linear-gradient(to bottom, var(--accent-hover), var(--accent));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn-load:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-load:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-load:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Status --- */
.status {
  text-align: center;
  font-size: 0.85rem;
  min-height: 1.5rem;
  color: var(--muted);
}

.status.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

.status.error {
  color: var(--error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Key Context Bar --- */
.key-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.key-select-wrap {
  flex: 1;
  max-width: 140px;
}

.key-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  padding: 0.4rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.key-select:hover {
  border-color: var(--accent);
}

.key-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.key-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.key-arrow {
  color: var(--muted);
  font-size: 0.9rem;
  opacity: 0.5;
}

/* --- Note Picker (Bottom Sheet) --- */
.note-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.note-picker-overlay.active {
  display: flex;
}

.note-picker {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  border-radius: 16px 16px 0 0;
  padding: 1rem 1.25rem calc(1.5rem + var(--safe-bottom));
}

.note-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.note-picker-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.note-picker-clear {
  font-size: 0.75rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.note-picker-clear:hover {
  color: var(--accent);
}

.note-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.note-btn {
  padding: 0.7rem 0;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.note-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.note-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* --- Key Translation --- */
.semitone-center {
  text-align: center;
  min-width: 5rem;
  background: var(--accent-dim);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
}

.key-translation {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* --- Player --- */
.player {
  margin-top: 0.5rem;
}

.song-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
  margin: 0 0 1.25rem;
  color: var(--text);
  line-height: 1.3;
}

/* --- Pitch Control --- */
.pitch-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.btn-step {
  width: 60px;
  height: 60px;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-step:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-step:active {
  transform: scale(0.92);
  background: var(--accent-dim);
}

.semitone-display {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
  user-select: none;
}

/* --- Semitone Dot Strip --- */
.semi-strip {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 12px 0 20px;
  margin-bottom: 1rem;
}

.semi-track {
  position: absolute;
  top: calc(50% - 4px);
  left: 8%;
  right: 8%;
  height: 1px;
  background: var(--border);
}

.semi-dot {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
}

.semi-dot::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #4a4638;
  background: var(--bg);
  transition: all 0.15s;
}

.semi-dot:hover::after {
  border-color: var(--accent);
  transform: scale(1.2);
}

.semi-dot.zero::after {
  width: 14px;
  height: 14px;
  border-color: var(--muted);
}

.semi-dot.active::after {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.semi-dot-label {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  pointer-events: none;
}

.semi-dot.active .semi-dot-label {
  opacity: 1;
  color: var(--accent);
}

.semi-dot:hover .semi-dot-label {
  opacity: 0.7;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  width: 100%;
  height: 44px;
  cursor: pointer;
  touch-action: none;
  display: flex;
  align-items: center;
  margin-bottom: 0.2rem;
}

.timeline-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
  background: var(--surface-2);
  border-radius: 3px;
  transition: height 0.12s ease;
  overflow: hidden;
  z-index: 1;
}

.timeline.touching .timeline-track {
  height: 8px;
}

.timeline-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  pointer-events: none;
}

.timeline-loop {
  position: absolute;
  top: calc(50% - 11px);
  height: 3px;
  background: var(--loop);
  opacity: 0.4;
  border-radius: 1.5px;
  display: none;
  pointer-events: none;
  z-index: 2;
}

.timeline-loop.visible {
  display: block;
}

.timeline-loop.active {
  animation: loop-pulse 2s ease-in-out infinite;
}

@keyframes loop-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.65; }
}

.timeline-marker {
  position: absolute;
  top: calc(50% - 7px);
  width: 2px;
  height: 14px;
  background: var(--loop);
  box-shadow: 0 0 4px var(--loop-glow);
  border-radius: 1px;
  display: none;
  pointer-events: none;
  z-index: 3;
  cursor: ew-resize;
}

/* Flag handle on top of marker */
.timeline-marker::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: var(--loop);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--loop-glow);
}

.timeline-marker.visible {
  display: block;
  pointer-events: auto;
}

/* Expand touch target for dragging */
.timeline-marker.visible::before {
  content: '';
  position: absolute;
  top: -16px;
  left: -20px;
  width: 44px;
  height: 44px;
}

.timeline-marker.dragging {
  transform: scaleX(1.5);
  box-shadow: 0 0 12px var(--loop-glow);
}

.timeline-marker.dragging::after {
  transform: translateX(-50%) scale(1.3);
  box-shadow: 0 0 12px var(--loop-glow);
}

.timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 2px solid var(--text);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
  box-shadow: 0 0 8px var(--accent-glow);
  z-index: 4;
}

.timeline.touching .timeline-thumb {
  opacity: 1;
}

.timeline-tooltip {
  position: absolute;
  top: -4px;
  left: 0%;
  transform: translate(-50%, -100%);
  z-index: 5;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.timeline.touching .timeline-tooltip {
  opacity: 1;
}

/* --- Time Display --- */
.time-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.time-sep {
  opacity: 0.4;
}

.loop-badge {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--loop);
  background: var(--loop-dim);
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  margin-left: 0.4rem;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.loop-badge:hover {
  border-color: var(--loop);
}

.loop-badge.disabled {
  color: var(--muted);
  background: var(--surface);
  opacity: 0.5;
  text-decoration: line-through;
}

/* --- Transport Controls --- */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.btn-transport {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.btn-transport:hover {
  color: var(--text);
}

.btn-transport:active {
  color: var(--accent);
}

.btn-home {
  padding: 0.35rem;
}

.transport-label {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Loop Buttons (pill-shaped SET IN / SET OUT) */
.btn-loop-point {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 40px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.loop-btn-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.btn-loop-point:hover {
  border-color: var(--loop);
  color: var(--loop);
}

.btn-loop-point.set {
  background: var(--loop);
  color: var(--bg);
  border-color: var(--loop);
  box-shadow: 0 0 10px var(--loop-glow);
}

/* Loop hint (first-use) */
.loop-hint {
  text-align: center;
  font-size: 0.7rem;
  font-style: italic;
  color: var(--muted);
  opacity: 0.6;
  margin: 0.25rem 0 0;
}

.loop-hint.dismissed {
  display: none;
}

.btn-play {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, var(--accent-hover), var(--accent));
  color: var(--bg);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-play:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-play:active {
  transform: scale(0.95);
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  padding: 2rem 1.25rem calc(2.5rem + var(--safe-bottom));
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 10000;
  margin-top: 2rem;
}

.footer-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.footer-nav a {
  color: var(--muted);
  transition: color 0.15s;
}

.footer-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.footer-dot {
  color: var(--border);
}

.footer-trust {
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0.75rem 0 0.5rem;
  opacity: 0.7;
}

.footer-credit {
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.5;
  margin: 0;
}

.footer-credit a {
  color: var(--muted);
}

.footer-credit a:hover {
  color: var(--accent);
}

/* Rendered Digital lockup (prism + wordmark) */
.rendered-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  text-decoration: none;
  color: inherit;
}

.rendered-lockup:hover {
  text-decoration: none;
  color: var(--accent);
}

.rendered-prism {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  vertical-align: middle;
}

.rendered-verb {
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.rendered-wordmark {
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 0.85em;
}

/* --- About Page --- */
.back-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.back-link:hover {
  color: var(--accent);
}

.app-icon-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.app-icon {
  width: 96px;
  height: 96px;
  border-radius: 22%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.app-icon-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.app-subtitle {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.app-version {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.6;
}

.about-page h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

.about-page p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 0.75rem;
}

.about-page ol,
.about-page ul {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  padding-left: 1.25rem;
  margin: 0 0 1rem;
}

.about-page li {
  margin-bottom: 0.4rem;
}

.about-page code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--surface);
  color: var(--accent);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.about-page dl {
  margin: 0 0 1.5rem;
}

.about-page dt {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 1rem;
}

.about-page dd {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0.25rem 0 0 0;
}

.log-callout {
  margin: 2rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.about-intro {
  font-size: 0.95rem;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.about-page details {
  margin: 1.5rem 0;
}

.about-page details summary {
  cursor: pointer;
  color: var(--text);
}

.about-page details summary:hover {
  color: var(--accent);
}

.about-page details[open] summary {
  margin-bottom: 0.75rem;
}

/* --- About Page Tooltips (copied from Boltkey log-version/log-tip) --- */
.about-ref {
  display: inline-block;
  position: relative;
  color: var(--accent);
  cursor: help;
  border-bottom: 1px dotted var(--accent);
  transition: opacity 0.2s;
}

.about-ref:hover {
  opacity: 1;
}

.about-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-family: var(--font-body);
  white-space: normal;
  width: min(280px, calc(100vw - 2rem));
  color: var(--muted);
  line-height: 1.6;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
}

.about-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 1rem;
  border: 5px solid transparent;
  border-top-color: var(--border);
}

.about-tip strong {
  color: var(--text);
  font-weight: 600;
}

.about-tip code {
  color: var(--accent);
  font-size: 0.6rem;
}

/* Desktop: JS controls visibility after positioning */
.about-ref.tooltip-visible .about-tip {
  opacity: 1;
  visibility: visible;
}

/* Mobile: tap to toggle */
.about-ref.tooltip-open .about-tip {
  opacity: 1;
  visibility: visible;
}

/* Flip below when near top of viewport */
.about-ref.tooltip-below .about-tip {
  bottom: auto;
  top: calc(100% + 6px);
}

.about-ref.tooltip-below .about-tip::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--border);
}

/* Anchor right when near right edge */
.about-ref.tooltip-right .about-tip {
  left: auto;
  right: 0;
}

.about-ref.tooltip-right .about-tip::after {
  left: auto;
  right: 1rem;
}

.about-cta {
  text-align: center;
  font-size: 0.95rem;
  margin: 2rem 0;
}

.about-credit {
  text-align: center;
  padding: 1.5rem 0 0;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.credit-sub {
  font-size: 0.75rem;
  opacity: 0.6;
}

/* --- Liner Notes --- */
.breadcrumb {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.liner-notes-page h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.page-intro {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 2rem;
}

.log-timeline {
  border-left: 2px solid var(--border);
  padding-left: 1.5rem;
  margin-left: 0.25rem;
}

.log-entry {
  position: relative;
  margin-bottom: 2.5rem;
}

.log-entry::before {
  content: '';
  position: absolute;
  left: -1.8rem;
  top: 0.35rem;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%;
}

.log-date {
  display: block;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.log-headline {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.log-body {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.7;
}

.log-body p {
  margin: 0 0 0.75rem;
}

.log-body a {
  color: var(--accent);
}

.liner-notes-credit {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

/* --- Landing Page (mobile-first) --- */
.landing {
  margin: 0 auto;
  padding: 0 1rem 2rem;
  position: relative;
  z-index: 10000;
}

/* Hero */
.hero {
  text-align: center;
  padding: 2.5rem 0 2rem;
}

.hero .wordmark {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 400;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.hero .wordmark-fork {
  display: block;
  width: 160px;
  height: 54px;
  margin: -14px auto 0;
  color: var(--accent);
  opacity: 0.85;
}

.hero-tagline {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
  margin: 1.25rem 0 0.5rem;
}

.hero-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto 1rem;
}

.hero-credibility {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 1.75rem;
  font-style: italic;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.875rem 2rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 0 24px rgba(212, 148, 60, 0.15);
}

.btn-download:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 32px var(--accent-glow);
  text-decoration: none;
}

.btn-download svg {
  flex-shrink: 0;
  width: 14px;
  height: 17px;
}

.btn-coming-soon {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.875rem 2rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  cursor: default;
}

.hero-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.75rem;
  font-family: var(--font-mono);
}

/* App Screenshot */
.screenshot-section {
  text-align: center;
  margin: 2rem 0 3rem;
}

.app-screenshot {
  width: 100%;
  max-width: 680px;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 148, 60, 0.06);
}

/* Sections */
.landing-section {
  margin-bottom: 3rem;
}

.landing-section h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  margin: 0 0 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.landing-section p {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
}

/* Features grid */
.features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: transform 0.2s;
}

.feature-card:hover {
  transform: translateY(-2px);
}

.feature-icon {
  width: 36px;
  height: 36px;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.feature-icon-wide {
  width: 90px;
  height: 23px;
}

.feature-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  margin: 0 0 0.4rem;
  color: var(--text);
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* Steps */
.steps {
  list-style: none;
  padding: 0;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.steps li strong {
  color: var(--text);
}

/* Download band */
.download-band {
  text-align: center;
  padding: 3rem 1.25rem;
  margin: 3rem -1rem 0;
  background: linear-gradient(180deg, rgba(212, 148, 60, 0.04) 0%, transparent 100%);
  border-top: 1px solid var(--border);
}

.download-reqs {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-mono);
  margin: 0.75rem 0 0.5rem;
}

.download-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.75rem auto 0;
  max-width: 400px;
  line-height: 1.5;
}

/* Fade-in animation */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Landing Breakpoints --- */

/* Larger phones: 2-col grid */
@media (min-width: 480px) {
  .landing { padding: 0 1.25rem 2rem; }
  .hero { padding: 3rem 0 2.5rem; }
  .hero .wordmark { font-size: 3rem; }
  .hero .wordmark-fork { width: 200px; height: 68px; margin-top: -18px; }
  .hero-tagline { font-size: 1.2rem; }
  .features { grid-template-columns: 1fr 1fr; }
  .feature-card-wide { grid-column: 1 / -1; }
  .landing-section { margin-bottom: 3.5rem; }
}

/* Tablets */
@media (min-width: 640px) {
  .landing { max-width: 780px; padding: 0 2rem 3rem; }
  .hero { padding: 4rem 0 3rem; }
  .hero .wordmark { font-size: 3.2rem; }
  .hero-tagline { font-size: 1.3rem; }
  .screenshot-section { margin: 2.5rem 0 4rem; }
  .landing-section { margin-bottom: 4rem; }
  .landing-section h2 { font-size: 1.5rem; }
  .download-band { padding: 3.5rem 2rem; margin-left: -2rem; margin-right: -2rem; }
}

/* Desktop */
@media (min-width: 900px) {
  .landing { max-width: 960px; padding: 0 2.5rem 3rem; }
  .hero { padding: 5rem 0 3.5rem; }
  .hero .wordmark { font-size: 3.6rem; }
  .hero .wordmark-fork { width: 240px; height: 82px; margin-top: -22px; }
  .hero-tagline { font-size: 1.5rem; }
  .hero-subtitle { font-size: 1rem; }
  .features { grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
  .feature-card-wide { grid-column: auto; }
  .screenshot-section { margin: 3rem 0 5rem; }
  .landing-section { margin-bottom: 4.5rem; }
  .landing-section h2 { font-size: 1.6rem; }
  .download-band {
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding: 3.5rem 2.5rem;
  }
}

/* --- Error Page --- */
.error-page {
  text-align: center;
  padding-top: 4rem;
}

.error-page h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.error-page p {
  color: var(--muted);
  font-size: 1rem;
  margin: 0 0 1.5rem;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Responsive: Tablet / Large Phone (≤520px) --- */
@media (max-width: 520px) {
  .semi-dot { width: 24px; height: 24px; }
}

/* --- Responsive: Phone (≤480px) --- */
@media (max-width: 480px) {
  .transport { gap: 0.4rem; }
  .btn-home { padding: 0.25rem; }
  .btn-play { width: 56px; height: 56px; }
  .key-select-wrap { max-width: 120px; }
}

/* --- Responsive: Small Phone (≤400px) --- */
@media (max-width: 400px) {
  .main { padding: 1.5rem 1rem 1.5rem; }
  .wordmark { font-size: 1.9rem; }
  .semi-dot { width: 20px; height: 20px; }
  .semi-dot::after { width: 8px; height: 8px; }
  .semi-dot.zero::after { width: 12px; height: 12px; }
  .semi-dot.active::after { width: 12px; height: 12px; }
  .btn-step { width: 52px; height: 52px; font-size: 1.5rem; }
  .semitone-display { font-size: 2.8rem; }
  .transport { gap: 0.3rem; }
  .btn-loop-point { min-width: 44px; padding: 0 6px; }
  .loop-btn-label { font-size: 0.52rem; }
}

/* --- Responsive: Tiny Phone (≤360px) --- */
@media (max-width: 360px) {
  .main { padding: 1.25rem 0.75rem 1.25rem; }
  .wordmark { font-size: 1.7rem; }
  .semi-dot { width: 17px; height: 17px; }
  .semi-dot::after { width: 7px; height: 7px; }
  .semi-dot.zero::after { width: 10px; height: 10px; }
  .semi-dot.active::after { width: 10px; height: 10px; }
  .semi-dot-label { font-size: 0.5rem; bottom: -10px; }
  .btn-step { width: 46px; height: 46px; font-size: 1.3rem; }
  .semitone-display { font-size: 2.5rem; min-width: 3.5rem; }
  .semitone-center { padding: 0.35rem 0.75rem; }
  .btn-play { width: 50px; height: 50px; }
  .key-select-wrap { max-width: 100px; }
  .key-value { font-size: 0.95rem; }
  .transport-label { font-size: 0.5rem; }
}

/* --- PWA Standalone --- */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
  }
}
