/* ------------------------------------------------------------------
   Max — companion timer prototype
   Palette: warm paper, ink, terracotta, sage, brass
------------------------------------------------------------------- */

:root {
  --paper:      #f6efe3;
  --paper-deep: #ece0cf;
  --ink:        #2b2620;
  --ink-soft:   #6b6154;
  --line:       rgba(43, 38, 32, .12);
  --terra:      #c4775a;
  --terra-deep: #a95c41;
  --sage:       #7c8b6d;
  --moss:       #5b6249;
  --brass:      #c9a34a;
  --card:       rgba(255, 252, 246, .72);
  --shadow:     0 24px 60px -28px rgba(74, 54, 32, .45);
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  --edge: 22px;
}

* { box-sizing: border-box; }

button:focus { outline: none; }
button:focus-visible { outline: 2px solid rgba(196, 119, 90, .5); outline-offset: 3px; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 20% -10%, #fffaf1 0%, transparent 55%),
    radial-gradient(900px 600px at 95% 10%, #f3e3cd 0%, transparent 60%),
    linear-gradient(160deg, #f8f2e7 0%, #efe4d3 55%, #e8dac6 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* soft edges */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(64, 45, 26, .16) 100%);
  mix-blend-mode: multiply;
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 41; opacity: .28;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* ── top bar ─────────────────────────────────────────── */

.topbar {
  position: fixed; inset: 0 0 auto 0; height: 62px; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 0 var(--edge);
  border-bottom: 1px solid rgba(30, 34, 22, .45);
  background:
    radial-gradient(700px 120px at 12% -40%, rgba(255, 255, 255, .1), transparent 70%),
    linear-gradient(to bottom, #5f6751, #545c45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09);
}
.brand {
  display: flex; align-items: center; gap: 10px; flex: none;
  color: #f7f0e2; text-decoration: none;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; overflow: hidden; flex: none;
  background: #f6efe3;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .22), 0 9px 18px -11px rgba(0, 0, 0, .7);
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s ease;
}
.brand:hover .brand-mark {
  transform: rotate(-4deg) scale(1.04);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .32), 0 12px 20px -11px rgba(0, 0, 0, .6);
}
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; gap: 2px; line-height: 1; }
.brand-name {
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  letter-spacing: -.015em; color: #fbf5e8;
}
.brand-sub {
  font-size: 8.5px; font-weight: 600; letter-spacing: .15em;
  text-transform: uppercase; color: rgba(247, 240, 226, .62);
}
.topbar-mid {
  display: flex; align-items: center; gap: 8px;
  margin: 0 auto 0 0; padding-left: 17px;
  border-left: 1px solid rgba(255, 255, 255, .18);
  font-size: 12.5px; color: rgba(247, 240, 226, .76); letter-spacing: .01em;
}
.topbar-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: #d9c884;
  box-shadow: 0 0 0 3px rgba(217, 200, 132, .2);
}
.beta-pill {
  flex: none; padding: 4px 9px 3px; border-radius: 6px;
  font-size: 9px; font-weight: 650; letter-spacing: .13em; text-transform: uppercase;
  color: #f7efdc;
  background: rgba(255, 255, 255, .1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}
.ghost-btn {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 12.5px; color: rgba(250, 244, 232, .82);
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08);
  cursor: pointer; transition: .22s ease; text-decoration: none;
}
.ghost-btn + .ghost-btn { margin-left: 8px; }
.ghost-btn[hidden] { display: none; }
#installBtn {
  color: #f2f6ea; background: rgba(233, 238, 226, .16);
  border-color: rgba(233, 238, 226, .38);
}
#installBtn:hover { background: rgba(233, 238, 226, .28); }
.ghost-btn:hover { color: #fffdf8; background: rgba(255, 255, 255, .18); }
.ghost-btn[aria-pressed="true"] {
  color: #3b4132; background: #f4ecdf; border-color: #f4ecdf;
}
/* quiet links in the top bar: no pill, no border */
.ghost-btn.bare {
  padding: 6px 9px; border-color: transparent; background: transparent;
  color: rgba(250, 244, 232, .74);
}
.ghost-btn.bare:hover {
  color: #fffdf8; background: rgba(255, 255, 255, .1);
  text-decoration: underline; text-underline-offset: 3px;
}
.ghost-btn.bare[aria-pressed="true"] {
  color: #fffdf8; background: rgba(255, 255, 255, .12); border-color: transparent;
}

/* ── layout ──────────────────────────────────────────── */

.app {
  position: relative; z-index: 10;
  height: 100%;
  padding: 78px var(--edge) 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
}

/* the animal changer sits at the top of the page, above the room */
.companion-bar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.companion-label {
  flex: none;
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft);
}
.companion-bar .companions { flex: 0 1 auto; }
.companion-bar .companion-btn { flex: 0 0 auto; padding: 6px 14px; }
/* the timer's settings sit at the far end of the same bar */

.panel {
  min-height: 0;
  display: flex; flex-direction: column;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .6);
  background: var(--card);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .8);
  backdrop-filter: blur(14px) saturate(1.05);
}

.panel-left { padding: 22px 20px 18px; gap: 16px; }
.panel-right { padding: 18px; gap: 10px; overflow: hidden; align-self: start; }

/* ── left panel ──────────────────────────────────────── */

.dog-id h1 {
  font-family: var(--serif);
  font-size: 27px; font-weight: 600; letter-spacing: -.02em;
  margin: 0;
}
.dog-id .sub {
  margin: 2px 0 0; font-size: 12px; color: var(--ink-soft);
  letter-spacing: .06em; text-transform: uppercase;
}

.timer-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 18px 14px 14px;
  border-radius: 18px;
  background: linear-gradient(170deg, rgba(255, 255, 255, .78), rgba(247, 236, 219, .5));
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: 0 14px 30px -22px rgba(80, 55, 25, .6);
}

.ring-wrap { position: relative; width: 186px; height: 186px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-track { stroke: rgba(43, 38, 32, .09); }
.ring-fill {
  stroke: var(--terra);
  stroke-linecap: round;
  stroke-dasharray: 553;
  stroke-dashoffset: 553;
  transition: stroke-dashoffset .5s linear, stroke .5s ease;
  filter: drop-shadow(0 1px 3px rgba(196, 119, 90, .35));
}

.time-stack {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
}
.time {
  font-family: var(--serif);
  font-size: 44px; font-variant-numeric: tabular-nums;
  letter-spacing: -.03em; line-height: 1;
}
.phase {
  font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-soft);
}

