/* ==========================================================================
   BENTO REDESIGN (layout-a) — scoped mosaic. Loaded AFTER app.css so it wins.
   Faithful to design-system/redesign/setC-bento.html. B/C layouts untouched.
   ========================================================================== */

/* Mosaic palette (fixed; independent of skin for design fidelity) */
:root {
  --bx-canvas:#0B0F14; --bx-surface:#111826; --bx-raised:#161F2E;
  --bx-hairline:#1E2A3A; --bx-hairline-strong:#2A3A4E;
  --bx-ink:#E8EEF5; --bx-body:#A9B7C6; --bx-muted:#6B7A8D;
  --bx-accent:#22C55E; --bx-indica:#8B5CF6; --bx-sativa:#F59E0B;
  --bx-display:"Space Grotesk","Outfit",system-ui,sans-serif;
  --bx-mono:"JetBrains Mono","IBM Plex Mono",ui-monospace,monospace;
}

/* Grid height must leave room for the 44px footer (app.css uses calc(100vh-70px),
   which overflows under the footer and clips the mosaic's bottom row). */
.bento-grid { height: calc(100vh - 114px); }

/* ---- Grid: rail + one big mosaic; hide stats/visualizer cards ---- */
.layout-a.bento-grid { grid-template-columns: 340px 1fr; grid-template-rows: 1fr; }
.layout-a .card-stats,
.layout-a .card-visualizer { display: none !important; } /* beat selectStrain inline display:flex */
.layout-a .card-sidebar { grid-column: 1; grid-row: 1; }
.layout-a .card-details {
  grid-column: 2; grid-row: 1;
  padding: 0; overflow: hidden; background: var(--bx-surface);
  border-color: var(--bx-hairline);
}

/* ---- Rail restyle ---- */
.layout-a .card-sidebar {
  background: var(--bx-surface); border-color: var(--bx-hairline);
  padding: 16px;
}
.layout-a .card-sidebar h2 {
  font-family: var(--bx-mono); color: var(--bx-muted);
  border-bottom-color: var(--bx-hairline);
}
.layout-a #search-input {
  background: var(--bx-raised); border-color: var(--bx-hairline); color: var(--bx-ink);
}
.layout-a .filter-pill {
  font-family: var(--bx-mono); border-color: var(--bx-hairline);
  color: var(--bx-muted); background: transparent;
}
.layout-a .filter-pill.active {
  background: var(--bx-raised); color: var(--bx-ink); border-color: var(--bx-hairline-strong);
}
.layout-a .strain-item { color: var(--bx-body); border-radius: 8px; border-left: 2px solid transparent; }
.layout-a .strain-item:hover { background: var(--bx-raised); }
.layout-a .strain-item.selected {
  background: var(--bx-raised); border-left: 2px solid var(--bx-accent); color: var(--bx-ink);
}
.layout-a .strain-item-type { font-family: var(--bx-mono); }

/* Rail stats strip (grafted from the hidden stats card) */
.rail-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--bx-hairline);
}
.rail-stats .rs-cell { display: flex; flex-direction: column; gap: 2px; text-align: center; }
.rail-stats .rs-num {
  font-family: var(--bx-mono); font-variant-numeric: tabular-nums;
  font-size: 1.05rem; font-weight: 600; color: var(--bx-ink); letter-spacing: -0.02em;
}
.rail-stats .rs-num.i { color: var(--bx-indica); }
.rail-stats .rs-num.s { color: var(--bx-sativa); }
.rail-stats .rs-num.h { color: var(--bx-accent); }
.rail-stats .rs-lbl {
  font-family: var(--bx-mono); font-size: 0.54rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--bx-muted);
}
.layout-a .rail-stats { display: grid; }         /* show only in bento */
.rail-stats { display: none; }

