/* =========================================================================
   SWARMIO SEASON 2 — shared chrome

   The walnut rail (desktop) and the walnut-framed masthead + tab bar (phone),
   used by EVERY page: the app shell, the code workspace, Mission Control, the
   admin console and the cloud's public pages. The app builds its masthead in
   app.js; every other page mounts the same markup through /rail.js. Load after
   /tokens.css (and after any page sheet, so this wins).

   Wood is only ever a frame. Text never sits on the grain.
   ========================================================================= */

.masthead button,
.tabbar button,
.masthead a,
.tabbar a {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}
.masthead .hidden,
.tabbar .hidden {
  display: none !important;
}
.masthead__icon {
  display: none;
  line-height: 0;
  flex: none;
}
.masthead__icon svg,
.tabbar__icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar {
  display: none;
}
:root {
  --rail-w: 264px;      /* walnut strip */
  --rail-plate-w: 238px;
}
html[data-rail="collapsed"] {
  --rail-w: 84px;
  --rail-plate-w: 58px;
}

/* ------------------------------------------------------------ desktop rail */
@media (min-width: 48.01rem) {
  body:has(> #app)::before,
  body.s2-rail::before {
    content: "";
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--rail-w);
    z-index: 0;
    transition: width 0.45s var(--ease);
    background: var(--walnut) var(--wood-v) center top / 360px 2400px;
    box-shadow: inset -1px 0 0 color-mix(in oklab, #000 40%, transparent);
  }
  .app,
  body.s2-rail {
    padding-left: var(--rail-w);
    transition: padding-left 0.45s var(--ease);
  }
  .masthead {
    position: fixed;
    inset: 13px auto 13px 13px;
    z-index: 40;
    width: var(--rail-plate-w);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: var(--space-6);
    margin: 0;
    padding: var(--space-6) var(--space-3) var(--space-3);
    border: 0;
    border-radius: var(--radius);
    background: var(--rail-plate);
    color: var(--rail-ink);
    font-family: var(--f-ui);
    font-size: 15px;
    line-height: 1.4;
    box-shadow: inset 0 1px 3px color-mix(in oklab, #000 30%, transparent), 0 1px 0 rgba(255, 238, 210, 0.18);
    overflow-y: auto;
    scrollbar-width: none;
    transition: background-color 0.7s var(--ease), width 0.45s var(--ease), padding 0.45s var(--ease);
  }
  .masthead__brand {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 var(--space-3);
    color: var(--rail-ink);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0;
    text-transform: none;
  }
  .masthead__brand b {
    color: var(--rail-ink);
    font-weight: 700;
  }
  .masthead__meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }
  .masthead__icon {
    display: inline-block;
  }
  .masthead__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    justify-content: flex-start;
    min-height: 40px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius);
    color: var(--rail-ink-2);
    font-size: 0.94rem;
    letter-spacing: 0;
    text-transform: none;
    text-align: left;
    transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
  }
  .masthead__link:hover {
    color: var(--rail-ink);
    background: var(--rail-hover);
  }
  .masthead__link.is-on {
    color: var(--rail-ink);
    background: var(--rail-pill);
  }
  .inbox,
  .acct {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .inbox__n {
    margin-left: auto;
    background: var(--rail-pill);
    color: var(--rail-ink);
  }
  .acct__chev {
    margin-left: auto;
  }
  /* popovers open beside the rail, not under the row */
  .inbox__drop,
  .acct__drop {
    position: fixed;
    top: auto;
    right: auto;
    left: calc(var(--rail-w) + 4px);
    color: var(--ink);
  }
  .inbox__drop {
    top: 16px;
  }
  .acct__drop {
    bottom: 16px;
  }
  .masthead__admin {
    color: var(--rail-ink);
    border-color: var(--rail-pill);
  }
  /* account then credits settle at the foot of the plate */
  .acct {
    order: 98;
    margin-top: auto;
  }
  .masthead .credits {
    order: 99;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding: var(--space-3);
    border: 0;
    border-top: 1px solid var(--rail-pill);
    border-radius: 0;
    color: var(--rail-ink-2);
    font-size: 0.72rem;
  }
  .masthead .credits:hover {
    color: var(--rail-ink);
  }
  .masthead .credits__coin {
    color: var(--rail-ink-2);
  }
  .masthead .credits__v {
    font-family: var(--f-ui);
    font-weight: var(--read-w);
    font-size: 1.35rem;
    color: var(--rail-ink);
    font-variant-numeric: tabular-nums;
  }
  .masthead .credits__k {
    color: var(--rail-ink-2);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.62rem;
  }
  .status-dot {
    color: var(--rail-ink-2);
  }
}

