/* Entropic Labs — The Observatory.
   ==========================================================================
   Same building, darker room. The palette, fonts and spacing conventions are
   the studio's, lifted from index.html so the two rooms match; what changes
   is the light level and the fact that everything is instrumentation rather
   than page furniture.

   One stylesheet serves phone and desktop. The Observatory is a canvas app
   whose layout is decided at runtime from viewport and pointer type, so it
   has no separate m/ build — the other pages are prose and can afford a
   hand-tuned twin, this cannot.
   ========================================================================== */

:root{
  /* --- the studio's tokens, unchanged --- */
  --ink: #07050F;
  --panel: #130E22;
  --panel-raised: #1C1433;
  --ash: #9C93B8;
  --paper: #F1EEFB;
  --signal: #FF3FA0;
  --trace: #2FE0C7;
  --violet: #7C4DFF;
  --hairline: rgba(241,238,251,0.12);
  --hairline-strong: rgba(241,238,251,0.22);

  --font-display: "Arial Narrow", "Helvetica Neue Condensed", "Roboto Condensed", Arial, sans-serif;
  --font-body: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* --- observatory-only --- */
  --void: #04030B;
  --glass: rgba(10,8,20,0.82);
  --glass-solid: rgba(9,7,18,0.96);
  --bar-h: 3.25rem;
  --pad: 1.1rem;
  --sheet-top: 26vh;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  background: var(--void);
}
html{ -webkit-text-size-adjust: 100%; }

body{
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  /* deep field: a faint warm core, cold at the edges */
  background:
    radial-gradient(120% 90% at 50% 42%, #0C0A1E 0%, #07061134 45%, transparent 72%),
    radial-gradient(70% 60% at 12% 88%, rgba(124,77,255,0.10) 0%, transparent 70%),
    radial-gradient(60% 55% at 88% 12%, rgba(47,224,199,0.06) 0%, transparent 70%),
    var(--void);
}
::selection{ background: var(--signal); color: var(--ink); }

a{ color: inherit; -webkit-tap-highlight-color: rgba(47,224,199,0.16); }
a:focus-visible, button:focus-visible, summary:focus-visible{
  outline: 2px solid var(--trace);
  outline-offset: 3px;
}
h1, h2, h3, h4{
  font-family: var(--font-display);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-wrap: balance;
  margin: 0;
}
.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;
}

/* ==========================================================================
   THE SKY
   ========================================================================== */
#sky{
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: manipulation;
  cursor: crosshair;
}

/* Instrument glass: scanlines, a static grain plate, and a vignette. All of
   it is one non-painting layer with no per-frame cost — the grain is a
   single SVG turbulence tile that drifts on a slow transform. */
.glass{
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.glass::before{
  content: "";
  position: absolute;
  inset: -50%;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
  background-size: 140px 140px;
  animation: grain 7s steps(6) infinite;
}
.glass::after{
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(241,238,251,0.030) 0px,
      rgba(241,238,251,0.030) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(115% 95% at 50% 50%, transparent 52%, rgba(2,1,6,0.55) 100%);
}
@keyframes grain{
  0%   { transform: translate(0,0); }
  20%  { transform: translate(-6px,3px); }
  40%  { transform: translate(4px,-5px); }
  60%  { transform: translate(-3px,-2px); }
  80%  { transform: translate(5px,4px); }
  100% { transform: translate(0,0); }
}

/* ==========================================================================
   NAV — the studio bar, kept recognisable
   ========================================================================== */
.obs-nav{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1.1rem, 3vw, 2.2rem);
  background: linear-gradient(rgba(4,3,11,0.92) 55%, rgba(4,3,11,0));
}
.obs-nav .brand{
  font-family: var(--font-display);
  text-transform: uppercase;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.03em;
  text-decoration: none;
  white-space: nowrap;
}
.obs-nav .brand span{ color: var(--signal); }
.navlinks{
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.7rem);
  list-style: none;
  margin: 0; padding: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.navlinks a{ text-decoration: none; color: var(--ash); transition: color .15s ease; }
.navlinks a:hover{ color: var(--paper); }
.navlinks a[aria-current="page"]{ color: var(--paper); }
/* Narrow screens drop the link set for a single way out, the way m/ does. */
.navlinks .nav-exit{ display: none; }
@media (max-width: 720px){
  .navlinks li:not(.nav-exit){ display: none; }
  .navlinks .nav-exit{ display: block; }
  .navlinks .nav-exit a{ color: var(--ash); }
}

