:root {
  --paper: #f1ede4;
  --fg: #22252c;
  --muted: #6d6a63;
  --line: rgba(34, 37, 44, 0.18);
  --accent: #d4552a;
  --chip: rgba(241, 237, 228, 0.82);
  --serif: 'Instrument Serif', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --fade: rgba(241, 237, 228, 0.85);
}
body.night {
  --fg: #e8ecf5;
  --muted: #8f9cb8;
  --line: rgba(200, 212, 240, 0.18);
  --chip: rgba(12, 19, 34, 0.72);
  --fade: rgba(8, 14, 27, 0.8);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--fg); }
body { font-family: var(--mono); font-size: 12px; transition: color 0.8s; }
body.night { background: #080e1b; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#leaders { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#leaders path { stroke: var(--accent); stroke-width: 1; fill: none; }
#leaders circle { fill: var(--paper); stroke: var(--accent); stroke-width: 1.5; }
body.night #leaders circle { fill: #080e1b; }

#labels { position: fixed; inset: 0; pointer-events: none; }
.label {
  position: absolute; left: 0; top: 0; opacity: 0; padding: 8px 12px 8px 14px;
  border-left: 1px solid var(--accent); background: var(--chip); backdrop-filter: blur(6px);
  display: grid; gap: 2px; white-space: nowrap;
}
.label.left { border-left: 0; border-right: 1px solid var(--accent); text-align: right; padding: 8px 14px 8px 12px; }
.label b { font-family: var(--serif); font-weight: 400; font-size: 20px; line-height: 1.1; letter-spacing: 0.005em; }
.label span { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }

.head { position: fixed; top: 0; left: 0; right: 0; padding: 22px 28px 40px; background: linear-gradient(var(--fade) 45%, transparent); display: flex; justify-content: space-between; gap: 32px; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 10px; letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; }
.brand .logo { display: block; width: 168px; line-height: 0; }
.brand .logo svg { width: 100%; height: auto; }
.brand em { font-style: normal; color: var(--muted); text-transform: none; letter-spacing: 0.02em; padding-left: 12px; border-left: 1px solid var(--line); }
.chapter { max-width: 380px; text-align: right; }
.chapter .idx { color: var(--accent); letter-spacing: 0.1em; }
.chapter h1 { margin: 2px 0 6px; font-family: var(--serif); font-weight: 400; font-size: 46px; line-height: 1; letter-spacing: -0.01em; }
.chapter p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 12px; }
.chapter.in > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.chapter.in h1 { animation-delay: 0.05s; }
.chapter.in p { animation-delay: 0.12s; }
.chapter .note { margin-top: 10px; padding: 7px 12px 7px 0; border-right: 2px solid var(--accent); padding-right: 10px; color: var(--fg); font-size: 11.5px; }
.chapter.in .note { animation-delay: 0.2s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.stats { position: fixed; left: 28px; bottom: 84px; display: flex; gap: 28px; align-items: baseline; opacity: 0; pointer-events: none; }
.stats div { display: grid; }
.stats b { font-family: var(--serif); font-weight: 400; font-size: 54px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent); }
.stats span, .stats small { color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-size: 10px; }
.stats small { align-self: end; padding-bottom: 6px; }

