/* base.css - the structural skeleton. Consumes tokens only, no colours of its
   own; the palette comes from skin-*.css. */

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------- scrollbars

   Site-wide rather than per pane, because every scroller on the site has the
   same problem - the assistant's chat list and its conversation column are just
   the two where it shows most.

   Two blocks, and they must stay separate. As of Chromium 121, declaring
   `scrollbar-color` or `scrollbar-width` makes the engine ignore
   `::-webkit-scrollbar` altogether, so writing both unconditionally would
   silently discard everything below. The standard properties are therefore
   fenced behind a supports query and reach only Firefox, which has no webkit
   pseudos to style. */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
  }
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner { background: transparent; }

/* No stepper arrows. They are the part that dates the widget, and on a phone
   they are untouchable anyway. */
::-webkit-scrollbar-button { display: none; }

/* The transparent border is clipped out of the background, so the thumb draws
   as a slim pill inset in the track instead of a bar filling it edge to edge. */
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hi); background-clip: content-box; }

/* The background layer (aurora / grid / flat) is defined by each skin */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
}

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

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
  min-height: 56px;
}

.topbar.back-only { min-height: 48px; }

/* The mark. It is a dot matrix - 47x40 squares - so below roughly 36px the dots
   stop resolving and it turns into a grey smudge. That is why it is a flat 40px
   rather than something that scales with the bar, and why it is not used
   anywhere smaller than the top bar. */
.topbar-logo {
  flex: none;
  display: block;
  height: 40px;
  width: auto;
}

/* On the home page it is the one piece of artwork, so it gets room to read. */
.home-hero .hero-logo {
  display: block;
  height: 88px;
  width: auto;
  margin: 0 auto 18px;
}

.back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-1);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}
.back:hover { background: var(--surface-hi); color: var(--fg-0); border-color: var(--line-hi); }
.back svg { width: 14px; height: 14px; }

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title p {
  margin: 2px 0 0;
  /* the body face, not the heading's: this line is a sentence, and Backsteal
     has no true lowercase to set a sentence in */
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--fg-2);
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- main */

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- Cover Flow */

.cf {
  flex: 1;
  min-height: 0;
  position: relative;
  perspective: var(--cf-persp, 1200px);
  perspective-origin: 50% 45%;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  /* The side cards sit well outside this box. Absolutely positioned elements
     count towards the page's scrollable width even at opacity 0, so without
     clipping the document grew a horizontal scrollbar (a 20-card page reached
     ~1350px on a 390px screen). coverflow.js also keeps only the nearby cards
     in the DOM, which bounds it further, but the outermost of those still
     reaches past the viewport - so the clip is what actually stops it.

     `clip` rather than `hidden`: hidden would make this a scroll container,
     which it has no reason to be. The `hidden` line above is the fallback for
     browsers without `clip`; the second declaration wins where it is supported. */
  overflow: hidden;
  overflow: clip;
}
.cf.dragging { cursor: grabbing; }

.cf-stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.cf-item {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--cf-w, 210px);
  height: var(--cf-h, 260px);
  margin-left: calc(var(--cf-w, 210px) / -2);
  margin-top: calc(var(--cf-h, 260px) / -2 - 14px);
  transform-style: preserve-3d;
  /* transform only - NOT opacity. will-change makes an element a backdrop root
     when it names a property that would create one, and opacity is on that list,
     so listing it here silently stopped every .cf-card backdrop-filter in the
     cover flow from sampling anything. Proven by measurement, see skin-glass.css */
  will-change: transform;
  backface-visibility: hidden;
  /* page-model.js fits these to the room .cf has left, which changes as the
     Round 4 drawer opens and closes. */
  transition: width .34s var(--ease), height .34s var(--ease),
              margin .34s var(--ease);
}

.cf-item.ease {
  transition: transform .46s var(--ease), opacity .46s var(--ease),
              width .34s var(--ease), height .34s var(--ease),
              margin .34s var(--ease);
}