.status {
  margin: 0; text-align: center; font-size: 12.5px; line-height: 1.5;
  color: var(--ink-soft); max-width: 230px; min-height: 34px;
}

.controls { display: flex; gap: 8px; width: 100%; }
.primary-btn {
  flex: 1;
  font: inherit; font-size: 13.5px; font-weight: 550;
  color: #fff7ec; background: linear-gradient(180deg, #cf8465, var(--terra-deep));
  border: 0; border-radius: 12px; padding: 12px 14px;
  cursor: pointer;
  box-shadow: 0 10px 20px -12px rgba(169, 92, 65, .9), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .16s ease, filter .2s ease;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: translateY(1px) scale(.995); }
.primary-btn.is-running { background: linear-gradient(180deg, #8b9a7b, #6d7c5e); }

.icon-btn {
  width: 44px; display: grid; place-items: center;
  color: var(--ink-soft); background: rgba(255, 255, 255, .6);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: .2s ease;
}
.icon-btn:hover { color: var(--ink); background: #fff; }

.text-btn {
  font: inherit; font-size: 12px; color: var(--terra-deep);
  background: none; border: 0; cursor: pointer; padding: 2px 6px;
  border-bottom: 1px dashed rgba(169, 92, 65, .4);
}
.text-btn:hover { border-bottom-style: solid; }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 0; padding: 12px 0 0; border-top: 1px solid var(--line);
}
.stats dt {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 3px;
}
.stats dd {
  margin: 0; font-family: var(--serif); font-size: 21px; font-variant-numeric: tabular-nums;
}

.fineprint { margin: auto 0 0; font-size: 10.5px; line-height: 1.5; color: rgba(107, 97, 84, .8); }

/* ── props Max brings back, on a card beside the plant ── */

/* the floor lamp: the photograph, cut out and placed in the room */
.stage-lamp {
  position: absolute; z-index: 0; pointer-events: none;
  display: block;
  filter: saturate(.88) sepia(.06) contrast(1.02)
          drop-shadow(0 8px 8px rgba(74, 54, 32, .16));
}

/* dark mode pulls the room down to evening; the lamp and the companion stay lit */
.room-night {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0; transition: opacity .6s ease;
  background:
    radial-gradient(30% 28% at 86% 42%, rgba(255, 216, 158, .5), rgba(255, 200, 130, 0) 72%),
    radial-gradient(46% 34% at 82% 66%, rgba(255, 206, 150, .18), transparent 74%),
    linear-gradient(180deg, rgba(24, 21, 17, .62), rgba(30, 26, 20, .5));
}
:root[data-theme="dark"] .room-night { opacity: 1; }
:root[data-theme="dark"] .stage-plant { filter: brightness(.74) saturate(.82) sepia(.08); }
:root[data-theme="dark"] .stage-character { filter: brightness(.9) saturate(.92); }
:root[data-theme="dark"] .stage-plant.is-wilted { filter: brightness(.6) saturate(.34) sepia(.2); }
:root[data-theme="dark"] .stage-lamp {
  filter: brightness(.78) saturate(.82) sepia(.08) drop-shadow(0 0 22px rgba(255, 206, 138, .14));
}

/* the ficus sprite that grows with the session */
.stage-plant {
  position: absolute; z-index: 0; pointer-events: none;
  background-repeat: no-repeat; background-size: 100% 100%;
  transform-origin: 50% 100%; will-change: transform;
  transition: filter .8s ease;
}
/* a session abandoned halfway: the ficus sulks until the next one */
.stage-plant.is-wilted { filter: saturate(.45) brightness(.92) sepia(.2); }

/* the lamp warming up when a session lands */
/* the light the bulb throws down and across the wall, centred under the shade */
.lamp-glow {
  position: absolute; z-index: 0; pointer-events: none; opacity: 0;
  background:
    radial-gradient(ellipse 58% 52% at 50% 38%,
      rgba(255, 233, 188, .5) 0%, rgba(255, 214, 150, .22) 38%,
      rgba(255, 199, 128, 0) 72%);
  filter: blur(10px);
  transition: opacity .8s ease;
}
.lamp-glow.is-lit { opacity: 1; animation: lamp-breathe 4.5s ease-in-out 1; }

/* the glass itself lit from within: screen blending keeps the bulb's
   outline visible instead of painting a halo over it */
.lamp-bulb {
  position: absolute; z-index: 0; pointer-events: none; opacity: 0;
  border-radius: 50%; mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 50%,
    rgba(255, 253, 243, 1) 0%, rgba(255, 246, 219, .96) 12%,
    rgba(255, 228, 174, .74) 26%, rgba(255, 210, 146, .26) 44%,
    rgba(255, 206, 138, 0) 66%);
  transition: opacity .5s ease;
}
.lamp-bulb.is-lit { opacity: 1; animation: bulb-breathe 4.5s ease-in-out 1; }

@keyframes lamp-breathe {
  0% { opacity: .3; }
  24% { opacity: 1; }
  58% { opacity: .86; }
  100% { opacity: 1; }
}
@keyframes bulb-breathe {
  0% { opacity: .2; }
  18% { opacity: 1; }
  64% { opacity: .9; }
  100% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .lamp-glow.is-lit, .lamp-bulb.is-lit { animation: none; }
}

.prop-card {
  position: absolute; z-index: 1; left: 1.8%; top: 23%;
  width: clamp(46px, 6%, 64px);
  padding: 6px;
  /* the finds shelf is tucked away for now */
  display: none; gap: 5px;
  border-radius: 14px;
  background: linear-gradient(170deg, rgba(255, 252, 245, .9), rgba(250, 240, 226, .72));
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: 0 22px 46px -32px rgba(70, 48, 22, .9);
  backdrop-filter: blur(14px) saturate(1.05);
  animation: card-in .45s ease both;
}

.prop-grid { display: grid; grid-template-columns: 1fr; gap: 5px; }

.prop-tile { border-radius: 9px; }



.prop-tile {
  position: relative; overflow: hidden; cursor: pointer;
  aspect-ratio: 1 / 1; display: grid; place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, .55);
  box-shadow: inset 0 0 0 1px rgba(74, 53, 39, .1);
  animation: tile-in .45s cubic-bezier(.34, 1.56, .64, 1) both;
}
.prop-tile svg {
  position: relative; z-index: 0;
  display: block; width: 84%; height: 84%; overflow: visible;
  transition: filter .35s ease, opacity .35s ease;
}

