/* Komorebi Studio — studio cyclorama at dawn. See DESIGN.md */
:root {
  --paper: #FBF8F4;
  --white: #FFFFFF;
  --ink: #2A1D14;
  --ink-2: #74604F;
  --line: #ECE3DA;
  --line-2: #D8CBBF;
  --orange: #FF6B1A;
  --orange-hover: #FF7D35;
  --orange-strong: #F25F0C;
  --orange-ink: #C2410C;
  --orange-tint: #FFF1E7;
  --orange-tint-2: #FFE0CA;
  --danger: #B42318;

  --stage-mid: #F8F3EE;
  --stage-edge: #EEE6DE;

  --shadow-1: 0 1px 2px rgba(74, 38, 12, .06), 0 6px 18px -6px rgba(74, 38, 12, .12);
  --shadow-2: 0 2px 6px rgba(74, 38, 12, .05), 0 22px 48px -18px rgba(74, 38, 12, .22);

  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);

  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --r-s: 10px; --r-m: 16px; --r-l: 24px; --r-pill: 999px;
  --topbar-h: 64px;
  --panel-w: 328px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  caret-color: var(--orange-strong);
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--orange-tint-2); color: var(--ink); }
* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--paper); }
a { color: var(--orange-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; font-weight: 400; }
p { text-wrap: pretty; margin: 0; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.75; flex: none; }

/* ---------- Stage ---------- */
.stage {
  position: fixed; inset: 0;
  background:
    radial-gradient(110% 75% at 50% 42%, #FFFFFF 0%, var(--stage-mid) 52%, var(--stage-edge) 100%);
  transition: opacity .9s var(--ease), filter 1.2s var(--ease);
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; transition: opacity 1s var(--ease); }
.stage.is-loading canvas { opacity: 0; }
body.page-open .stage { opacity: 0; }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s5);
  padding-top: env(safe-area-inset-top);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
body.page-open .topbar { background: color-mix(in srgb, var(--paper) 92%, transparent); }
body.in-studio .topbar { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; }
.nav { display: flex; align-items: center; gap: 2px; }
.nav a {
  color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500;
  height: 38px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: var(--r-pill);
  transition: background .3s var(--ease), color .3s var(--ease);
}
.nav a:hover { color: var(--ink); background: rgba(42, 29, 20, .04); }
.nav a[aria-current="page"] { color: var(--orange-ink); background: var(--orange-tint); }
.nav .nav-icon { padding: 0 10px; }
.nav .nav-home { padding: 0 10px; margin-right: 2px; color: #A3907F; }
.nav .nav-home svg.lucide { width: 17px; height: 17px; stroke-width: 1.5; }
.nav .nav-home:hover { color: var(--ink-2); background: rgba(42, 29, 20, .03); }
.nav .nav-home[aria-current="page"] { color: var(--orange-ink); background: transparent; }

/* ---------- Home: a quiet clock in the leaf light ---------- */
.view-home { background: var(--paper); overflow: hidden; display: grid; place-items: center; }
body.on-home .topbar { background: transparent; }
/* small pill switch tucked under the settings icon: turns the clock pure white */
.clock-tone {
  position: absolute; top: calc(var(--topbar-h) - 10px + env(safe-area-inset-top)); right: 25px; z-index: 2;
  width: 36px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto;
  opacity: .7; transition: opacity .3s var(--ease);
}
.clock-tone:hover, .clock-tone:focus-visible, .clock-tone[aria-checked="true"] { opacity: 1; }
.clock-tone:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 3px; border-radius: 22px; }
.clock-tone-track { display: block; position: relative; width: 100%; height: 100%; border-radius: 22px; background: var(--line-2); transition: background .4s var(--ease); }
.clock-tone-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(74, 38, 12, .3); transition: transform .5s var(--ease); }
.clock-tone[aria-checked="true"] .clock-tone-track { background: var(--orange); }
.clock-tone[aria-checked="true"] .clock-tone-track::after { transform: translateX(14px); }
.view-home .clock { transition: color .8s var(--ease), text-shadow .8s var(--ease); }
.view-home.is-white .clock { color: #FFFFFF; text-shadow: 0 1px 14px rgba(74, 38, 12, .14); }
.view-home .clock-date { transition: color .8s var(--ease); }
.view-home.is-white .clock-date { color: #CFC5BC; text-shadow: none; }
.home-clock { position: relative; text-align: center; padding: 0 var(--s5); }
.clock {
  font-family: var(--font-display); font-size: clamp(5rem, 18vw, 12rem); line-height: 1;
  letter-spacing: -0.02em; display: inline-flex; align-items: baseline;
}
/* On for 1 s, off for 1 s: a hard blink, no fade. */
.clock .colon { display: inline-block; margin: 0 0.04em; transform: translateY(-0.06em); animation: colon-blink 2s linear infinite; }
@keyframes colon-blink { 0%, 49.99% { opacity: 1; } 50%, 100% { opacity: 0; } }
.clock-date { margin-top: var(--s4); color: var(--ink-2); font-size: clamp(1rem, 1.6vw, 1.2rem); }

/* ---------- Views ---------- */
.view {
  position: fixed; inset: 0; z-index: 10;
  opacity: 0; visibility: hidden;
  transform: translateY(10px);
  transition: opacity .3s ease-out, transform .6s var(--ease), visibility 0s linear .3s;
  pointer-events: none;
}
.view.is-active { opacity: 1; visibility: visible; transform: none; transition: opacity .9s var(--ease) .14s, transform 1.1s var(--ease) .14s, visibility 0s; }
.view-today > *, .view-studio > * { pointer-events: auto; }
.view-page { pointer-events: auto; overflow-y: auto; background: var(--paper); }
.view-page.is-active { pointer-events: auto; }

/* ---------- Buttons ---------- */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 18px; border-radius: var(--r-pill);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-size: 15px; font-weight: 500; letter-spacing: -0.005em; white-space: nowrap; text-decoration: none; color: var(--ink);
  transition: background .3s var(--ease), border-color .3s var(--ease), transform .4s var(--ease), box-shadow .4s var(--ease), opacity .3s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-lg { --h: 52px; padding: 0 26px; font-size: 16px; }
.btn-primary { background: var(--orange); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(194, 65, 12, .25), 0 8px 20px -10px rgba(255, 107, 26, .8); }
.btn-primary:hover:not(:disabled) { background: var(--orange-hover); transform: translateY(-1px); box-shadow: 0 2px 4px rgba(194, 65, 12, .22), 0 14px 28px -12px rgba(255, 107, 26, .85); }
.btn-quiet { background: var(--white); border-color: var(--line-2); }
.btn-quiet:hover:not(:disabled) { border-color: var(--orange-strong); }
.btn-text { padding: 0 8px; color: var(--orange-ink); --h: 36px; }
.btn-text:hover:not(:disabled) { background: var(--orange-tint); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #FDECEA; }
.btn-danger-solid { background: var(--danger); color: #fff; font-weight: 600; }
.btn-danger-solid:hover { background: #9A1D13; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid transparent; background: none; cursor: pointer;
  display: inline-grid; place-items: center; color: var(--ink);
  transition: background .3s var(--ease), transform .4s var(--ease);
}
.icon-btn:hover { background: rgba(42, 29, 20, .05); }
.icon-btn:active { transform: scale(.94); }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.inline .input { flex: 1 1 220px; width: auto; }

/* ---------- Inputs ---------- */
.input {
  height: 44px; padding: 0 14px; border-radius: var(--r-s);
  border: 1px solid var(--line-2); background: var(--white); min-width: 0; width: 100%;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.input::placeholder { color: #8C7766; }
.input:focus { outline: none; border-color: var(--orange-strong); box-shadow: 0 0 0 3px var(--orange-tint-2); }
.input-lg { height: 56px; font-size: 20px; padding: 0 18px; }

.range {
  --p: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--orange) 0 var(--p), var(--line-2) var(--p) 100%); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-2); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--orange); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
  background: var(--thumb, #fff); border: 2px solid var(--orange-strong);
  box-shadow: 0 1px 2px rgba(74, 38, 12, .18), 0 4px 10px -4px rgba(74, 38, 12, .3);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--thumb, #fff); border: 2px solid var(--orange-strong); box-shadow: 0 2px 6px rgba(74, 38, 12, .25); }
.range:hover::-webkit-slider-thumb { transform: scale(1.08); }
.range:active::-webkit-slider-thumb { transform: scale(1.2); box-shadow: 0 0 0 6px rgba(255, 107, 26, .16), 0 4px 10px -4px rgba(74, 38, 12, .3); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--orange-strong); }
.range-kelvin::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(to right, #FFB46B, #FFD1A3 14%, #FFE4CE 29%, #FFF6EE 50%, #E6ECFF 71%, #CCDBFF); }
.range-kelvin::-moz-range-track { height: 6px; background: linear-gradient(to right, #FFB46B, #FFD1A3 14%, #FFE4CE 29%, #FFF6EE 50%, #E6ECFF 71%, #CCDBFF); }
.range-kelvin::-moz-range-progress { background: transparent; }
.range-kelvin::-webkit-slider-thumb { margin-top: -8px; }
.range-mini { width: 92px; }

.switch { position: relative; display: inline-flex; width: 44px; height: 26px; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { width: 100%; height: 100%; border-radius: 26px; background: var(--line-2); transition: background .4s var(--ease); position: relative; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(74, 38, 12, .3); transition: transform .5s var(--ease); }
.switch input:checked + .switch-track { background: var(--orange); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--orange-strong); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: rgba(42, 29, 20, .05); gap: 2px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: var(--r-pill); font-size: 14px; font-weight: 500; color: var(--ink-2); transition: background .35s var(--ease), color .35s var(--ease), box-shadow .35s; }
.segmented input:checked + span { background: var(--white); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + span { outline: 2px solid var(--orange-strong); outline-offset: 1px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 34px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--white);
  font-size: 14px; font-weight: 500; cursor: pointer; font-variant-numeric: tabular-nums;
  transition: border-color .3s var(--ease), background .3s var(--ease), color .3s;
}
.chip:hover { border-color: var(--orange-strong); }
.chip[aria-pressed="true"] { background: var(--orange-tint); border-color: var(--orange-strong); color: var(--orange-ink); }

/* ---------- Today ---------- */
.today-head {
  position: absolute; top: calc(var(--topbar-h) + 8px); left: 0; right: 0;
  text-align: center; padding: 0 var(--s5);
}
.today-date { font-family: var(--font-display); font-size: clamp(2.6rem, 5.4vw, 3.6rem); line-height: 1; letter-spacing: -0.015em; }
.greeting { color: var(--ink-2); font-size: 16px; margin-top: var(--s2); }
.week {
  position: absolute; top: calc(var(--topbar-h) + 118px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: clamp(8px, 2vw, 18px); list-style: none; margin: 0; padding: 0;
}
.week li { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.day {
  position: relative; width: 52px; height: 52px; border-radius: 50%; padding: 0;
  border: 1.5px solid var(--line-2); background: color-mix(in srgb, var(--white) 70%, transparent);
  display: grid; place-items: center; overflow: visible; cursor: default;
  transition: transform .6s var(--ease), border-color .4s var(--ease), background .4s var(--ease), box-shadow .6s var(--ease);
}
.day img { width: 82%; height: 82%; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(74, 38, 12, .18)); }
.day.is-done { background: var(--orange-tint); border-color: var(--orange); cursor: pointer; }
.day.is-done:hover { transform: translateY(-3px) scale(1.06); box-shadow: var(--shadow-1); }
.day.is-today { border-color: var(--orange-strong); border-width: 2px; width: 60px; height: 60px; }
.day.is-today:not(.is-done)::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 1px solid var(--orange);
  opacity: 0; animation: halo 4.5s var(--ease-io) infinite;
}
@keyframes halo { 0% { opacity: 0; transform: scale(.9); } 40% { opacity: .5; } 100% { opacity: 0; transform: scale(1.18); } }
.day .count { position: absolute; right: -4px; top: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.day.just-filled { animation: fill-in 1.4s var(--ease); }
@keyframes fill-in { 0% { transform: scale(.7); background: var(--white); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.day-label { font-size: 12px; color: var(--ink-2); line-height: 1.2; text-align: center; font-variant-numeric: tabular-nums; }
.day-label b { display: block; font-weight: 600; color: var(--ink); font-size: 12px; }
.is-today + .day-label b { color: var(--orange-ink); }

.today-foot {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--s5) var(--s6) calc(var(--s6) + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5);
}
.product-cat { font-size: 14px; color: var(--ink-2); }
.product-name { font-family: var(--font-display); font-size: clamp(2.2rem, 4.4vw, 3.4rem); line-height: 1.02; letter-spacing: -0.015em; margin-top: 2px; }
.product-dims { font-size: 14px; color: var(--ink-2); margin-top: var(--s2); font-variant-numeric: tabular-nums; }
.product-dims a { color: var(--ink-2); }
.today-actions { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s3); }
.picks { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.pick {
  height: 44px; padding: 0 14px 0 5px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--white);
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: border-color .35s var(--ease), background .35s var(--ease), transform .5s var(--ease), box-shadow .35s;
  animation: rise-in .9s var(--ease) both;
}
.pick img, .pick .pick-ph { width: 34px; height: 34px; border-radius: 50%; object-fit: contain; background: var(--paper); }
.pick .pick-ph { display: grid; place-items: center; color: var(--ink-2); }
.pick:hover { border-color: var(--orange-strong); transform: translateY(-1px); }
.pick[aria-pressed="true"] { border: 2px solid var(--orange-strong); background: var(--orange-tint); padding-left: 4px; }
.pick .done { color: var(--orange-ink); display: inline-flex; }
.pick-more { border-style: dashed; padding: 0 14px; color: var(--ink-2); }
.pick-more:hover { color: var(--ink); }
.pick-more small { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.stage-status {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center;
  color: var(--ink-2); font-size: 15px; pointer-events: none; max-width: 340px;
  opacity: 0; transition: opacity .6s var(--ease);
}
.stage-status.is-on { opacity: 1; }
.stage-status.is-error { pointer-events: auto; color: var(--ink); }
.stage-status .pct { font-variant-numeric: tabular-nums; }
.loader { width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle, var(--orange) 0 22%, rgba(255, 107, 26, .22) 23% 48%, transparent 50%); animation: breathe 2.4s var(--ease-io) infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.8); opacity: .7; } 50% { transform: scale(1.1); opacity: 1; } }

/* ---------- Studio ---------- */
body.in-studio { --panel-space: calc(var(--panel-w) + 32px); }
body.in-studio.panel-closed { --panel-space: 0px; }
.studio-top {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 16px; right: 16px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3);
}
.studio-top > :last-child { justify-self: end; }
.studio-top > :first-child { justify-self: start; }
.studio-title { text-align: center; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.studio-title #studioName { font-family: var(--font-display); font-size: 28px; letter-spacing: -0.01em; }
.studio-sub { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.panel-toggle[aria-expanded="true"] { border-color: var(--orange-strong); background: var(--orange-tint); }

.panel {
  position: absolute; top: 76px; right: 16px; width: var(--panel-w);
  max-height: calc(100% - 76px - 96px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--white); border-radius: 22px; box-shadow: var(--shadow-2);
  padding: 4px 20px 12px;
  transition: transform .8s var(--ease), opacity .6s var(--ease);
}
body.panel-closed .panel { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.pgroup { padding: 14px 0 12px; border-bottom: 1px solid var(--line); }
.pgroup:last-child { border-bottom: 0; }
.pgroup-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: 4px; }
.pgroup-head h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; font-family: var(--font-ui); }
.field { padding: 4px 0; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.field-row label { color: var(--ink); }
.field-row output, output { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.field-hint { font-size: 13px; color: var(--ink-2); margin-top: 6px; line-height: 1.45; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 44px; font-size: 14px; }
[data-dim] { transition: opacity .5s var(--ease); }
.is-dim { opacity: .38; }
.globe-wrap { display: flex; gap: 14px; align-items: center; padding: 6px 0 4px; }
.globe { width: 120px; height: 120px; flex: none; cursor: grab; touch-action: none; border-radius: 50%; }
.globe:active { cursor: grabbing; }
.globe:focus-visible { outline-offset: 2px; border-radius: 50%; }
.globe-side { flex: 1; min-width: 0; }
.globe-hint { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; margin-bottom: 6px; }
/* labels placed at their true slider positions (thumb travel is inset by half the 22px thumb) */
.focal-presets { position: relative; height: 24px; margin-top: 0; }
.focal-presets button { position: absolute; top: 0; left: calc(11px + var(--at) * (100% - 22px)); transform: translateX(-50%); border: 0; background: none; font-size: 12px; color: var(--ink-2); padding: 3px 3px; border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums; transition: color .3s, background .3s; }
.focal-presets button:hover { color: var(--ink); background: var(--orange-tint); }
.focal-presets button[aria-pressed="true"] { color: var(--orange-ink); font-weight: 600; }

.session-bar {
  position: absolute; bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: var(--white); border-radius: var(--r-pill); box-shadow: var(--shadow-2);
  transition: left .8s var(--ease), opacity 1.2s var(--ease), transform .6s var(--ease);
}
.sb-idle, .sb-run { display: flex; align-items: center; gap: 6px; }
.sb-run { display: none; }
body.session-running .sb-idle { display: none; }
body.session-running .sb-run { display: flex; }
.duration { position: relative; }
.timer { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; min-width: 92px; text-align: center; padding: 0 6px 0 12px; }
.timer-line { width: 90px; height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.timer-line span { display: block; height: 100%; width: 0; background: var(--orange); border-radius: 3px; transition: width 1s linear; }
body.session-paused .timer { color: var(--ink-2); }
/* Capture: an orange shutter and up to three Instax Square prints (card 72×86, picture 62×62) */
body.in-studio { --capture-space: 330px; }
@media (max-width: 900px) {
  body.in-studio:not(.panel-closed) .capture { opacity: 0; pointer-events: none; }
}
@media (max-width: 1180px) {
  body.in-studio { --capture-space: 0px; }
  body.in-studio .capture { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (max-width: 720px) {
  body.in-studio .capture { left: 12px; gap: 22px; }
  body.in-studio .shutter { width: 50px; height: 50px; }
  body.in-studio .focal-whisper { left: 25px; bottom: 58px; }
  body.in-studio .polaroids li { --pw: 70px; --ph: 84px; }
  body.in-studio .polaroid { width: 70px; padding: 6px 6px 0; }
  body.in-studio .polaroid img { width: 58px; height: 58px; }
  body.in-studio .polaroid .cap { height: 20px; font-size: 13px; }
}
.capture {
  position: absolute; left: 20px; bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 28px;
}
.shutter {
  width: 58px; height: 58px; border-radius: 50%; flex: none; cursor: pointer; display: grid; place-items: center;
  background: var(--orange); color: var(--ink); border: 0;
  box-shadow: inset 0 0 0 3px var(--orange), inset 0 0 0 5px rgba(255, 255, 255, .85), 0 2px 4px rgba(194, 65, 12, .25), 0 10px 22px -10px rgba(255, 107, 26, .9);
  transition: transform .45s var(--ease), background .3s var(--ease), box-shadow .45s var(--ease);
}
.shutter svg.lucide { width: 22px; height: 22px; stroke-width: 1.9; }
.shutter:hover { background: var(--orange-hover); transform: translateY(-2px); }
.shutter:active { transform: scale(.92); }
.shutter:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 4px; border-radius: 50%; }
.polaroids { display: flex; align-items: flex-end; list-style: none; margin: 0; padding: 0; }
.polaroids li { position: relative; --pw: 84px; --ph: 100px; }
/* bin: appears at the top-right corner of the enlarged (selected) print */
.polaroid-bin {
  position: absolute; z-index: 1; width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  left: calc(var(--pw) * 1.1); top: calc(var(--ph) * -0.2); transform: translate(-60%, -40%) scale(.6);
  display: grid; place-items: center; background: var(--white); color: var(--ink-2);
  box-shadow: 0 1px 2px rgba(74, 38, 12, .16), 0 6px 14px -6px rgba(74, 38, 12, .4);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .3s var(--ease), transform .45s var(--ease), visibility 0s linear .3s, color .25s, background .25s;
}
.polaroid-bin svg.lucide { width: 15px; height: 15px; stroke-width: 1.75; }
.polaroid-bin:hover { color: var(--ink); background: var(--orange); }
.polaroid-bin:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 2px; }
/* only for a print you clicked to apply, never for a fresh capture */
.polaroids li.show-bin:has(.polaroid[aria-pressed="true"]) .polaroid-bin {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-60%, -40%) scale(1);
  transition: opacity .35s var(--ease) .45s, transform .5s var(--ease) .45s, visibility 0s, color .25s, background .25s;
}
.capture.is-replacing .polaroid-bin { display: none; }
.polaroids li.confirming .polaroid-bin { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; transition: opacity .15s, visibility 0s linear .15s !important; }
/* "Sure?": hangs from the bin's spot like a little tag on a pin, swings down into level */
.polaroid-sure {
  position: absolute; z-index: 2; left: calc(var(--pw) * 1.1); top: calc(var(--ph) * -0.2);
  height: 30px; padding: 0 14px; border: 0; border-radius: var(--r-pill); cursor: pointer; white-space: nowrap;
  background: var(--orange); color: var(--ink); font: 600 13px/1 var(--font-ui); letter-spacing: .01em;
  box-shadow: 0 1px 2px rgba(194, 65, 12, .25), 0 8px 18px -8px rgba(255, 107, 26, .8);
  transform-origin: 14px 50%; transform: translate(-14px, -50%);
  visibility: hidden; opacity: 0; pointer-events: none;
}
.polaroid-sure:hover { background: var(--orange-hover); }
.polaroid-sure:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 2px; }
.polaroids li.confirming .polaroid-sure { visibility: visible; opacity: 1; pointer-events: auto; animation: tag-swing .7s both; }
@keyframes tag-swing {
  0%   { transform: translate(-14px, -50%) rotate(-15deg); opacity: 0; animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  10%  { opacity: 1; }
  38%  { transform: translate(-14px, -50%) rotate(6.75deg); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  62%  { transform: translate(-14px, -50%) rotate(-2.6deg); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  82%  { transform: translate(-14px, -50%) rotate(0.9deg); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  100% { transform: translate(-14px, -50%) rotate(0deg); opacity: 1; }
}

.polaroids li + li { margin-left: -18px; } /* prints overlap a little, like a small stack on a desk */
.polaroid {
  width: 84px; padding: 7px 7px 0; display: flex; flex-direction: column; border: 0; border-radius: 2px; cursor: pointer;
  background: #FFFEFC; color: #B5A393;
  box-shadow: 0 1px 2px rgba(74, 38, 12, .14), 0 10px 20px -10px rgba(74, 38, 12, .45);
  transform-origin: 50% 100%;
  /* ease-in-out: grows and settles at the same pace the print slides */
  transition: transform .52s var(--ease-io), box-shadow .52s var(--ease-io);
}
.polaroid img { width: 70px; height: 70px; object-fit: cover; background: #EEE8E1; display: block; }
.polaroid .cap { height: 23px; display: grid; place-items: center; font: italic 14px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.polaroid:hover { transform: translateY(-6px); box-shadow: 0 2px 4px rgba(74, 38, 12, .12), 0 18px 30px -14px rgba(74, 38, 12, .5); }
.polaroid:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 4px; }
/* the view on stage right now: its print stands forward, larger */
.polaroid[aria-pressed="true"] { transform: scale(1.2); box-shadow: 0 2px 4px rgba(74, 38, 12, .12), 0 20px 32px -14px rgba(74, 38, 12, .5); }
.polaroid.is-new { animation: eject 1s var(--ease) backwards; }
@keyframes eject { from { opacity: 0; transform: translate(-46px, 26px) scale(.7); } }
.capture.is-replacing .polaroid { box-shadow: 0 0 0 2px var(--orange-strong), 0 10px 20px -10px rgba(74, 38, 12, .45); animation: bob-pick 1.6s ease-in-out infinite alternate; }
@keyframes bob-pick { from { transform: translateY(0); } to { transform: translateY(-5px); } }
.focal-whisper {
  /* sits right on top of the shutter (the row is taller than the shutter once prints are there) */
  position: absolute; left: 29px; bottom: 66px; transform: translate(-50%, 4px);
  font: italic 21px/1 var(--font-display); color: #B5A393; font-variant-numeric: tabular-nums; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .6s var(--ease-io), transform .6s var(--ease-io);
}
.focal-whisper.is-on { opacity: 1; transform: translate(-50%, 0); transition-duration: .25s; }
.capture.is-replacing .focal-whisper { display: none; }
.capture.is-replacing .shutter { background: var(--white); color: var(--orange-ink); }
.replace-hint {
  position: absolute; left: 0; bottom: calc(100% + 14px); display: flex; align-items: center; gap: 4px; white-space: nowrap;
  background: var(--white); border-radius: var(--r-pill); padding: 4px 4px 4px 16px; box-shadow: var(--shadow-2); font-size: 14px;
  animation: pop .5s var(--ease);
}
/* a soft bloom of warm light rather than a hard strobe */
.shutter-flash { position: absolute; inset: 0; background: #FFF9F2; opacity: 0; pointer-events: none; }
.shutter-flash.is-on { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: 0; } 14% { opacity: .42; } 100% { opacity: 0; } }

/* Finish sheet: which captured view was sketched */
.pick-view { margin-top: var(--s5); }
.pick-view-title { font-size: 14px; font-weight: 500; margin-bottom: var(--s3); }
.pick-view-row { display: flex; flex-wrap: wrap; gap: 30px; padding: 34px 14px 0; }
.pick-view-row label { position: relative; cursor: pointer; }
.pick-view-row input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pick-view-row .polaroid { width: 72px; padding: 6px 6px 0; cursor: pointer; }
.pick-view-row .polaroid img { width: 60px; height: 60px; }
.pick-view-row .polaroid .cap { height: 20px; font-size: 13px; }
.pick-view-row .pv { position: relative; display: block; }
/* the print and each sketch scale on their own about the print's bottom centre, so the sketches can follow in turn */
.pick-view-row .pv .polaroid { position: relative; z-index: 3; transform-origin: 50% 100%; transition: transform .52s var(--ease-io), box-shadow .52s var(--ease-io); }
.pick-view-row .polaroid:hover { transform: none; }
.pick-view-row input:checked + .pv .polaroid { transition-duration: .3s; transform: scale(1.2); box-shadow: 0 2px 4px rgba(74, 38, 12, .12), 0 20px 32px -14px rgba(74, 38, 12, .5); }
.pick-view-row input:focus-visible + .pv .polaroid { outline: 2px solid var(--orange-strong); outline-offset: 4px; }
/* linked sketches: cropped to the print's shape, tucked behind it and fanned a little to the right */
.pick-view-row label { margin-right: calc(var(--n, 0) * 13px); transition: margin .4s var(--ease-io); }
.pv-sketch {
  --off: translate(calc(var(--k) * 13px), calc(var(--k) * -3px));
  position: absolute; top: 0; left: 0; width: 72px; height: 86px; object-fit: cover; border-radius: 2px; background: var(--paper);
  box-shadow: 0 1px 2px rgba(74, 38, 12, .14), 0 8px 16px -8px rgba(74, 38, 12, .4);
  z-index: calc(3 - var(--k));
  transform-origin: 36px 86px; transform: scale(1) var(--off);
  /* shrinking back: each sketch starts when the one in front of it is halfway down */
  transition: transform .52s var(--ease-io) calc(var(--k) * .18s);
}
.pick-view-row input:checked + .pv .pv-sketch { transform: scale(1.2) var(--off); transition-delay: calc(var(--k) * .12s); transition-duration: .3s; }
/* the reveal: sketches slide out from behind the print, only when a print with sketches is chosen (or a sketch is added) */
.pv.reveal .pv-sketch, .pv-sketch.reveal { animation: tuck-in .5s var(--ease-io) calc((var(--k) - 1) * 70ms) backwards; }
@keyframes tuck-in { from { opacity: 0; transform: scale(1.2) translate(0, 0); } }
/* selected print: its sketches can be clicked to come forward */
.pick-view-row input:checked + .pv .pv-sketch { cursor: grab; touch-action: none; }
.pv.front-mode .pv-sketch { transition-delay: 0s !important; }
.pick-view-row input:checked + .pv .pv-sketch.is-front { --off: translate(0, 0); z-index: 5; cursor: grab; touch-action: none; }
/* dragging the front sketch onto another print moves its link there */
.pv-sketch.is-dragging { opacity: .25; }
.pv-sketch-ghost {
  position: fixed; top: 0; left: 0; z-index: 1000; pointer-events: none; object-fit: cover; border-radius: 2px; background: var(--paper);
  cursor: grabbing; box-shadow: 0 2px 4px rgba(74, 38, 12, .16), 0 24px 36px -14px rgba(74, 38, 12, .55);
}
.pick-view-row label.drop-target .polaroid { transform: scale(1.12); outline: 2px solid var(--orange-strong); outline-offset: 4px; }
.pick-view-row label.drop-full .polaroid { opacity: .5; }
.pv-bin {
  position: absolute; z-index: 6; left: 79px; top: -17px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; background: var(--white); color: var(--ink-2);
  box-shadow: 0 1px 2px rgba(74, 38, 12, .16), 0 6px 14px -6px rgba(74, 38, 12, .4);
  transform: translate(-50%, -50%) scale(.6); opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .2s var(--ease), transform .35s var(--ease), visibility 0s linear .2s, background .25s, color .25s;
}
.pv-bin svg.lucide { width: 15px; height: 15px; stroke-width: 1.75; }
.pv-bin:hover { background: var(--orange); color: var(--ink); }
.pv-bin:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 2px; }
/* while a sketch is forward, its print steps aside; it fades back when you click out */
.pick-view-row .pv .polaroid { transition: transform .52s var(--ease-io), box-shadow .52s var(--ease-io), opacity .3s var(--ease-io); }
.pv.has-front .polaroid { opacity: 0; }
.pv.has-front .pv-bin { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, -50%) scale(1); transition: opacity .3s var(--ease) .2s, transform .4s var(--ease) .2s, visibility 0s, background .25s, color .25s; }
.link-count {
  position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--orange); color: var(--ink); font: 600 12px/22px var(--font-ui); text-align: center; font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(194, 65, 12, .3);
}

/* faint serif numbers to step through views and sketches */
.num-tabs { display: flex; align-items: center; justify-content: center; gap: 4px; }
.num {
  border: 0; background: none; cursor: pointer; padding: 4px 9px; border-radius: 8px;
  font: 400 24px/1 var(--font-display); color: #CDBFB2; font-variant-numeric: tabular-nums;
  transition: color .3s var(--ease), background .3s var(--ease);
}
.num:hover { color: var(--ink-2); }
.num.is-on { color: var(--ink-2); }
.num:focus-visible { outline: 2px solid var(--orange-strong); outline-offset: 1px; }

/* Finish sheet: the selected view's print stacked on top of its sketch */
.link-stage { margin-top: var(--s4); }
.ls-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-top: var(--s3); }
/* finish popup: resume / keep sketching sits in the top-right corner */
#finishSheet .sheet-card { position: relative; }
.sheet-corner { position: absolute; top: var(--s5); right: var(--s5); }
#finishSheet #finishTitle { padding-right: 190px; }
.add-time { text-align: center; }
.add-time .sheet-actions { justify-content: center; }
.min-counter { display: flex; align-items: center; justify-content: center; gap: var(--s4); margin-top: var(--s5); }
.min-counter .icon-btn { border: 1px solid var(--line-2); width: 44px; height: 44px; }
.min-counter .icon-btn:hover:not(:disabled) { border-color: var(--orange-strong); background: var(--orange-tint); }
.min-counter .icon-btn:disabled { opacity: .35; cursor: not-allowed; }
#minOut { min-width: 140px; font: 400 2.4rem/1 var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.photo-drop.is-disabled { cursor: not-allowed; opacity: .5; filter: grayscale(1); border-style: solid; }
.photo-drop.is-disabled:hover { border-color: var(--line-2); background: var(--paper); }

body:not(.session-running) .sound { display: none; }
/* background sound: arrow beside the volume slider opens the picker */
.sound-menu { position: relative; }
.sound-menu-btn svg.lucide { transition: transform .35s var(--ease); }
.sound-menu-btn[aria-expanded="true"] svg.lucide { transform: rotate(180deg); }
.sound-pop { left: auto; right: -10px; width: 280px; padding: 12px; }
.sound-pop-title { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); margin: 2px 6px 8px; }
.sound-pop-title svg.lucide { width: 15px; height: 15px; }
.sound-pop .track-add + .sound-pop-title { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
/* master slider, or (via the arrow) a music slider and a background slider */
.sound-master, .sound-mix { display: flex; align-items: center; gap: 2px; }
.sound-mix { animation: mix-in .35s var(--ease); }
.sound-mix .range-mini { width: 72px; }
.sound-mix .chan-btn + .range-mini { margin-right: 6px; }
@keyframes mix-in { from { opacity: 0; transform: translateX(6px); } }
/* a channel switched off: its icon is struck through and its slider greys out */
.chan-btn { position: relative; }
.chan-btn::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 2px; border-radius: 2px;
  background: currentColor; box-shadow: 0 0 0 1.5px var(--white);
  transform: translate(-50%, -50%) rotate(-45deg) scaleX(0); transition: transform .3s var(--ease);
}
.chan-btn.is-off { color: var(--ink-2); }
.chan-btn.is-off::after { transform: translate(-50%, -50%) rotate(-45deg) scaleX(1); }
.range.is-off { opacity: .45; }
/* settings: one group per channel */
.sound-group { display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; padding-top: var(--s4); border-top: 1px dashed var(--line); }
.sound-group > .toggle-row, .sound-group > .track-list, .sound-group > .field { align-self: stretch; }
.sound-head { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; }
.sound-head svg.lucide { width: 18px; height: 18px; color: var(--orange-strong); }
.track-list { display: flex; flex-direction: column; gap: 2px; }
.track-list-wide { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.track { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; transition: background .25s var(--ease); }
.track-list-wide .track { border: 1px solid var(--line); background: var(--white); }
.track:hover { background: var(--orange-tint); }
.track input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.track-dot { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-2); transition: border .25s, background .25s, box-shadow .25s; }
.track input:checked ~ .track-dot { border-color: var(--orange-strong); background: var(--orange); box-shadow: inset 0 0 0 3px #fff; }
.track input:focus-visible ~ .track-dot { outline: 2px solid var(--orange-strong); outline-offset: 2px; }
.track-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.track-text b { font-weight: 500; font-size: 14.5px; }
.track-text small { font-size: 12.5px; color: var(--ink-2); }
.track.is-missing .track-text b { color: var(--ink-2); }
.track.is-missing .track-text small { color: var(--orange-ink); }
.setting-label { font-size: 14px; font-weight: 500; }
.track-wrap { position: relative; }
.track-del {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: none; color: var(--ink-2); cursor: pointer; transition: background .25s, color .25s;
}
.track-del svg.lucide { width: 15px; height: 15px; }
.track-del:hover { background: var(--orange-tint); color: var(--ink); }
.track.is-user { padding-right: 44px; }
.track-add { margin-top: 6px; --h: 34px; font-size: 14px; }
.track-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sound-pop .track-list { max-height: 300px; overflow-y: auto; }
.track-empty { font-size: 13px; color: var(--ink-2); padding: 6px 12px; line-height: 1.45; }
.track-empty code { font-size: 12px; background: var(--orange-tint); padding: 1px 5px; border-radius: 4px; }
.sound { display: flex; align-items: center; gap: 2px; padding: 0 10px 0 4px; border-left: 1px solid var(--line); margin-left: 4px; }
.popover {
  position: absolute; bottom: calc(100% + 14px); left: 0; width: 300px;
  background: var(--white); border-radius: var(--r-m); box-shadow: var(--shadow-2); padding: 14px 16px;
  animation: pop .5s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.popover .chip-row { margin-bottom: 10px; }
.studio-hint {
  position: absolute; bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  font-size: 13px; color: var(--ink-2); white-space: nowrap; transition: opacity 1.2s var(--ease), left .8s var(--ease);
}
.studio-hint.is-gone { opacity: 0; }
body.is-idle .fade-idle { opacity: 0 !important; pointer-events: none; transition-duration: 1.6s; }
body.is-idle .stage canvas { cursor: none; }

/* ---------- Pages ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: calc(var(--topbar-h) + 40px) var(--s6) var(--s8); }
.page-narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head h1 { font-family: var(--font-display); font-size: clamp(2.6rem, 5vw, 3.6rem); line-height: 1; letter-spacing: -0.015em; }
.page-sub { color: var(--ink-2); margin-top: var(--s2); font-variant-numeric: tabular-nums; }
.page-foot { margin-top: var(--s6); font-size: 14px; color: var(--ink-2); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s5); }

.coll-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; }
.tile {
  position: relative; width: 100%; aspect-ratio: 1 / 1.12; border-radius: var(--r-m); border: 1px solid var(--line);
  background: var(--white); padding: 10px 10px 12px; display: flex; flex-direction: column; align-items: stretch; text-align: left;
  cursor: pointer; transition: transform .6s var(--ease), box-shadow .6s var(--ease), border-color .4s var(--ease);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-1); border-color: var(--line-2); }
.tile-img { flex: 1; min-height: 0; position: relative; }
.tile-img img { position: absolute; inset: 4% 8%; width: 84%; height: 92%; object-fit: contain; transition: filter .6s var(--ease), transform .8s var(--ease); }
.tile.is-unknown .tile-img img {
  --c: #CDBCAE;
  filter: brightness(0) invert(1) drop-shadow(1px 0 0 var(--c)) drop-shadow(-1px 0 0 var(--c)) drop-shadow(0 1px 0 var(--c)) drop-shadow(0 -1px 0 var(--c));
}
.tile.is-unknown:hover .tile-img img { --c: var(--orange); }
.tile:hover .tile-img img { transform: scale(1.04); }
.tile-cap { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; margin-top: 6px; }
.tile-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.is-unknown .tile-name { color: var(--ink-2); font-weight: 400; }
.tile-no { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 12px; flex: none; }
.tile-badge { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; background: var(--orange); color: var(--ink); display: grid; place-items: center; }
.tile-badge svg.lucide { width: 13px; height: 13px; stroke-width: 2.5; }
.tile-detail { grid-column: 1 / -1; }

.empty { text-align: center; padding: var(--s9) var(--s5); display: flex; flex-direction: column; align-items: center; gap: var(--s4); color: var(--ink-2); }
.empty h2 { font-family: var(--font-display); font-size: 2rem; color: var(--ink); }

.month { margin-top: var(--s6); }
.month:first-child { margin-top: 0; }
.month h2 { font-family: var(--font-display); font-size: 1.75rem; margin-bottom: var(--s4); }
.sketch-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s4); }
.sk {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--white); padding: 0; overflow: hidden; text-align: left; cursor: pointer;
  transition: transform .6s var(--ease), box-shadow .6s var(--ease);
}
.sk:hover { transform: translateY(-3px); box-shadow: var(--shadow-1); }
.sk-media { display: block; position: relative; aspect-ratio: 4 / 3; background: var(--paper); }
.sk-media > img { width: 100%; height: 100%; object-fit: cover; }
.sk-media.no-photo > img { object-fit: contain; padding: 12%; }
.sk-chip { position: absolute; left: 10px; bottom: 10px; width: 44px; height: 44px; border-radius: 50%; background: var(--orange-tint); border: 1.5px solid var(--orange); display: grid; place-items: center; }
.sk-chip img { width: 80%; height: 80%; object-fit: contain; }
.sk-tag { position: absolute; right: 10px; top: 10px; font-size: 12px; background: rgba(255, 255, 255, .92); padding: 2px 8px; border-radius: var(--r-pill); color: var(--ink-2); }
.sk-cap { display: block; padding: 14px 16px 16px; }
.sk-cap > span { display: block; margin-top: 2px; }
.sk-cap b { font-weight: 500; display: block; }
.sk-cap span { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.setting { padding: var(--s5) 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s3); }
.setting h2 { font-size: 17px; font-weight: 600; font-family: var(--font-ui); }
.setting .field label { display: block; font-size: 14px; margin-bottom: 6px; }

/* ---------- Welcome & onboarding ---------- */
.welcome, .onboard {
  position: fixed; inset: 0; z-index: 60; background: var(--paper);
  display: grid; place-items: center; overflow: hidden;
  transition: opacity 1.1s var(--ease), visibility 0s linear 1.1s;
}
.welcome.is-leaving, .onboard.is-leaving { opacity: 0; visibility: hidden; }
.welcome-inner { position: relative; text-align: center; padding: 0 var(--s5); }
.welcome-date {
  font-family: var(--font-display); font-size: clamp(4.25rem, 14vw, 10rem); line-height: 1; letter-spacing: -0.02em;
  opacity: 0; filter: blur(14px); transform: translateY(18px);
  animation: dawn 2s var(--ease) .25s forwards;
  transform-origin: center;
}
.welcome-greeting { font-size: clamp(1.05rem, 2vw, 1.35rem); margin-top: var(--s4); opacity: 0; animation: dawn-soft 1.6s var(--ease) 1.25s forwards; }
.welcome-skip { position: absolute; bottom: calc(32px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 13px; color: var(--ink-2); opacity: 0; animation: dawn-soft 1.4s var(--ease) 2.6s forwards; }
@keyframes dawn { to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes dawn-soft { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.welcome.is-leaving .welcome-greeting, .welcome.is-leaving .welcome-skip { opacity: 0 !important; transition: opacity .5s; animation: none; }

/* Komorebi: sunlight on a wall, with the soft shadow of leaves moving across it */
.komorebi {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  animation: dawn-soft 2.6s var(--ease) .1s forwards;
  background:
    radial-gradient(95% 75% at 86% 2%, rgba(255, 216, 172, .50), rgba(255, 228, 198, .22) 46%, rgba(255, 238, 220, 0) 76%),
    radial-gradient(60% 50% at 6% 96%, rgba(255, 226, 196, .28), rgba(255, 226, 196, 0) 70%);
}
.komorebi canvas { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: multiply; }
.komorebi .k-far { filter: blur(2.8px); opacity: .15; }
.komorebi .k-near { filter: blur(11px); opacity: .09; }

.onboard-card { position: relative; width: min(560px, calc(100% - 48px)); display: flex; flex-direction: column; gap: var(--s4); animation: dawn-soft 1.4s var(--ease) .2s both; }
.onboard-card h1 { font-family: var(--font-display); font-size: clamp(2.8rem, 7vw, 4.4rem); line-height: 1; letter-spacing: -0.02em; }
.onboard-card > p { color: var(--ink-2); font-size: 18px; margin-bottom: var(--s4); }
.onboard-card label { font-weight: 500; }
.onboard-card .inline { margin-top: var(--s3); }

/* ---------- Sheets ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--s4);
  background: rgba(42, 29, 20, .26);
  animation: fade .6s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet.is-leaving { opacity: 0; transition: opacity .45s var(--ease); }
.sheet-card {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--white); border-radius: var(--r-l); box-shadow: var(--shadow-2); padding: var(--s6);
  animation: rise .8s var(--ease);
}
.sheet-small { width: min(420px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.985); } to { opacity: 1; transform: none; } }
.sheet-card h2 { font-family: var(--font-display); font-size: 2.6rem; line-height: 1; letter-spacing: -0.015em; }
.sheet-sub { color: var(--ink-2); margin-top: var(--s2); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); align-items: center; }
.photo-drop {
  margin-top: var(--s5); display: grid; place-items: center; min-height: 200px; border-radius: var(--r-m);
  border: 1.5px dashed var(--line-2); background: var(--paper); cursor: pointer; overflow: hidden;
  transition: border-color .4s var(--ease), background .4s var(--ease);
}
.photo-drop:hover, .photo-drop.is-over { border-color: var(--orange-strong); background: var(--orange-tint); }
.photo-drop img { width: 100%; max-height: 340px; object-fit: contain; background: var(--paper); }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: var(--s5); }
.photo-empty svg.lucide { width: 28px; height: 28px; color: var(--orange-ink); }
.photo-empty span { font-weight: 500; }
.photo-empty small { color: var(--ink-2); font-size: 13px; }

.sheet-full { padding: 0; background: var(--paper); place-items: stretch; }
.compare { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
.compare-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s4); padding: calc(16px + env(safe-area-inset-top)) var(--s5) var(--s3); }
.compare-head > :first-child { justify-self: start; }
.compare-head > :last-child { justify-self: end; }
.compare-titles { text-align: center; }
.compare-titles h2 { font-family: var(--font-display); font-size: 2rem; line-height: 1.05; }
.compare-titles p { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.compare-body { min-height: 0; padding: var(--s3) var(--s5); display: grid; gap: var(--s4); }
.compare-body.side { grid-template-columns: 1fr 1fr; }
/* each pane keeps a band at the top for the number tabs, so the image sits lower */
.pane { position: relative; min-height: 0; margin: 0; background: var(--white); border-radius: var(--r-m); border: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.pane-nums { flex: none; height: 52px; display: flex; align-items: center; justify-content: center; }
.pane-nums.is-split { justify-content: space-between; padding: 0 var(--s4); }
.pane-img { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; margin: 0 12px 12px; }
.pane-img > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pane-img > .overlay-stack { position: absolute; inset: 0; }
.pane figcaption { position: absolute; left: 12px; bottom: 12px; font-size: 12.5px; background: rgba(255, 255, 255, .92); padding: 3px 10px; border-radius: var(--r-pill); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pane-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s3); color: var(--ink-2); text-align: center; padding: var(--s5); }
.overlay-stack { position: relative; width: 100%; height: 100%; }
.overlay-stack img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.overlay-stack .top { opacity: var(--amt, .5); mix-blend-mode: multiply; transform-origin: center; user-select: none; }
.compare-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; padding: var(--s3) var(--s5) calc(var(--s4) + env(safe-area-inset-bottom)); }
.overlay-ctl { display: flex; align-items: center; gap: var(--s3); font-size: 14px; }
.overlay-ctl .range { width: 220px; }

/* Add-your-own-model dialog */
.import-card { width: min(940px, 100%); padding: 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); overflow-y: auto; }
.imp-stage {
  position: relative; aspect-ratio: 1; min-height: 340px;
  background: radial-gradient(110% 80% at 50% 42%, #FFFFFF 0%, var(--stage-mid) 55%, var(--stage-edge) 100%);
}
.imp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
.imp-canvas:active { cursor: grabbing; }
.imp-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); color: var(--ink-2); font-size: 14px; padding: var(--s5); text-align: center; }
.imp-reset { position: absolute; top: 14px; left: 14px; --h: 36px; padding: 0 14px; font-size: 14px; }
.imp-hint { position: absolute; left: var(--s5); right: var(--s5); bottom: 16px; font-size: 13px; color: var(--ink-2); text-align: center; pointer-events: none; }
.imp-form { padding: var(--s6); display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.imp-form .field label, .imp-cats legend { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.imp-cats { border: 0; padding: 0; margin: 0; min-width: 0; }
.legend-note { font-weight: 400; color: var(--ink-2); margin-left: 4px; }
.imp-new { margin-top: var(--s3); }
.imp-form .sheet-actions { margin-top: auto; padding-top: var(--s2); }
.chip-radio { position: relative; display: inline-flex; }
.chip-radio input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip-radio span {
  display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); background: var(--white); font-size: 14px; font-weight: 500;
  transition: border-color .3s var(--ease), background .3s var(--ease), color .3s;
}
.chip-radio:hover span { border-color: var(--orange-strong); }
.chip-radio input:checked + span { background: var(--orange-tint); border-color: var(--orange-strong); color: var(--orange-ink); }
.chip-radio input:focus-visible + span { outline: 2px solid var(--orange-strong); outline-offset: 2px; }
.chip-new { display: inline-flex; align-items: center; gap: 4px; border-style: dashed; color: var(--ink-2); }
.chip-new svg.lucide { width: 15px; height: 15px; }
.chip-new[aria-expanded="true"] { border-color: var(--orange-strong); color: var(--ink); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.input[aria-invalid="true"] { border-color: var(--danger); }

.detail-img { display: block; width: 180px; height: 180px; object-fit: contain; margin: 0 auto var(--s4); }
.detail-img.is-outline img { width: 100%; height: 100%; object-fit: contain;
  --c: #CDBCAE;
  filter: brightness(0) invert(1) drop-shadow(1px 0 0 var(--c)) drop-shadow(-1px 0 0 var(--c)) drop-shadow(0 1px 0 var(--c)) drop-shadow(0 -1px 0 var(--c)); }
.tile.is-new { animation: tile-new 2.6s var(--ease) .3s both; }
@keyframes tile-new {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 26, 0); border-color: var(--line); }
  25% { box-shadow: 0 0 0 4px rgba(255, 107, 26, .28), var(--shadow-1); border-color: var(--orange-strong); transform: translateY(-3px); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 26, 0); border-color: var(--line); transform: none; }
}

.dropzone { position: fixed; inset: 12px; z-index: 70; border: 2px dashed var(--orange-strong); border-radius: var(--r-l); background: rgba(255, 241, 231, .9); display: grid; place-items: center; font-family: var(--font-display); font-size: 2rem; pointer-events: none; animation: fade .3s; }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--r-pill); font-size: 14px; box-shadow: var(--shadow-2);
  transition: opacity .5s var(--ease), transform .7s var(--ease); max-width: calc(100% - 32px); text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Boot ---------- */
body.is-booting .view, body.is-booting .topbar { opacity: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root { --panel-w: 100%; }
  body.in-studio { --panel-space: 0px; }
  .panel {
    top: auto; right: 0; left: 0; bottom: 0; width: auto; border-radius: 22px 22px 0 0;
    max-height: 52vh; padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  body.panel-closed .panel { transform: translateY(105%); }
  .session-bar { z-index: 2; }
  .studio-hint { display: none; }
  .panel-toggle span { display: none; }
  .panel-toggle { width: 40px; padding: 0; }
}
@media (min-width: 600px) and (max-width: 900px) {
  .panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; max-height: 46vh; }
  .pgroup:nth-child(2) { grid-row: span 2; border-bottom: 0; }
  .pgroup:nth-child(1) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .sheet-corner { position: static; display: flex; justify-content: flex-end; margin-bottom: var(--s3); }
  #finishSheet #finishTitle { padding-right: 0; }
  .clock-tone { right: 17px; }
  .topbar { padding: 0 var(--s4); }
  .brand span { display: none; }
  .nav a { padding: 0 11px; font-size: 14px; }
  .week { top: calc(var(--topbar-h) + 102px); gap: 6px; }
  .day { width: 42px; height: 42px; }
  .day.is-today { width: 46px; height: 46px; }
  .today-foot { flex-direction: column; align-items: stretch; gap: var(--s4); padding: var(--s4) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); }
  .product-meta { text-align: center; }
  .today-actions { align-items: stretch; }
  .picks { justify-content: center; }
  .today-actions .btn-lg { width: 100%; }
  .page { padding: calc(var(--topbar-h) + 24px) var(--s4) var(--s7); }
  .coll-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
  .sheet-card.import-card { grid-template-columns: 1fr; padding: 0; }
  .imp-stage { aspect-ratio: auto; min-height: 0; height: min(72vw, 320px); }
  .imp-form { padding: var(--s5); }
  .compare-head { grid-template-columns: 1fr auto; }
  .compare-titles { grid-column: 1 / -1; grid-row: 2; }
  .compare-body.side { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .studio-title #studioName { font-size: 22px; }
  .sheet-card { padding: var(--s5); }
  .session-bar { max-width: calc(100% - 16px); }
  .timer-line, .range-mini { display: none; }
  .timer { min-width: 76px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; }
  .view { transform: none !important; }
  .welcome-date { filter: none; transform: none; }
  .day.is-today::after { display: none; }
  .clock .colon { animation: none !important; opacity: 1; }
  .polaroids li.confirming .polaroid-sure { animation: none; transform: translate(-14px, -50%); }
}

/* shown only if start-up stalls (another tab holding the database, stale cached files) */
.boot-problem { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; gap: var(--s3); padding: var(--s5); background: var(--paper); text-align: center; }
.boot-problem h1 { font-family: var(--font-display); font-size: 2.6rem; }
.boot-problem p { color: var(--ink-2); max-width: 46ch; margin: 0 auto; }
.boot-problem kbd { font: 500 13px var(--font-ui); padding: 2px 7px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; background: var(--white); color: var(--ink); }
