:root {
  --bg1: #04222e;
  --bg2: #0b3d52;
  --accent: #5eead4;
  --tint: #bef264;
  --text: #f5f3ee;
  --muted: rgba(245, 243, 238, 0.62);
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 10%, var(--bg2), var(--bg1) 70%);
  transition: background 1.2s ease;
  overflow-x: hidden;
}

/* Ambient floating light orbs */
.ambient { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35; transition: background 2s ease; }
.orb-a { width: 520px; height: 520px; background: var(--accent); top: -160px; left: -120px; animation: drift 22s ease-in-out infinite; }
.orb-b { width: 460px; height: 460px; background: var(--tint); bottom: -180px; right: -100px; animation: drift 26s ease-in-out infinite reverse; }
.orb-c { width: 300px; height: 300px; background: var(--tint); top: 40%; left: 45%; opacity: .18; animation: drift 30s ease-in-out infinite; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.15); }
}

.top { position: relative; z-index: 1; text-align: center; padding: 28px 20px 6px; }
.top h1 {
  font-family: "Cormorant Garamond", serif; font-weight: 400; font-size: clamp(2.2rem, 4vw, 3.2rem);
  margin: 0; letter-spacing: .04em;
}
.top h1 em { color: var(--accent); transition: color 1s; }
.top p { margin: 4px 0 0; color: var(--muted); font-weight: 300; }