/* ==========================================================================
   TITLE PLATE
   ========================================================================== */
.plate{
  position: fixed;
  top: calc(var(--bar-h) + clamp(1rem, 5vh, 3.2rem));
  left: 0; right: 0;
  z-index: 10;
  text-align: center;
  padding: 0 var(--pad);
  pointer-events: none;
  transition: opacity .5s ease, transform .5s ease;
}
.plate h1{
  font-size: clamp(1.45rem, 3.2vw + 0.6rem, 2.55rem);
  letter-spacing: 0.02em;
  line-height: 1.05;
}
.plate h1 .slash{ color: var(--signal); }
.plate .sub{
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 1.4vw, 0.78rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ash);
  margin: 0.9rem 0 0;
}
.plate .hint{
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(156,147,184,0.55);
  margin: 0.7rem 0 0;
}
body[data-view="category"] .plate,
body[data-view="record"] .plate{
  opacity: 0;
  transform: translateY(-10px);
}

/* ==========================================================================
   TELEMETRY
   ========================================================================== */
/* Bottom right on a wide screen: the catalogue owns the top left, so the
   instrumentation takes the opposite corner and the two never meet. */
.status{
  position: fixed;
  z-index: 20;
  right: clamp(1.1rem, 3vw, 2.2rem);
  bottom: calc(clamp(1.1rem, 3vw, 2.2rem) + env(safe-area-inset-bottom));
  width: 16.5rem;
  max-width: calc(100vw - 2.2rem);
  background: var(--glass);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--trace);
  font-family: var(--font-mono);
}
.status > summary{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  list-style: none;
  cursor: pointer;
  padding: 0.62rem 0.75rem;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash);
  min-height: 2.5rem;
}
.status > summary::-webkit-details-marker{ display: none; }
.status > summary .lamp{
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--trace);
  box-shadow: 0 0 0 3px rgba(47,224,199,0.14);
  flex: none;
  animation: lamp 2.6s ease-in-out infinite;
}
@keyframes lamp{ 0%,100%{ opacity: 1; } 50%{ opacity: 0.32; } }
.status > summary .sum-left{ display: flex; align-items: center; gap: 0.55em; }
.status > summary .status-time{
  margin-left: auto;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}
.status > summary .caret{ color: var(--trace); font-size: 0.7rem; }
.status[open] > summary .caret::after{ content: "–"; }
.status:not([open]) > summary .caret::after{ content: "+"; }
.status[open] > summary{ border-bottom: 1px solid var(--hairline); }

.status-body{ padding: 0.55rem 0.75rem 0.7rem; }
.status-row{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.3rem 0;
  font-size: 0.63rem;
  letter-spacing: 0.05em;
  border-bottom: 1px dashed rgba(241,238,251,0.07);
}
.status-row:last-child{ border-bottom: 0; }
.status-key{ color: var(--ash); text-transform: uppercase; letter-spacing: 0.11em; white-space: nowrap; }
.status-val{
  color: var(--paper);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.status-sub{
  display: block;
  color: rgba(156,147,184,0.62);
  font-size: 0.56rem;
  letter-spacing: 0.1em;
}
.status-row[data-meter] .status-val{ color: var(--violet); letter-spacing: -0.06em; font-size: 0.6rem; }
.status-note{
  margin: 0.6rem 0 0;
  font-size: 0.55rem;
  line-height: 1.6;
  letter-spacing: 0.05em;
  color: rgba(156,147,184,0.55);
  border-left: 1px solid var(--hairline);
  padding-left: 0.6rem;
}
.status-note b{ color: var(--ash); font-weight: 400; }

/* ==========================================================================
   READOUT STRIP — coordinates + system messages
   ========================================================================== */
.readout{
  position: fixed;
  z-index: 20;
  left: clamp(1.1rem, 3vw, 2.2rem);
  bottom: calc(clamp(1.1rem, 3vw, 2.2rem) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  font-family: var(--font-mono);
  pointer-events: none;
}
.coords{
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: rgba(156,147,184,0.7);
  font-variant-numeric: tabular-nums;
}
.coords b{ color: var(--trace); font-weight: 400; }
.syslog{
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--trace);
  min-height: 1.1em;
  opacity: 0;
  transition: opacity .35s ease;
}
.syslog.on{ opacity: 0.9; }
.syslog::before{ content: "› "; color: rgba(47,224,199,0.5); }

/* ==========================================================================
   OBSERVE CONTROL
   ========================================================================== */
.actions{
  position: fixed;
  z-index: 22;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(clamp(1.1rem, 3vw, 2.2rem) + env(safe-area-inset-bottom));
  display: flex;
  gap: 0.7rem;
  align-items: center;
}
.obs-btn{
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--paper);
  background: rgba(10,8,20,0.78);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  border: 1px solid var(--hairline-strong);
  border-radius: 2px;
  min-height: 3rem;
  padding: 0 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65em;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.obs-btn:hover{ border-color: var(--trace); color: var(--trace); }
.obs-btn:active{ transform: translateY(1px); }
.obs-btn .dot{
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(255,63,160,0.16);
  flex: none;
}
.obs-btn.ghost{ background: transparent; color: var(--ash); border-color: var(--hairline); }
.obs-btn.ghost:hover{ color: var(--paper); border-color: var(--hairline-strong); }
.obs-btn[hidden]{ display: none; }

/* ==========================================================================
   PANELS — catalogue (a category) and record (one observation)
   ========================================================================== */
.panel{
  position: fixed;
  z-index: 25;
  background: var(--glass-solid);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .5s cubic-bezier(.22,.61,.36,1), opacity .35s ease;
}
.panel[hidden]{ display: none; }
.panel-scroll{
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.panel-head{
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 2.4vw, 1.6rem) 0.9rem;
  border-bottom: 1px solid var(--hairline);
}
.panel-close{
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ash);
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  min-height: 2.75rem;   /* 44px — the site's touch-target floor */
  min-width: 2.75rem;
  padding: 0 0.7rem;
  cursor: pointer;
}
.panel-close:hover{ color: var(--trace); border-color: var(--trace); }

