/* Hatchery Hollow — "Bioluminescent Terrarium".
   Re-skin onto the LIVE markup (templates.py / admin.py). The look is translated from
   the approved mockup (mockups/terrarium.html) onto the real selectors the app emits —
   the DOM is fixed, only this stylesheet changes.

   Palette + bright text tints are lifted verbatim from the mockup (they clear WCAG AA
   ~8.9:1 on the near-black abyss). Stellar tokens (tokens.css) stay linked for radii/sizing
   fallbacks but the terrarium colour system below drives the look.

   Motion is deliberately minimal — every player action re-morphs all of #app, so entrance
   animations would replay on each click. Allowed: body atmosphere drift, the Breed-button
   bloom pulse, the egg wobble, and hover. All respect prefers-reduced-motion. */

:root {
  /* --- terrarium palette (from the mockup) --- */
  --abyss:   #07120f;
  --abyss2:  #0a1622;
  --cyan:    #3fe9d0;
  --jade:    #6bf09a;
  --violet:  #c08bff;
  --amber:   #ffc35a;
  --magenta: #ff7ad9;
  --glass-edge: rgba(150,235,220,.55);

  /* text tints pushed bright for AA on near-black */
  --ink:   #eaf6f2;   /* body */
  --ink-2: #c4dbd4;   /* secondary */
  --ink-3: #9fbfb7;   /* tertiary / labels */
  --muted: var(--ink-3);

  --line:      rgba(120,200,185,.16);
  --line-soft: rgba(120,200,185,.10);
  --line-glow: rgba(150,235,220,.34);

  --radius:    18px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --pill: 999px;

  --panel-grad: linear-gradient(180deg, rgba(16,34,30,.74), rgba(7,17,15,.74));
  --jar-grad:
    radial-gradient(120% 62% at 50% 0%, rgba(40,80,72,.40), transparent 62%),
    linear-gradient(180deg, rgba(12,28,24,.92), rgba(6,15,13,.94));

  --shadow-card: 0 18px 40px -26px rgba(0,0,0,.95), inset 0 1px 0 rgba(170,255,238,.05);
  --shadow-panel: 0 24px 60px -30px rgba(0,0,0,.9), inset 0 1px 0 rgba(160,255,235,.06);
  --shadow-lift: 0 22px 48px -22px rgba(0,0,0,.95), 0 0 30px -6px rgba(70,240,205,.30), inset 0 1px 0 rgba(170,255,238,.08);

  --ease: cubic-bezier(.4,0,.2,1);
  --t-fast: 150ms;

  --head: "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
  --body: "Spline Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* =========================================================================
   AMBIENT ATMOSPHERE — pure CSS, no markup.
   body = deep abyssal gradient. ::before = drifting glowing spores (multiple
   radial dots that float upward). ::after = swaying god-rays.
   ========================================================================= */
body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(70,230,200,.18), transparent 55%),
    radial-gradient(90% 60% at 12% 8%, rgba(120,90,255,.13), transparent 60%),
    radial-gradient(80% 70% at 92% 16%, rgba(255,140,210,.09), transparent 60%),
    radial-gradient(140% 120% at 50% 120%, rgba(10,40,34,.9), transparent 70%),
    linear-gradient(180deg, #07120f 0%, #081a16 42%, #06100d 100%);
  background-attachment: fixed;
}

/* god-rays: soft conic shafts raining from above, gently swaying */
body::before {
  content: "";
  position: fixed;
  left: 0; right: 0; top: -20%;
  height: 95%;
  z-index: 0;
  pointer-events: none;
  background:
    conic-gradient(from 200deg at 50% -20%,
      transparent 0deg, rgba(110,240,210,.10) 18deg, transparent 36deg,
      transparent 60deg, rgba(150,120,255,.08) 80deg, transparent 100deg);
  filter: blur(6px);
  opacity: .7;
  animation: rays-sway 22s ease-in-out infinite alternate;
}

/* drifting glowing spores: a field of soft luminous dots that slowly rise.
   Built from layered radial-gradients on one fixed plane animated upward. */
body::after {
  content: "";
  position: fixed;
  inset: -20% 0 -20% 0;
  z-index: 0;
  pointer-events: none;
  background-repeat: repeat;
  background-image:
    radial-gradient(2px 2px at 8% 30%,  rgba(120,248,222,.9), transparent 60%),
    radial-gradient(2px 2px at 22% 70%, rgba(155,240,191,.85), transparent 60%),
    radial-gradient(3px 3px at 38% 20%, rgba(120,248,222,.8), transparent 60%),
    radial-gradient(2px 2px at 52% 55%, rgba(199,155,255,.8), transparent 60%),
    radial-gradient(2px 2px at 66% 35%, rgba(120,248,222,.85), transparent 60%),
    radial-gradient(3px 3px at 78% 80%, rgba(255,206,114,.75), transparent 60%),
    radial-gradient(2px 2px at 90% 25%, rgba(120,248,222,.85), transparent 60%),
    radial-gradient(2px 2px at 95% 62%, rgba(255,150,220,.7), transparent 60%);
  background-size: 100% 60vh;
  opacity: .85;
  animation: spores-drift 34s linear infinite;
}

@keyframes rays-sway {
  from { transform: translateX(-3%) rotate(-1deg); }
  to   { transform: translateX(3%)  rotate(1deg); }
}
@keyframes spores-drift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  to   { background-position: 0 -60vh, 10px -60vh, -8px -60vh, 6px -60vh, -10px -60vh, 4px -60vh, -6px -60vh, 8px -60vh; }
}