/* a find still behind frosted glass — you can see its shape, not quite its face */
.prop-tile.is-locked svg { filter: blur(.9px) saturate(.7); opacity: .84; transform: scale(1.02); }
.prop-tile.is-locked::before {
  content: ''; position: absolute; inset: 0; z-index: 1; border-radius: inherit;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, .5) 0%, rgba(255, 252, 246, .2) 42%, rgba(244, 232, 214, .34) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7), inset 0 -8px 12px -10px rgba(74, 53, 39, .3);
}
.prop-tile.is-unlocked svg { animation: find-in .5s cubic-bezier(.34, 1.56, .64, 1) both; }
.prop-tile:focus-visible {
  outline: 2px solid rgba(196, 119, 90, .5); outline-offset: 2px;
}
.prop-tile.is-poked svg { animation: find-poke .42s cubic-bezier(.34, 1.56, .64, 1); }

/* hover a find and it says what it is — the frosted ones included */
.prop-tile:hover { overflow: visible; }
.prop-tip {
  position: absolute; left: calc(100% + 9px); top: 50%;
  transform: translateY(-50%) translateX(-4px);
  padding: 5px 9px; border-radius: 8px; white-space: nowrap;
  font-size: 11.5px; font-weight: 500; line-height: 1.2; color: #4a3527;
  background: rgba(255, 252, 246, .97);
  box-shadow: 0 10px 22px -14px rgba(70, 48, 22, .9), inset 0 0 0 1px rgba(74, 53, 39, .12);
  opacity: 0; pointer-events: none; z-index: 4;
  transition: opacity .16s ease, transform .16s ease;
}
.prop-tile:hover .prop-tip { opacity: 1; transform: translateY(-50%); }

@keyframes find-in {
  from { opacity: .4; transform: scale(.7); }
  to   { opacity: 1; transform: none; }
}