/* ------------------------------------------------- collapsible rail */
.masthead__collapse {
  display: none;
}
@media (min-width: 48.01rem) {
  .masthead__collapse {
    order: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    margin-top: var(--space-1);
    border-radius: var(--radius);
    color: var(--rail-ink-2);
    transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
  }
  .masthead__collapse:hover {
    color: var(--rail-ink);
    background: var(--rail-hover);
  }
  .masthead__collapse svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.45s var(--ease);
  }
  html[data-rail="collapsed"] .masthead__collapse svg {
    transform: rotate(180deg);
  }
  /* collapsed: an icon strip. Names stay as the rows' titles (hover). */
  html[data-rail="collapsed"] .masthead {
    padding-inline: 6px;
    align-items: center;
  }
  html[data-rail="collapsed"] .masthead__brand {
    align-self: center;
    padding: 0;
    font-size: 0;
  }
  html[data-rail="collapsed"] .masthead__brand::before {
    content: "A";
    font-size: 1.15rem;
  }
  html[data-rail="collapsed"] .masthead__meta {
    width: 100%;
  }
  html[data-rail="collapsed"] .masthead__link {
    justify-content: center;
    padding: 0;
    font-size: 0;
    gap: 0;
  }
  html[data-rail="collapsed"] .masthead__link .inbox__n,
  html[data-rail="collapsed"] .masthead__link .cnt,
  html[data-rail="collapsed"] .acct__chev,
  html[data-rail="collapsed"] .masthead .credits__v,
  html[data-rail="collapsed"] .masthead .credits__k {
    display: none;
  }
  html[data-rail="collapsed"] .masthead .credits {
    justify-content: center;
    padding: var(--space-3) 0;
  }
  html[data-rail="collapsed"] .masthead .credits__coin {
    font-size: 1rem;
  }
  html[data-rail="collapsed"] .masthead__collapse {
    width: 100%;
  }
}