/* iPhone 16 Pro (natural titanium) running the Gemstone Lights app */
.iphone { position: fixed; right: 40px; bottom: 74px; width: 258px; opacity: 0; pointer-events: none; user-select: none; -webkit-user-select: none; }
.iphone.live { pointer-events: auto; }
.iphone [data-demo] { cursor: pointer; }
.ip-frame {
  position: relative; padding: 3px; border-radius: 43px;
  background: linear-gradient(140deg, #a8a59e 0%, #e7e4de 14%, #8f8c86 32%, #d2cfc8 55%, #7f7c77 78%, #c4c1bb 100%);
  box-shadow: 0 50px 80px -40px rgba(0, 0, 0, 0.6), 0 18px 30px -18px rgba(0, 0, 0, 0.35), inset 0 0 0 0.5px rgba(255, 255, 255, 0.5);
}
.ip-btn { position: absolute; width: 3px; background: linear-gradient(90deg, #77746f, #c8c5bf); }
.ip-action, .ip-vol-up, .ip-vol-down { left: -2.5px; border-radius: 2px 0 0 2px; }
.ip-action { top: 94px; height: 22px; }
.ip-vol-up { top: 134px; height: 42px; }
.ip-vol-down { top: 186px; height: 42px; }
.ip-side { right: -2.5px; top: 156px; height: 66px; border-radius: 0 2px 2px 0; background: linear-gradient(270deg, #77746f, #c8c5bf); }
.ip-bezel { padding: 5.5px; border-radius: 40px; background: #050506; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07); }
/* antenna breaks in the titanium band */
.ip-frame::before, .ip-frame::after { content: ''; position: absolute; width: 3px; height: 1.5px; background: rgba(60, 58, 54, 0.55); }
.ip-frame::before { left: 0; top: 64px; }
.ip-frame::after { right: 0; bottom: 64px; }
.ip-screen {
  position: relative; overflow: hidden; border-radius: 34px; background: #eef1f5; aspect-ratio: 393 / 852;
  font-family: -apple-system, 'SF Pro Text', system-ui, sans-serif; color: #18212d; -webkit-font-smoothing: antialiased;
}
.ip-screen::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 9; background: linear-gradient(118deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 32%); }
.ip-island { position: absolute; top: 7px; left: 50%; width: 32%; height: 23px; transform: translateX(-50%); border-radius: 12px; background: #000; z-index: 8; }
.ip-island i { position: absolute; right: 9px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #2b3a55 0, #0b0f18 55%); }
.ip-status { position: relative; z-index: 7; height: 38px; display: grid; grid-template-columns: 1fr 32% 1fr; align-items: center; color: #fff; background: #237bc0; }
.ip-status > * { justify-self: center; }
.ip-status .ip-icons { grid-column: 3; }
.ip-time { font-size: 13.5px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding-left: 4px; }
.ip-icons { display: flex; gap: 4px; align-items: center; padding-right: 4px; }
.ip-icons svg { height: 9px; width: auto; fill: #fff; }
.ip-batt { position: relative; width: 20px; height: 10px; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 3.2px; padding: 1.2px; margin-right: 2px; }
.ip-batt::after { content: ''; position: absolute; right: -2.8px; top: 2.8px; width: 1.4px; height: 3px; border-radius: 0 1px 1px 0; background: rgba(255, 255, 255, 0.5); }
.ip-batt i { display: block; width: 78%; height: 100%; border-radius: 1.5px; background: #fff; }
.ip-head { display: grid; grid-template-columns: 24px 1fr 24px; align-items: center; height: 36px; padding: 0 12px 4px; background: #237bc0; color: #fff; }
.ip-title { display: inline-flex; gap: 4px; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.ip-title svg { width: 9px; height: 6px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ip-hb { width: 24px; height: 24px; display: grid; place-items: center; border: 1.3px solid rgba(255, 255, 255, 0.85); border-radius: 6px; }
.ip-hb svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; }
.ip-device { display: flex; align-items: center; gap: 6px; margin: 8px 12px 0; font-size: 10px; font-weight: 500; color: #3b4757; }
.ip-device span { margin-left: auto; color: #7a8696; font-weight: 400; }
.ip-online { width: 6px; height: 6px; border-radius: 50%; background: #2fb35a; box-shadow: 0 0 0 2px rgba(47, 179, 90, 0.18); }
.ip-playing { margin: 7px 10px 0; padding: 9px 11px 8px; background: #fff; border-radius: 14px; box-shadow: 0 1px 3px rgba(20, 40, 70, 0.08); display: grid; gap: 6px; }
.ip-np-top { display: flex; align-items: center; gap: 8px; }
.ip-np-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 17px; background: #eef4fb; }
.ip-np-text { flex: 1; display: grid; line-height: 1.15; }
.ip-np-text small { font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.07em; color: #7a8696; }
.ip-np-text strong { font-size: 13.5px; font-weight: 600; }
.ip-pp { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: #237bc0; display: grid; place-items: center; cursor: pointer; }
.ip-pp:active { transform: scale(0.9); }
.ip-playing.paused .ip-live { animation: none; background: #9aa4b1; }
.ip-pp svg { width: 10px; height: 10px; fill: #fff; }
#npStrip { width: 100%; height: 12px; border-radius: 6px; background: #141a26; }
.ip-live { display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 50%; background: #2fb35a; vertical-align: 1px; animation: live 1.6s ease-in-out infinite; }
@keyframes live { 50% { opacity: 0.35; } }
.ip-meta { display: flex; align-items: center; gap: 6px; font-size: 9.5px; color: #5b6676; }
.ip-anim { padding: 2px 7px; border-radius: 10px; background: #eef4fb; color: #237bc0; font-weight: 600; }
.ip-cols { display: flex; }
.ip-cols i { width: 11px; height: 11px; border-radius: 50%; margin-left: -3px; box-shadow: 0 0 0 1.5px #fff, inset 0 0 0 0.5px rgba(0, 0, 0, 0.15); }
.ip-cols i:first-child { margin-left: 0; }
.ip-edit { margin-left: auto; color: #237bc0; font-weight: 600; }
.ip-slider { display: grid; grid-template-columns: 16px 1fr 28px; gap: 6px; align-items: center; font-size: 9.5px; color: #4b5666; cursor: pointer; touch-action: none; padding: 3px 0; margin: -3px 0; }
.ip-slider svg { width: 13px; height: 13px; fill: none; stroke: #6b7787; stroke-width: 1.3; stroke-linecap: round; }
.ip-slider b { font-weight: 500; text-align: right; }
@property --v { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
.ip-slider i.drag { transition: none; }
.ip-slider i { transition: --v 0.6s ease; position: relative; height: 4px; border-radius: 2px; background: #dfe5ec; }
.ip-slider i::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--v); border-radius: 2px; background: #237bc0; }
.ip-slider i::after { content: ''; position: absolute; left: var(--v); top: 50%; width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28); }
.ip-seg { display: grid; grid-template-columns: 1fr 1fr; margin: 9px 10px 7px; padding: 2px; border-radius: 9px; background: #e1e6ec; font-size: 10px; font-weight: 500; text-align: center; color: #5b6676; }
.ip-seg span { padding: 4px 0; border-radius: 7px; }
.ip-seg .on { background: #fff; color: #18212d; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.ip-list { position: relative; height: 196px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.ip-list::-webkit-scrollbar { display: none; }
#presets { list-style: none; margin: 0; padding: 0 10px 70px; display: grid; gap: 5px; }
#presets li { position: relative; display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px; background: #fff; border-radius: 11px; box-shadow: 0 1px 2px rgba(20, 40, 70, 0.06); font-size: 11.5px; font-weight: 600; overflow: hidden; }
#presets li > i { width: 32px; height: 32px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 17px; font-style: normal; }
#presets li span { flex: 1; display: grid; line-height: 1.2; }
#presets li small { font-size: 9px; font-weight: 400; color: #7a8696; }
#presets li b { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid #c9d2dc; display: grid; place-items: center; }
#presets li { cursor: pointer; transition: transform 0.12s; }
#presets li:active { transform: scale(0.98); }
#presets li:focus-visible { outline: 2px solid #237bc0; outline-offset: 1px; }
#presets li.on { box-shadow: 0 0 0 1.5px #237bc0; }
#presets li.on b { border-color: #2fb35a; background: #eaf8ef; }
#presets li.on b::after { content: ''; width: 8px; height: 4px; border: 2px solid #2fb35a; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
#presets li .tap { position: absolute; left: 62%; top: 50%; width: 36px; height: 36px; margin: -18px; border-radius: 50%; background: rgba(35, 123, 192, 0.3); opacity: 0; }
#presets li.tapped .tap { animation: tap 0.7s ease-out; }
@keyframes tap { 0% { opacity: 1; transform: scale(0.3); } 100% { opacity: 0; transform: scale(2.4); } }
.ip-toast {
  position: absolute; left: 50%; bottom: 70px; z-index: 6; padding: 7px 12px; border-radius: 16px; white-space: nowrap;
  background: rgba(24, 33, 45, 0.88); color: #fff; font-size: 10px; font-weight: 500; transform: translate(-50%, -8px); opacity: 0;
}
.ip-toast.show { animation: toast 1.8s ease both; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 12%, 78% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -4px); } }
.ip-tabs {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; height: 54px; padding: 5px 6px 0; display: flex; justify-content: space-around; align-items: flex-start;
  background: rgba(250, 251, 252, 0.92); backdrop-filter: blur(14px) saturate(1.4); box-shadow: 0 -0.5px 0 rgba(0, 0, 0, 0.14); font-size: 8.5px; font-weight: 500; color: #8e96a3; letter-spacing: 0.01em;
}
.ip-tabs span { display: grid; justify-items: center; gap: 2px; width: 50px; }
.ip-tabs svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.ip-tabs .on { color: #237bc0; }
.ip-tabs .on svg { fill: rgba(35, 123, 192, 0.14); }
.ip-home-bar { position: absolute; bottom: 5px; left: 50%; z-index: 6; width: 35%; height: 3.5px; transform: translateX(-50%); border-radius: 3px; background: #0d0d0e; }

.hint { position: fixed; left: 50%; bottom: 82px; transform: translateX(-50%); padding: 8px 14px; border-radius: 18px; background: var(--chip); border: 1px solid var(--line); color: var(--muted); font-size: 11px; opacity: 0; pointer-events: none; transition: opacity 0.6s; }
body.exploring .hint { opacity: 1; animation: hint-out 0.6s 5s forwards; }
@keyframes hint-out { to { opacity: 0; } }
@media (max-height: 780px) { .iphone { transform-origin: bottom right; scale: 0.84; } }

/* track colour swatches */
.swatches { position: fixed; left: 28px; bottom: 84px; display: grid; gap: 8px; opacity: 0; pointer-events: none; }
.sw-title, .sw-note { color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-size: 10px; }
.sw-row { display: flex; gap: 6px; }
.sw-row i { width: 22px; height: 22px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.sw-row i.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--accent); }

.bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 18px 28px 22px; display: flex; align-items: center; gap: 18px; }
.bar button { font: inherit; color: var(--fg); background: none; border: 1px solid var(--line); cursor: pointer; }
.icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.icon svg { width: 12px; height: 12px; fill: currentColor; }
.icon .i-play, .icon.paused .i-pause { display: none; }
.icon.paused .i-play { display: block; }
.pill { height: 34px; padding: 0 16px; border-radius: 17px; letter-spacing: 0.04em; }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.bar button:hover { border-color: var(--accent); }
.bar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scrub { position: relative; flex: 1; height: 34px; cursor: pointer; touch-action: none; }
.rail { position: absolute; left: 0; right: 0; top: 16px; height: 2px; background: var(--line); }
.fill { height: 100%; width: 0; background: var(--accent); }
.marks { position: absolute; inset: 0; }
.mark { position: absolute; top: 11px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; padding: 0; background: var(--paper) !important; border: 1px solid var(--muted) !important; }
body.night .mark { background: #080e1b !important; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 92px; text-align: right; }

#flash { position: fixed; inset: 0; background: #fbfaf6; pointer-events: none; opacity: 1; }

@media (max-width: 720px) {
  .head { flex-direction: column; gap: 14px; padding: 16px; }
  .brand em { display: none; }
  .chapter { text-align: left; }
  .chapter h1 { font-size: 34px; }
  .bar { padding: 12px 16px 16px; gap: 10px; }
  .time { display: none; }
  .stats { left: 16px; bottom: 70px; }
  .stats b { font-size: 38px; }
  .iphone { right: 12px; bottom: 66px; transform-origin: bottom right; scale: 0.6; }
  .swatches { left: 16px; bottom: 70px; }
  .label b { font-size: 16px; }
}