.cf-card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}

.cf-item.center .cf-card {
  border-color: var(--card-line-c);
  box-shadow: var(--card-shadow-c);
}

.cf-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.cf-card img.ready { opacity: 1; }

.cf-skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-3);
  font-size: 11px;
  letter-spacing: .1em;
}
.cf-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--sheen) 50%, transparent 80%);
  animation: sheen 1.5s linear infinite;
}
@keyframes sheen {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

.cf-label {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--fg-1);
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity .35s var(--ease);
}
.cf-item.center .cf-label { opacity: 1; }

.cf-index {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 32px;
  text-align: center;
  font-size: 10.5px;
  color: var(--fg-3);
  letter-spacing: .14em;
  font-variant-numeric: tabular-nums;
}

/* swipe hint arrow */
.cf-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  color: var(--fg-3);
  opacity: .5;
  pointer-events: none;
}
.cf-hint.l { left: 8px; }
.cf-hint.r { right: 8px; }

/* current index xx / nn */
.cf-counter {
  flex: none;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: .2em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  padding: 10px 0 12px;
}

/* ---------------------------------------------------------------- bottom nav */

.bottombar {
  flex: none;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bar-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.tab {
  /* Size to the label rather than to an equal share: "khora3 Canopy" is twice
     the length of the others and would otherwise wrap onto two lines, which
     leaves that one tab's text sitting higher than its neighbours. */
  flex: 1 1 auto;
  min-width: 0;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 5px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 10px;
  letter-spacing: .04em;
  text-decoration: none;
  cursor: pointer;
  transition: color .22s var(--ease), background .22s var(--ease);
}
.tab-name { white-space: nowrap; }
.tab:hover { color: var(--fg-0); background: var(--surface); }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { background: var(--accent); color: var(--bg-0); }

.tab-ico {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  transition: background .22s var(--ease), color .22s var(--ease), border-color .22s var(--ease);
}
.tab.active .tab-ico { border-color: transparent; }
.tab-ico svg { width: 13px; height: 13px; }

.tab-num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- parent page */

.home {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 18px 28px;
  /* a column, so the tiles can be pushed to the bottom of it - see .tiles */
  display: flex;
  flex-direction: column;
}
.home-hero { flex: none; }

.home-hero {
  padding: 14px 2px 22px;
  /* The whole block sits on the centre line, over the mark in .bg-layer */
  text-align: center;
}

.home-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 7vw, 34px);
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: .01em;
}

.home-hero h1 .accent { color: var(--accent); }

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  flex: none;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 132px;
  padding: 15px 15px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--card-line);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: transform .32s var(--ease), border-color .32s var(--ease), box-shadow .32s var(--ease);
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-3px);
  border-color: var(--card-line-c);
  box-shadow: var(--card-shadow-c);
  outline: none;
}
.tile:active { transform: translateY(-1px) scale(.99); }

.tile-num {
  font-size: 10.5px;
  letter-spacing: .18em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.tile-body { margin-top: auto; }

.tile-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 5px;
  letter-spacing: .01em;
}

.tile-sub {
  margin: 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--fg-2);
}

.tile-count {
  display: inline-block;
  margin-top: 9px;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.tile-mark {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
}
.tile-mark svg { width: 15px; height: 15px; }

.tile.wide { grid-column: 1 / -1; min-height: 112px; }

/* ---------------------------------------------------------------- home entry to the assistant */

/* Sits centred between the hero title and the tiles. */
/* Sits between the hero title and the tiles - the way in to the assistant. */
.ai-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  /* it is a flex item of .home now, not of the centred hero, so it has to be
     centred itself - a flex item stretches across the cross axis by default */
  align-self: center;
  /* no top margin: the hero's own bottom padding is the gap on a phone. A wide
     screen drops both and lets space-between place it. */
  margin: 0 0 6px;
  padding: 15px 28px;
  border-radius: 999px;
  border: 1px solid var(--card-line);
  background: var(--glass-surface), var(--card-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)) brightness(var(--glass-bright));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)) brightness(var(--glass-bright));
  box-shadow: var(--card-shadow);
  color: var(--fg-0);
  font: inherit;
  font-size: 15px;
  letter-spacing: .02em;
  text-decoration: none;
  cursor: pointer;
  transition: transform .26s var(--ease), box-shadow .26s var(--ease);
}
.ai-cta:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-c); }
.ai-cta svg { width: 19px; height: 19px; flex: none; opacity: .9; }
.ai-cta .ai-cta-go { color: var(--accent); font-size: 17px; line-height: 1; }