/* ------------------------------------------------- phone: masthead + tab bar */
@media (max-width: 48rem) {
  .masthead {
    position: relative;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    border: 8px solid transparent;
    border-top-width: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    background:
      linear-gradient(var(--rail-plate), var(--rail-plate)) padding-box,
      var(--walnut) var(--wood-h) center / 2400px 220px border-box;
    color: var(--rail-ink);
    font-family: var(--f-ui);
    padding: 0.55rem 0.9rem;
  }
  .masthead__brand,
  .masthead__brand b {
    color: var(--rail-ink);
    text-transform: none;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0;
  }
  .masthead__meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
  }
  /* the tab bar owns the destinations on a phone */
  .masthead__link,
  .masthead__admin,
  .masthead .acct {
    display: none;
  }
  .masthead .credits {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.32rem 0.72rem;
    border: 1px solid var(--rail-pill);
    border-radius: 100px;
    color: var(--rail-ink-2);
    font-size: 0.72rem;
  }
  .masthead .credits__v,
  .masthead .credits__coin {
    color: var(--rail-ink);
    font-variant-numeric: tabular-nums;
  }
  .masthead .credits__k {
    display: none;
  }
  .masthead .inbox__btn {
    color: var(--rail-ink-2);
  }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    align-items: stretch;
    border: 8px solid transparent;
    border-bottom-width: calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 0;
    background:
      linear-gradient(var(--rail-plate), var(--rail-plate)) padding-box,
      var(--walnut) var(--wood-h) center / 2400px 220px border-box;
    font-family: var(--f-ui);
    /* The reset at the top (`.tabbar button { color: inherit }`) outranks
       `.tabbar__btn`, so the buttons take THIS colour. Unset, they inherited
       the page ink: dark green on the dark plate in the Day theme. */
    color: var(--rail-ink-2);
  }
  .tabbar__btn {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    padding: 0.35rem 0.15rem;
    border-radius: var(--radius);
    color: var(--rail-ink-2);
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar__icon {
    display: block;
    line-height: 0;
  }
  .tabbar__icon svg {
    width: 22px;
    height: 22px;
  }
  .tabbar__label {
    font-size: 0.7rem;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
  }
  .tabbar__btn.is-on {
    color: var(--rail-ink);
    background: var(--rail-pill);
  }
  .tabbar__btn.is-on::before {
    content: none;
  }
  body:has(> #app),
  body.s2-rail {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
  html.kb-open .tabbar {
    display: none;
  }
}

/* ----------------------------------------------- rail account popover (rail.js) */
.s2-acct__drop {
  position: fixed;
  left: calc(var(--rail-w) + 4px);
  bottom: 16px;
  z-index: 70;
  min-width: 19rem;
  padding: var(--space-1);
  border-radius: var(--radius);
  background: var(--room);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px color-mix(in oklab, var(--shadow) 88%, transparent);
  font-family: var(--f-ui);
  display: flex;
  flex-direction: column;
}
.s2-acct__drop a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.s2-acct__drop a:hover {
  background: color-mix(in oklab, var(--ink) 6%, transparent);
}
@media (max-width: 48rem) {
  .s2-acct__drop {
    left: 8px;
    right: 8px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    min-width: 0;
  }
}

/* Appearance control (theme.js) — shared so every page can show it. */
.appear {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: var(--space-1);
  color: var(--ink);
  font-family: var(--f-ui);
}
.appear__label {
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.appear__label--sub {
  margin-top: var(--space-1);
}
.appear__seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line);
}
.appear button {
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.appear__mode {
  min-height: 34px;
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink-2);
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
.appear__mode[aria-checked="true"] {
  background: var(--ink);
  color: var(--room);
}
.appear__nights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
}
.appear__night {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 60px;
  padding: var(--space-2) 2px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  transition: box-shadow 0.3s var(--ease), color 0.3s var(--ease);
}
.appear__night i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line), inset 0 0 0 4px color-mix(in oklab, #fff 6%, transparent);
}
.appear__night[aria-checked="true"] {
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink-2);
}

/* ------------------------------------------------------------ the player */
/* Full player (the show card): a small console screen — readout, scrubber
   marked at each story, transport — and the read-along transcript. */
.sp {
  display: grid;
  gap: var(--space-3);
  font-family: var(--f-ui);
}
.sp button {
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}
.sp__screen {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-radius: var(--radius);
  background: var(--scr);
  color: var(--scr-ink);
  box-shadow: 0 0 0 9px var(--bezel), 0 0 0 10px var(--bezel-edge);
  margin: 10px;
  transition: background-color 0.7s var(--ease);
}
.sp__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.sp__readout {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.sp__t {
  font-weight: var(--read-w);
  font-size: 2.1rem;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--scr-hi);
  font-variant-numeric: tabular-nums;
}
.sp__d {
  font-size: 0.92rem;
  color: var(--scr-ink-2);
  font-variant-numeric: tabular-nums;
}
.sp__rate {
  min-width: 48px;
  min-height: 30px;
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--scr-line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--scr-ink);
  font-variant-numeric: tabular-nums;
}
.sp-scrub {
  position: relative;
  height: 22px;
  cursor: pointer;
  touch-action: none;
  outline-offset: 4px;
}
.sp-scrub__track,
.sp-scrub__fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  height: 6px;
  border-radius: var(--radius);
}
.sp-scrub__track {
  background: var(--track);
}
.sp-scrub__fill {
  background: var(--fill);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.25s linear;
}
.sp-scrub__ticks b {
  position: absolute;
  top: 5px;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  border-radius: var(--radius);
  background: var(--scr);
  box-shadow: 0 0 0 1px var(--scr-line);
}
.sp-scrub__thumb {
  position: absolute;
  top: 4px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--scr-hi);
  box-shadow: 0 0 0 3px var(--scr);
  left: 0;
  transition: left 0.25s linear;
}
.sp__ctl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
}
.sp__skip {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--scr-ink-2);
  transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
}
.sp__skip:hover {
  color: var(--scr-hi);
  background: var(--scr-2);
}
.sp__skip svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sp__play {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ochre) !important;
  color: var(--ochre-ink) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 12px -6px var(--shadow);
  transition: transform 0.15s var(--ease), background-color 0.25s var(--ease);
}
.sp__play:hover {
  background: var(--ochre-hi) !important;
}
.sp__play:active {
  transform: scale(0.96);
}
.sp__play svg {
  width: 26px;
  height: 26px;
}
.sp__play.is-loading {
  animation: spPulse 1.2s var(--ease) infinite;
}
@keyframes spPulse {
  50% { opacity: 0.6; }
}
.sp-read {
  margin: 0 10px;
}
.sp-read summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: var(--space-2) 0;
}
.sp-read__lines {
  display: grid;
  gap: 2px;
  max-height: 22rem;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sp-line {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--ink-2);
  line-height: 1.55;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}