/* ---- Tabs bar inside details ---- */
.layout-a .panel-tabs {
  display: flex; gap: 4px; padding: 10px 16px 0; flex-shrink: 0;
  border-bottom: 1px solid var(--bx-hairline); background: var(--bx-surface);
}
.layout-a .panel-tab-btn {
  background: none; border: none; padding: 8px 12px 12px; color: var(--bx-muted);
  font-size: 0.85rem; cursor: pointer; position: relative; font-family: var(--bx-display);
}
.layout-a .panel-tab-btn:hover { color: var(--bx-body); }
.layout-a .panel-tab-btn.active { color: var(--bx-ink); font-weight: 600; }
.layout-a .panel-tab-btn.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; background: var(--bx-accent); border-radius: 2px;
}

/* Deep Dive / KB panes as scrolling readers in bento */
.layout-a #deepdive-tab-content,
.layout-a #kb-tab-content { padding: 22px 26px; overflow: auto; height: 100%; color: var(--bx-body); }
.layout-a #profile-tab-content { padding: 0 !important; height: 100%; min-height: 0; display: flex; flex-direction: column; }
.layout-a #details-placeholder { display: none !important; }

/* ==========================================================================
   MOSAIC — profile tab
   ========================================================================== */
.layout-a #details-content.mosaic {
  display: grid !important;              /* beat inline display:flex from selectStrain */
  flex: 1 1 auto; min-height: 0;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  grid-template-rows: 1.3fr 1fr 1fr 1fr;
  grid-template-areas:
    "hero  hero  effct effct"
    "hero  hero  ling  ling"
    "ratio terp  ling  ling"
    "pot   terp  aroma grow";
  gap: 1px; background: var(--bx-hairline); overflow: auto;
}
/* When Deep Dive/KB active the profile pane is display:none via switchTab — fine */

.bx-tile {
  background: var(--bx-surface); min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; padding: 16px 18px;
}
.bx-tile-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px;
}
.bx-label {
  font-family: var(--bx-mono); text-transform: uppercase; font-size: 0.64rem;
  letter-spacing: 0.14em; color: var(--bx-muted); font-weight: 500;
}
.bx-est {
  font-family: var(--bx-mono); font-size: 0.58rem; letter-spacing: 0.08em; text-transform: lowercase;
  color: var(--bx-muted); border: 1px dashed var(--bx-hairline-strong); border-radius: 999px; padding: 2px 8px;
}

/* hero */
.bx-hero {
  grid-area: hero; padding: 26px 28px; justify-content: space-between; gap: 16px;
  background: radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--bx-accent) 9%, transparent), transparent 60%), var(--bx-surface);
}
.bx-hero .bx-taxrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.layout-a #strain-type-badge, .bx-tax-lg {
  font-family: var(--bx-mono); font-size: 0.64rem; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; border: 1px solid;
  color: var(--bx-indica); border-color: color-mix(in srgb, var(--bx-indica) 50%, transparent);
  background: color-mix(in srgb, var(--bx-indica) 10%, transparent);
}
.layout-a #strain-type-badge.sativa { color: var(--bx-sativa); border-color: color-mix(in srgb, var(--bx-sativa) 50%, transparent); background: color-mix(in srgb, var(--bx-sativa) 10%, transparent); }
.layout-a #strain-type-badge.hybrid { color: var(--bx-accent); border-color: color-mix(in srgb, var(--bx-accent) 50%, transparent); background: color-mix(in srgb, var(--bx-accent) 10%, transparent); }
.bx-hero .bx-origin { font-family: var(--bx-mono); font-size: 0.64rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bx-muted); }
.layout-a #strain-name {
  font-family: var(--bx-display); font-weight: 700; font-size: clamp(2rem, 3.6vw, 3.4rem);
  line-height: 0.98; letter-spacing: -0.025em; color: var(--bx-accent); margin: 4px 0 0; text-wrap: balance;
}
.layout-a #strain-description {
  max-width: 64ch; color: var(--bx-body); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 0.9rem; line-height: 1.55;
}
.bx-hero-foot { display: flex; gap: 24px; flex-wrap: wrap; }
.bx-hf { display: flex; flex-direction: column; gap: 2px; }
.bx-hf .k { font-family: var(--bx-mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bx-muted); }
.bx-hf .v { font-family: var(--bx-mono); font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--bx-ink); }