/* ---------- catalogue ---------- */
.catalog{
  left: clamp(1.1rem, 3vw, 2.2rem);
  top: calc(var(--bar-h) + 0.6rem);
  width: 21rem;
  max-height: min(30rem, calc(100vh - var(--bar-h) - 10rem));
  border-left: 2px solid var(--trace);
}
.catalog .cat-index{
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--trace);
  display: block;
  margin-bottom: 0.4rem;
}
.catalog h2{ font-size: 1.3rem; line-height: 1.15; }
.catalog .cat-line{
  color: var(--ash);
  font-size: 0.83rem;
  margin: 0.6rem 0 0;
  line-height: 1.55;
}
.cat-list{ list-style: none; margin: 0; padding: 0; }
.cat-list li{ border-bottom: 1px solid rgba(241,238,251,0.07); }
.cat-list li:last-child{ border-bottom: 0; }
.cat-item{
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0.8rem clamp(1rem, 2.4vw, 1.6rem);
  min-height: 3.25rem;
  transition: background .15s ease;
}
.cat-item:hover, .cat-item:focus-visible{ background: rgba(241,238,251,0.045); }
.cat-item .ci-main{ flex: 1; min-width: 0; }
.cat-item .ci-title{
  display: block;
  font-size: 0.95rem;
  line-height: 1.3;
}
.cat-item .ci-sub{
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ash);
  margin-top: 0.2rem;
}
.cat-item .ci-go{
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(156,147,184,0.5);
}
.cat-item:hover .ci-go{ color: var(--trace); }

/* status pip, shared by catalogue and record */
.pip{
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
  background: var(--ash);
}
.pip[data-tone="trace"]{ background: var(--trace); }
.pip[data-tone="signal"]{ background: var(--signal); }
.pip[data-tone="violet"]{ background: var(--violet); }
.pip[data-tone="ash"]{ background: var(--ash); }

/* ---------- record ---------- */
.record{
  right: 0;
  top: 0;
  bottom: 0;
  width: min(36rem, 46vw);
  border-right: 0;
  border-top: 0;
  border-bottom: 0;
  border-left: 2px solid var(--signal);
}
.record-inner{ padding: 0 clamp(1.25rem, 2.6vw, 2.1rem) 3rem; }
.record .panel-head{
  padding-top: calc(var(--bar-h) + 0.4rem);
  align-items: center;
}
.rec-desig{
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--signal);
}
.rec-title{
  font-size: clamp(1.6rem, 2.4vw + 0.8rem, 2.4rem);
  line-height: 1.05;
  margin: 1.4rem 0 0;
}
.rec-status{
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash);
  margin-top: 0.9rem;
}
.rec-meta{
  margin: 1.5rem 0 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}