/* ---------------------------------------------------------------- intro bumper */

/* Full-screen on arrival. `contain`, not `cover`: the clip is 16:9 and its
   content stays centred and never spans more than about 60% of the frame, so on
   a portrait phone `cover` would show the middle 26% and cut the span in half.
   The clip's own background is pure black, so this background is pure black too
   - matching it exactly is what makes the letterboxing disappear; the page's
   #08080a would show as two visible bands above and below. */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  transition: opacity .5s var(--ease);
}
.intro[hidden] { display: none; }
.intro.leaving { opacity: 0; pointer-events: none; }

.intro video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.intro-skip {
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-1);
  font: inherit;
  font-size: 10.5px;
  letter-spacing: .18em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.intro-skip:hover { border-color: var(--line-hi); color: var(--fg-0); }

/* the page must not scroll away underneath the bumper */
body.intro-lock .home { overflow: hidden; }

/* On a phone the content already fills the screen, so there is no empty band to
   centre the button in - the only way to satisfy "halfway between the title and
   the tiles" is to make the two gaps equal. The title does not move; the cards
   below do, by the difference, and the page scrolls either way. */
@media (max-width: 719px) {
  .home-hero { padding-bottom: 30px; }
  .home .ai-cta { margin-bottom: 30px; }
}

/* On a model page the button sits at the foot of the stage, under the cards and
   above the counter. It is not in .home, so none of the centring rules apply. */
.ai-cta-stage {
  flex: none;
  margin: 8px 0 12px;
}

/* ---------------------------------------------------------------- video page */

/* A vertical list, so the page scrolls rather than centring one clip. */
.video-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 28px;
  gap: 16px;
}

.video-meta {
  padding: 0 4px;
}
.video-meta p {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--fg-2);
}

.clips { display: grid; gap: 24px; }

.clip-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.clip-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}
.clip-len {
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.clip-sub {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--fg-2);
}

/* preload="none" plus a poster frame: the page costs four small JPEGs until a
   visitor actually taps one, which matters when the four clips are 49 MB. */
.clip video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: #000;
  border: 1px solid var(--card-line);
  box-shadow: var(--card-shadow-c);
}

/* ---------------------------------------------------------------- detail panel (Round 4) */

/* A drawer, shut by default so the cover flow gets the whole screen. Tapping the
   grip opens it; tapping again shuts it.

   Only the body caps its own height, and .cf is `flex: 1` above it, so the cover
   flow absorbs the difference rather than being covered - the cards stay centred
   in whatever room is left, which is what moves them up the page as it opens.

   The safe-area inset moves from the grip to the body on opening, so it is paid
   once either way round. */