/* potency tile (consolidated THC + CBD) */
.bx-pot { grid-area: pot; border-left: 2px solid var(--bx-accent); }
.bx-pot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 2px; }
.bx-pot-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bx-pk { font-family: var(--bx-mono); font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bx-muted); }
.bx-pv { font-family: var(--bx-mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: clamp(1.15rem, 1.8vw, 1.7rem); line-height: 1.05; letter-spacing: -0.03em; color: var(--bx-ink); overflow-wrap: anywhere; }
.bx-pv.thc { color: var(--bx-accent); }
.bx-pv small { font-size: 0.55em; color: var(--bx-body); font-weight: 400; letter-spacing: 0; }
.bx-pv.unset { font-size: 0.9rem; color: var(--bx-muted); font-weight: 400; letter-spacing: 0; }
.bx-market { margin-top: 12px; font-family: var(--bx-mono); font-size: 0.6rem; color: var(--bx-muted); letter-spacing: 0.03em; line-height: 1.5; }
.bx-market strong { color: var(--bx-body); font-weight: 600; }

/* ratio tile */
.bx-ratio { grid-area: ratio; }
.layout-a #ratio-bar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; border: 1px solid var(--bx-hairline); }
.layout-a #ratio-bar .cannabinoid-segment {
  display: flex; align-items: center; padding: 0 14px; font-size: 0.78rem; color: var(--bx-ink);
  font-family: var(--bx-mono); font-variant-numeric: tabular-nums; font-weight: 600;
}
.layout-a #ratio-bar .cannabinoid-segment.thc { justify-content: flex-end; background: color-mix(in srgb, var(--bx-sativa) 24%, var(--bx-surface)) !important; }
.layout-a #ratio-bar .cannabinoid-segment.cbd { background: color-mix(in srgb, var(--bx-indica) 26%, var(--bx-surface)) !important; }
.layout-a #ratio-source-badge { display: none; }

/* terpene tile */
.bx-terp { grid-area: terp; }
.bx-terp .bx-radar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 0; }
.bx-terp #terpene-radar-svg { max-height: 190px; width: auto; }
.layout-a #terpene-radar-svg .grid-line, .layout-a #terpene-radar-svg .axis-line { stroke: var(--bx-hairline); fill: none; }
.layout-a #terpene-radar-svg .axis-label { fill: var(--bx-muted); font-family: var(--bx-mono); font-size: 8px; }
.layout-a #terpene-radar-svg .data-polygon { fill: color-mix(in srgb, var(--bx-accent) 12%, transparent); stroke: var(--bx-accent); stroke-width: 1.75; stroke-linejoin: round; }
.layout-a #terpene-radar-svg .estimated-radar { stroke-dasharray: 4 3; }
.bx-terp-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 18px; width: 100%; }
.bx-terp-legend .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bx-terp-legend .tn { font-size: 0.78rem; color: var(--bx-body); }
.bx-terp-legend .tv { font-family: var(--bx-mono); font-variant-numeric: tabular-nums; font-size: 0.78rem; color: var(--bx-ink); }