.rec-meta .row{
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 0.62rem 0;
  border-bottom: 1px solid rgba(241,238,251,0.07);
}
.rec-meta dt{ color: var(--ash); letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; }
.rec-meta dd{ margin: 0; text-align: right; color: var(--paper); }
.rec-body{ margin-top: 1.8rem; }
.rec-body p{
  color: #E4DFF2;
  margin: 0 0 1.05rem;
  font-size: 1rem;
}
.rec-body p:last-child{ margin-bottom: 0; }

.rec-section{ margin-top: 2.2rem; }
.rec-section > h3{
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--trace);
  font-weight: 400;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 1rem;
}
.rec-why{
  border-left: 2px solid var(--signal);
  padding: 0.1rem 0 0.1rem 1.1rem;
}
.rec-why p{
  margin: 0;
  color: var(--paper);
  font-size: 1.04rem;
  line-height: 1.62;
}

.certainty{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.certainty li{ display: grid; grid-template-columns: 7.4rem 1fr; gap: 0.9rem; align-items: start; }
.certainty .tag{
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 0.3rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  text-align: center;
  line-height: 1.2;
}
.certainty .tag[data-k="ESTABLISHED"]{ color: var(--trace); }
.certainty .tag[data-k="HYPOTHESIS"]{ color: var(--violet); }
.certainty .tag[data-k="CONTESTED"]{ color: var(--signal); }
.certainty .tag[data-k="UNRESOLVED"]{ color: var(--ash); }
.certainty .tag[data-k="SPECULATION"]{ color: rgba(156,147,184,0.65); border-style: dashed; }
.certainty p{ margin: 0; color: #D9D3EC; font-size: 0.92rem; line-height: 1.6; }
@media (max-width: 460px){
  .certainty li{ grid-template-columns: 1fr; gap: 0.45rem; }
  .certainty .tag{ justify-self: start; padding: 0.3rem 0.55rem; }
}

.related{ display: flex; flex-direction: column; gap: 0.5rem; }
.rel-item{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--hairline-strong);
  border-radius: 2px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0.7rem 0.85rem;
  min-height: 3rem;
  transition: border-color .15s ease, background .15s ease;
}
.rel-item:hover{ border-left-color: var(--trace); background: rgba(241,238,251,0.04); }
.rel-item .rl-title{ font-size: 0.92rem; }
.rel-item .rl-id{
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--ash);
  white-space: nowrap;
}