h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* =========================================================================
   TOP BAR
   ========================================================================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(180deg, rgba(8,20,17,.86), rgba(8,20,17,.62));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar h1 {
  margin: 0;
  font-family: var(--head);
  font-weight: 700;
  letter-spacing: .05em;
  font-size: clamp(1.4rem, 1.05rem + 1.4vw, 1.9rem);
  color: #eafff9;
  text-shadow: 0 0 18px rgba(70,240,205,.55), 0 0 2px rgba(70,240,205,.6);
}
.admin-link {
  font-family: var(--head);
  color: var(--ink-2); text-decoration: none;
  font-size: .8rem; letter-spacing: .14em; text-transform: uppercase;
  padding: 8px 16px; border-radius: var(--pill);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20,44,38,.6), rgba(8,20,17,.6));
  box-shadow: inset 0 1px 0 rgba(180,255,240,.08);
  transition: color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.admin-link:hover, .admin-link:focus-visible {
  color: #eafff9; border-color: var(--line-glow);
  box-shadow: inset 0 1px 0 rgba(180,255,240,.12), 0 0 16px rgba(70,240,205,.2);
}

main, body.admin {
  position: relative; z-index: 1;
  padding: 28px 28px 70px;
  max-width: 2200px; margin: 0 auto;
}

/* =========================================================================
   LAYOUT — "workspace" 3-zone grid: breeding flow | collection gallery | sidebar.
   The collection sits BESIDE the breed controls so you pick parents without a
   vertical scroll round-trip. Collapses to flow-over-collection (≤1280px), then
   a single column (≤900px).
   ========================================================================= */
.layout {
  display: grid;
  grid-template-columns: minmax(600px, 680px) minmax(0, 1fr) 332px;
  grid-template-areas: "flow collection sidebar";
  gap: 26px; align-items: start;
}
.main-col { grid-area: flow; min-width: 0; display: flex; flex-direction: column; gap: 26px; }
#collection { grid-area: collection; min-width: 0; }
.sidebar { grid-area: sidebar; position: sticky; top: 22px; display: flex; flex-direction: column; gap: 26px;
  max-height: calc(100vh - 44px); overflow-y: auto; scrollbar-width: thin;
  scrollbar-color: var(--line-glow) transparent; }
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-glow); border-radius: 4px; }
.sidebar section { margin: 0; }

/* Small laptop / tablet: the gallery can't keep its own column — drop it under
   the flow, keep the sidebar in its right column spanning both rows. */
@media (max-width: 1280px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 332px;
    grid-template-areas:
      "flow       sidebar"
      "collection sidebar";
  }
}
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: "flow" "collection" "sidebar";
  }
  .sidebar { position: static; max-height: none; overflow: visible; }
}

/* =========================================================================
   PANELS — each section is a glass terrarium panel
   ========================================================================= */
section {
  position: relative;
  margin: 0;
  border-radius: var(--radius-lg);
  background: var(--panel-grad);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(3px);
  padding: 20px 22px 24px;
}
h2 {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  font-family: var(--head); font-weight: 600; letter-spacing: .05em;
  font-size: 1.28rem; margin: 0 0 16px;
  color: #dffaf2;
  text-shadow: 0 0 14px rgba(70,240,205,.30);
}
.sub { font-family: var(--body); color: var(--ink-3); font-weight: 400; font-size: .9rem; letter-spacing: .02em; }
.hint { color: var(--ink-2); font-size: .92rem; line-height: 1.55; max-width: 62ch; }

.row { display: flex; gap: 18px; align-items: stretch; flex-wrap: wrap; }
.row.wrap, .litter-row { flex-wrap: wrap; }

/* COLLECTION fills the full main column: a responsive grid so cards spread
   edge-to-edge instead of clumping to the left. The grid cell sizes the card
   (override the global 174px width). */
#collection .row.wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
#collection .row.wrap > .card { width: auto; min-width: 0; }

/* PARENTS + LITTER: portrait cards sitting side by side, capped so they don't
   balloon to fill an empty row. */
#parents .row > .card,
.litter-row > .card {
  flex: 0 1 300px;
  max-width: 320px;
}

/* Narrow phones: parents/litter cards fill the width; compact collection tiles
   shrink so 2-3 still flow per row instead of one big single column. (Placed
   AFTER the base #collection / #parents rules so it wins on source order.) */
@media (max-width: 560px) {
  #collection .row.wrap { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
  #parents .row > .card,
  .litter-row > .card { flex: 1 1 100%; max-width: none; }
}

/* =========================================================================
   CREATURE CARD = GLASS JAR / VIVARIUM
   The card itself is the jar. ::before = curved specular highlights on the
   glass. ::after = a soft luminous substrate mound at the base. The pixel
   sprite sits inside with a colored bioluminescent halo behind it.
   (img elements can't host ::before/::after, so all generated chrome lives
   on .card; the sprite gets its glow via background + box-shadow.)
   ========================================================================= */
.card {
  --halo: rgba(70,240,205,.40);   /* default cyan/teal bioluminescence */
  --jar-edge: var(--line);
  position: relative;
  width: 174px;
  padding: 14px 14px 16px;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius);
  background: var(--jar-grad);
  border: 1px solid var(--jar-edge);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast),
              box-shadow var(--t-fast);
}

/* ---------------------------------------------------------------------------
   PORTRAIT TRADING CARD (creatures only — NOT egg pods, which keep the
   centered vertical look further down). "Proposal 2 · Collectible trading
   card": the fixed flat-sibling DOM already flows top-to-bottom as the card
   zones — hero sprite window → name banner → rarity → traits → 2×2 stat grid →
   care meters → demoted footer. So we just lay it out as a single-column flow
   (no grid placement needed) and style each zone. Width comes from the grid
   cell / flex basis; the card fills it.
   --------------------------------------------------------------------------- */
.card:not(.egg) {
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 14px 16px 16px;
  text-align: left;
}
/* HERO SPECIMEN WINDOW — the glass jar at the top, sprite centered inside with
   its bioluminescent halo. A rarity corner accent sits at the top-right via
   ::before on the sprite's host card (see below). */