/* Side tab + slide-in sidebar */
@property --st-angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.side-tab {
  --st-angle: 0deg;
  position: fixed; right: 0; top: 50%; z-index: 40; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 9px 16px 10px; border-radius: 16px 0 0 16px; cursor: pointer; color: #fff;
  font: 600 .8rem "Inter", sans-serif; letter-spacing: .06em;
  border: 1.5px solid transparent; border-right: 0;
  background:
    linear-gradient(160deg, rgba(18,22,40,.94), rgba(30,24,52,.94)) padding-box,
    conic-gradient(from var(--st-angle), #5eead4, #a78bfa, #f472b6, #facc15, #5eead4) border-box;
  box-shadow: -8px 10px 30px -12px rgba(167,139,250,.7);
  animation: stSpin 5s linear infinite;
  transition: padding .25s ease, box-shadow .25s ease;
}
@keyframes stSpin { to { --st-angle: 360deg; } }
.side-tab:hover, .side-tab:focus-visible { padding-right: 14px; box-shadow: -10px 12px 34px -10px rgba(94,234,212,.75); }
.side-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-icon { font-size: 1.05rem; display: inline-block; animation: stTilt 2.6s ease-in-out infinite; }
@keyframes stTilt { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.st-label { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
body.sb-open .side-tab { opacity: 0; pointer-events: none; }

.side-backdrop {
  position: fixed; inset: 0; z-index: 45; background: rgba(2,8,16,.5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .3s ease;
}
body.sb-open .side-backdrop { opacity: 1; }

.sidebar {
  position: fixed; top: 0; right: 0; z-index: 50; height: 100%; height: 100dvh;
  width: min(320px, 86vw); padding: 22px 18px; display: flex; flex-direction: column; gap: 18px;
  background: linear-gradient(170deg, rgba(14,20,36,.97), rgba(26,20,46,.97));
  border-left: 1px solid var(--border); box-shadow: -20px 0 60px -20px rgba(0,0,0,.7);
  transform: translateX(105%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto; visibility: hidden;
}
body.sb-open .sidebar { transform: none; visibility: visible; }
.sb-head { display: flex; align-items: center; justify-content: space-between; }
.sb-brand { font: 400 1.6rem "Cormorant Garamond", serif; letter-spacing: .04em; }
.sb-brand em { color: var(--accent); }
.sb-close {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; font-size: .85rem;
}
.sb-close:hover { border-color: var(--accent); }
.sb-nav { display: flex; flex-direction: column; gap: 8px; }
.sb-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px;
  color: var(--text); text-decoration: none; border: 1px solid transparent; transition: all .2s ease;
}
.sb-item:hover, .sb-item:focus-visible { background: var(--card); border-color: var(--border); }
.sb-item.active { background: rgba(94,234,212,.08); border-color: rgba(94,234,212,.25); }
.sb-item b { display: block; font-weight: 600; font-size: .92rem; }
.sb-item small { display: block; margin-top: 2px; font-size: .74rem; color: var(--muted); }
.sb-ic {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 1.05rem;
  background: radial-gradient(circle at 35% 30%, rgba(167,139,250,.5), rgba(94,234,212,.15));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.sb-lab { border-color: rgba(167,139,250,.35); background: linear-gradient(135deg, rgba(167,139,250,.14), rgba(94,234,212,.08)); }
.sb-foot { margin: auto 0 0; font-size: .78rem; color: var(--muted); line-height: 1.5; }
@media (max-width: 640px) {
  .side-tab { padding: 10px 6px 12px 7px; gap: 7px; font-size: .7rem; border-radius: 12px 0 0 12px; }
  .side-tab:hover, .side-tab:focus-visible { padding-right: 6px; }
  .st-icon { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .side-tab, .st-icon { animation: none; }
  .sidebar { transition: none; }
}

.edit-link {
  display: inline-block; margin-top: 8px; font-size: .8rem; color: var(--accent); text-decoration: none;
  padding: 4px 12px; border: 1px solid currentColor; border-radius: 999px; opacity: .9;
}
.edit-link:hover { opacity: 1; background: rgba(255,255,255,.06); }
.edit-link[hidden] { display: none; }

.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(340px, 470px) 1fr; gap: 32px;
  max-width: 1240px; margin: 0 auto; padding: 20px 28px 48px;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* Stage */
.stage { display: flex; flex-direction: column; align-items: center; }

.picker { width: 100%; }
.picker label { display: block; font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.select-wrap { position: relative; }
.select-wrap::after { content: "▾"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--accent); }
select {
  width: 100%; appearance: none; cursor: pointer;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  padding: 14px 44px 14px 16px; border-radius: 14px; font: 500 1rem "Inter", sans-serif;
  backdrop-filter: blur(10px);
}
select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
select option { background: #111; color: #eee; font-weight: 400; font-style: normal; }
select optgroup {
  background: #0a2530; color: var(--accent);
  font-weight: 700; font-style: normal; letter-spacing: .08em;
}

.bottle-area { position: relative; width: min(400px, 88vw); margin: 10px auto 0; }
.bottle-wrap { width: 100%; aspect-ratio: 400 / 500; position: relative; }
.bottle-wrap svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 30px 40px rgba(0,0,0,.45)); }
.bottle-wrap.swap-in svg { animation: bottleIn .8s cubic-bezier(.2,.9,.3,1.2); }
@keyframes bottleIn {
  from { opacity: 0; transform: translateY(30px) scale(.92) rotate(-3deg); }
  to   { opacity: 1; transform: none; }
}
.bottle-wrap.idle-float svg { animation: float 5s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.actuator { cursor: pointer; transition: transform .12s ease; transform-box: fill-box; }
.actuator:hover { filter: brightness(1.15) drop-shadow(0 0 6px var(--accent)); }
.actuator.pressed { transform: translateY(9px); }
.actuator:focus { outline: none; }
.actuator, .bottle-wrap, .bottle-wrap svg { -webkit-tap-highlight-color: transparent; }
.actuator:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#liquid { transition: y .6s ease, height .6s ease; }

/* Hint: JS places its bottom-left corner (the arrow tip) just above-right of the nozzle */
.hint {
  position: absolute; left: 0; top: 0; transform: translate(0, -100%);
  display: flex; align-items: flex-end; flex-direction: column-reverse; gap: 0;
  font-size: .85rem; color: var(--accent); letter-spacing: .05em; white-space: nowrap;
  pointer-events: none; transition: opacity .5s;
}
.hint .hint-arrow { font-size: 1.6rem; line-height: 1; align-self: flex-start; animation: nudge 1.4s ease-in-out infinite; }
.hint .hint-text { padding: 4px 10px; border: 1px solid var(--accent); border-radius: 999px; background: rgba(0,0,0,.35); margin-left: 14px; }
.hint.gone { opacity: 0; }
.hint.flip { transform: translate(-100%, -100%); align-items: flex-start; }
.hint.flip .hint-arrow { align-self: flex-end; animation-name: nudgeFlip; }
.hint.flip .hint-text { margin-left: 0; margin-right: 14px; }
@keyframes nudgeFlip { 0%,100% { transform: scaleX(-1) translate(0,0); } 50% { transform: scaleX(-1) translate(-5px,5px); } }
@keyframes nudge { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-5px,5px); } }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

.pulse-ring { transform-box: fill-box; transform-origin: center; animation: ring 1.6s ease-out infinite; pointer-events: none; }
@keyframes ring { 0% { transform: scale(.7); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
.bottle-wrap.sprayed .pulse-ring { display: none; }

/* Persistent note bubbles hovering around the bottle */
.scent-cloud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.bubble {
  position: absolute; transform: translate(-50%, -50%) scale(var(--s, 1));
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: left 1.2s ease, top 1.2s ease, opacity 1s ease, transform 1.2s ease;
  opacity: 0;
}
.bubble.show { opacity: var(--o, 1); }
.bubble .orb-in {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.28), rgba(255,255,255,.05) 60%);
  border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(6px);
  box-shadow: 0 0 22px -6px var(--tint), inset 0 0 12px rgba(255,255,255,.08);
  animation: bob var(--bob, 4s) ease-in-out infinite; animation-delay: var(--delay, 0s);
}
.bubble .lbl2 { font-size: .68rem; letter-spacing: .06em; color: var(--text); background: rgba(0,0,0,.35); padding: 1px 7px; border-radius: 999px; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.identity { text-align: center; margin-top: 6px; }
.house { font-size: .75rem; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); }
.name { font-family: "Cormorant Garamond", serif; font-size: 2rem; line-height: 1.1; margin-top: 2px; }
.tagline { color: var(--muted); font-size: .9rem; margin-top: 4px; font-weight: 300; }

.pyramid { width: 100%; margin-top: 18px; display: grid; gap: 8px; }
.tier { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: start; font-size: .82rem; }
.tier-name { color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: .66rem; padding-top: 5px; }
.tier-notes { display: flex; flex-wrap: wrap; gap: 6px; }
.tier-notes span { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); transition: all .5s; }
.tier.active .tier-name { color: var(--accent); }
.tier.active .tier-notes span { border-color: var(--accent); box-shadow: 0 0 12px -4px var(--accent); }

/* Panel */
.panel {
  background: linear-gradient(160deg, rgba(255,255,255,.09), rgba(255,255,255,.03));
  border: 1px solid var(--border); border-radius: 24px; padding: 28px 30px;
  backdrop-filter: blur(16px); min-height: 560px; position: relative; overflow: clip;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.6);
}
.panel::before {
  content: ""; position: absolute; inset: -40%; pointer-events: none;
  background: radial-gradient(circle at 30% 20%, var(--tint), transparent 45%);
  opacity: .12; transition: background 1.5s ease;
}
.panel.burst::before { animation: glow 1.6s ease-out; }
@keyframes glow { 0% { opacity: .45; } 100% { opacity: .12; } }

.idle { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 500px; color: var(--muted); }
.idle-icon { font-size: 3rem; color: var(--accent); animation: pulse 2s infinite; }
.idle h2 { font-family: "Cormorant Garamond", serif; font-weight: 400; font-size: 2rem; color: var(--text); margin: 10px 0; }
.idle p { max-width: 440px; line-height: 1.6; }
kbd { border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; background: var(--card); font-family: inherit; }

.eyebrow { font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
/* Sticky so the timer stays visible while scrolling the journey/accords */
.clock-row {
  display: flex; justify-content: space-between; align-items: flex-end;
  position: sticky; top: 0; z-index: 5;
  margin: -28px -30px 0; padding: 22px 30px 14px;
  background: rgba(6, 28, 38, .82);
  background: var(--bg1);
  box-shadow: 0 8px 18px -10px rgba(0,0,0,.6);
  border-bottom: 1px solid var(--border); border-radius: 24px 24px 0 0;
}
.clock-row .eyebrow { margin-top: 0; }
.clock { font-family: "Cormorant Garamond", serif; font-size: 2.8rem; line-height: 1; font-variant-numeric: tabular-nums; }
.phase-badge {
  padding: 6px 14px; border-radius: 999px; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase;
  border: 1px solid var(--tint); color: var(--tint); background: rgba(0,0,0,.2); transition: all .8s;
}

.phase-block { position: relative; }
.phase-block.fade { animation: phaseIn .9s ease; }
@keyframes phaseIn { from { opacity: 0; transform: translateY(12px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.stage-line { margin-top: 18px; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text); }
.stage-line #stageTime { color: var(--tint); font-weight: 600; }
.stage-line .sep { margin: 0 8px; color: var(--muted); }

.journey-list { list-style: none; margin: 0; padding: 0; position: relative; }
.journey-list::before { content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 2px; background: rgba(255,255,255,.1); }
.jstep {
  position: relative; display: grid; grid-template-columns: 16px 110px 1fr; gap: 14px; align-items: start;
  padding: 10px 12px 10px 0; cursor: pointer; border-radius: 12px; transition: background .3s, opacity .4s;
  opacity: .55;
}
.jstep:hover { background: rgba(255,255,255,.04); opacity: .85; }
.jstep .jdot { width: 16px; height: 16px; border-radius: 50%; background: #1b1b1f; border: 2px solid var(--border); margin-top: 2px; position: relative; z-index: 1; transition: all .4s; }
.jstep .jtime { font-weight: 600; font-size: .88rem; font-variant-numeric: tabular-nums; }
.jstep .jstage { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.jstep .jtitle { font-family: "Cormorant Garamond", serif; font-size: 1.2rem; line-height: 1.15; }
.jstep .jnotes { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.jstep .jprog { height: 3px; border-radius: 2px; background: rgba(255,255,255,.1); margin-top: 8px; overflow: hidden; display: none; }
.jstep .jprog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--tint)); }
.jstep.done { opacity: .75; }
.jstep.done .jdot { background: var(--accent); border-color: var(--accent); }
.jstep.current { opacity: 1; background: rgba(255,255,255,.06); }
.jstep.current .jdot { background: var(--tint); border-color: #fff; box-shadow: 0 0 14px var(--tint); }
.jstep.current .jtime { color: var(--tint); }
.jstep.current .jprog { display: block; }

.phase-title { font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 2.1rem; margin: 4px 0 0; color: var(--tint); transition: color .8s; }
.smell { font-size: 1.05rem; line-height: 1.7; margin: 0; font-weight: 300; }

.feels { display: flex; flex-wrap: wrap; gap: 8px; }
.feel {
  padding: 8px 14px; border-radius: 14px; background: rgba(0,0,0,.22); border: 1px solid var(--border);
  font-style: italic; font-family: "Cormorant Garamond", serif; font-size: 1.1rem;
  opacity: 0; animation: chipIn .6s ease forwards;
}
@keyframes chipIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }

.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.note {
  display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 4px 8px;
  padding: 8px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--border);
  opacity: 0; animation: chipIn .6s ease forwards;
}
.note .emo { font-size: 1.35rem; grid-row: span 2; text-align: center; }
.note .nm { font-size: .88rem; }
.note .bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
.note .bar i { display: block; height: 100%; background: var(--tint); border-radius: 2px; transition: width 1s ease; }

.split { display: grid; grid-template-columns: 1fr 200px; gap: 28px; }
@media (max-width: 640px) { .split { grid-template-columns: 1fr; } }

.accord { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; font-size: .8rem; margin-bottom: 6px; }
.accord .lbl { color: var(--muted); }
.accord .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.accord .track2 { height: 8px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.accord .track2 i { display: block; height: 100%; border-radius: 4px; width: 0; box-shadow: 0 0 10px -2px currentColor; }

.meter { height: 140px; width: 46px; border-radius: 23px; background: rgba(255,255,255,.08); border: 1px solid var(--border); position: relative; overflow: hidden; margin: 0 auto; }
.meter-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(to top, var(--accent), var(--tint)); border-radius: 23px; }
.proj-label { text-align: center; font-size: .82rem; color: var(--muted); margin-top: 10px; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; margin-top: 24px; }
.speed { display: flex; gap: 4px; background: rgba(0,0,0,.2); padding: 4px; border-radius: 12px; }
.ctl { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 9px 16px; cursor: pointer; font: 500 .85rem "Inter", sans-serif; transition: all .2s; }
.ctl:hover { border-color: var(--accent); }
.speed .ctl { border: 0; background: transparent; padding: 7px 12px; }
.speed .ctl.active { background: var(--accent); color: #111; }
.ctl.primary { background: var(--accent); color: #111; border-color: var(--accent); }

/* Phones */
@media (max-width: 640px) {
  .top { padding: 20px 14px 0; }
  .top p { font-size: .9rem; }
  .layout { padding: 14px 14px 40px; gap: 22px; }
  .name { font-size: 1.7rem; }

  .panel { padding: 18px 16px; border-radius: 20px; min-height: 0; }
  .idle { min-height: 260px; }
  .idle h2 { font-size: 1.6rem; }
  .clock-row { margin: -18px -16px 0; padding: 12px 16px 10px; border-radius: 20px 20px 0 0; }
  .clock { font-size: 2.1rem; }
  .phase-badge { padding: 5px 10px; font-size: .68rem; }
  .phase-title { font-size: 1.7rem; }
  .smell { font-size: .98rem; line-height: 1.6; }

  /* Timeline: time/stage on one line above the title so the title gets the full width */
  .jstep { grid-template-columns: 16px 1fr; gap: 4px 12px; padding-right: 8px; }
  .jstep .jdot { grid-row: span 2; }
  .jstep > div:nth-of-type(1) { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
  .jstep > div:nth-of-type(2) { grid-column: 2; }

  .accord { grid-template-columns: 92px 1fr 30px; gap: 8px; }
  .meter { height: 110px; }

  .bubble .orb-in { width: 44px; height: 44px; font-size: 1.3rem; }
  .bubble .lbl2 { font-size: .62rem; }

  .controls { justify-content: center; }
  .controls #btnRespray { flex: 1 1 100%; }
}

/* Overlays */
#mist { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 5; }