/* effects / aroma tiles */
.bx-effct { grid-area: effct; }
.bx-aroma { grid-area: aroma; }
.bx-chip-group + .bx-chip-group { margin-top: 12px; }
.bx-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.bx-chip { font-size: 0.76rem; padding: 5px 11px; border-radius: 999px; background: var(--bx-raised); border: 1px solid var(--bx-hairline); color: var(--bx-body); }
.bx-chips-lg .bx-chip { font-size: 0.86rem; padding: 8px 15px; background: color-mix(in srgb, var(--bx-accent) 8%, var(--bx-raised)); border-color: color-mix(in srgb, var(--bx-accent) 22%, var(--bx-hairline)); color: var(--bx-ink); }
/* inline lineage-head facts */
.bx-hf-inline { font-family: var(--bx-mono); font-size: 0.62rem; letter-spacing: 0.04em; color: var(--bx-body); text-transform: none; }
.bx-hf-inline .k { color: var(--bx-muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* grow tile */
.bx-grow { grid-area: grow; }
.bx-kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 0; }
.bx-kv dt { font-family: var(--bx-mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bx-muted); align-self: center; }
.bx-kv dd { margin: 0; font-family: var(--bx-mono); font-variant-numeric: tabular-nums; font-size: 0.8rem; color: var(--bx-ink); text-align: right; }

/* lineage tile */
.bx-ling { grid-area: ling; }
.bx-ling .bx-lin-body { display: flex; flex-direction: column; gap: 12px; overflow: auto; min-height: 0; }
.bx-ling .bx-lin-row .bx-sub { font-family: var(--bx-mono); font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bx-muted); margin-bottom: 6px; display: block; }
.layout-a #parents-list, .layout-a #children-list { display: flex; flex-wrap: wrap; gap: 6px; }
.layout-a #parents-list .pill, .layout-a #children-list .pill {
  font-size: 0.76rem; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--bx-hairline);
  background: var(--bx-raised); color: var(--bx-body); cursor: pointer;
}
.layout-a #parents-list .pill:hover, .layout-a #children-list .pill:hover { border-color: var(--bx-accent); color: var(--bx-ink); }
.layout-a .no-lineage-data { color: var(--bx-muted); font-size: 0.8rem; }

/* keep app.js targets alive but out of view */
.bx-hidden { display: none !important; }

/* Responsive: stack the mosaic on narrow screens */
@media (max-width: 1180px) {
  .layout-a.bento-grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .layout-a .card-sidebar { max-height: 300px; }
  .layout-a #details-content.mosaic {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
    grid-template-areas: "hero hero" "effct effct" "ling ling" "ratio pot" "terp terp" "aroma grow";
    overflow: auto;
  }
}

/* ==========================================================================
   VIEW B — SPLIT (editorial reader). Light parchment monograph, single column.
   ========================================================================== */