@keyframes tile-in {
  from { opacity: 0; transform: scale(.45); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes find-poke {
  0%, 100% { transform: none; }
  35%      { transform: scale(.88) rotate(-3deg); }
  70%      { transform: scale(1.06) rotate(2deg); }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ── stage ───────────────────────────────────────────── */

.stage {
  position: relative; min-height: 0;
  border-radius: 26px; overflow: hidden;
  background: #e9dbc6;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, .5);
  cursor: default;
}
#scene { display: block; width: 100%; height: 100%; }

/* the companion itself is a button: tab to it, press Enter, it hops */
.stage-character:focus-visible {
  outline: 2px dashed rgba(43, 38, 32, .34);
  outline-offset: 6px; border-radius: 14px;
}

/* ── Miso, the cat ───────────────────────────────────────
   SVG in the page with a four-beat walk: thigh and shin are separate
   bones, diagonal pairs move together, and the body bobs once per step.
   The room only moves and flips the whole thing. */
/* Miso's eyes: drawn into her animation's eye layers, so they ride her head */
.miso-eye { transform-box: fill-box; transform-origin: 50% 50%; animation: miso-blink 4.6s ease-in-out infinite; }
.miso-eye .eye-white { fill: #fdf4e2; stroke: #4a3527; }
.miso-eye .eye-iris { fill: #c98a3f; }
.miso-eye .eye-pupil { fill: #4a3527; }
.miso-eye .eye-glint { fill: #fffdf6; }

@keyframes miso-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 96%      { transform: scaleY(.08); }
}

.companion-cat { opacity: 0; transition: opacity .45s ease; }
.companion-cat.is-in { opacity: 1; }
.companion-cat svg { display: block; overflow: visible; }

.cat-leg rect { fill: var(--fur, #d89158); stroke: #4a3527; stroke-width: 2.1; }

.cat-leg, .cat-leg .shin {
  transform-box: fill-box;
  transform-origin: 50% 2%;
  animation-duration: .62s;
  animation-timing-function: cubic-bezier(.45, .05, .55, .95);
  animation-iteration-count: infinite;
}
.cat-leg { animation-name: cat-thigh; }
.cat-leg .shin { animation-name: cat-shin; }

/* diagonal pairs: back-near with front-far */
.leg-f1, .leg-f4,
.leg-f1 .shin, .leg-f4 .shin { animation-delay: -.31s; }

.cat-tail {
  transform-box: fill-box; transform-origin: 4% 92%;
  animation: cat-tail 1.8s ease-in-out infinite alternate;
}
.cat-body {
  transform-box: fill-box; transform-origin: 50% 100%;
  animation: cat-bob .31s ease-in-out infinite alternate;
}
.cat-head {
  transform-box: fill-box; transform-origin: 50% 84%;
  animation: cat-head-bob .62s ease-in-out infinite;
}

@keyframes cat-thigh {
  0%, 100% { transform: rotate(-15deg); }
  50%      { transform: rotate(13deg); }
}
@keyframes cat-shin {
  0%, 100% { transform: rotate(14deg); }
  50%      { transform: rotate(-10deg); }
}
@keyframes cat-tail { from { transform: rotate(-8deg); } to { transform: rotate(8deg); } }
@keyframes cat-bob { from { transform: translateY(0); } to { transform: translateY(-1.4px); } }
@keyframes cat-head-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(.9px) rotate(-1.4deg); }
}

/* ── timer, on top of the room ───────────────────────── */

.hud {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 18px 20px 22px;
  pointer-events: none;
}

/* the clock console: companion, timer and today's numbers in one card, so the
   top of the room reads as a single panel instead of three floating islands */
.hud-top {
  display: flex; flex-direction: column; align-items: center; gap: 13px;
}

/* the clock console: a wide card over the sofa, with the clock and the
   start button on the left and every session setting on the right, so
   nothing has to hide in the top bar */
.console {
  pointer-events: auto;
  position: relative; left: 8%;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  grid-template-areas:
    "head head"
    "timer settings"
    "cycle settings"
    "actions settings";
  align-items: start;
  width: min(470px, calc(100% - 32px));
  padding: 14px 16px 13px;
  border-radius: 24px;
  background: linear-gradient(170deg, rgba(255, 252, 245, .95), rgba(250, 240, 226, .86));
  border: 1px solid rgba(255, 255, 255, .82);
  box-shadow: 0 26px 54px -34px rgba(70, 48, 22, .85), inset 0 1px 0 rgba(255, 255, 255, .8);
  backdrop-filter: blur(16px) saturate(1.06);
}

@media (min-width: 721px) {
  /* sit a little closer to the sofa */
  .console { margin-top: 26px; }
}

.console-head {
  grid-area: head;
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 10px; margin-bottom: 2px;
  border-bottom: 1px solid rgba(74, 53, 39, .1);
  min-width: 0;
}
.console .hud-id {
  display: flex; align-items: baseline; gap: 8px; flex: none;
  padding: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none;
}
.console .hud-id h1 { font-size: 22px; margin: 0; }
.console .hud-id .sub { font-size: 8.5px; letter-spacing: .15em; }
.console-head .focus-task { flex: 1 1 auto; width: auto; min-width: 0; margin: 0; }
.console-head .focus-task input { text-align: left; font-size: 11.5px; padding: 6px 2px 5px; }

.console .hud-timer { grid-area: timer; justify-self: center; margin: 10px 0 0; }
.console .ring-wrap { width: 106px; height: 106px; }
.console .cycle { grid-area: cycle; justify-self: center; margin: 6px 0 0; }
.console .timer-actions {
  grid-area: actions; width: 100%; margin-top: 8px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
}
.console .timer-actions .primary-btn { flex: 1 1 auto; font-size: 11.5px; padding: 8px 6px; }
.console .timer-actions .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.console .timer-actions .text-btn { flex: 1 0 100%; font-size: 9.5px; padding: 1px 0; }

.console-settings {
  grid-area: settings;
  display: flex; flex-direction: column; min-height: 100%;
  padding-left: 16px; border-left: 1px solid rgba(74, 53, 39, .1);
}
.settings-title {
  margin: 2px 0 2px; font-size: 8px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-soft);
}

/* the lengths live in the card now: one line per stretch */
.console .lengths {
  position: static; transform: none; width: auto; max-width: none;
  padding: 0; border: 0; background: none; box-shadow: none;
  backdrop-filter: none; pointer-events: auto; animation: none;
}
.console .lengths-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr);
  align-items: center; gap: 5px; padding: 4px 0;
}
.console .lengths-row + .lengths-row { border-top: 0; }
.console .lengths-label { font-size: 7.5px; letter-spacing: .08em; }
.console .lengths .pills { gap: 3px; }
.console .lengths .pill-btn { min-width: 24px; padding: 3px 0; font-size: 9.5px; border-radius: 6px; }
.console .lengths .custom-min { margin-left: auto; font-size: 8.5px; gap: 2px; }
.console .lengths .custom-min input { width: 28px; padding: 3px 1px; font-size: 9.5px; }

/* the two options read as switches inside the card */
.console .cycle-tools { display: flex; flex-direction: column; gap: 0; width: 100%; margin: 4px 0 0; }
.console .chip.pref {
  width: 100%; justify-content: space-between; gap: 10px;
  padding: 7px 0; border: 0; border-radius: 0; background: none;
  font-size: 10.5px; color: var(--ink-soft);
}
.console .chip.pref:hover { background: none; color: var(--ink); }
.console .chip.pref i {
  order: 2; flex: none; width: 34px; height: 19px; opacity: 1;
  border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .65); position: relative;
  transition: background .2s ease, border-color .2s ease;
}
.console .chip.pref i::after {
  content: ''; position: absolute; top: 2px; left: 2.5px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #bcb09d; transition: left .2s ease, background .2s ease;
}
.console .chip.pref[aria-pressed="true"] i {
  background: rgba(124, 139, 109, .3); border-color: rgba(124, 139, 109, .55);
}
.console .chip.pref[aria-pressed="true"] i::after { left: 17px; background: var(--sage); }
.console .chip.chip-icon { display: none; }

.console .hud-stats {
  width: 100%; margin-top: auto; padding: 8px 0 0;
  border-top: 1px solid rgba(74, 53, 39, .12);
  display: flex; justify-content: stretch;
  background: none; border-radius: 0; box-shadow: none; backdrop-filter: none;
}
.console .hud-stats > div { flex: 1 1 0; padding: 0; }
.console .hud-stats > div + div { border-left: 1px solid rgba(74, 53, 39, .1); }
.console .hud-stats dt { font-size: 7px; letter-spacing: .07em; }
.console .hud-stats dd { font-size: 13px; }

/* the controls follow the clock, centred under it */
.hud-controls {
  position: relative; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.hud-controls > * { pointer-events: auto; }
.hud-controls .cycle,
.hud-controls .timer-actions,
.hud-controls .cycle-tools,
.hud-controls .focus-task { margin-top: 0; }
.hud-controls .focus-task { margin-top: 0; width: 100%; }


.hud-glass {
  background: linear-gradient(170deg, rgba(255, 252, 245, .88), rgba(250, 240, 226, .72));
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: 0 22px 46px -34px rgba(70, 48, 22, .9);
  backdrop-filter: blur(14px) saturate(1.05);
}

.hud-id {
  pointer-events: auto;
  padding: 11px 17px 12px; border-radius: 16px;
  background: linear-gradient(170deg, rgba(255, 252, 245, .88), rgba(250, 240, 226, .72));
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: 0 22px 46px -34px rgba(70, 48, 22, .9);
  backdrop-filter: blur(14px) saturate(1.05);
}

.hud-id h1 {
  font-family: var(--serif); font-size: 25px; line-height: 1;
  letter-spacing: -.015em; margin: 0 0 5px;
}

.hud-id .sub {
  margin: 0; font-size: 9.5px; letter-spacing: .15em;
  text-transform: uppercase; color: var(--ink-soft);
}

.hud-timer {
  position: relative; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center;
}

.hud .ring-wrap {
  position: relative; width: 106px; height: 106px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(255, 252, 245, .9), rgba(248, 236, 219, .62));
  border: 1px solid rgba(255, 255, 255, .6);
  box-shadow: 0 24px 50px -34px rgba(70, 48, 22, .95);
  backdrop-filter: blur(12px);
}

.hud .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.hud .time-stack { position: relative; text-align: center; }
.hud .time {
  font-family: var(--serif); font-variant-numeric: tabular-nums;
  font-size: 28px; line-height: 1; letter-spacing: -.02em;
}
.hud .phase {
  margin-top: 5px; font-size: 9px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-soft);
}

.hud-stats {
  pointer-events: auto;
  display: flex; gap: 2px; margin: 0;
  padding: 9px 6px; border-radius: 14px;
  background: linear-gradient(170deg, rgba(255, 252, 245, .86), rgba(250, 240, 226, .7));
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 22px 46px -34px rgba(70, 48, 22, .9);
  backdrop-filter: blur(14px);
}

.hud-stats > div { padding: 0 10px; text-align: center; }
.hud-stats dt {
  font-size: 8.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 2px;
}
.hud-stats dd { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1; }

/* the stage owns the left column */
.room-col { display: grid; min-height: 0; }

/* session control sits with the timer it drives */
.timer-actions {
  width: 172px; margin-top: 9px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  pointer-events: auto;
}
.timer-actions .primary-btn { flex: 1 1 auto; font-size: 12.5px; padding: 9px 12px; border-radius: 10px; }
.timer-actions .icon-btn { width: 34px; border-radius: 10px; }
.timer-actions .text-btn { flex: 1 0 100%; text-align: center; font-size: 10.5px; padding: 1px 0; }

/* the four stretches of the cycle, under the ring */
.cycle { display: flex; gap: 7px; margin-top: 10px; pointer-events: auto; }
.cycle span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(74, 53, 39, .14);
  box-shadow: inset 0 0 0 1px rgba(74, 53, 39, .1);
  transition: background .35s ease, box-shadow .35s ease, transform .35s ease;
}
.cycle span.is-next { background: rgba(74, 53, 39, .3); }
.cycle span.is-done { background: var(--terra); box-shadow: none; }
.cycle.is-long span.is-done { background: var(--brass); }