.card:not(.egg) > .sprite {
  align-self: stretch;
  width: auto;
  height: 176px;
  margin: 0 0 12px;
  padding: 14px;
  display: block;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-glow);
  background:
    radial-gradient(120% 120% at 50% 30%, var(--halo), transparent 68%),
    linear-gradient(180deg, rgba(10,28,30,.95), rgba(6,16,18,.96));
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.4),
    0 10px 30px -16px rgba(70,240,205,.5);
}
/* curved specular streaks on the glass */
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(60% 90% at 26% 8%, rgba(220,255,248,.16), transparent 42%),
    radial-gradient(40% 70% at 82% 10%, rgba(200,255,246,.10), transparent 50%);
  z-index: 2;
}
/* luminous substrate mound at the jar floor */
.card::after {
  content: "";
  position: absolute; left: 8%; right: 8%; bottom: 0; height: 40px;
  border-radius: 50% 50% 0 0;
  pointer-events: none;
  background:
    radial-gradient(80% 120% at 50% 100%, var(--halo), transparent 70%),
    linear-gradient(180deg, rgba(50,120,105,.32), rgba(10,32,26,.65));
  opacity: .8;
  z-index: 0;
}
/* portrait cards: the hero window IS the jar now, so kill the card-floor
   substrate mound (it would glow under the footer). */
.card:not(.egg)::after { content: none; }
/* portrait cards keep a single soft glass specular at the top-left (the
   landscape card's second streak read oddly on the taller portrait form). The
   rarity itself is communicated by the pill under the name banner. */
.card:not(.egg)::before {
  background:
    radial-gradient(60% 90% at 26% 8%, rgba(220,255,248,.14), transparent 42%);
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--line-glow);
  box-shadow: var(--shadow-lift);
}
.card.selected {
  --jar-edge: rgba(70,240,205,.65);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(70,240,205,.45),
              0 0 26px -4px rgba(70,240,205,.45);
}
/* relatedness ring (inbreeding cue) */
.card.rel-safe  { --jar-edge: rgba(107,240,154,.6); }
.card.rel-near  { --jar-edge: rgba(255,195,90,.6); }
.card.rel-close { --jar-edge: rgba(255,122,168,.65); }
/* shiny: iridescent magenta halo + frame */
.card.shiny {
  --halo: rgba(255,122,217,.45);
  --jar-edge: rgba(255,122,217,.5);
}
.card.shiny .sprite { box-shadow: 0 0 26px -2px rgba(255,122,217,.55); }

/* the pixel sprite, glowing inside the jar */
.sprite {
  position: relative;
  z-index: 1;
  width: 112px; height: 112px;
  image-rendering: pixelated;
  /* generous rounding (not a full circle) so a winged/horned sprite's corner
     pixels never get clipped; the radial halo still reads as bioluminescence */
  border-radius: var(--radius-sm);
  padding: 6px;
  background: radial-gradient(closest-side, var(--halo), transparent 82%);
  box-shadow: 0 0 24px -4px var(--halo);
}

.name {
  position: relative; z-index: 1;
  font-family: var(--head); font-weight: 600; letter-spacing: .03em;
  font-size: 1.04rem; margin-top: 9px; color: #ecfbf6;
}
/* landscape header: bigger, top-flush name (egg cards keep the base above) */
.card:not(.egg) > .name {
  font-size: 1.12rem; line-height: 1.2; margin-top: 0;
}

/* primary facts read clearly; dense genetics demoted to quiet footer */
.traits {
  position: relative; z-index: 1;
  font-size: .9rem; color: var(--ink-2); margin-top: 5px;
  text-transform: capitalize; letter-spacing: .01em;
}
.traits b { color: var(--ink); font-weight: 500; }

/* STAT CHIPS — a 2×2 grid of big-number chips (the centrepiece of the
   trading card). Each `.stat` chip is `.stat-k` (small label) + `.stat-v`
   (big number, e.g. "3" or trained "3+2"). */
.stats {
  position: relative; z-index: 1;
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(70,240,205,.05);
  border: 1px solid var(--line);
}
.stat-k {
  font-family: var(--head); font-weight: 600;
  font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
}
.stat-v {
  font-family: var(--head); font-weight: 700;
  font-size: 1.3rem; line-height: 1; color: #ecfbf6;
  font-variant-numeric: tabular-nums;
}
.stat.spd .stat-v { color: var(--cyan); }
.carries, .genes, .fertility { position: relative; z-index: 1; font-size: .8rem; margin-top: 5px; }
.carries { color: var(--amber); }
.genes { color: var(--ink-3); font-family: var(--font-mono, ui-monospace, monospace); word-break: break-word; }
.fertility { color: var(--ink-3); }
.fertility.infertile { color: var(--magenta); font-weight: 700; }
.hue-note { color: var(--ink-3); font-size: .76rem; }

/* --- TRADING-CARD ZONES via the flat sibling list (no wrappers) ------------
   The header (name banner → rarity → traits → stats) flows under the hero
   window; the care meters open a zone; the demoted footer (fertility onward)
   sits below a divider. */

/* NAME BANNER — bold, centered, on a faint glass strip. */
.card:not(.egg) > .name {
  font-size: 1.22rem; line-height: 1.1; letter-spacing: .03em;
  text-align: center; margin: 0;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(70,240,205,.10), rgba(70,240,205,.02));
  border: 1px solid var(--line-glow);
}
/* RARITY — centered pill line under the banner. */
.card:not(.egg) > .rarity {
  display: block; width: max-content; max-width: 100%;
  margin: 9px auto 0; text-align: center;
}
.card:not(.egg) > .legendary { text-align: center; margin: 6px 0 0; }
/* TRAITS subtitle — centered. */
.card:not(.egg) > .traits {
  text-align: center; margin-top: 9px;
}
.card:not(.egg) > .appendages { text-align: center; margin-top: 5px; }

/* care meters open a zone with a subtle divider. */
.card:not(.egg) > .care {
  margin-top: 13px; padding-top: 13px;
  border-top: 1px solid var(--line-soft);
}
/* DEMOTED FOOTER — fertility + carries/genes/badges + release, below a divider. */
.card:not(.egg) > .fertility {
  margin-top: 13px; padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
}
.card:not(.egg) > .carries,
.card:not(.egg) > .genes {
  opacity: .85; text-align: center;
}
.card:not(.egg) > .badges { justify-content: center; }
.card:not(.egg) > .release-btn { align-self: center; }
.card:not(.egg) > .care .care-actions,
.card:not(.egg) > .care .train-actions { justify-content: center; }