.layout-b {
  --ed-paper:#F7F4EC; --ed-card:#FDFCF8; --ed-ink:#201C16; --ed-soft:#5A5347;
  --ed-faint:#8A8072; --ed-sage:#4A6B5D; --ed-sage-deep:#31513F; --ed-rule:#D8D0BF; --ed-rule-strong:#B7AD97;
  --ed-serif:"Cormorant Garamond","Playfair Display",Georgia,serif;
  --ed-mono:"IBM Plex Mono",ui-monospace,monospace;
}
.layout-b.bento-grid { grid-template-columns: 360px 1fr; grid-template-rows: 1fr; background: var(--ed-paper); }
.layout-b .card-stats, .layout-b .card-visualizer { display: none !important; }
.layout-b .card-sidebar { grid-column: 1; grid-row: 1; background: var(--ed-paper); border-color: var(--ed-rule-strong); color: var(--ed-ink); }
.layout-b .card-details { grid-column: 2; grid-row: 1; background: var(--ed-card); border-color: var(--ed-rule-strong); color: var(--ed-ink); padding: 0; overflow: hidden; }
/* sidebar as field index */
.layout-b .card-sidebar h2 { font-family: var(--ed-mono); color: var(--ed-faint); border-bottom-color: var(--ed-rule); }
.layout-b #search-input { background: transparent; border: none; border-bottom: 1px solid var(--ed-rule-strong); border-radius: 0; color: var(--ed-ink); }
.layout-b #search-input::placeholder { color: var(--ed-faint); font-style: italic; }
.layout-b .filter-pill { font-family: var(--ed-mono); color: var(--ed-soft); background: transparent; border-color: var(--ed-rule-strong); }
.layout-b .filter-pill.active { color: var(--ed-sage-deep); background: transparent; border-color: var(--ed-sage); }
.layout-b .strain-item { color: var(--ed-ink); border-bottom: 1px solid var(--ed-rule); border-radius: 0; border-left: 2px solid transparent; }
.layout-b .strain-item:hover { background: rgba(74,107,93,0.06); }
.layout-b .strain-item.selected { background: transparent; border-left: 2px solid var(--ed-sage); color: var(--ed-sage-deep); font-weight: 600; }
.layout-b .strain-item span:first-child { font-family: var(--ed-serif); font-size: 1.05rem; }
.layout-b .strain-item-type { font-family: var(--ed-mono); color: var(--ed-faint); background: transparent; border: 1px solid var(--ed-rule); }
.layout-b .status-msg { color: var(--ed-faint); }
.layout-b .rail-stats { border-top-color: var(--ed-rule); }
.layout-b .rail-stats .rs-num { color: var(--ed-ink); }
.layout-b .rail-stats .rs-lbl { color: var(--ed-faint); }
/* tabs */
.layout-b .panel-tabs { border-bottom: 1px solid var(--ed-rule-strong); background: var(--ed-card); padding: 14px 40px 0; }
.layout-b .panel-tab-btn { font-family: var(--ed-mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ed-soft); }
.layout-b .panel-tab-btn.active { color: var(--ed-sage-deep); }
.layout-b .panel-tab-btn.active::after { background: var(--ed-sage); }
/* reader: single column, stacked tiles */
.layout-b #profile-tab-content { padding: 0; height: 100%; overflow: auto; }
.layout-b #details-content { display: block !important; max-width: 760px; margin: 0 auto; padding: 40px 40px 80px; }
.layout-b .bx-tile { background: transparent; padding: 0; margin-bottom: 34px; display: block; }
.layout-b .bx-hidden { display: none; }
.layout-b .bx-tile-head { border-bottom: 1px solid var(--ed-rule); padding-bottom: 8px; margin-bottom: 16px; }
.layout-b .bx-label { font-family: var(--ed-mono); color: var(--ed-faint); }
.layout-b .bx-hero { border-bottom: 1px solid var(--ed-rule-strong); padding-bottom: 26px; background: none; }
.layout-b .bx-origin { font-family: var(--ed-mono); color: var(--ed-faint); }
.layout-b #strain-type-badge { font-family: var(--ed-mono); color: var(--ed-sage-deep); background: transparent; border-color: var(--ed-sage); }
.layout-b #strain-name { font-family: var(--ed-serif); font-weight: 600; color: var(--ed-ink); font-size: clamp(2.6rem, 5vw, 4.2rem); line-height: 0.98; }
.layout-b #strain-description { color: var(--ed-soft); font-family: var(--ed-serif); font-size: 1.15rem; line-height: 1.6; -webkit-line-clamp: unset; display: block; max-width: 62ch; }
.layout-b .bx-hero-foot .k { font-family: var(--ed-mono); color: var(--ed-faint); }
.layout-b .bx-hero-foot .v { font-family: var(--ed-mono); color: var(--ed-ink); }
.layout-b .bx-chips-lg .bx-chip, .layout-b .bx-chip { background: rgba(74,107,93,0.07); border-color: var(--ed-rule-strong); color: var(--ed-ink); }
.layout-b .bx-hf-inline, .layout-b .bx-hf-inline .k { color: var(--ed-faint); }
.layout-b #parents-list .pill, .layout-b #children-list .pill { background: rgba(74,107,93,0.07); border-color: var(--ed-rule-strong); color: var(--ed-ink); }
.layout-b .bx-sub { font-family: var(--ed-mono); color: var(--ed-faint); }
.layout-b .no-lineage-data { color: var(--ed-faint); font-style: italic; }
.layout-b .bx-pv { color: var(--ed-ink); font-family: var(--ed-serif); font-weight: 600; }
.layout-b .bx-pv.thc { color: var(--ed-sage-deep); }
.layout-b .bx-pk, .layout-b .bx-market { font-family: var(--ed-mono); color: var(--ed-faint); }
.layout-b #ratio-bar { border-color: var(--ed-rule-strong); }
.layout-b #ratio-bar .cannabinoid-segment.thc { background: var(--ed-sage-tint, #E9EEE9) !important; color: var(--ed-sage-deep) !important; }
.layout-b #ratio-bar .cannabinoid-segment.cbd { background: var(--ed-sage-deep) !important; color: #F2F0E7 !important; }
.layout-b #terpene-radar-svg .grid-line, .layout-b #terpene-radar-svg .axis-line { stroke: var(--ed-rule); }
.layout-b #terpene-radar-svg .axis-label { fill: var(--ed-faint); }
.layout-b #terpene-radar-svg .data-polygon { fill: rgba(74,107,93,0.12); stroke: var(--ed-sage); }
.layout-b .bx-terp-legend .tn { color: var(--ed-ink); }
.layout-b .bx-terp-legend .tv { color: var(--ed-sage-deep); }
.layout-b .bx-kv dt { font-family: var(--ed-mono); color: var(--ed-faint); }
.layout-b .bx-kv dd { font-family: var(--ed-mono); color: var(--ed-ink); }
.layout-b #deepdive-tab-content, .layout-b #kb-tab-content { color: var(--ed-ink); }