.sources{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.sources li{
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.6;
  color: var(--ash);
  padding-left: 0.85rem;
  border-left: 1px solid var(--hairline);
}
.sources a{ color: var(--paper); text-decoration: none; border-bottom: 1px solid var(--hairline-strong); }
.sources a:hover{ color: var(--trace); border-color: var(--trace); }
.sources-note{
  font-family: var(--font-mono);
  font-size: 0.58rem;
  line-height: 1.65;
  letter-spacing: 0.04em;
  color: rgba(156,147,184,0.6);
  margin: 1rem 0 0;
}

.rec-foot{
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.rec-foot .obs-btn{ flex: 1 1 12rem; }

/* ---------- the anomaly reads differently ---------- */
/* Both edges, because the sheet shows its top border on a phone and its
   left border on a wide screen. */
.record.anomaly{ border-left-color: var(--violet); border-top-color: var(--violet); }
.record.anomaly .rec-desig{ color: var(--violet); }
.record.anomaly .rec-title{ letter-spacing: 0.2em; }
.record.anomaly .rec-body p{
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  line-height: 1.9;
  color: var(--ash);
}
.anomaly-plate{
  margin-top: 2rem;
  border: 1px dashed rgba(124,77,255,0.4);
  padding: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1.85;
  letter-spacing: 0.08em;
  color: var(--ash);
}
.anomaly-plate .lead{ color: var(--violet); letter-spacing: 0.2em; text-transform: uppercase; display: block; margin-bottom: 0.7rem; }
.anomaly-plate .redacted{
  background: rgba(156,147,184,0.22);
  color: transparent;
  user-select: none;
  border-radius: 1px;
}

/* On a wide screen the record takes the right edge, so the floating chrome
   steps aside rather than hiding under it. --rec-w mirrors .record's width. */
@media (min-width: 861px){
  :root{ --rec-w: min(36rem, 46vw); }
  /* The record carries its own Return and Observe buttons, so the floating
     pair would only duplicate them — and collide with the telemetry. */
  body[data-view="record"] .actions{ display: none; }
  body[data-view="category"] .actions{
    left: calc((100vw - 21rem - clamp(1.1rem, 3vw, 2.2rem)) / 2 + 21rem);
  }
  body[data-view="record"] .status{
    right: calc(var(--rec-w) + clamp(1.1rem, 3vw, 2.2rem));
  }
}

/* ==========================================================================
   KEYBOARD ROUTE — real controls for people not using a pointer
   ========================================================================== */
.keynav{
  position: fixed;
  z-index: 40;
  left: 0; top: 0;
  width: 1px; height: 1px;
  overflow: hidden;
}
.keynav:focus-within{
  width: auto; height: auto;
  max-width: min(24rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  margin: 0.6rem;
  padding: 0.9rem;
  background: var(--glass-solid);
  border: 1px solid var(--trace);
}
.keynav h2{
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--trace);
  font-weight: 400;
  margin-bottom: 0.6rem;
}
.keynav ul{ list-style: none; margin: 0; padding: 0; }
.keynav button{
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  padding: 0.6rem 0.2rem;
  min-height: 2.6rem;
  cursor: pointer;
}
.keynav button:hover{ color: var(--trace); }

/* ==========================================================================
   MOBILE — panels become sheets, not shrunken desktop furniture
   ========================================================================== */
@media (max-width: 860px), (pointer: coarse) and (max-width: 1100px){
  .status{
    left: 0; right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-top: 2px solid var(--trace);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .status-body{ max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; }
  .status > summary{ padding: 0.7rem var(--pad); min-height: 2.9rem; }
  .status-body{ padding: 0.5rem var(--pad) 0.9rem; }
  .status-row{ padding: 0.42rem 0; font-size: 0.68rem; }

  .readout{
    right: var(--pad);
    left: var(--pad);
    bottom: calc(3.2rem + env(safe-area-inset-bottom));
    align-items: flex-end;
    gap: 0.4rem;
  }
  .coords{ font-size: 0.58rem; }
  .syslog{ font-size: 0.56rem; }

  .actions{
    left: var(--pad);
    right: var(--pad);
    transform: none;
    bottom: calc(6.1rem + env(safe-area-inset-bottom));
    justify-content: center;
  }
  .obs-btn{ flex: 1 1 auto; max-width: 22rem; }

  /* both panels become bottom sheets */
  .catalog, .record{
    left: 0; right: 0; bottom: 0;
    top: auto;
    width: auto;
    max-height: none;
    height: auto;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  .catalog{
    max-height: 62vh;
    border-top: 2px solid var(--trace);
  }
  .record{
    top: var(--sheet-top);
    border-top: 2px solid var(--signal);
  }
  .record .panel-head{ padding-top: 1rem; }
  .record-inner{ padding: 0 var(--pad) 2.6rem; }
  .rec-title{ font-size: 1.75rem; }
  .rec-why p{ font-size: 1rem; }

  /* the sheet owns the bottom of the screen while it is open */
  body[data-panel="1"] .actions,
  body[data-panel="1"] .readout,
  body[data-panel="1"] .status{ display: none; }
}

/* very small phones */
@media (max-width: 360px){
  :root{ --pad: 0.85rem; }
  .plate h1{ font-size: 1.35rem; }
  .obs-nav{ padding: 0 var(--pad); }
}

/* short landscape phones: the sheet takes the side instead of the bottom */
@media (max-height: 460px) and (orientation: landscape){
  :root{ --sheet-top: 0; }
  .record{
    top: 0; left: auto;
    width: min(28rem, 62vw);
    border-top: 0;
    border-left: 2px solid var(--signal);
  }
  .catalog{
    top: 0; bottom: 0; right: auto;
    width: min(20rem, 55vw);
    max-height: none;
    border-top: 0;
    border-left: 2px solid var(--trace);
  }
  .plate{ top: calc(var(--bar-h) + 0.2rem); }
  .plate .sub, .plate .hint{ margin-top: 0.4rem; }

  /* These sheets reach the top of the screen, so their headers have to clear
     the fixed bar — and the bar drops to a single way out, as it does on a
     narrow phone, rather than sitting on top of an open record. */
  .record .panel-head, .catalog .panel-head{ padding-top: calc(var(--bar-h) + 0.3rem); }
  .navlinks li:not(.nav-exit){ display: none; }
  .navlinks .nav-exit{ display: block; }
  .navlinks .nav-exit a{ color: var(--ash); }
}

/* ==========================================================================
   MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce){
  .glass::before{ animation: none; }
  .status > summary .lamp{ animation: none; }
  .panel, .plate, .syslog{ transition: none; }
  *{ scroll-behavior: auto; }
}