.sp-line:hover {
  background: color-mix(in oklab, var(--ink) 5%, transparent);
}
.sp-line.is-on {
  background: color-mix(in oklab, var(--fill) 16%, transparent);
  color: var(--ink);
}
.sp-line__who {
  display: inline-block;
  margin-right: var(--space-2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Docked mini player: in the rail on desktop, above the tab bar on a phone. */
.s2-mini {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius);
  background: color-mix(in oklab, var(--rail-ink) 7%, transparent);
  color: var(--rail-ink);
  font-family: var(--f-ui);
  overflow: hidden;
}
.s2-mini.hidden {
  display: none !important;
}
.s2-mini button {
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
}
.s2-mini__play {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ochre) !important;
  color: var(--ochre-ink) !important;
}
.s2-mini__play svg {
  width: 17px;
  height: 17px;
}
.s2-mini__text {
  display: grid;
  min-width: 0;
  text-align: left;
  line-height: 1.25;
}
.s2-mini__title {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s2-mini__sub {
  font-size: 0.72rem;
  color: var(--rail-ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s2-mini__btns {
  display: flex;
}
.s2-mini__btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--rail-ink-2);
}
.s2-mini__btn:hover {
  color: var(--rail-ink);
  background: var(--rail-hover);
}
.s2-mini__btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}
.s2-mini__line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: color-mix(in oklab, var(--rail-ink) 10%, transparent);
}
.s2-mini__bar {
  display: block;
  height: 100%;
  background: var(--fill);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.25s linear;
}
@media (min-width: 48.01rem) {
  .masthead .s2-mini {
    order: 97;
    margin-top: auto;
  }
  .masthead .s2-mini:not(.hidden) ~ .acct {
    margin-top: var(--space-2);
  }
  /* room for the title: forward-15 lives in the full player and media keys */
  .masthead .s2-mini__fwd {
    display: none;
  }
  /* collapsed rail: just the play button */
  html[data-rail="collapsed"] .masthead .s2-mini {
    grid-template-columns: auto;
    justify-items: center;
    padding: var(--space-2) 0;
    background: none;
  }
  html[data-rail="collapsed"] .masthead .s2-mini__text,
  html[data-rail="collapsed"] .masthead .s2-mini__btns {
    display: none;
  }
}
@media (max-width: 48rem) {
  .masthead .s2-mini {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    z-index: 59;
    padding: 7px var(--space-2);
    border-radius: var(--radius);
    background: var(--rail-plate);
    box-shadow: 0 0 0 1px color-mix(in oklab, var(--rail-ink) 12%, transparent), 0 10px 26px -12px var(--shadow);
  }
  body:has(.s2-mini:not(.hidden)) {
    padding-bottom: calc(132px + env(safe-area-inset-bottom, 0px));
  }
  html.kb-open .masthead .s2-mini {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sp-scrub__fill, .sp-scrub__thumb, .s2-mini__bar { transition: none; }
}

/* the account popover doubles as the phone's More sheet; these rows are the
   rail's own on a desktop */
@media (min-width: 48.01rem) {
  .s2-acct__drop .s2-acct__phone {
    display: none;
  }
}

/* ------------------------------------------------- moving between pages */
/* Cross-document view transitions: following a link between the app, the
   code workspace, Mission Control, admin and the public pages fades the
   content instead of flashing a reload. The rail and tab bar are named, so
   they hold perfectly still while only the content changes. rail.js adds
   speculation rules that prerender a link on hover, so the swap is instant. */
@view-transition {
  navigation: auto;
}
html {
  background: var(--room);
}
.masthead {
  view-transition-name: s2-rail;
}
.tabbar {
  view-transition-name: s2-tabs;
}
::view-transition-group(s2-rail),
::view-transition-group(s2-tabs) {
  animation-duration: 0s;
}
::view-transition-old(root) {
  animation: s2PageOut 0.16s var(--ease) both;
}
::view-transition-new(root) {
  animation: s2PageIn 0.34s var(--ease) both;
}
@keyframes s2PageOut {
  to { opacity: 0; }
}
@keyframes s2PageIn {
  from { opacity: 0; transform: translateY(6px); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* =========================================================================
   SW-1 rail — a walnut cheek set into the room on every page (app, admin,
   public pages). The wood is the component: a rounded walnut panel inset from
   the window edge, 9px of wood all round a recessed plate. The plate carries
   numbered keys (icon over label, an LED that lights for the current page),
   the token meter and the three-icon room switch at the foot.
   Phone: no header; the rail becomes a walnut bar of seven keys.
   ========================================================================= */
:root,
html[data-rail="collapsed"] {
  --rail-w: 96px;         /* the cheek, flush to the window edge; the page adds its own gap */
  --rail-plate-w: 78px;
}
@media (min-width: 48.01rem) {
  body:has(> #app)::before,
  body.s2-rail::before {
    inset: 0 auto 0 0;
    width: 96px;
    border-radius: 0;
    background-size: 300px 2000px;
    box-shadow: 0 1px 0 rgba(255, 238, 210, 0.12) inset, 0 0 0 1px rgba(0, 0, 0, 0.18);
  }
  .masthead {
    inset: 9px auto 9px 9px;
    width: 78px;
    padding: 14px 6px 10px;
    gap: 14px;
    border-radius: 7px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
    overflow-x: hidden;
    min-width: 0;
  }
  .masthead__brand {
    align-self: center;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: center;
    row-gap: 3px;
    padding: 0;
    min-height: 0;
    font: 700 10px var(--f-ui) !important;
    letter-spacing: 0.08em;
    margin-right: 0;
    text-align: center;
  }
  .masthead__brand b { font: inherit; letter-spacing: inherit; }
  .masthead__brand .brand__ask { line-height: 1.1; }
  .masthead__brand .brand__url {
    font: 400 7.5px/1.1 var(--f-code);
    letter-spacing: 0;
    color: var(--rail-ink-2);
  }
  .masthead__brand::after {
    content: attr(data-sub);
    grid-column: 1;
    font: 400 8.5px var(--f-code);
    letter-spacing: 0.12em;
    color: var(--rail-ink-2);
    min-height: 1em;
  }
  html[data-rail="collapsed"] .masthead__brand::before { content: none; }
  .masthead__meta { gap: 2px; counter-reset: navk; }
  .masthead__link,
  html[data-rail="collapsed"] .masthead__link {
    position: relative;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    min-height: 56px;
    padding: 6px 2px;
    border-radius: 5px;
    font: 500 9px/1.1 var(--f-code) !important;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
  }
  .masthead__link .masthead__icon svg { width: 18px; height: 18px; stroke-width: 1.4; }
  /* numbered keys with an LED; Account is not a key */
  .masthead__meta > .masthead__link:not(.hidden),
  .masthead__meta > .inbox:not(.hidden) > .masthead__link {
    counter-increment: navk;
  }
  .masthead__meta > .masthead__link:not(.hidden)::before,
  .masthead__meta > .inbox:not(.hidden) > .masthead__link::before {
    content: counter(navk);
    position: absolute;
    top: 7px;
    left: 8px;
    font: 400 8px var(--f-code);
    opacity: 0.55;
  }
  .masthead__meta > .masthead__link::after,
  .masthead__meta > .inbox > .masthead__link::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--rail-pill);
  }
  .masthead__link.is-on::after { background: var(--scr-live, #86cdb0) !important; }
  .inbox__n,
  html[data-rail="collapsed"] .masthead__link .inbox__n {
    display: inline-grid !important;
    place-items: center;
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 1;
    min-width: 15px;
    height: 15px;
    margin: 0;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--done);
    color: var(--rail-plate);
    font: 600 8.5px/15px var(--f-code);
    letter-spacing: 0;
  }
  .inbox__n.hidden { display: none !important; }
  .acct__chev { display: none; }
  /* the collapse key sits under the room switch */
  .masthead__collapse { order: 94; min-height: 26px; margin-top: 0; width: 100%; }
  .masthead .status-dot { display: none !important; }
  /* the foot: tokens with a ten-bar meter, then Account, then the room switch */
  .masthead .credits,
  html[data-rail="collapsed"] .masthead .credits {
    order: 90;
    margin-top: auto;
    display: grid !important;
    justify-items: center;
    gap: 6px;
    padding: 12px 4px 0;
    border: 0;
    border-top: 1px solid var(--rail-pill);
    border-radius: 0;
    background: none;
  }
  .masthead .credits.hidden { display: none !important; }
  .masthead .credits__coin { display: none; }
  .masthead .credits__k,
  html[data-rail="collapsed"] .masthead .credits__k {
    display: block !important;
    order: 1;
    font: 500 8.5px var(--f-code);
    letter-spacing: 0.12em;
    margin-right: -0.12em;
    text-transform: uppercase;
    color: var(--rail-ink-2);
  }
  .masthead .credits__v,
  html[data-rail="collapsed"] .masthead .credits__v {
    display: block !important;
    order: 2;
    font: 300 17px/1 var(--f-ui);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--rail-ink);
    max-width: 100%;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }
  .masthead .credits::after {
    content: "";
    order: 3;
    justify-self: stretch;
    height: 3px;
    background: linear-gradient(90deg, var(--scr-live, #86cdb0) var(--tok, 100%), var(--rail-pill) var(--tok, 100%));
    -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 2px), transparent calc(10% - 2px) 10%);
    mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 2px), transparent calc(10% - 2px) 10%);
  }
  .masthead .s2-mini { order: 91; }
  .masthead .acct { order: 92; margin-top: 0 !important; }
  .masthead .themesw { order: 93; }
  /* the mini player in a narrow plate: a play key and a line */
  .s2-mini { flex-direction: column; align-items: center; gap: 6px; }
  .s2-mini__text, .s2-mini__btns { display: none !important; }
  /* the docked show in the plate: a flat key and a progress line */
  .masthead .s2-mini { padding: 10px 0 0; border-top: 1px solid var(--rail-pill); background: none !important; box-shadow: none !important; border-radius: 0 !important; }
  .masthead .s2-mini__play { width: 100% !important; height: 30px !important; min-height: 0 !important; border-radius: 5px !important; background: var(--rail-pill) !important; color: var(--rail-ink) !important; box-shadow: none !important; display: grid; place-items: center; }
  .masthead .s2-mini__play svg { width: 12px; height: 12px; }
  .masthead .s2-mini__line { width: 100%; height: 2px; background: var(--rail-pill); }
  .masthead .s2-mini__bar { background: var(--scr-live, #86cdb0) !important; }
  .inbox__drop, .acct__drop, .s2-acct__drop { left: calc(var(--rail-w) + 8px); }

  /* collapsed: the cheek folds to a thin walnut edge holding one key that
     opens it again; the page takes the rest of the width */
  html[data-rail="collapsed"] {
    --rail-w: 28px;
    --rail-plate-w: 20px;
  }
  html[data-rail="collapsed"] body:has(> #app)::before,
  html[data-rail="collapsed"] body.s2-rail::before {
    width: 28px;
  }
  .masthead { transition: background-color 0.7s var(--ease), width 0.45s var(--ease), padding 0.45s var(--ease), inset 0.45s var(--ease); }
  html[data-rail="collapsed"] .masthead {
    inset: 4px auto 4px 4px;
    width: 20px;
    padding: 0;
    gap: 0;
    border-radius: 5px;
    overflow: hidden;
  }
  html[data-rail="collapsed"] .masthead > :not(.masthead__meta),
  html[data-rail="collapsed"] .masthead__meta > :not(.masthead__collapse) {
    display: none !important;
  }
  html[data-rail="collapsed"] .masthead__meta { height: 100%; }
  html[data-rail="collapsed"] .masthead__collapse {
    order: 0;
    flex: 1;
    align-items: flex-start;
    min-height: 0;
    padding: 10px 0 0;
    border-radius: 5px;
    color: var(--rail-ink);
  }
  html[data-rail="collapsed"] .masthead__collapse svg { width: 12px; height: 12px; }
}

/* the three-icon room switch */
.themesw {
  --sw-line: var(--rail-pill);
  --sw-ink: var(--rail-ink-2);
  --sw-thumb: var(--rail-ink);
  --sw-on: var(--rail-plate);
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 28px;
  margin: 0 2px;
  border-radius: 6px;
  border: 1px solid var(--sw-line);
  flex: none;
}
.themesw button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0 !important;
  border: 0;
  background: none;
  padding: 0;
  color: var(--sw-ink);
  cursor: pointer;
  transition: color 0.25s var(--ease);
}
.themesw button:hover { color: var(--sw-thumb); }
.themesw button[aria-checked="true"] { color: var(--sw-on); }
.themesw svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.themesw svg .fill { fill: currentColor; stroke: none; }
.themesw .thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / 3);
  border-radius: 4px;
  background: var(--sw-thumb);
  transition: transform 0.3s var(--ease);
}