.panel {
  --panel-safe: env(safe-area-inset-bottom);
  flex: none;
  position: relative;
  border-top: 1px solid var(--line);
  background: var(--bar-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.panel-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 9px 16px calc(9px + var(--panel-safe));
  border: 0;
  background: none;
  color: var(--fg-2);
  font: inherit;
  font-size: 10.5px;
  letter-spacing: .18em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: padding-bottom .36s var(--ease), color .25s var(--ease);
}
.panel.open .panel-grip { padding-bottom: 9px; }
.panel-grip:hover { color: var(--fg-0); }
.panel-grip:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The pill that says there is something under here. */
.panel-grip .grip-bar {
  width: 34px;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  transition: background .3s var(--ease);
}
.panel-grip:hover .grip-bar,
.panel-grip[aria-expanded="true"] .grip-bar { background: var(--accent); }

.panel-grip .grip-chev {
  width: 11px;
  height: 11px;
  transition: transform .34s var(--ease);
}
.panel-grip[aria-expanded="true"] .grip-chev { transform: rotate(180deg); }

.panel-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 16px;
  transition: max-height .36s var(--ease), opacity .26s var(--ease),
              padding .36s var(--ease);
}
.panel.open .panel-body {
  /* 38vh left too little for the way in to the assistant that now sits at the
     foot of the stage; at 32vh the cards keep their full size with the drawer
     open. Checked at 390x844. */
  max-height: 32vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 1;
  padding: 4px 16px calc(16px + var(--panel-safe));
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 11px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.panel-head .pid {
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.panel-pass {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: .1em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-2);
}
.panel-pass.ok { color: var(--accent); border-color: var(--accent); }

.panel-prompt {
  margin: 0 0 13px;
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--fg-2);
  padding-left: 10px;
  border-left: 2px solid var(--accent);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 8px;
  margin-bottom: 13px;
}

.metric {
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.metric .k {
  font-family: var(--font-body);
  font-size: 9.5px;
  letter-spacing: .1em;
  color: var(--fg-3);
}

.metric .v {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  color: var(--fg-0);
}
.metric .v.hi { color: var(--accent); }

.bars { display: grid; gap: 9px; }

.bar-row {
  display: grid;
  grid-template-columns: 52px 1fr 42px;
  align-items: center;
  gap: 9px;
  font-size: 10.5px;
  color: var(--fg-2);
}
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--fg-1); }

.bar-track {
  height: 5px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  width: 0;
  transition: width .7s var(--ease);
}

/* ---------------------------------------------------------------- 3D viewer overlay */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  /* Width of the neighbour strips, shared with .viewer-side below. */
  --side-w: clamp(58px, min(21vw, 27vh), 190px);
  --side-pad: clamp(4px, 1.4vw, 12px);
  /* Flat, not a gradient: letting the sides go clear showed the blurred
     carousel through as a bright smudge behind the model. The strips no longer
     cut the model off either way, because the canvas now spans the full width
     and they float over it. */
  background: var(--viewer-bg);
  backdrop-filter: blur(26px) saturate(1.3);
  -webkit-backdrop-filter: blur(26px) saturate(1.3);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.viewer.open { opacity: 1; pointer-events: auto; }

/* The canvas spans the whole box and the neighbour cards float over its edges,
   rather than the three sitting side by side. In a row layout the canvas ends
   where the strips begin, so a wide model was sliced off by a straight vertical
   edge on each side as it turned. */
.viewer-body {
  flex: 1;
  min-height: 0;
  position: relative;
  /* gives the neighbour previews the same receding feel as the cover flow sides */
  perspective: 900px;
}

.viewer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  transition: opacity .24s var(--ease);
}

/* Held while the next model is being fetched and built, so stepping looks like
   a dissolve rather than the previous model snapping into the new one. */
.viewer.switching canvas { opacity: .18; }

/* Neighbour previews. Shows the model one step left / right so it is obvious
   what tapping a side will bring up. Hidden at the ends of the set.

   The width follows the window rather than being a fixed strip: a share of the
   width, but capped by the height as well, so a short wide window does not hand
   the sides more room than the model in the middle can spare. A tall narrow
   phone gets proportionally narrower strips. */