.cycle-tools { display: flex; gap: 6px; margin-top: 9px; pointer-events: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 9.5px; letter-spacing: .05em;
  color: var(--ink-soft); padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .5);
  cursor: pointer; transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.chip i {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: .3; transition: .2s ease;
}
.chip:hover { color: var(--ink); background: rgba(255, 255, 255, .85); }
.chip[aria-pressed="true"] { color: var(--ink); background: rgba(255, 255, 255, .92); border-color: rgba(74, 53, 39, .2); }
.chip[aria-pressed="true"] i { background: var(--sage); opacity: 1; }
.chip-icon { padding: 4px 7px; }

/* the lengths sheet, hanging under the timer */
.lengths {
  position: absolute; z-index: 6; top: calc(100% + 10px); left: 50%;
  transform: translateX(-50%);
  width: 244px; max-width: calc(100vw - 44px);
  padding: 11px 12px 9px; border-radius: 16px;
  background: linear-gradient(170deg, rgba(255, 252, 245, .97), rgba(250, 240, 226, .95));
  border: 1px solid rgba(255, 255, 255, .8);
  box-shadow: 0 28px 54px -32px rgba(60, 40, 20, .9), inset 0 1px 0 rgba(255, 255, 255, .8);
  backdrop-filter: blur(14px) saturate(1.05);
  pointer-events: auto;
  animation: sheet-in .24s ease both;
}
@keyframes sheet-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.lengths-row { display: flex; flex-direction: column; gap: 6px; padding: 7px 0; }
.lengths-row + .lengths-row { border-top: 1px solid rgba(74, 53, 39, .08); }
.lengths-label {
  font-size: 8.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft);
}
.pills { display: flex; align-items: center; gap: 4px; }
.pill-btn {
  font: inherit; font-size: 11px; min-width: 29px; padding: 5px 0;
  color: var(--ink-soft); background: rgba(255, 255, 255, .55);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.pill-btn:hover { color: var(--ink); background: #fff; }
.pill-btn[aria-pressed="true"] {
  color: #fff7ec; background: var(--terra); border-color: var(--terra);
  box-shadow: 0 6px 14px -10px rgba(169, 92, 65, .9);
}
.custom-min {
  margin-left: auto; display: inline-flex; align-items: baseline; gap: 3px;
  font-size: 9.5px; color: var(--ink-soft);
}
.custom-min input {
  width: 38px; font: inherit; font-size: 11px; text-align: center;
  color: var(--ink); padding: 4px 2px;
  background: rgba(255, 255, 255, .7); border: 1px solid var(--line);
  border-radius: 7px; outline: none;
  appearance: textfield; -moz-appearance: textfield;
  transition: border-color .16s ease, background .16s ease;
}
.custom-min input::-webkit-outer-spin-button,
.custom-min input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.custom-min input:focus { border-color: rgba(169, 92, 65, .55); background: #fff; }

.focus-task { display: block; width: 172px; margin-top: 9px; pointer-events: auto; }
.focus-task input {
  width: 100%; font: inherit; font-size: 10.5px; text-align: center;
  color: var(--ink); padding: 4px 2px 3px;
  background: none; border: 0; border-bottom: 1px dashed rgba(74, 53, 39, .2);
  border-radius: 0; outline: none;
  transition: border-color .2s ease, opacity .3s ease;
}
.focus-task input::placeholder { color: rgba(74, 53, 39, .34); }
.focus-task input:focus { border-bottom-color: rgba(169, 92, 65, .55); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* focus mode: while a stretch runs, the room is the interface */
body.is-focus .hud-stats,
body.is-focus .prop-card,
body.is-focus .panel-right,
body.is-focus .ghost-btn,
body.is-focus #demoBtn,
body.is-focus .focus-task,
body.is-focus .cycle-tools,
body.is-focus .topbar-mid,
body.is-focus .beta-pill {
  opacity: .22; filter: saturate(.85); pointer-events: none;
  transition: opacity .9s ease, filter .9s ease;
}

.stage-status {
  position: absolute; left: 18px; bottom: 15px; margin: 0;
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(43, 38, 32, .48); pointer-events: none;
}

.loader {
  position: absolute; inset: 0; display: grid; place-content: center;
  gap: 10px; justify-items: center;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(43, 38, 32, .45);
  background: #e9dbc6;
  transition: opacity .8s ease;
}
.loader span {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(43, 38, 32, .14); border-top-color: var(--terra);
  animation: spin 1s linear infinite;
}
.loader.is-gone { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── right panel ─────────────────────────────────────── */

.panel-head { display: flex; align-items: baseline; justify-content: space-between; }
.panel-head h2 {
  font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 0;
  letter-spacing: -.01em;
}
.pill {
  font-size: 10.5px; letter-spacing: .06em; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
  font-variant-numeric: tabular-nums;
}

/* who is in the room: one pill per animal in the house */
.companions { display: flex; gap: 5px; }
.companion-btn {
  flex: 1 1 0; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 10.5px; letter-spacing: .04em;
  color: var(--ink-soft); padding: 6px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .5);
  cursor: pointer; transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.companion-btn i {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: currentColor; opacity: .35; transition: .2s ease;
}
.companion-btn:hover { color: var(--ink); background: #fff; }
.companion-btn[aria-pressed="true"] {
  color: #fff7ec; background: var(--ink); border-color: var(--ink);
}
.companion-btn[aria-pressed="true"] i { background: var(--brass); opacity: 1; }
.lede { margin: 0; font-size: 11.5px; line-height: 1.55; color: var(--ink-soft); }

.rewards {
  list-style: none; margin: 4px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  overflow: auto; min-height: 0; flex: 1;
}
.reward {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: 12px;
  border: 1px solid transparent;
  transition: .3s ease;
}
.reward:hover { background: rgba(255, 255, 255, .5); }
.reward-ico {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px;
  background: rgba(43, 38, 32, .06);
  filter: grayscale(1) opacity(.42);
  transition: .4s ease;
}
.reward-name { font-size: 12.5px; line-height: 1.25; }
.reward-note { font-size: 10.5px; color: var(--ink-soft); }
.reward.is-unlocked .reward-ico { filter: none; background: rgba(201, 163, 74, .2); }
.reward.is-unlocked { border-color: rgba(201, 163, 74, .35); background: rgba(255, 251, 240, .7); }
.reward.is-new { animation: pop .6s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { 0% { transform: scale(.94); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }

.week-head {
  display: flex; justify-content: space-between;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 10px; border-top: 1px solid var(--line);
}
.week { display: flex; gap: 6px; align-items: flex-end; }
.week-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.week-bar {
  width: 100%; height: 34px; border-radius: 6px;
  background: rgba(43, 38, 32, .07);
  display: flex; align-items: flex-end; overflow: hidden;
}
.week-bar i {
  display: block; width: 100%; border-radius: 6px;
  background: linear-gradient(180deg, #d9a45e, var(--terra));
  transition: height .6s cubic-bezier(.2, .8, .2, 1);
}
.week-day span { font-size: 9px; color: var(--ink-soft); letter-spacing: .04em; }
.week-day.is-today span { color: var(--terra-deep); font-weight: 650; }

/* ── reward modal ────────────────────────────────────── */

.modal-scrim {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(43, 34, 22, .34);
  backdrop-filter: blur(5px);
  animation: fade .35s ease;
}
.modal-scrim[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }

.reward-card {
  width: min(340px, 88vw);
  padding: 26px 24px 22px;
  text-align: center;
  border-radius: 24px;
  background: linear-gradient(175deg, #fffdf8, #f7ecdc);
  border: 1px solid #fff;
  box-shadow: 0 40px 80px -30px rgba(60, 40, 18, .55);
  animation: lift .5s cubic-bezier(.2, 1.2, .3, 1);
}
@keyframes lift { from { transform: translateY(14px) scale(.97); opacity: 0; } }

.reward-art {
  width: 84px; height: 84px; margin: 0 auto 12px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 38px;
  background: radial-gradient(circle at 40% 35%, #fff6e2, #f0dcc0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), 0 12px 24px -14px rgba(120, 80, 30, .6);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-4px); } }

.eyebrow {
  margin: 0; font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--terra-deep);
}
.reward-card h3 {
  font-family: var(--serif); font-size: 24px; font-weight: 600;
  margin: 5px 0 7px; letter-spacing: -.02em;
}
.reward-copy { margin: 0 0 18px; font-size: 12.5px; line-height: 1.55; color: var(--ink-soft); }
.reward-card .primary-btn { width: 100%; }

/* ── toast ───────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  z-index: 58; padding: 9px 16px; border-radius: 999px;
  background: rgba(43, 38, 32, .92); color: #fff6ea;
  font-size: 12px; opacity: 0; pointer-events: none;
  transition: .4s cubic-bezier(.2, .8, .2, 1);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── dark mode ─────────────────────────────────────────
   The same room after dark: paper becomes brown-black, the glass panels
   go smoky, and the painted room is washed down to evening in room.js
   so the lamp and the companion stay the only warm things in it. */

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:      #1b1916;
  --paper-deep: #23201a;
  --ink:        #f2eadc;
  --ink-soft:   #ab9f8f;
  --line:       rgba(242, 234, 220, .16);
  --terra:      #d68a67;
  --terra-deep: #e5a687;
  --sage:       #98a78a;
  --moss:       #c3ccb1;
  --brass:      #e3bd6d;
  --card:       rgba(41, 37, 31, .74);
  --shadow:     0 24px 60px -26px rgba(0, 0, 0, .8);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(1100px 700px at 18% -10%, #2a2620 0%, transparent 58%),
    radial-gradient(900px 600px at 95% 8%, #292219 0%, transparent 62%),
    linear-gradient(160deg, #191712 0%, #1e1b16 55%, #141210 100%);
}
:root[data-theme="dark"] .vignette {
  background: radial-gradient(120% 90% at 50% 45%, transparent 52%, rgba(0, 0, 0, .5) 100%);
}
:root[data-theme="dark"] .grain { opacity: .18; }
:root[data-theme="dark"] .topbar {
  background:
    radial-gradient(700px 120px at 12% -40%, rgba(255, 255, 255, .06), transparent 70%),
    linear-gradient(to bottom, #2c3127, #232820);
  border-bottom-color: rgba(0, 0, 0, .5);
}
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .stage {
  border-color: rgba(255, 255, 255, .09);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, .05);
}
:root[data-theme="dark"] .stage { background: #17140f; }

/* the glass cards in the room */
:root[data-theme="dark"] .hud-id,
:root[data-theme="dark"] .hud .ring-wrap,
:root[data-theme="dark"] .hud-stats,
:root[data-theme="dark"] .prop-card,
:root[data-theme="dark"] .hud-glass {
  background: linear-gradient(170deg, rgba(52, 47, 40, .84), rgba(35, 31, 26, .74));
  border-color: rgba(255, 255, 255, .1);
  box-shadow: 0 22px 46px -30px rgba(0, 0, 0, .95);
}
:root[data-theme="dark"] .hud .ring-wrap {
  background: radial-gradient(circle at 50% 45%, rgba(56, 50, 42, .9), rgba(32, 28, 23, .72));
}
:root[data-theme="dark"] .console {
  background: linear-gradient(170deg, rgba(52, 47, 40, .9), rgba(33, 29, 24, .82));
  border-color: rgba(255, 255, 255, .1);
  box-shadow: 0 24px 48px -30px rgba(0, 0, 0, .95);
}
:root[data-theme="dark"] .console .chip.pref i {
  background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18);
}
:root[data-theme="dark"] .console .chip.pref i::after { background: #8d8578; }
:root[data-theme="dark"] .console .chip.pref[aria-pressed="true"] i {
  background: rgba(124, 139, 109, .4); border-color: rgba(140, 160, 120, .6);
}
:root[data-theme="dark"] .console .chip.pref[aria-pressed="true"] i::after { background: #b6c7a3; }
:root[data-theme="dark"] .console .hud-stats { border-left-color: rgba(242, 234, 220, .16); }
:root[data-theme="dark"] .ring-track { stroke: rgba(242, 234, 220, .16); }
:root[data-theme="dark"] .cycle span { background: rgba(242, 234, 220, .16); }
:root[data-theme="dark"] .cycle span.is-next { background: rgba(242, 234, 220, .34); }
:root[data-theme="dark"] .cycle span.is-done { background: var(--terra); }
:root[data-theme="dark"] .cycle.is-long span.is-done { background: var(--brass); }

/* controls */
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .companion-btn,
:root[data-theme="dark"] .icon-btn,
:root[data-theme="dark"] .pill-btn,
:root[data-theme="dark"] .custom-min input,
:root[data-theme="dark"] .prop-tile {
  background: rgba(255, 255, 255, .06);
  border-color: var(--line);
  color: var(--ink-soft);
}
:root[data-theme="dark"] .chip:hover,
:root[data-theme="dark"] .companion-btn:hover,
:root[data-theme="dark"] .icon-btn:hover,
:root[data-theme="dark"] .pill-btn:hover { background: rgba(255, 255, 255, .12); color: var(--ink); }
:root[data-theme="dark"] .chip[aria-pressed="true"] {
  background: rgba(255, 255, 255, .14); color: var(--ink); border-color: rgba(255, 255, 255, .2);
}
/* inside the timer card the two preferences are plain rows, not chips:
   no fill behind the label */
:root[data-theme="dark"] .console .chip.pref,
:root[data-theme="dark"] .console .chip.pref:hover {
  background: none; border-color: transparent;
}
:root[data-theme="dark"] .companion-btn[aria-pressed="true"] {
  background: var(--ink); color: #211d18; border-color: var(--ink);
}
:root[data-theme="dark"] .companion-btn[aria-pressed="true"] i { background: #6f5730; }
:root[data-theme="dark"] .pill-btn[aria-pressed="true"] {
  background: var(--terra); border-color: var(--terra); color: #241b16;
}
:root[data-theme="dark"] .focus-task input {
  color: var(--ink); border-bottom-color: rgba(242, 234, 220, .24);
}
:root[data-theme="dark"] .focus-task input::placeholder { color: rgba(242, 234, 220, .38); }
:root[data-theme="dark"] .text-btn { color: #d99a80; }
:root[data-theme="dark"] .stage-status { color: rgba(242, 234, 220, .5); }

/* the lengths sheet */
:root[data-theme="dark"] .lengths {
  background: linear-gradient(170deg, rgba(52, 47, 40, .97), rgba(37, 33, 28, .96));
  border-color: rgba(255, 255, 255, .12);
  box-shadow: 0 28px 54px -30px rgba(0, 0, 0, .95);
}

/* the finds shelf */
:root[data-theme="dark"] .prop-tile { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .prop-tile.is-locked::before {
  background: linear-gradient(150deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .04) 45%, rgba(20, 18, 15, .3));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), inset 0 -8px 12px -10px rgba(0, 0, 0, .6);
}
:root[data-theme="dark"] .prop-tile.is-locked svg { opacity: .6; }
:root[data-theme="dark"] .prop-tip {
  color: var(--ink); background: rgba(44, 40, 34, .98);
  box-shadow: 0 10px 22px -14px rgba(0, 0, 0, .9), inset 0 0 0 1px rgba(255, 255, 255, .12);
}

/* the week strip and the reward card */
:root[data-theme="dark"] .week-bar { background: rgba(242, 234, 220, .1); }
:root[data-theme="dark"] .week-bar i { background: linear-gradient(180deg, #d1a05c, var(--terra)); }
:root[data-theme="dark"] .reward-card {
  background: linear-gradient(175deg, #322c25, #241f1a);
  border-color: rgba(255, 255, 255, .12);
}
:root[data-theme="dark"] .reward-art {
  background: radial-gradient(circle at 40% 35%, #43392c, #2a231c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), 0 12px 24px -14px #000;
}
:root[data-theme="dark"] .reward .reward-ico { background: rgba(255, 255, 255, .07); }
:root[data-theme="dark"] .reward.is-unlocked .reward-ico { background: rgba(201, 163, 74, .22); }
:root[data-theme="dark"] .reward.is-unlocked {
  border-color: rgba(201, 163, 74, .3); background: rgba(255, 255, 255, .05);
}
:root[data-theme="dark"] .primary-btn {
  background: linear-gradient(180deg, #bb755a, #8f5238);
  color: #fff6ea;
}
:root[data-theme="dark"] .primary-btn.is-running { background: linear-gradient(180deg, #6b7a5c, #4f5c43); }
:root[data-theme="dark"] .loader { background: #1e1b16; color: rgba(242, 234, 220, .5); }
:root[data-theme="dark"] .loader span { border-color: rgba(242, 234, 220, .18); border-top-color: var(--terra); }

/* the moon / sun switch in the top bar */
.theme-btn { gap: 0; padding: 6px 9px; margin-left: 6px; }
.theme-btn svg { display: block; }
.theme-btn .theme-icon { display: block; }
.theme-btn .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .theme-icon { display: none; }
:root[data-theme="dark"] .theme-btn .theme-icon-sun { display: block; }

/* ── responsive ──────────────────────────────────────── */

@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  /* the room card has nothing left to show once the switcher moved to
     the top and the week chart hides, so it steps aside */
  .panel-right { display: none; }
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .topbar-mid, .beta-pill { display: none; }
  :root { --edge: 14px; }
  .topbar { gap: 10px; }
  .brand { margin-right: auto; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 9px; }
  .brand-name { font-size: 16px; }
  .brand-sub { display: none; }
  .ghost-btn { font-size: 11.5px; padding: 6px 10px; }
  .only-wide { display: none; }
  .ghost-btn + .ghost-btn { margin-left: 4px; }
  .app {
    height: auto; padding: 74px 14px 14px;
    grid-template-columns: 1fr;
    grid-template-rows: auto 68vh;
  }
  .companion-bar { order: -2; }
  .stage { order: -1; }
  .hud { padding: 12px 12px 14px; }
  .hud-stats,
  .console .hud-stats { display: none; }
  .companion-bar { flex-wrap: wrap; row-gap: 8px; }
  /* the phone has no room for the name card beside the clock */
  .hud-id { display: none; }
  /* on a phone the console is just the clock and its controls: no card */
  .console {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    width: auto; left: 0; padding: 0;
    background: none; border: 0; box-shadow: none; backdrop-filter: none;
  }
  .console-head { display: contents; }
  .console .hud-id { display: none; }
  .console .hud-timer { order: 1; margin: 0; }
  .console .cycle { order: 2; margin-top: 0; }
  .console .timer-actions { order: 3; width: 168px; margin-top: 2px; }
  .console .focus-task { order: 5; width: 168px; margin: 9px 0 0; }
  .console .focus-task input { text-align: center; font-size: 10.5px; padding: 4px 2px 3px; }
  .hud .ring-wrap { width: 104px; height: 104px; }
  .hud .time { font-size: 24px; }
  .hud-controls .focus-task { width: 168px; }
  .panel-right { flex-wrap: wrap; }

  .timer-actions { width: 168px; }
  .timer-actions .primary-btn { font-size: 11.5px; padding: 8px 10px; }
  .focus-task { width: 168px; }
  .chip { font-size: 9px; padding: 3px 7px; }

  .companions { flex: 1 1 100%; }

  /* on a phone the finds run as a strip along the floor, clear of the plant
     and out of the clock's way */
  .prop-card {
    left: 14px; right: 14px; top: auto; bottom: 8px;
    width: auto; padding: 5px; border-radius: 13px;
    animation: none;
  }
  /* the finds take the floor's caption line, and the pet walks above it */
  .stage-status { display: none; }
  .prop-grid { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .prop-tip {
    left: 50%; top: auto; bottom: calc(100% + 7px);
    transform: translateX(-50%) translateY(4px);
  }
  .prop-tile:hover .prop-tip { transform: translateX(-50%); }
}

/* ── phone session settings: floating with the clock, no card ────
   The clock, the start button and a slim glass strip with the session
   settings all sit on the room itself. */
.len-text { display: none; }

@media (max-width: 720px) {
  .console { width: 264px; }
  :root[data-theme="dark"] .console {
    background: none; border-color: transparent; box-shadow: none;
  }
  /* the session settings join the clock cluster instead of the top bar */
  .console-settings {
    display: flex; flex-direction: column; align-items: center;
    order: 4; width: 100%; min-height: 0; padding: 0; border: 0;
  }
  .console .settings-title,
  .console .hud-stats { display: none; }

  .console .cycle-tools {
    display: flex; flex-direction: row; align-items: center; gap: 5px;
    width: max-content; max-width: 100%; flex-wrap: nowrap;
    margin: 10px 0 0; padding: 4px;
    border-radius: 999px;
    background: rgba(255, 252, 246, .66);
    border: 1px solid rgba(255, 255, 255, .75);
    box-shadow: 0 12px 26px -20px rgba(70, 48, 22, .8);
    backdrop-filter: blur(12px) saturate(1.05);
  }
  .console .chip.pref {
    width: auto; padding: 5px 9px; border-radius: 999px;
    font-size: 9px; background: rgba(255, 255, 255, .5);
    border: 1px solid transparent; white-space: nowrap;
  }
  .console .chip.pref i {
    order: 0; width: 5px; height: 5px; border: 0; border-radius: 50%;
    background: currentColor; opacity: .3;
  }
  .console .chip.pref i::after { display: none; }
  .console .chip.pref[aria-pressed="true"] i {
    background: var(--sage); opacity: 1;
  }
  .console .chip.chip-icon { display: inline-flex; white-space: nowrap; }
  .console .chip.chip-icon svg { display: none; }
  .len-text { display: inline; font-size: 9px; letter-spacing: .04em; }

  .console-settings .cycle-tools { order: 1; }
  .console-settings .lengths { order: 2; }
  .console .lengths {
    width: 248px; margin-top: 8px; padding: 8px 10px 6px;
    border-radius: 16px;
    background: linear-gradient(170deg, rgba(255, 252, 245, .97), rgba(250, 240, 226, .95));
    border: 1px solid rgba(255, 255, 255, .8);
    box-shadow: 0 20px 40px -26px rgba(70, 48, 22, .9);
  }
  .console .lengths-row { grid-template-columns: 54px minmax(0, 1fr); }
  /* on a phone the presets are enough: the custom box is a desktop thing */
  .console .lengths .custom-min { display: none; }
  .console .lengths .pills { justify-content: space-between; }
  body.lengths-open .console .focus-task { display: none; }

  /* the same glass, at night */
  :root[data-theme="dark"] .console .cycle-tools {
    background: rgba(35, 31, 26, .72); border-color: rgba(255, 255, 255, .14);
    box-shadow: 0 14px 30px -22px #000;
  }
  :root[data-theme="dark"] .console .chip.pref {
    background: rgba(255, 255, 255, .07);
  }
  :root[data-theme="dark"] .console .lengths {
    background: linear-gradient(170deg, rgba(52, 47, 40, .97), rgba(37, 33, 28, .96));
    border-color: rgba(255, 255, 255, .12);
  }
}

/* ── the phone's own edges ──────────────────────────────────────
   In a browser tab these insets are zero; once installed they keep
   the top bar clear of the notch and the controls off the home bar. */
@supports (padding: max(0px)) {
  .topbar {
    height: calc(62px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-left: calc(var(--edge) + env(safe-area-inset-left));
    padding-right: calc(var(--edge) + env(safe-area-inset-right));
  }
  .app {
    padding-top: calc(78px + env(safe-area-inset-top));
    padding-left: calc(var(--edge) + env(safe-area-inset-left));
    padding-right: calc(var(--edge) + env(safe-area-inset-right));
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* installed: it should feel like an app, not a page in a tab */
@media (display-mode: standalone) {
  .topbar-mid, .beta-pill { display: none; }
  .vignette { opacity: .85; }
}