/* ---------------------------------------------------------------------------
   COMPACT TILE (collection gallery only). A dense projection of the trading
   card: small sprite + name + trimmed rarity pill. Overrides the tall
   .card:not(.egg) hero zones — must sit AFTER them to win on equal specificity.
   --------------------------------------------------------------------------- */
.card.compact {
  width: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 10px 14px;
  text-align: center; gap: 2px;
}
.card.compact > .sprite {
  align-self: center;
  width: 72px; height: 72px;
  margin: 0 0 4px; padding: 6px;
  border: none;
  background: radial-gradient(closest-side, var(--halo), transparent 82%);
  box-shadow: 0 0 20px -4px var(--halo);
}
.card.compact > .name {
  font-size: .92rem; line-height: 1.15; margin: 0;
  padding: 4px 6px; background: none; border: none;
}
.card.compact > .rarity {
  display: block; width: max-content; max-width: 100%;
  margin: 4px auto 0; font-size: .66rem; text-align: center;
}

/* Mode-aware lens strip under the rarity pill. Kept tight so switching lenses
   never reflows the gallery past its density budget (breed/battle = one inline
   line; nurture = 4 hairline bars). */
.card.compact .mini-stats {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline;
  gap: 3px 8px; margin: 5px 2px 0;
  font-family: var(--head); font-size: .64rem; letter-spacing: .03em;
  color: var(--ink-3); line-height: 1.2;
}
.card.compact .mini-stats.ms-battle { gap: 3px 9px; color: var(--ink-2); }
.card.compact .ms-pow { color: #ffce72; font-weight: 600; }
.card.compact .ms-trained { color: var(--amber); font-weight: 600; }  /* trained stat (base+bonus) */
.card.compact .ms-fert.infertile { color: var(--magenta); }
.card.compact .ms-carries {
  width: 100%; color: var(--ink-3); opacity: .85;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card.compact .mini-meters {
  display: flex; flex-direction: column; gap: 3px;
  width: 100%; max-width: 86px; margin: 6px auto 0;
}
.card.compact .mini-meter {
  display: block; height: 3px; border-radius: var(--pill);
  background: rgba(8,22,18,.9); border: 1px solid var(--line); overflow: hidden;
}
.card.compact .mini-fill { display: block; height: 100%; border-radius: var(--pill); }
.card.compact .mm-hunger      .mini-fill { background: linear-gradient(90deg, #c98a23, #ffce72); }
.card.compact .mm-energy      .mini-fill { background: linear-gradient(90deg, #7d52c9, #c79bff); }
.card.compact .mm-happiness   .mini-fill { background: linear-gradient(90deg, #27a85e, #74f3a0); }
.card.compact .mm-cleanliness .mini-fill { background: linear-gradient(90deg, #1fae98, #54f3d6); }
/* A neglected creature's meters glow magenta to draw the eye (non-gating cue). */
.card.compact.neglected .mini-meter { border-color: rgba(255,90,170,.55); }

.lens-hint {
  margin: -8px 0 12px; font-size: .72rem; color: var(--ink-3);
  font-style: italic; opacity: .85;
}

.release-btn {
  position: relative; z-index: 1;
  margin-top: 11px;
  font-family: var(--head); font-size: .72rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 14px; border-radius: var(--pill);
  border: 1px solid var(--line);
  background: transparent; color: var(--ink-3); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.release-btn:hover, .release-btn:focus-visible { border-color: var(--magenta); color: var(--magenta); }

.badges { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 9px; }
.badge {
  font-family: var(--head); font-size: .7rem; font-weight: 600;
  letter-spacing: .06em;
  padding: 3px 10px; border-radius: var(--pill);
  color: #06241f; background: linear-gradient(180deg, #74f3a0, #34c97e);
  box-shadow: 0 0 12px rgba(116,243,160,.35);
}

/* rarity / legendary / appendage flourishes */
.rarity {
  position: relative; z-index: 1;
  display: inline-block;
  font-family: var(--head); font-size: .72rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  margin: 7px 0 2px; padding: 3px 11px; border-radius: var(--pill);
  border: 1px solid;
}
.tier-common   { color: #bfe9df; border-color: rgba(120,200,185,.4); background: rgba(40,70,64,.4); }
.tier-uncommon { color: #a8f0c0; border-color: rgba(107,240,154,.5); background: rgba(20,60,40,.45); }
.tier-rare     { color: #d7b6ff; border-color: rgba(192,139,255,.55); background: rgba(48,28,72,.5); text-shadow: 0 0 10px rgba(192,139,255,.5); }
.tier-epic     { color: #ff9bdf; border-color: rgba(255,122,217,.55); background: rgba(64,20,52,.5); text-shadow: 0 0 10px rgba(255,122,217,.5); }
.tier-legendary{ color: #ffd98a; border-color: rgba(255,195,90,.6); background: rgba(70,48,14,.5); text-shadow: 0 0 12px rgba(255,195,90,.55); }
.legendary {
  position: relative; z-index: 1;
  font-family: var(--head); font-size: .82rem; font-weight: 700;
  color: #ffe7a6; margin: 3px 0 4px;
  text-shadow: 0 0 12px rgba(255,195,90,.6);
}
.appendages { position: relative; z-index: 1; font-size: .78rem; color: #9fe7d4; margin-top: 4px; }

/* =========================================================================
   BREED / BATTLE CTAs — glowing glass pills
   ========================================================================= */
.parent-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 20px; }
.breed-btn, .battle-btn, .stance-btn, .explore-btn {
  font-family: var(--head); font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  border: none; cursor: pointer; border-radius: var(--pill);
  transition: transform var(--t-fast), filter var(--t-fast), box-shadow var(--t-fast);
}
.breed-btn {
  flex: 1; min-width: 200px;
  font-size: 1rem;
  padding: 14px 26px;
  color: #02201a;
  background: linear-gradient(180deg, #67f7d6, #27c9a8);
  box-shadow: 0 0 0 1px rgba(160,255,240,.5) inset,
              0 10px 30px -8px rgba(50,230,195,.6), 0 0 28px rgba(70,240,205,.35);
  animation: breed-bloom 3.4s ease-in-out infinite;
}
.breed-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.breed-btn:active { transform: translateY(0); }
@keyframes breed-bloom {
  0%, 100% { box-shadow: 0 0 0 1px rgba(160,255,240,.5) inset, 0 10px 30px -8px rgba(50,230,195,.5), 0 0 22px rgba(70,240,205,.30); }
  50%      { box-shadow: 0 0 0 1px rgba(200,255,248,.7) inset, 0 14px 38px -8px rgba(70,240,205,.75), 0 0 40px rgba(70,240,205,.55); }
}
.battle-btn {
  font-size: 1rem;
  padding: 14px 26px;
  color: #f3e7ff;
  background: linear-gradient(180deg, rgba(80,52,128,.85), rgba(40,24,64,.85));
  box-shadow: 0 0 0 1px rgba(199,155,255,.4) inset, 0 0 20px rgba(160,90,255,.2);
}
.battle-btn:hover { transform: translateY(-2px); filter: brightness(1.12); box-shadow: 0 0 0 1px rgba(199,155,255,.6) inset, 0 0 28px rgba(160,90,255,.35); }
.breed-btn:focus-visible, .battle-btn:focus-visible, .explore-btn:focus-visible,
.stance-btn:focus-visible, .ghost-btn:focus-visible {
  outline: 3px solid rgba(180,255,240,.7); outline-offset: 2px;
}
.spinner { margin-left: 10px; color: var(--cyan); font-family: var(--head); font-weight: 600; }

/* =========================================================================
   BATTLE
   ========================================================================= */
#battle { border-color: rgba(160,90,255,.34); }
.battle-hp { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-family: var(--head); font-weight: 600; }
.battle-hp .you { color: var(--jade); }
.battle-hp .ghost { color: #c79bff; }
.battle-hp .vs { color: var(--ink-3); font-weight: 400; }
.battle-log {
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: .85rem; line-height: 1.6;
  background: rgba(6,15,13,.82); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px; max-height: 320px; overflow-y: auto;
}
.battle-log .log-line { color: var(--ink-2); }
.battle-log .log-line:first-child, .battle-log .log-line:last-child { color: #eafff9; font-weight: 700; }
.battle-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.stance-btn {
  font-size: .92rem;
  padding: 11px 22px;
  color: #f3e7ff;
  background: linear-gradient(180deg, rgba(125,82,201,.9), rgba(58,37,102,.9));
  box-shadow: 0 0 0 1px rgba(199,155,255,.4) inset;
}
.stance-btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.ghost-btn {
  font-family: var(--head); letter-spacing: .06em;
  background: transparent; color: var(--ink-3);
  border: 1.5px dashed var(--line); border-radius: var(--pill);
  padding: 10px 20px; cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.ghost-btn:hover { color: var(--ink); border-color: var(--violet); }

/* =========================================================================
   NEST / GESTATING EGG-PODS
   ========================================================================= */
#nest { border-color: rgba(107,240,154,.3); }
.card.egg {
  --halo: rgba(107,240,154,.4);
  cursor: default;
  border-style: solid;
  border-color: rgba(107,240,154,.4);
}
.card.egg:hover { transform: none; box-shadow: var(--shadow-card); }
.egg-sprite {
  position: relative; z-index: 1;
  width: 112px; height: 112px; line-height: 112px;
  margin: 0 auto;
  font-size: 70px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(107,240,154,.4), transparent 78%);
  box-shadow: 0 0 26px -2px rgba(107,240,154,.5);
  animation: egg-wobble 2.4s ease-in-out infinite;
}
.hatch-countdown {
  position: relative; z-index: 1;
  display: inline-block; margin-top: 9px;
  font-family: var(--head); font-size: .82rem; letter-spacing: .04em;
  color: #bdf3e6; font-weight: 600;
  padding: 5px 13px; border-radius: var(--pill);
  border: 1px solid rgba(107,240,154,.35);
  background: rgba(16,46,34,.55);
}
@keyframes egg-wobble { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

/* =========================================================================
   DISCOVERIES — caught wild creatures (sidebar)
   ========================================================================= */
#discoveries { border-color: rgba(107,240,154,.3); }
#discoveries .row { flex-wrap: wrap; }
.discovery { display: flex; flex-direction: column; align-items: center; width: 100%; }
.discovery .card {
  --halo: rgba(107,240,154,.4);
  width: 100%;
  border-color: rgba(107,240,154,.4);
}
/* The 332px sidebar leaves ~290px usable — the portrait trading card fits at
   width:100% (it's already a centered flex column), so it needs no special
   re-layout here. Just ensure it fills the sidebar width. */
.discovery .card:not(.egg) { width: 100%; }
.origin-tag {
  font-family: var(--head); font-size: .72rem; font-weight: 600;
  letter-spacing: .06em;
  color: #a8f0c0;
  background: rgba(20,60,40,.5);
  border: 1px solid rgba(107,240,154,.35);
  border-radius: var(--pill); padding: 4px 13px; margin-bottom: 9px;
}
.region-hint { font-size: .82rem; color: var(--ink-2); margin-top: 9px; line-height: 1.5; }
.region-hint code, .region-list code {
  font-family: var(--font-mono, ui-monospace, monospace); color: var(--amber);
  background: rgba(60,40,14,.5); padding: 0 5px; border-radius: 5px;
}

/* =========================================================================
   EXPLORE THE WILD (sidebar hero)
   ========================================================================= */
#world {
  border: 1px solid rgba(255,195,90,.26);
  background:
    radial-gradient(90% 60% at 80% 0%, rgba(255,195,90,.12), transparent 60%),
    var(--panel-grad);
}
.region-list {
  list-style: none; margin: 14px 0; padding: 0;
  display: grid; gap: 9px;
  font-size: .86rem; color: var(--ink-2); line-height: 1.5;
}
.region-list li {
  padding: 11px 13px; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(18,38,34,.6), rgba(8,18,16,.6));
  border: 1px solid var(--line);
}
.region-list .region-name { font-family: var(--head); color: #ffd98a; font-weight: 600; letter-spacing: .02em; }
.explore-btn {
  width: 100%;
  font-size: 1rem;
  padding: 14px 22px;
  color: #241400;
  background: linear-gradient(180deg, #ffd277, #f0a93a);
  box-shadow: 0 0 0 1px rgba(255,225,170,.55) inset,
              0 10px 26px -8px rgba(255,180,70,.55), 0 0 24px rgba(255,180,70,.3);
}
.explore-btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.05); }
.explore-btn:disabled { filter: grayscale(.45) brightness(.7); cursor: not-allowed; box-shadow: none; }

/* =========================================================================
   STATUS BANNER ("Lab log" feel)
   ========================================================================= */
.status {
  position: relative;
  background: linear-gradient(180deg, rgba(16,46,34,.7), rgba(8,20,17,.7));
  border: 1px solid rgba(107,240,154,.3);
  border-left: 3px solid var(--jade);
  padding: 12px 18px; border-radius: var(--radius-sm);
  color: var(--ink); font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(170,255,238,.06), 0 0 22px -8px rgba(107,240,154,.4);
}

/* =========================================================================
   COLLECTION CONTROLS (sort / filter chips)
   ========================================================================= */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 14px; }
.ctl-label { font-family: var(--head); font-size: .72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .14em; margin-right: 2px; }
.chip {
  font-family: var(--head); font-size: .76rem; letter-spacing: .06em;
  color: var(--ink-2);
  background: linear-gradient(180deg, rgba(20,44,38,.6), rgba(8,20,17,.6));
  border: 1px solid var(--line); border-radius: var(--pill);
  padding: 5px 14px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(180,255,240,.06);
  transition: color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.chip:hover { color: #eafff9; border-color: var(--line-glow); }
.chip.on {
  color: #02201a; font-weight: 600;
  background: linear-gradient(180deg, #67f7d6, #27c9a8);
  border-color: rgba(160,255,240,.6);
  box-shadow: 0 0 16px -2px rgba(70,240,205,.45);
}

/* =========================================================================
   NURTURE — care meters + collapsible actions
   .care-panel visibility is owned by Datastar data-show (toggles inline
   display). DO NOT set `display` here, or it overrides the framework.
   ========================================================================= */
.care { position: relative; z-index: 1; margin-top: 11px; display: flex; flex-direction: column; gap: 6px; }
.meter { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: var(--ink-3); }
.meter-label { width: 50px; text-align: right; flex: none; letter-spacing: .02em; }
.meter-track {
  flex: 1; height: 7px; border-radius: var(--pill);
  background: rgba(8,22,18,.9); border: 1px solid var(--line);
  overflow: hidden;
}
.meter-fill { display: block; height: 100%; border-radius: var(--pill); transition: width .25s var(--ease); }
.meter-hunger      .meter-fill { background: linear-gradient(90deg, #c98a23, #ffce72); box-shadow: 0 0 8px rgba(255,206,114,.55); }
.meter-cleanliness .meter-fill { background: linear-gradient(90deg, #1fae98, #54f3d6); box-shadow: 0 0 8px rgba(84,243,214,.6); }
.meter-happiness   .meter-fill { background: linear-gradient(90deg, #27a85e, #74f3a0); box-shadow: 0 0 8px rgba(116,243,160,.55); }
.meter-energy      .meter-fill { background: linear-gradient(90deg, #7d52c9, #c79bff); box-shadow: 0 0 8px rgba(199,155,255,.5); }

.care-toggle-wrap { position: relative; z-index: 1; margin-top: 9px; }
.care-toggle {
  width: 100%;
  font-family: var(--head); font-size: .74rem; font-weight: 600; letter-spacing: .08em;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--pill);
  background: linear-gradient(180deg, rgba(20,44,38,.6), rgba(8,20,17,.6));
  color: var(--ink-2); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.care-toggle:hover, .care-toggle:focus-visible { color: #eafff9; border-color: rgba(107,240,154,.5); }
/* no `display` here — data-show owns the panel's visibility */
.care-panel { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line-soft); }
.care-actions, .train-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.train-actions { margin-top: 6px; }
.care-btn, .train-btn {
  font-family: var(--head); font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--pill);
  background: transparent; color: var(--ink-2); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.care-btn:hover, .care-btn:focus-visible { border-color: var(--jade); color: var(--jade); }
.train-btn:hover, .train-btn:focus-visible { border-color: var(--amber); color: var(--amber); }

/* Nurture mode: care actions pulled OUT of the card into the left panel, so they
   are the primary (always-visible) action rather than a per-card toggle. */
.care-actions-panel { margin-top: 14px; }
.care-actions-panel .train-actions { margin-top: 8px; }
.care-actions-panel .care-cost-hint {
  margin: 10px 0 0; font-size: .72rem; color: var(--ink-3); text-align: center; opacity: .85;
}
.care-cost-hint { font-size: .74rem; color: var(--ink-3); margin: 9px 0 0; line-height: 1.5; }

/* neglected: dim the jar; the cached PNG can't change, so this is a pure CSS cue */
.card.neglected { opacity: .82; }
.card.neglected .sprite { filter: grayscale(.45) brightness(.9); }

/* =========================================================================
   ADMIN (local tool — keep usable, terrarium-tinted)
   ========================================================================= */
body.admin section {
  background: var(--panel-grad);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 20px 22px 24px;
  margin-bottom: 22px;
}
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.inline-form label, .locus span { display: flex; flex-direction: column; font-size: .82rem; color: var(--ink-3); gap: 5px; }
.inline-form input, .inline-form select, .locus select {
  background: rgba(6,15,13,.85); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.inline-form input:focus, .inline-form select:focus, .locus select:focus {
  outline: 2px solid rgba(70,240,205,.6); outline-offset: 1px; border-color: var(--cyan);
}
.inline-form button, form button {
  font-family: var(--head); font-weight: 600; letter-spacing: .06em;
  color: #02201a;
  background: linear-gradient(180deg, #67f7d6, #27c9a8); border: none;
  border-radius: var(--radius-sm); padding: 9px 18px; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(160,255,240,.4) inset;
  transition: filter var(--t-fast);
}
.inline-form button:hover, form button:hover { filter: brightness(1.08); }
.locus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.locus { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--ink-3); }
.locus select { display: inline-block; width: 48%; }
.caps { list-style: none; padding: 0; margin: 0; font-size: .9rem; line-height: 1.85; color: var(--ink-2); }
.caps b { color: var(--amber); }
table.codex { width: 100%; border-collapse: collapse; font-size: .82rem; color: var(--ink-2); }
table.codex th, table.codex td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
table.codex th { color: var(--ink-3); font-weight: 600; }
table.codex td:first-child { font-family: var(--font-mono, ui-monospace, monospace); color: var(--amber); }

/* =========================================================================
   REDUCED MOTION
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  .breed-btn { animation: none; }
  .egg-sprite { animation: none; }
  .card { transition: none; }
}

/* =========================================================================
   NEIGHBOURS — players directory + read-only collection (GDD §8 foundation)
   ========================================================================= */
.logo { text-decoration: none; display: inline-flex; align-items: center; }

/* Directory + a single keeper's collection sit in one centred column. */
.page-narrow { max-width: 1080px; margin: 0 auto; display: grid; gap: 22px; }

.back { margin: 0; }
.back a {
  font-family: var(--head); color: var(--ink-2); text-decoration: none;
  font-size: .82rem; letter-spacing: .12em; text-transform: uppercase;
}
.back a:hover, .back a:focus-visible { color: #eafff9; text-shadow: 0 0 12px var(--line-glow); }

.player-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 12px; }
.player-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;  /* lets the rename form drop to its own full-width line */
  padding: 15px 18px; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(18,38,34,.6), rgba(8,18,16,.6));
  border: 1px solid var(--line);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.player-row:hover { border-color: var(--line-glow); box-shadow: 0 0 18px -4px rgba(70,240,205,.28); transform: translateY(-1px); }
.player-link { display: inline-flex; align-items: baseline; gap: 10px; text-decoration: none; }
.player-link .handle {
  font-family: var(--head); font-weight: 600; font-size: 1.08rem; letter-spacing: .03em;
  color: #dffaf2; text-shadow: 0 0 12px rgba(70,240,205,.3);
}
.you-tag {
  font-family: var(--head); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase;
  color: #07120f; background: linear-gradient(180deg, var(--jade), #46c97f);
  padding: 2px 8px; border-radius: var(--pill); vertical-align: middle;
}
.player-stats { font-size: .84rem; color: var(--ink-3); text-align: right; }

/* Inline rename on your own row — name your hatchery (handle stays the stable id). */
.rename { display: flex; gap: 8px; flex: 0 0 100%; margin-top: 4px; }
.rename input {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--body); font-size: .9rem; color: var(--ink);
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: rgba(7,17,15,.6); border: 1px solid var(--line);
}
.rename input:focus-visible { outline: none; border-color: var(--line-glow); box-shadow: 0 0 0 2px rgba(70,240,205,.18); }
.rename button {
  font-family: var(--head); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase;
  color: #07120f; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(180deg, var(--cyan), #2bbfa8);
  box-shadow: 0 0 16px -4px rgba(70,240,205,.5);
  transition: transform var(--t-fast), filter var(--t-fast);
}
.rename button:hover { transform: translateY(-1px); filter: brightness(1.06); }

/* Discovery on the directory: copy-my-link + find-a-keeper (login-less). */
.discovery {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
  margin: 4px 0 14px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: rgba(7,17,15,.5); border: 1px solid rgba(107,240,154,.28);
}
.discovery .share-mine { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.copy-link {
  font-family: var(--head); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  color: #07120f; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(180deg, var(--cyan), #2bbfa8);
  box-shadow: 0 0 16px -4px rgba(70,240,205,.5);
  transition: transform var(--t-fast), filter var(--t-fast);
}
.copy-link:hover { transform: translateY(-1px); filter: brightness(1.06); }
.my-hollow-link { color: #c9ffe6; font-size: .9rem; }
.player-code { font-family: var(--mono, monospace); color: var(--jade, #6bf09a); }
.find-keeper { display: flex; gap: 8px; flex: 1 1 260px; min-width: 0; }
.find-keeper input {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--body); font-size: .9rem; color: var(--ink);
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: rgba(7,17,15,.6); border: 1px solid var(--line);
}
.find-keeper input:focus-visible { outline: none; border-color: var(--line-glow); box-shadow: 0 0 0 2px rgba(70,240,205,.18); }
.find-keeper button {
  font-family: var(--head); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase;
  color: #07120f; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(180deg, var(--cyan), #2bbfa8);
  transition: transform var(--t-fast), filter var(--t-fast);
}
.find-keeper button:hover { transform: translateY(-1px); filter: brightness(1.06); }

/* Read-only collection: the same gallery grid (#collection .row.wrap), no controls. */
#collection.readonly h2 { color: #dffaf2; }

/* Sidebar entry into the directory. */
#community { border-color: rgba(107,240,154,.3); }
.neighbours-link {
  display: inline-block; margin-top: 6px;
  font-family: var(--head); font-size: .92rem; letter-spacing: .02em; text-decoration: none;
  color: #c9ffe6;
  padding: 11px 16px; border-radius: var(--radius-sm); width: 100%; box-sizing: border-box; text-align: center;
  background: linear-gradient(180deg, rgba(24,52,42,.7), rgba(8,20,17,.7));
  border: 1px solid rgba(107,240,154,.4);
  box-shadow: inset 0 1px 0 rgba(180,255,240,.08);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.neighbours-link:hover, .neighbours-link:focus-visible {
  border-color: var(--jade); transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(180,255,240,.12), 0 0 18px -4px rgba(107,240,154,.4);
}
@media (max-width: 720px) {
  .player-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .player-stats { text-align: left; }
}

/* --- Trading (GDD §8) ---------------------------------------------------- */
/* Owner-only "↺ trade" toggle on collection tiles. */
.trade-toggle {
  margin-top: 6px; width: 100%; box-sizing: border-box;
  font-family: var(--head); font-size: .72rem; letter-spacing: .03em;
  padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer;
  color: #bfe9d8; background: rgba(12,28,23,.7);
  border: 1px dashed rgba(107,240,154,.35);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.trade-toggle:hover { border-color: var(--jade); }
.trade-toggle.on {
  color: #06160f; background: linear-gradient(180deg, var(--jade), #57c98a);
  border-style: solid; border-color: var(--jade); font-weight: 700;
}
.trades-link { margin-top: 8px; }
.trade-badge {
  display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px;
  border-radius: 9px; background: #ff7a59; color: #1a0a05;
  font-weight: 700; font-size: .8rem; text-align: center;
}

/* Inbox + detail pages reuse .page-narrow chrome from the directory. */
.page-title { font-family: var(--head); margin: 8px 0 16px; }
.banner { padding: 10px 14px; border-radius: var(--radius-sm); margin: 8px 0; font-weight: 600; }
.banner.ok { background: rgba(107,240,154,.14); border: 1px solid rgba(107,240,154,.5); color: #d6ffe9; }
.banner.error { background: rgba(255,122,89,.14); border: 1px solid rgba(255,122,89,.5); color: #ffd9cd; }

.trade-box { margin: 18px 0; }
.trade-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.trade-row a {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius-sm); text-decoration: none; color: #d8fff0;
  background: linear-gradient(180deg, rgba(24,52,42,.55), rgba(8,20,17,.55));
  border: 1px solid rgba(107,240,154,.3);
}
.trade-row a:hover { border-color: var(--jade); }
.trade-row .who { font-family: var(--head); font-weight: 700; }
.trade-row .bundle { opacity: .8; font-size: .9rem; }

.trade-status { font-family: var(--head); font-size: .78rem; padding: 2px 8px; border-radius: 9px; margin-left: auto; }
.trade-status.s-pending { background: rgba(255,210,107,.18); color: #ffe6a8; }
.trade-status.s-accepted { background: rgba(107,240,154,.2); color: #d6ffe9; }
.trade-status.s-denied, .trade-status.s-voided, .trade-status.s-withdrawn { background: rgba(255,122,89,.16); color: #ffd0c2; }
.trade-status.s-superseded { background: rgba(160,170,200,.16); color: #d6dcf0; }

/* Detail: bundles, composer, chat. */
.trade-bundles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.bundle-box { padding: 12px; border-radius: var(--radius-sm); border: 1px solid rgba(107,240,154,.25); background: rgba(10,24,20,.5); }
.trade-creature-row, .pick-row { display: flex; flex-wrap: wrap; gap: 10px; }
.trade-creature { display: flex; flex-direction: column; align-items: center; width: 76px; font-size: .72rem; text-align: center; }
.trade-creature .sprite { image-rendering: pixelated; border-radius: 6px; }

.trade-actions { display: flex; gap: 10px; margin: 12px 0; }
.trade-actions button { font-family: var(--head); padding: 10px 18px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.trade-actions .accept { background: linear-gradient(180deg, var(--jade), #57c98a); color: #06160f; font-weight: 700; }
.trade-actions .deny { background: rgba(255,122,89,.16); color: #ffd0c2; border-color: rgba(255,122,89,.5); }

.offer-composer { margin: 16px 0; padding: 14px; border-radius: var(--radius-sm); border: 1px solid rgba(107,240,154,.3); background: rgba(10,24,20,.5); }
.offer-composer fieldset { border: 1px solid rgba(107,240,154,.2); border-radius: var(--radius-sm); margin: 10px 0; }
.offer-composer legend { font-family: var(--head); font-size: .85rem; padding: 0 6px; }
.offer-composer textarea, .msg-form input { width: 100%; box-sizing: border-box; padding: 8px; border-radius: var(--radius-sm); background: rgba(6,16,13,.7); color: #e6fff4; border: 1px solid rgba(107,240,154,.3); }
.offer-composer button, .msg-form button { margin-top: 8px; font-family: var(--head); padding: 9px 18px; border-radius: var(--radius-sm); cursor: pointer; background: linear-gradient(180deg, var(--jade), #57c98a); color: #06160f; font-weight: 700; border: none; }
.pick { display: inline-flex; flex-direction: column; align-items: center; width: 84px; font-size: .72rem; text-align: center; cursor: pointer; padding: 6px; border-radius: 6px; }
.pick input { margin-bottom: 4px; }
.pick .sprite { image-rendering: pixelated; border-radius: 6px; }
.pick:has(input:checked) { outline: 2px solid var(--jade); background: rgba(107,240,154,.1); }
.mini-rarity { opacity: .8; }

.counter-wrap summary { cursor: pointer; font-family: var(--head); margin: 8px 0; }
.trade-chat { margin-top: 18px; }
.msg-thread { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.msg-thread li { padding: 8px 12px; border-radius: 10px; max-width: 80%; }
.msg-thread li.mine { align-self: flex-end; background: rgba(107,240,154,.16); }
.msg-thread li.theirs { align-self: flex-start; background: rgba(255,255,255,.06); }
.msg-who { display: block; font-size: .7rem; opacity: .7; font-family: var(--head); }
.msg-form { display: flex; gap: 8px; }
.msg-form input { flex: 1; }
.msg-form button { margin-top: 0; }

@media (max-width: 720px) {
  .trade-bundles { grid-template-columns: 1fr; }
}

/* Owner tile actions: trade toggle + release side by side (both, not either/or). */
.tile-actions { display: flex; gap: 6px; margin-top: 6px; }
.tile-actions .trade-toggle { margin-top: 0; flex: 1; }
.tile-actions .release-btn { margin-top: 0; flex: 0 0 auto; }