/* ==========================================================================
   VIEW C — CANVAS (kinetic). Aurora field + glass panels over the lineage stage.
   ========================================================================== */
.layout-c.bento-grid {
  background:
    radial-gradient(46vw 46vw at 8% 12%, rgba(34,197,94,0.16), transparent 60%),
    radial-gradient(52vw 52vw at 92% 4%, rgba(139,92,246,0.16), transparent 60%),
    radial-gradient(44vw 44vw at 60% 100%, rgba(56,189,248,0.12), transparent 62%),
    var(--bx-canvas);
}
.layout-c .card-sidebar, .layout-c .card-details, .layout-c .card-stats {
  background: rgba(17,24,38,0.55); backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 20px;
}
.layout-c .card-visualizer { background: transparent; border: none; box-shadow: none; }
.layout-c .card-stats { display: none; }
.layout-c .card-sidebar h2, .layout-c .card-details .bx-label, .layout-c .bento-card h2 { color: var(--bx-muted); }
/* VERTICAL genealogy stage, shared by Canvas (c) and Wild (d):
   selected strain on top, then parents, then grandparents; each tier a
   horizontal row of nodes, centered between the floating rail and drawer. */
.layout-c #visualizer-content, .layout-d #visualizer-content { height: 100%; }
.layout-c #tree-container, .layout-d #tree-container {
  color: var(--bx-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; height: 100%; width: 100%;
  padding: 88px 600px 40px 400px;   /* clear header + drawer(right) + rail(left) */
  overflow: auto;
}
.layout-c #tree-connections-svg, .layout-d #tree-connections-svg { display: none; } /* bezier geometry doesn't fit vertical */
.layout-c #tree-active, .layout-d #tree-active { order: 1; }
.layout-c #tree-parents, .layout-d #tree-parents { order: 2; }
.layout-c #tree-grandparents, .layout-d #tree-grandparents { order: 3; }
.layout-c .tree-col, .layout-d .tree-col {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: auto; height: auto; flex: none;
}
.layout-c .tree-col .col-label, .layout-d .tree-col .col-label {
  text-align: center; margin: 0 0 2px;
  color: var(--bx-muted); font-family: var(--bx-mono);
  font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.layout-c .nodes-container, .layout-d .nodes-container {
  display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center;
  gap: 14px; width: auto; flex: none;   /* shrink to content so cards sit side by side */
}
.layout-c .tree-node-card, .layout-d .tree-node-card {
  width: auto; min-width: 150px; max-width: 210px; text-align: center;   /* beat app.css width:100% */
  background: rgba(22,31,46,0.72); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px; backdrop-filter: blur(14px); color: var(--bx-body);
}
.layout-c .tree-node-card.node-active {
  border-color: rgba(34,197,94,0.6); color: var(--bx-ink);
  box-shadow: 0 0 40px -6px rgba(34,197,94,0.55), inset 0 1px 0 rgba(255,255,255,0.12);
}
.layout-c .no-lineage-data, .layout-d .no-lineage-data { color: var(--bx-muted); }
/* Wild: neon nodes */
.layout-d .tree-node-card { border-color: rgba(56,240,255,0.25); background: rgba(8,16,20,0.62); }
.layout-d .tree-node-card.node-active {
  border-color: rgba(42,255,160,0.7); color: #eafff4;
  box-shadow: 0 0 44px -6px rgba(42,255,160,0.6), inset 0 1px 0 rgba(255,255,255,0.14);
}
.layout-d .tree-col .col-label { color: rgba(56,240,255,0.7); }
/* the details drawer stacks the mosaic tiles as a glass reader */
.layout-c .card-details .panel-tabs { background: transparent; border-bottom-color: rgba(255,255,255,0.1); }
.layout-c #details-content { padding: 20px 22px 50px; }
.layout-c .card-details .bx-tile { background: transparent; padding: 0; margin-bottom: 22px; border: none; }
.layout-c .card-details .bx-hidden { display: none; }
.layout-c .card-details .bx-tile-head { border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 8px; margin-bottom: 12px; }
.layout-c .card-details .bx-hero { background: none; }

/* ==========================================================================
   VIEW D — WILD. Full-bleed animated organism; the detail drawer floats as a HUD.
   ========================================================================== */
.layout-d.bento-grid {
  grid-template-columns: 1fr; grid-template-rows: 1fr; position: relative;
  background:
    radial-gradient(40vw 40vw at 20% 24%, rgba(42,255,160,0.22), transparent 60%),
    radial-gradient(46vw 46vw at 80% 30%, rgba(255,46,196,0.16), transparent 60%),
    radial-gradient(50vw 50vw at 50% 96%, rgba(56,240,255,0.16), transparent 62%),
    #04070a;
  animation: wild-hue 24s ease-in-out infinite alternate;
}
@keyframes wild-hue { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(28deg); } }
@media (prefers-reduced-motion: reduce) { .layout-d.bento-grid { animation: none; } }
.layout-d .card-stats { display: none !important; }
.layout-d .card-visualizer { grid-column: 1; grid-row: 1; background: transparent; border: none; box-shadow: none; height: 100%; overflow: hidden; }
.layout-d .card-sidebar {
  position: absolute; left: 2.5rem; top: 2.5rem; bottom: 2.5rem; width: 320px; z-index: 20;
  background: rgba(4,8,10,0.66); backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(42,255,160,0.18); border-radius: 18px; box-shadow: 0 20px 60px -20px rgba(0,0,0,0.8);
}
.layout-d .card-details {
  position: absolute; right: 2.5rem; top: 2.5rem; bottom: 2.5rem; width: min(560px, 44vw); z-index: 20;
  background: rgba(4,8,10,0.62); backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(56,240,255,0.18); border-radius: 18px; box-shadow: 0 20px 60px -20px rgba(0,0,0,0.8);
  padding: 0; overflow: hidden;
}
.layout-d #close-details-btn { display: none; }
.layout-d #details-content { display: block !important; padding: 26px 28px 60px; overflow: auto; height: 100%; }
.layout-d .bx-tile { background: transparent; padding: 0; margin-bottom: 26px; border: none; }
.layout-d .bx-hidden { display: none; }
.layout-d .bx-hero { background: none; }
.layout-d #strain-name {
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  background: linear-gradient(96deg, #c9ff2a, #2affa0 40%, #38f0ff 78%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.layout-d .bx-tile-head { border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 8px; margin-bottom: 14px; }
.layout-d .bx-chips-lg .bx-chip, .layout-d .bx-chip { background: rgba(138,77,255,0.14); border-color: rgba(138,77,255,0.4); color: #e7dcff; }
.layout-d .bx-aroma .bx-chip { background: rgba(255,46,196,0.12); border-color: rgba(255,46,196,0.4); color: #ffc7ee; }
.layout-d #parents-list .pill, .layout-d #children-list .pill { background: rgba(56,240,255,0.1); border-color: rgba(56,240,255,0.4); color: #bff4ff; }
.layout-d .bx-pv.thc { color: #2affa0; }
.layout-d .panel-tabs { background: transparent; border-bottom-color: rgba(255,255,255,0.1); }

/* ==========================================================================
   MOBILE (<=768px) — the desktop grids/absolute panels don't work on phones.
   Collapse every view into one scrollable, dark, single-column profile.
   ========================================================================== */
@media (max-width: 768px) {
  html, body { overflow-y: auto !important; height: auto !important; }
  .app-container { height: auto !important; min-height: 100vh; }
  .app-footer { position: static; }

  .app-header { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .logo-area { font-size: 1rem; }
  .header-controls { margin-left: 0; width: 100%; gap: 10px; flex-wrap: wrap; }
  .control-group { flex: 1 1 auto; }
  .layout-selector { width: 100%; justify-content: space-between; }
  .layout-btn { flex: 1; text-align: center; }

  /* one stacked layout for all views */
  .bento-grid {
    display: flex !important; flex-direction: column; height: auto !important;
    padding: 12px; gap: 12px; background: var(--bx-canvas) !important; overflow: visible !important;
  }
  .bento-card {
    position: static !important; inset: auto !important; right: auto !important; left: auto !important;
    transform: none !important; width: auto !important; height: auto !important;
    max-height: none !important; min-width: 0 !important;
    background: var(--bx-surface) !important; border: 1px solid var(--bx-hairline) !important;
    color: var(--bx-ink) !important; backdrop-filter: none !important;
  }
  .card-stats, .card-visualizer { display: none !important; }  /* declutter; lineage lives in the profile tile */
  .card-sidebar { order: 2; max-height: 340px; }
  .card-details { order: 1; padding: 0 !important; }
  #close-details-btn { display: none !important; }

  /* details tiles → full-width stacked sections (beat the .layout-a #details-content.mosaic grid) */
  #details-content, #profile-tab-content,
  .layout-a #details-content.mosaic,
  .layout-b #details-content, .layout-c #details-content, .layout-d #details-content {
    display: block !important; grid-template-columns: none !important; grid-template-rows: none !important;
    grid-template-areas: none !important;
    max-width: none !important; margin: 0 !important; padding: 14px !important; overflow: visible !important;
  }
  .bx-tile {
    display: block !important; grid-area: auto !important;
    background: transparent !important; border: none !important;
    border-bottom: 1px solid var(--bx-hairline) !important; border-radius: 0 !important;
    margin: 0 0 16px !important; padding: 0 0 16px !important; border-left: none !important;
  }
  .bx-hero { background: none !important; }
  #strain-name { font-size: 2rem !important; color: var(--bx-accent) !important; font-family: var(--bx-display) !important; }
  #strain-description { -webkit-line-clamp: 6 !important; -webkit-box-orient: vertical; display: -webkit-box !important; overflow: hidden; color: var(--bx-body) !important; }
  .bx-pot-grid { grid-template-columns: 1fr 1fr; }
  .bx-terp #terpene-radar-svg { max-height: 240px; }
  .panel-tabs { flex-wrap: wrap !important; padding: 8px 12px !important; gap: 4px; }
  .panel-tab-btn { font-size: 0.8rem !important; padding: 8px 10px !important; }

  /* keep the editorial reader legible but consistent with the dark mobile shell */
  .layout-b #strain-description, .layout-b .bx-pv, .layout-b .bx-terp-legend .tn { color: var(--bx-body) !important; }
  .layout-b #strain-name { color: var(--bx-accent) !important; }
  .layout-b .bx-chip, .layout-b #parents-list .pill, .layout-b #children-list .pill { color: var(--bx-body) !important; }
  /* Split stays the "full read" on mobile — show the entire description */
  .layout-b #strain-description { -webkit-line-clamp: unset !important; display: block !important; }
}