.viewer-side {
  position: absolute;
  top: 50%;
  z-index: 2;                 /* over the canvas, so a tap still steps the model */
  /* A tall panel rather than a card cut to the thumbnail's own shape: it reads
     at a glance, and its height lines up with the model in the middle. Width
     comes from the strip, height from the body, and the thumbnail is centred
     inside without ever being stretched. */
  width: calc(var(--side-w) - 2 * var(--side-pad));
  height: 46%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--side-pad);
  /* Same language as the home page cards: a faint glass fill under a hairline. */
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  border-radius: clamp(6px, 1.8vw, 14px);
  cursor: pointer;
  transition: transform .34s var(--ease);
}
/* Leaning back on the inner edge, the way the cover flow's side cards do, so
   the viewer reads as the middle card opened up rather than a separate screen.
   The lean is on the panel, not the thumbnail, or the picture would sit crooked
   inside a straight frame. */
.viewer-side.prev {
  left: var(--side-pad);
  transform-origin: right center;
  transform: translateY(-50%) rotateY(38deg) scale(.94);
}
.viewer-side.next {
  right: var(--side-pad);
  transform-origin: left center;
  transform: translateY(-50%) rotateY(-38deg) scale(.94);
}
.viewer-side:hover,
.viewer-side:focus-visible {
  outline: none;
  transform: translateY(-50%) rotateY(0deg) scale(1.02);
}
.viewer-side[hidden] { display: none; }

.viewer-side img {
  display: block;
  /* sized by whichever limit bites first, so the thumbnail keeps its proportions */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  animation: side-in .32s var(--ease) both;
}

@keyframes side-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.viewer-side-wait {
  color: var(--fg-3);
  font-size: 16px;
  letter-spacing: .1em;
}

.viewer-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  padding-top: calc(13px + env(safe-area-inset-top));
}

.viewer-bar .vt {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iconbtn {
  flex: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-1);
  cursor: pointer;
  transition: background .22s var(--ease), color .22s var(--ease);
}
.iconbtn:hover { background: var(--surface-hi); color: var(--fg-0); }
.iconbtn svg { width: 15px; height: 15px; }
.iconbtn.on { color: var(--accent); border-color: var(--accent); }

.viewer-foot {
  flex: none;
  padding: 9px 16px calc(11px + env(safe-area-inset-bottom));
  font-size: 10.5px;
  color: var(--fg-3);
  letter-spacing: .05em;
  text-align: center;
}

/* ---------------------------------------------------------------- states */

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--fg-2);
  font-size: 11.5px;
  letter-spacing: .12em;
  transition: opacity .4s var(--ease);
}
.loading.done { opacity: 0; pointer-events: none; }

.loading .ring {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--track);
  border-top-color: var(--accent);
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-3);
  font-size: 12px;
}

/* ---------------------------------------------------------------- responsive */

@media (min-width: 720px) {
  /* One row of five. The tiles are the five stages, and reading them in a single
     left-to-right sweep is the point - a 4+1 wrap puts the fifth on its own line
     and breaks that. Phones stay at two columns: five across 390px would be 70px
     each, which is narrower than the titles. */
  /* hero at the top, the way in to the assistant in the middle, the five stages
     along the bottom. Auto margins would beat justify-content, so the tiles must
     not keep theirs here. */
  .home { justify-content: space-between; }
  /* space-between already makes the gap, and it works from the hero's border
     box - so the hero's own bottom padding would push the button 22px below the
     true centre of the title-to-tiles space. */
  .home-hero { padding-bottom: 0; }
  .home .ai-cta { margin: 0; }
  .tiles { grid-template-columns: repeat(5, 1fr); gap: 10px; }
  .tile.wide { grid-column: auto; }

  /* Tighter, so five fit the width without the descriptions running away */
  .tile { min-height: 118px; padding: 12px 12px 11px; }
  .tile-title { font-size: 13.5px; margin-bottom: 4px; }
  .tile-sub {
    font-size: 10.5px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tile-count { margin-top: 7px; }
  .tile-mark { top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 9px; }

  .cf-item { --cf-w: 250px; --cf-h: 310px; }
}