/* phone: no header — the rail is a walnut bar of seven keys under the thumb */
@media (max-width: 48rem) {
  .masthead {
    position: static;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    min-height: 0;
  }
  .masthead__brand,
  .masthead .credits,
  .masthead .status-dot,
  .masthead .themesw { display: none !important; }
  body:has(> #app)::before,
  body.s2-rail::before { content: none !important; }
  .tabbar {
    border: 0 !important;
    border-radius: 0 !important;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--walnut) var(--wood-h) center / 2400px 220px !important;
    box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
    gap: 0;
  }
  .tabbar::before {
    content: "";
    position: absolute;
    inset: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px));
    border-radius: 7px;
    background: var(--rail-plate);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  }
  .tabbar__btn {
    z-index: 1;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    min-height: 50px !important;
    margin: 3px 1px;
    gap: 4px !important;
    border-radius: 5px !important;
    font: 500 8.5px var(--f-code) !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .tabbar__btn:first-of-type { margin-left: 3px; }
  .tabbar__btn:last-of-type { margin-right: 3px; }
  .tabbar__icon svg { width: 18px !important; height: 18px !important; stroke-width: 1.4; }
  .tabbar__label { font: inherit !important; letter-spacing: inherit; text-transform: uppercase !important; white-space: nowrap; overflow: hidden; text-overflow: clip; max-width: 100%; }
  .tabbar__btn::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--rail-pill);
  }
  .tabbar__btn.is-on::after { background: var(--scr-live, #86cdb0); }
  .tabbar__btn[aria-label="More"]::after { content: none; }
  body:has(> #app),
  body.s2-rail { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* phone: the docked show sits on the tab bar as a flat plate */
@media (max-width: 48rem) {
  .s2-mini:not(.hidden) { border-radius: 7px !important; background: var(--rail-plate) !important; color: var(--rail-ink) !important; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) !important; }
  .s2-mini__play { width: 36px !important; height: 36px !important; border-radius: 5px !important; background: var(--rail-pill) !important; color: var(--rail-ink) !important; box-shadow: none !important; }
  .s2-mini__play svg { width: 13px; height: 13px; }
  .s2-mini__title { font-weight: 500 !important; color: var(--rail-ink) !important; }
  .s2-mini__sub { font: 400 10px var(--f-code) !important; color: var(--rail-ink-2) !important; }
  .s2-mini__btn { color: var(--rail-ink-2) !important; }
  .s2-mini__bar { background: var(--scr-live, #86cdb0) !important; }
}
