/* ====================================================================
   THE APIARIST — a beekeeping simulation
   Visual style: naturalist field-guide. Warm parchment, honey tones,
   hand-drawn feel, hexagon motifs. Zero dependencies.
   ==================================================================== */

:root {
  /* Parchment + ink */
  --parch:      #f3e7c8;
  --parch-2:    #ece0bf;
  --paper:      #fbf5e3;
  --paper-2:    #f6edd5;
  --ink:        #3a2c18;
  --ink-soft:   #6b5836;
  --ink-faint:  #9a855c;

  /* Honey + wax */
  --honey:      #e3a52a;
  --honey-deep: #c9851a;
  --honey-dk:   #9c6614;
  --wax:        #f0d99a;
  --comb-line:  #c79f57;

  /* Nature */
  --leaf:       #6f8f44;
  --leaf-dk:    #4f6a2e;
  --sky:        #8fb4c4;
  --bark:       #7a5c33;

  /* Status */
  --ok:         #5d8a3a;
  --ok-bg:      #e3eccf;
  --warn:       #d4901f;
  --warn-bg:    #f6e6c2;
  --bad:        #b03f24;
  --bad-bg:     #f0d6cc;
  --info:       #4a7a8c;
  --info-bg:    #d8e6ea;

  --line:       #cdb888;
  --line-dk:    #b29a63;
  --shadow:     0 2px 6px rgba(58,44,24,0.18);
  --shadow-lg:  0 8px 28px rgba(58,44,24,0.32);

  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  --sans:  'Segoe UI', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--parch);
  background-image:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.35) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(160,130,70,0.14) 0%, transparent 45%);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }

button { font-family: var(--sans); cursor: pointer; }
::selection { background: var(--honey); color: #fff; }

/* scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--parch-2); }
::-webkit-scrollbar-thumb { background: var(--line-dk); border-radius: 6px; border: 2px solid var(--parch-2); }

/* ====================================================================
   APP LAYOUT
   ==================================================================== */

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 60px; flex: none;
  background: linear-gradient(180deg, #4a3a20, #3a2c18);
  color: var(--wax);
  border-bottom: 3px solid var(--honey-dk);
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  z-index: 20;
}
.topbar .brand {
  font-family: var(--serif); font-size: 20px; font-weight: 600;
  color: var(--honey); letter-spacing: 0.3px; white-space: nowrap;
}
.topbar .brand .bee { filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.topbar-clock { display: flex; align-items: center; gap: 10px; }
.topbar-clock .weather-ico { font-size: 24px; }
.topbar-clock .when { line-height: 1.15; }
.topbar-clock .when b { font-size: 15px; color: #fff; font-family: var(--serif); }
.topbar-clock .when small { font-size: 11px; color: var(--honey); display: block; text-transform: uppercase; letter-spacing: .8px; }
.topbar-spacer { flex: 1; }
.topbar-stat { text-align: right; line-height: 1.15; }
.topbar-stat b { font-size: 16px; color: #fff; font-family: var(--serif); }
.topbar-stat small { font-size: 10px; color: var(--honey); display: block; text-transform: uppercase; letter-spacing: .8px; }
.topbar-stat.cash b { color: #f4d77a; }
.topbar-btn {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.20);
  color: var(--wax); font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.topbar-btn:hover { background: rgba(255,255,255,0.22); }

/* save & load modal */
.sl-note { font-size: 13.5px; line-height: 1.62; color: var(--ink); margin-bottom: 12px; }
.sl-current {
  font-size: 13px; font-weight: 600; color: var(--honey-dk);
  background: var(--warn-bg); border: 1px solid var(--honey);
  border-radius: 8px; padding: 9px 12px; margin-bottom: 14px;
}
.sl-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sl-actions .btn { flex: 1; min-width: 140px; justify-content: center; }

/* nav */
.navbar {
  display: flex; gap: 4px; padding: 6px 14px; flex: none;
  background: var(--parch-2);
  border-bottom: 1px solid var(--line-dk);
}
.nav-btn {
  border: 1px solid transparent; background: transparent;
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 7px 7px 0 0;
  display: flex; align-items: center; gap: 6px;
}
.nav-btn:hover { background: var(--paper-2); color: var(--ink); }
.nav-btn.active {
  background: var(--paper); color: var(--honey-dk);
  border-color: var(--line-dk); border-bottom-color: var(--paper);
  margin-bottom: -1px;
}
.nav-btn .ico { font-size: 15px; }
.nav-btn .pip {
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
}

.stage { flex: 1; overflow: hidden; position: relative; }

/* ====================================================================
   BUTTONS
   ==================================================================== */

.btn {
  border: 1px solid var(--line-dk); background: var(--paper);
  color: var(--ink); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .05s, box-shadow .1s, background .12s;
  box-shadow: 0 1px 2px rgba(58,44,24,0.15);
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: saturate(0.25); }
.btn-primary {
  background: linear-gradient(180deg, var(--honey), var(--honey-deep));
  border-color: var(--honey-dk); color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #eeb13a, var(--honey-deep)); }
.btn-danger { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: #e9c4b8; }
.btn-leaf { background: linear-gradient(180deg, #82a455, var(--leaf-dk)); border-color: var(--leaf-dk); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(0,0,0,0.06); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ====================================================================
   APIARY VIEW
   ==================================================================== */

.apiary-view { display: flex; height: 100%; }
.apiary-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.apiary-head {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.apiary-head h2 { font-size: 19px; }
.apiary-head .site-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  background: var(--leaf); color: #fff; padding: 3px 9px; border-radius: 10px;
}
.apiary-head .forage-note { font-size: 12px; color: var(--ink-soft); font-style: italic; }
.apiary-switch { display: flex; gap: 4px; }

.yard {
  flex: 1; overflow: auto; position: relative;
  background:
    linear-gradient(180deg, #cfe0e6 0%, #d8e3d0 38%, #bfcf94 38%, #aebd7f 100%);
  padding: 30px;
}
.yard-row {
  display: flex; flex-wrap: wrap; gap: 26px 30px; align-content: flex-end;
  justify-content: center; min-height: 100%;
  padding: 34px 30px 58px;
}

/* a single hive — illustrated stacked boxes */
.hive {
  width: 132px; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center;
  transition: transform .12s;
}
.hive:hover { transform: translateY(-4px); }
.hive-roof {
  width: 116px; height: 16px;
  background: linear-gradient(180deg, #6a4a26, #533a1f);
  border-radius: 5px 5px 2px 2px; border: 1px solid #3f2c16;
  position: relative; z-index: 3;
}
.hive-roof::after {
  content: ''; position: absolute; left: 8px; right: 8px; top: 5px; height: 2px;
  background: rgba(255,255,255,0.12);
}
.hive-stack { display: flex; flex-direction: column; align-items: center; }
.hive-box {
  width: 104px; border: 1px solid #93733f;
  background: linear-gradient(180deg, #eccf8c, #d3ac63);
  position: relative; box-shadow: inset 0 -3px 4px rgba(90,60,25,0.16);
}
.hive-box.super { height: 24px; background: linear-gradient(180deg, #efd9a0, #ddc07c); overflow: hidden; }
.hive-box.super::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: var(--honey-fill, 0%);
  background: rgba(195, 135, 20, 0.45);
  pointer-events: none;
}
.hive-box.brood { height: 42px; }
.hive-box::before {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  top: 50%; margin-top: -3px; width: 38px; height: 6px;
  background: rgba(90,60,25,0.30); border-radius: 3px;
}
.hive-floor {
  width: 116px; height: 13px; position: relative; z-index: 2;
  background: linear-gradient(180deg, #876539, #5f4626); border-radius: 0 0 3px 3px;
}
.hive-floor::before {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  top: 4px; width: 36px; height: 5px; background: #241a0d; border-radius: 3px;
}
.hive-floor::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: -4px; width: 72px; height: 5px;
  background: linear-gradient(180deg, #9a7745, #7a5a33); border-radius: 0 0 4px 4px;
}
.hive-stand {
  width: 94px; height: 17px; margin-top: 2px;
  background: linear-gradient(180deg, #8a7048, #5f482e); border-radius: 2px;
}
.hive-plaque {
  margin-top: 8px; background: var(--paper); border: 1px solid var(--line-dk);
  border-radius: 6px; padding: 4px 10px; text-align: center; box-shadow: var(--shadow);
  min-width: 110px;
}
.hive-plaque .nm { font-family: var(--serif); font-weight: 600; font-size: 13px; }
.hive-plaque .st { font-size: 11px; color: var(--ink-soft); }
.hive-dot {
  position: absolute; top: 4px; right: 8px; width: 14px; height: 14px;
  border-radius: 50%; border: 2px solid var(--paper); z-index: 5;
}
.hive-dot.ok { background: var(--ok); }
.hive-dot.warn { background: var(--warn); }
.hive-dot.bad { background: var(--bad); }
.hive-dot.dead { background: #555; }
.hive-dot.unknown { background: var(--ink-faint); }
.hive-badge {
  position: absolute; top: -8px; left: -6px; font-size: 18px; z-index: 6;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.35));
}
/* queen-cell crown: slow pulse on hive roof when cells observed (no other badge) */
.hive-qcell-crown {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  font-size: 14px; z-index: 7; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
  animation: qcell-pulse 3s ease-in-out 3;  /* 3 slow pulses then settles */
  pointer-events: none;
}
@keyframes qcell-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%       { transform: translateX(-50%) scale(1.18); }
}
.hive.is-dead { opacity: .55; filter: grayscale(.7); }
.hive.is-dead .hive-box {
  background: repeating-linear-gradient(
    -45deg, rgba(100,80,50,0.22) 0, rgba(100,80,50,0.22) 3px,
    transparent 3px, transparent 10px
  ), linear-gradient(180deg, #c8b898, #b09878) !important;
}
/* 3px red left stripe when disease observed */
.hive.has-disease .hive-stack { position: relative; }
.hive.has-disease .hive-stack::before {
  content: ''; position: absolute; left: -5px; top: 0; bottom: 0; width: 3px;
  background: var(--bad); border-radius: 2px; z-index: 4;
}
.hive-bees { position: absolute; left: 0; right: 0; top: -24px; bottom: 28px; pointer-events: none; z-index: 6; overflow: visible; }
.bee {
  position: absolute; font-size: 14px; opacity: 0;
  animation-timing-function: linear; animation-iteration-count: infinite;
  will-change: transform, opacity;
}
.bee-face { display: block; transform: scaleX(var(--face,1)) rotate(var(--tilt,0deg)); }
.bee-glyph { display: block; animation: beebob var(--bob,0.45s) ease-in-out infinite; }
/* a forager leaving: climbs, drifts to the side, shrinks into the distance */
@keyframes bee-out {
  0%   { transform: translate(0,0) scale(0.9); opacity: 0; }
  9%   { opacity: 0.96; }
  72%  { opacity: 0.96; }
  100% { transform: translate(var(--dx,140px), var(--dy,-200px)) scale(0.16); opacity: 0; }
}
/* a forager returning: appears small and far, grows as it nears the hive */
@keyframes bee-in {
  0%   { transform: translate(var(--dx,140px), var(--dy,-200px)) scale(0.16); opacity: 0; }
  16%  { opacity: 0.96; }
  86%  { transform: translate(0,0) scale(0.96); opacity: 0.96; }
  100% { transform: translate(0,0) scale(0.78); opacity: 0; }
}
/* a gentle in-flight bob */
@keyframes beebob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

.add-hive-slot {
  width: 132px; min-height: 120px; border: 2px dashed rgba(255,255,255,0.6);
  border-radius: 10px; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center; cursor: pointer;
  color: #5a5230; background: rgba(255,255,255,0.18); font-weight: 600; font-size: 13px;
}
.add-hive-slot:hover { background: rgba(255,255,255,0.34); }
.add-hive-slot .plus { font-size: 30px; line-height: 1; }

/* Bait hive slot — empty box waiting to catch a swarm */
.bait-hive-slot {
  width: 132px; min-height: 120px; border: 2px dashed rgba(180,140,60,0.7);
  border-radius: 10px; display: flex; flex-direction: column; gap: 5px;
  align-items: center; justify-content: center;
  color: var(--ink-soft); background: rgba(240,210,130,0.22); font-size: 12px;
}
.bait-hive-icon { font-size: 32px; line-height: 1; }
.bait-hive-label { font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.bait-hive-sub { font-size: 11px; color: var(--ink-faint); text-align: center; padding: 0 6px; }

/* Spare hive slot — empty hive box awaiting a colony */
.spare-hive-slot {
  width: 132px; min-height: 120px; border: 2px dashed rgba(100,120,80,0.5);
  border-radius: 10px; display: flex; flex-direction: column; gap: 5px;
  align-items: center; justify-content: center; cursor: pointer;
  color: var(--ink-soft); background: rgba(180,200,140,0.15); font-size: 12px;
  transition: background .15s, border-color .15s;
}
.spare-hive-slot:hover { background: rgba(180,200,140,0.28); border-color: rgba(100,120,80,0.75); }
.spare-hive-icon { font-size: 32px; line-height: 1; }
.spare-hive-label { font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.spare-hive-sub { font-size: 11px; color: var(--ink-faint); text-align: center; padding: 0 6px; }

/* ====================================================================
   STATUSBAR — persistent bottom resource strip
   ==================================================================== */
.statusbar {
  display: flex; align-items: center; gap: 0; flex: none;
  height: 42px; padding: 0 16px;
  background: linear-gradient(180deg, #3a2c18, #2a1e10);
  border-top: 2px solid var(--honey-dk);
  z-index: 20;
}
.sb-stat {
  display: flex; align-items: center; gap: 5px;
  padding: 0 12px; height: 100%;
  border-right: 1px solid rgba(180,140,60,0.2);
}
.sb-stat:last-child { border-right: none; }
.sb-icon { font-size: 16px; line-height: 1; }
.sb-val { font-size: 13px; font-weight: 700; color: var(--wax); letter-spacing: .3px; }
.sb-lbl { font-size: 10px; color: var(--honey); text-transform: uppercase; letter-spacing: .6px; }
.sb-has .sb-val { color: #b8e890; }
.sb-divider { width: 1px; height: 24px; background: rgba(180,140,60,0.35); margin: 0 4px; }

/* advisor sidebar */
.apiary-side {
  width: 326px; flex: none; background: var(--paper);
  border-left: 1px solid var(--line-dk); display: flex; flex-direction: column;
  overflow: hidden;
}
.side-section {
  border-bottom: 1px solid var(--line);
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.side-head {
  font-family: var(--serif); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--honey-dk);
  padding: 9px 14px 4px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
}
.side-body { padding: 4px 14px 12px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }

/* time-controls — see action list section below */

/* mentor — an on-screen teaching companion with a speech bubble */
.mentor { display: flex; gap: 10px; align-items: flex-start; margin: 12px 14px; }
.mentor-face {
  flex: none; width: 44px; height: 44px; font-size: 25px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 38% 32%, #f8e4ad, var(--honey));
  border-radius: 50%; box-shadow: 0 2px 5px rgba(120,90,30,0.3);
}
.mentor-bubble {
  flex: 1; position: relative; background: var(--info-bg); border: 1px solid var(--info);
  border-radius: 4px 12px 12px 12px; padding: 9px 11px;
}
.mentor-bubble::before {
  content: ''; position: absolute; left: -7px; top: 10px; width: 0; height: 0;
  border: 7px solid transparent; border-right-color: var(--info); border-left: 0;
}
.mentor-who {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--info); margin-bottom: 2px;
}
.mentor-text { font-size: 13px; line-height: 1.5; color: var(--ink); }
.mentor.tone-bad .mentor-bubble { background: var(--bad-bg); border-color: var(--bad); }
.mentor.tone-bad .mentor-bubble::before { border-right-color: var(--bad); }
.mentor.tone-bad .mentor-who { color: var(--bad); }
.mentor.tone-warn .mentor-bubble { background: var(--warn-bg); border-color: var(--honey-dk); }
.mentor.tone-warn .mentor-bubble::before { border-right-color: var(--honey-dk); }
.mentor.tone-warn .mentor-who { color: var(--honey-dk); }
.mentor.tone-ok .mentor-bubble { background: var(--ok-bg); border-color: var(--ok); }
.mentor.tone-ok .mentor-bubble::before { border-right-color: var(--ok); }
.mentor.tone-ok .mentor-who { color: var(--leaf-dk); }

/* advisor items */
.advisor-item {
  display: flex; gap: 8px; padding: 8px; border-radius: 8px;
  margin-bottom: 6px; font-size: 13px; align-items: flex-start;
}
.advisor-item .ico { font-size: 15px; flex: none; }
.advisor-item.bad  { background: var(--bad-bg); }
.advisor-item.warn { background: var(--warn-bg); }
.advisor-item.ok   { background: var(--ok-bg); }
.advisor-item.info { background: var(--info-bg); }
.advisor-empty { font-size: 13px; color: var(--ink-faint); font-style: italic; padding: 6px 2px; }

/* ====================================================================
   CARDS / PANELS / GENERIC
   ==================================================================== */

.panel-view { height: 100%; overflow-y: auto; padding: 22px 26px; }
.panel-view.narrow { max-width: 980px; margin: 0 auto; }

.page-title {
  font-size: 24px; margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px;
}
.page-sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 18px; font-style: italic; }

.card {
  background: var(--paper); border: 1px solid var(--line-dk);
  border-radius: 10px; padding: 14px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-title {
  font-family: var(--serif); font-size: 15px; font-weight: 700;
  margin-bottom: 8px; color: var(--honey-dk);
  display: flex; align-items: center; gap: 7px;
}
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3,1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); }

.stat-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.stat-row .lbl { color: var(--ink-soft); }
.stat-row .val { font-weight: 700; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit,minmax(120px,1fr)); gap: 10px; }
.stat-tile {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; text-align: center;
}
.stat-tile b { font-family: var(--serif); font-size: 20px; display: block; }
.stat-tile small { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }

.bar { background: var(--parch-2); border: 1px solid var(--line); border-radius: 5px; height: 14px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: var(--honey); transition: width .3s; }
.bar-fill.ok { background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }
.bar-fill.info { background: var(--info); }
.bar-label { position: absolute; inset: 0; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; color: var(--ink); text-shadow: 0 0 3px rgba(255,255,255,.8); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  background: var(--parch-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge.ok { background: var(--ok-bg); color: var(--ok-dk,#3f6027); border-color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--honey-dk); border-color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info); }

.divider { height: 1px; background: var(--line); margin: 12px 0; }
.muted { color: var(--ink-faint); }
.tiny { font-size: 11px; }
.center { text-align: center; }
.hex-rule {
  text-align: center; color: var(--comb-line); letter-spacing: 6px;
  font-size: 13px; margin: 14px 0;
}

/* ====================================================================
   MODALS
   ==================================================================== */

#modal-root { position: fixed; inset: 0; pointer-events: none; z-index: 150; }
.modal-overlay {
  position: absolute; inset: 0; background: rgba(40,28,12,0.55);
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; padding: 24px; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--paper); border: 1px solid var(--honey-dk);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column;
  width: 560px; animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal.wide  { width: 900px; }
.modal.xwide { width: min(1400px, 96vw); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-bottom: 2px solid var(--honey);
  background: var(--paper-2); border-radius: 12px 12px 0 0;
}
.modal-head h3 { font-size: 18px; flex: 1; }
.modal-head .x {
  border: none; background: transparent; font-size: 22px; line-height: 1;
  color: var(--ink-soft); padding: 2px 6px; border-radius: 6px;
}
.modal-head .x:hover { background: var(--bad-bg); color: var(--bad); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end; background: var(--paper-2);
  border-radius: 0 0 12px 12px;
}

/* ====================================================================
   HIVE DETAIL — cross-section with real frame content
   ==================================================================== */

.hive-detail { display: flex; gap: 24px; min-height: 0; height: calc(88vh - 110px); }
.hive-cross  { flex: none; width: 260px; display: flex; flex-direction: column; overflow-y: visible; max-height: none; }
.hive-left-col > .hive-cross { width: 100%; }
.hive-right-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.hive-tab-bar {
  display: flex; gap: 0; border-bottom: 2px solid var(--honey);
  margin-bottom: 14px; flex-shrink: 0;
}
.hive-tab {
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  background: transparent; border: none; border-bottom: 3px solid transparent;
  cursor: pointer; color: var(--ink-soft); margin-bottom: -2px;
  border-radius: 6px 6px 0 0; transition: color .12s;
}
.hive-tab:hover { color: var(--ink); background: var(--paper-2); }
.hive-tab.active { color: var(--honey-dk); border-bottom-color: var(--honey-dk); background: transparent; }
.hive-tab-panel { flex: 1; min-height: 0; overflow-y: auto; }
.hive-tab-hidden { display: none; }

/* Primary action row — big buttons at the top of the actions panel */
.action-primary-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 2px solid var(--honey);
}
.action-primary-row .btn { font-size: 14px; padding: 10px 16px; }
.btn-action {
  background: var(--paper-2); border-color: var(--line-dk);
}

.cross-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--honey-dk); margin-bottom: 8px;
}
.cross-stack { display: flex; flex-direction: column; align-items: center; }

/* Individual boxes (super / brood) */
.cross-box {
  width: 210px; border: 2px solid #8a6a38;
  background: linear-gradient(180deg, #ead592, #d4af68);
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.cross-box.clickable { cursor: pointer; }
.cross-box.clickable:hover { filter: brightness(1.06); outline: 2px solid var(--honey-dk); outline-offset: -1px; }
.cross-super { min-height: 62px; }
.cross-brood { min-height: 84px; }
.cross-excluder {
  width: 210px; height: 14px;
  background: repeating-linear-gradient(90deg, #b59a63 0 4px, #d4bf88 4px 8px);
  display: flex; align-items: center;
}
.cross-excluder-label { font-size: 8px; font-weight: 700; color: #6a4a22; padding: 0 5px; }

.cross-box-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; color: #6a4a22;
  padding: 3px 5px 0; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 11 frame strips inside each box */
.cross-frames {
  display: flex; flex: 1; gap: 1px; padding: 3px 4px 2px; align-items: stretch; min-height: 0;
}
.cross-frame {
  flex: 1; position: relative; border-radius: 1px; overflow: hidden;
  border: 1px solid rgba(139, 90, 43, 0.25); background: #e9d5a3;
  min-height: 36px; cursor: pointer;
}
.cross-frame:hover { outline: 1.5px solid #7a5a28; z-index: 2; }
.cross-frame.cf-has-queen { border-color: #b8880a; border-width: 1.5px; }
.cross-frame.cf-has-qcell { border-color: #c02020; border-width: 1.5px; }
.cross-frame-strip.cf-unknown {
  flex: 1; min-height: 36px; border-radius: 1px; border: 1px solid rgba(139,90,43,0.15);
  background: repeating-linear-gradient(135deg,#d8cdb0 0px,#d8cdb0 3px,#c8bcA0 3px,#c8bcA0 6px);
  opacity: 0.55;
}
.cross-frame.cf-foundation {
  background: repeating-linear-gradient(
    45deg, #f2ede0 0px, #f2ede0 2px, #e0d8c4 2px, #e0d8c4 4px
  );
  border-color: rgba(160,140,100,0.3);
  opacity: 0.75;
}

/* Frame band colours — match cell type palette */
.cf-band.cf-honey    { background: #d07010; }
.cf-band.cf-nectar   { background: #f0c010; }
.cf-band.cf-pollen   { background: #d04818; }
.cf-band.cf-capped   { background: #b87840; }
.cf-band.cf-larva    { background: #c8e8b0; }
.cf-band.cf-eggs     { background: #f0ece0; }
.cf-band.cf-drone    { background: #704828; }
.cf-band.cf-empty    { background: #cfc4a4; }

/* Queen / queen-cell marker dots on frame strip */
.cf-queen-dot {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: #f5d800; border: 1.5px solid #8a6a00;
  left: 50%; bottom: 28%; transform: translateX(-50%);
  z-index: 4; box-shadow: 0 1px 2px rgba(0,0,0,0.45);
}
.cf-qcell-dot {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: #c83030; border: 1px solid #6a1010;
  left: 50%; bottom: 6%; transform: translateX(-50%);
  z-index: 4;
}

/* Super fill bar */
.cross-fill-bar {
  height: 5px; background: #c8aa60; margin: 1px 4px 3px;
  border-radius: 2px; overflow: hidden; flex: none;
}
.cross-fill-fill { height: 100%; border-radius: 2px; transition: width .4s ease; }

/* Hive floor under brood boxes */
.cross-floor {
  width: 210px; height: 11px;
  background: #7a5a28; border-radius: 0 0 3px 3px;
  border: 2px solid #5a3c18; border-top: none;
  display: flex; align-items: center; justify-content: center;
}
.cross-entrance-tab {
  width: 28px; height: 7px; background: #3a2a12; border-radius: 1px;
}

/* Swarm pressure bar */
.cross-swarm-bar { width: 210px; margin-top: 9px; }
.csb-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 3px;
}
.csb-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-soft); }
.csb-pct   { font-size: 10px; font-weight: 700; }
.csb-track { height: 6px; background: #ddd0b8; border-radius: 3px; overflow: hidden; }
.csb-fill  { height: 100%; border-radius: 3px; transition: width .4s ease; }

/* Meta lines below the stack */
.cross-meta-line  { font-size: 11px; color: var(--ink-soft); margin-top: 4px; }
.cross-click-hint { font-size: 10px; color: var(--ink-faint); margin-top: 5px; font-style: italic; }

/* Queen cell peanut overlays on brood box */
.cross-box { position: relative; }
.cross-qcell-overlay {
  position: absolute; display: flex; gap: 3px;
  z-index: 6; pointer-events: none;
}
.cross-qcells-bottom {
  bottom: -7px; left: 50%; transform: translateX(-50%);
  flex-direction: row;
}
.cross-qcells-face {
  left: 6px; top: 50%; transform: translateY(-50%);
  flex-direction: column;
}
.cross-qcell-peanut {
  width: 8px; height: 14px;
  background: radial-gradient(ellipse 60% 100% at 50% 80%, #d4a030 60%, #a07020 100%);
  border: 1.5px solid #7a5010;
  border-radius: 40% 40% 50% 50% / 30% 30% 70% 70%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.cross-qcell-peanut.qc-capped {
  background: radial-gradient(ellipse 60% 100% at 50% 80%, #c07820 60%, #804808 100%);
  border-color: #502800;
}
.cross-qcell-peanut.qc-super {
  background: radial-gradient(ellipse 60% 100% at 50% 80%, #c84030 60%, #882018 100%);
  border-color: #501010;
  border-radius: 50% 50% 50% 50%;
  width: 9px; height: 9px;
}

/* Swarm imminent — brood box pulsing glow */
@keyframes swarm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 40, 20, 0); outline-color: #c82814; }
  50%       { box-shadow: 0 0 8px 3px rgba(200, 40, 20, 0.55); outline-color: #ff4020; }
}
.cross-brood-imminent {
  outline: 2px solid #c82814 !important;
  outline-offset: -1px !important;
  animation: swarm-pulse 1.2s ease-in-out infinite;
}

/* Demaree top-box style */
.cross-brood-demaree {
  outline: 2px dashed var(--honey-dk) !important;
  outline-offset: -1px !important;
  background: linear-gradient(180deg, #f5e8b0, #d8bc72) !important;
}

/* OSR warning blocks */
.cross-osr-warn {
  font-size: 10px; font-weight: 700; color: #8a3000;
  background: #fde8c8; border: 1px solid #c07020; border-radius: 3px;
  padding: 3px 6px; margin-top: 6px; width: 210px; box-sizing: border-box;
}
.cross-osr-notice {
  font-size: 10px; color: var(--honey-dk);
  background: #fef4d8; border: 1px solid #d4a020; border-radius: 3px;
  padding: 2px 6px; margin-top: 5px; width: 210px; box-sizing: border-box;
}

/* Demaree info block */
.cross-demaree-info {
  font-size: 10px; color: var(--ink-soft);
  background: #f4ecd0; border: 1px solid #c0a050; border-radius: 3px;
  padding: 2px 6px; margin-top: 5px; width: 210px; box-sizing: border-box;
}

/* Queen cells meta line */
.cross-qc-meta {
  font-size: 11px; color: var(--ink-soft); margin-top: 4px;
}

/* Urgent highlight for imminent states */
.qc-urgent {
  color: #b01810 !important; font-weight: 700;
  background: #fde8e0 !important; border-color: #c82020 !important;
  border-radius: 3px; padding: 2px 5px;
}

/* Hive card inspection urgency badge */
.hive-insp-badge {
  font-size: 11px; font-weight: 700; border-radius: 3px;
  padding: 1px 5px; margin-top: 2px; display: inline-block;
}
.insp-warn    { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.insp-urgent  { background: var(--bad-bg);  color: var(--bad);  border: 1px solid var(--bad);  }

/* Hive card urgency badges */
.badge-warn     { background: var(--warn-bg,#fef3c7); color: var(--honey-dk); }
.badge-bad      { background: var(--bad-bg,#fee2e2);  color: var(--bad,#c03030); }
.badge-imminent {
  background: #ffe0d0; color: #b01810;
  animation: swarm-pulse 1.2s ease-in-out infinite;
}

/* ====================================================================
   BUG A/B FIX — Foundation vs drawn empty super states
   ==================================================================== */

/* Foundation super: pale grey-cream background, clearly undrawn */
.cross-super-foundation {
  background: linear-gradient(180deg, #e8e4d8, #d6d0bc) !important;
  opacity: 0.85;
}

/* Foundation note label inside the super box */
.cross-foundation-note {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; color: var(--ink-soft);
  background: rgba(180,160,120,0.25); border-radius: 2px;
  padding: 1px 5px; margin: 0 4px 2px; text-align: center;
  flex: none;
}

/* Bug B fix: empty drawn comb — light amber, distinguishable from foundation grey */
.cross-super-empty {
  background: linear-gradient(180deg, #f5ead8, #e8d8b0) !important;
}

/* ====================================================================
   BUG D FIX — Swarm peanut: add qc-swarm tint rule (was missing)
   ==================================================================== */

/* Swarm cells (hanging from bottom): warm wax tone — distinct from supersedure */
.cross-qcell-peanut.qc-swarm {
  background: radial-gradient(ellipse 60% 100% at 50% 80%, #d4b030 60%, #a07820 100%);
  border-color: #7a5a10;
}

/* Post-swarm cells: muted orange-grey — old queen gone, virgin present */
.cross-qcell-peanut.qc-post-swarm {
  background: radial-gradient(ellipse 60% 100% at 50% 80%, #c09050 60%, #806030 100%);
  border-color: #604818;
  opacity: 0.8;
}

/* ====================================================================
   BUG H FIX — Dead colony cross-section state
   ==================================================================== */

.hive-cross-dead { opacity: 0.7; filter: grayscale(0.5); }

.cross-dead-state {
  width: 210px; min-height: 180px;
  background: linear-gradient(180deg, #c8c0b0, #b0a898);
  border: 2px solid #8a8278; border-radius: 4px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 18px;
}

.cross-dead-icon { font-size: 36px; }

.cross-dead-label {
  font-family: var(--serif); font-size: 14px; font-weight: 700;
  color: var(--ink); text-transform: uppercase; letter-spacing: .5px;
}

.cross-dead-reason {
  font-size: 12px; color: var(--ink-soft); text-align: center;
  background: rgba(0,0,0,0.08); border-radius: 4px;
  padding: 4px 8px; line-height: 1.4;
}

/* ====================================================================
   HIVE STACK EDITOR
   ==================================================================== */

.hive-left-col {
  display: flex; flex-direction: column; gap: 12px;
  flex: none; width: 260px;
}

.hive-stack-editor {
  background: var(--paper-2); border: 1px solid var(--line-dk);
  border-radius: 6px; padding: 10px 12px;
  font-size: 12px;
}

.stack-editor-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--honey-dk); margin-bottom: 8px;
}

.stack-editor-list {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px;
}

.stack-item {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 8px; min-height: 28px;
}

.stack-item-floor {
  background: #e8dfc8; border-color: #b8a070; color: var(--ink-soft);
  font-style: italic;
}

.stack-item-icon { font-size: 14px; flex: none; width: 20px; text-align: center; }
.stack-item-label { flex: 1; color: var(--ink); }
.stack-item-hint { font-size: 10px; color: var(--ink-faint); white-space: nowrap; }

.stack-item-remove {
  flex: none; font-size: 10px; padding: 2px 7px;
  background: var(--paper-2); border-color: var(--line-dk);
  color: var(--ink-soft);
}
.stack-item-remove:hover { background: #fde; border-color: #c88; color: #933; }

.stack-editor-warnings {
  margin-bottom: 8px;
}

.stack-item-warn {
  font-size: 11px; color: #9a5c00; background: #fff3cd;
  border: 1px solid #f0c060; border-radius: 4px;
  padding: 4px 8px; margin-bottom: 4px; line-height: 1.4;
}

.stack-palette {
  display: flex; flex-direction: column; gap: 4px;
  border-top: 1px solid var(--line); padding-top: 8px;
}

.stack-palette-item {
  font-size: 11px; padding: 5px 10px; text-align: left;
  background: var(--paper); border-color: var(--honey);
  color: var(--honey-dk); font-weight: 600;
}
.stack-palette-item:hover { background: var(--honey); color: #fff; }

/* On mobile, left col stacks naturally with the rest */
@media (max-width: 860px) {
  .hive-left-col { width: 100%; }
}

/* ====================================================================
   HIVE CARD — swarm pressure strip
   ==================================================================== */

.hive-swarm-strip {
  width: 68px; height: 4px; margin: 0 auto 2px;
  background: linear-gradient(90deg, var(--spc, #4a9e5c) var(--sp, 20%), #ddd0b8 var(--sp, 20%));
  border-radius: 2px;
}

/* ====================================================================
   FRAME MANAGEMENT MODAL
   ==================================================================== */

.frame-mgmt-body { display: flex; flex-direction: column; gap: 16px; }
.fm-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--honey-dk); margin-bottom: 7px;
}
.fm-thumbs-row { display: flex; gap: 4px; }
.fm-frame-thumb {
  width: 28px; height: 90px; border-radius: 2px;
  border: 2px solid #9a7b44; cursor: pointer;
  position: relative; overflow: hidden; background: #e9d5a3;
  flex-shrink: 0;
}
.fm-frame-thumb:hover { outline: 2px solid var(--honey-dk); outline-offset: 1px; }
.fm-frame-thumb.fm-frame-selected { outline: 3px solid var(--honey-dk); outline-offset: 1px; }
.fm-frame-num {
  position: absolute; bottom: 2px; left: 0; right: 0;
  text-align: center; font-size: 8px; font-weight: 700;
  color: rgba(60, 40, 10, 0.6); z-index: 10; pointer-events: none;
}
.fm-frames-section { background: var(--parch-2); border-radius: 8px; padding: 10px 12px; }

.fm-detail-wrap { display: flex; gap: 16px; align-items: flex-start; }
.fm-detail-right { flex: 1; }
.fm-frame-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.fm-frame-title { font-weight: 700; font-size: 14px; }
.fm-flip-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border: 1.5px solid var(--honey-dk); border-radius: 20px;
  background: var(--parch-2); color: var(--honey-dk);
  font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.fm-flip-btn:hover { background: var(--honey-dk); color: white; }
.fm-flip-btn--b {
  background: var(--honey-dk); color: white;
}
.fm-flip-icon { font-size: 13px; }
.fm-frame-state { font-size: 11px; color: var(--ink-soft); margin-top: 8px; }

.fm-super-info {
  font-size: 12px; background: var(--parch-2); border-radius: 6px; padding: 9px 12px;
}
.fm-si-row   { margin-bottom: 4px; }
.fm-si-note  { color: var(--ink-soft); }
.fm-si-advice {
  margin-top: 7px; font-size: 11px; padding: 5px 8px; border-radius: 4px;
}
.fm-si-advice.good { background: var(--ok-bg);   color: var(--ok); }
.fm-si-advice.warn { background: var(--warn-bg); color: var(--warn); }

/* fm-comb-col: wraps hex comb (brood or super) in detail view */
.fm-comb-col { flex: none; display: flex; flex-direction: column; align-items: flex-start; }
.fm-comb-side { flex: 1; min-width: 0; }
.fm-comb-tip  { font-size: 11px; color: var(--ink-soft); margin-top: 8px; line-height: 1.4; }

/* Super frame comb wrapper */
.fm-super-comb-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.fm-sfv-pct {
  font-size: 11px; font-weight: 700; color: var(--honey-dk);
}

.colony-known-note {
  font-size: 12px; font-style: italic; color: var(--info);
  background: var(--info-bg); border-radius: 6px; padding: 6px 9px; margin-bottom: 10px;
}

/* ====================================================================
   HARVEST DIALOG
   ==================================================================== */

.harv-body { display: flex; flex-direction: column; gap: 12px; }
.harv-intro { font-size: 13px; color: var(--ink-soft); }
.harv-rows { display: flex; flex-direction: column; gap: 8px; }
.harv-super-row { background: var(--parch-2); border-radius: 6px; padding: 6px 10px; }
.harv-super-label {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 13px;
}
.harv-cb { width: 16px; height: 16px; cursor: pointer; accent-color: var(--honey-dk); }
.harv-super-num { font-weight: 700; min-width: 56px; }
.harv-fill-bar {
  flex: 1; height: 8px; background: #ddd0b8; border-radius: 4px; overflow: hidden;
}
.harv-fill-fill { height: 100%; border-radius: 4px; transition: width .3s ease; }
.harv-kg  { font-weight: 700; min-width: 52px; text-align: right; }
.harv-pct { font-size: 11px; color: var(--ink-soft); min-width: 36px; }
.harv-type { font-size: 11px; color: var(--honey-dk); font-style: italic; }

.harv-note {
  font-size: 11px; padding: 7px 10px; border-radius: 5px;
  background: var(--ok-bg); color: var(--ok);
}
.harv-note.warn { background: var(--warn-bg); color: var(--warn); }

/* ====================================================================
   INSPECTION VIEW
   ==================================================================== */

/* big comb */
.comb {
  --c: 13px;
  flex: none; padding: 10px; background: #9a7b44; border-radius: 6px;
  border: 3px solid #7d6033; position: relative;
}
.comb.has-bottom-qc { margin-bottom: 26px; }
.comb-grid { display: flex; flex-direction: column; gap: 1px; }
.comb-line { display: flex; gap: 1px; }
.comb-line:nth-child(even) { margin-left: 7px; }
.cell {
  width: 14px; height: 14px;
  clip-path: polygon(50% 0,100% 25%,100% 75%,50% 100%,0 75%,0 25%);
  background: var(--wax);
}
/* Cell type palette — maximally distinct.
   Problem solved: separate hue for every category, patterns for lookalike pairs. */
.cell.empty   { background: #cfc4a4; }
.cell.found   { background: #c9aa6a; }
/* Eggs: pale cream + fine dot grid (tiny eggs standing upright) */
.cell.eggs    { background: #f0ece0;
                background-image: radial-gradient(circle, #b8a880 1px, transparent 1px);
                background-size: 4px 4px; }
/* Larva: sage green — larvae float in pearlescent royal jelly, greenish tint */
.cell.larva   { background: #c8e8b0; }
/* Capped brood: warm brown cappings */
.cell.capbrood{ background: #b87840; }
/* Drone brood: darker brown + diagonal hatch to distinguish from capped worker */
.cell.dronebr { background: #704828;
                background-image: repeating-linear-gradient(45deg, transparent, transparent 2px,
                                  rgba(255,255,255,0.18) 2px, rgba(255,255,255,0.18) 4px); }
/* Nectar: bright yellow — fresh, watery */
.cell.nectar  { background: #f0c010; }
/* Honey: deep amber — fully ripened, darker and richer than nectar */
.cell.honey   { background: #d07010; }
/* Pollen: vivid orange-red — protein stores are distinctly coloured in the hive */
.cell.pollen  { background: #d04818; }
/* Queen cell: royal purple — unmistakable peanut, treat it as unmistakable in legend too */
.cell.qcell   { background: #7850a0; }
/* Disease: dark grey-olive + diagonal warning stripe */
.cell.disease { background: #585848;
                background-image: repeating-linear-gradient(-45deg, transparent, transparent 3px,
                                  rgba(255,255,255,0.2) 3px, rgba(255,255,255,0.2) 4px); }
/* Mite: bright scarlet */
.cell.mite    { background: #c01828; }
.comb-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 11px; }
.comb-legend span { display: flex; align-items: center; gap: 4px; }
.comb-legend i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

.frame-read { flex: 1; }
.read-line { display: flex; gap: 7px; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.read-line .ico { flex: none; }

/* the queen and queen cells drawn on the comb */
.comb-queen {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 12px; height: 22px; z-index: 4;
  border-radius: 50% 50% 48% 48% / 26% 26% 70% 70%;
  background: repeating-linear-gradient(165deg, #2c2010 0 2.6px, #e8a92e 2.6px 5.6px);
  border: 1px solid #241a0c;
  box-shadow: 0 1px 3px rgba(0,0,0,0.55);
}
.comb-queen::after {            /* the queen's coloured mark */
  content: ''; position: absolute; left: 50%; top: 3px; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%;
  background: #f3efe1; border: 1px solid #8a7a48;
}
.queen-mini {                   /* small drawn queen used inline in text */
  display: inline-block; vertical-align: -2px;
  width: 9px; height: 15px; margin-right: 4px;
  border-radius: 50% 50% 48% 48% / 26% 26% 70% 70%;
  background: repeating-linear-gradient(165deg, #2c2010 0 2px, #e8a92e 2px 4px);
  border: 1px solid #241a0c;
}
.comb-qcells { position: absolute; display: flex; gap: 7px; z-index: 5; }
.comb-qcells.at-bottom { left: 0; right: 0; bottom: -20px; justify-content: center; }
.comb-qcells.on-face { left: 50%; top: 38%; transform: translateX(-50%); }
.queen-cell {                   /* a wax queen cell — pale, pitted, peanut-shaped */
  width: 13px; height: 27px; position: relative;
  background: linear-gradient(180deg, #ecd49a 0%, #d4ad62 58%, #bd9550 100%);
  border: 1px solid #9a7a40;
  border-radius: 6px 6px 7px 7px / 8px 8px 17px 17px;
  box-shadow: inset 0 2px 3px rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.3);
}
.queen-cell::after {            /* the sculptured, pitted texture */
  content: ''; position: absolute; inset: 3px 2px 6px;
  background:
    radial-gradient(circle at 35% 20%, rgba(120,85,35,0.5) 1px, transparent 2.3px),
    radial-gradient(circle at 64% 40%, rgba(120,85,35,0.5) 1px, transparent 2.3px),
    radial-gradient(circle at 38% 60%, rgba(120,85,35,0.45) 1px, transparent 2.3px),
    radial-gradient(circle at 60% 80%, rgba(120,85,35,0.4) 1px, transparent 2.3px);
}
.box-frame-qc {                 /* tiny queen cell marker on an examined frame */
  position: absolute; bottom: 3px; left: 3px; z-index: 3;
  width: 7px; height: 13px;
  background: linear-gradient(180deg, #ecd49a, #c9a45f);
  border: 1px solid #9a7a40;
  border-radius: 4px 4px 5px 5px / 5px 5px 11px 11px;
}

/* inspection — progress, locked summary, score */
.inspect-progress {
  font-size: 13px; font-weight: 600; color: var(--honey-dk);
  background: var(--warn-bg); border: 1px solid var(--honey);
  border-radius: 8px; padding: 8px 12px; margin-bottom: 12px;
}
.inspect-progress.done { background: var(--ok-bg); border-color: var(--ok); color: var(--leaf-dk); }
.inspect-locked {
  display: flex; gap: 11px; align-items: center;
  background: var(--paper-2); border: 1px dashed var(--line-dk);
  border-radius: 9px; padding: 14px 16px; margin-top: 14px;
  font-size: 13px; color: var(--ink-soft); line-height: 1.5;
}
.inspect-locked .lock-ico { font-size: 22px; flex: none; }
.inspect-score {
  font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--info-bg); border-left: 4px solid var(--info);
  border-radius: 0 8px 8px 0; padding: 9px 12px; margin: 12px 0;
}

/* inspection — the per-frame teaching question */
.qa-block {
  background: var(--paper-2); border: 1px solid var(--line-dk);
  border-radius: 10px; padding: 12px 14px; margin-top: 14px;
}
.qa-q { font-weight: 700; font-size: 14px; color: var(--ink); margin-bottom: 9px; line-height: 1.4; }
.qa-options { display: flex; flex-direction: column; gap: 7px; }
.qa-option {
  border: 1px solid var(--line-dk); background: var(--paper);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.4;
}
.qa-option.live { cursor: pointer; transition: background .12s, border-color .12s; }
.qa-option.live:hover { border-color: var(--honey); background: var(--warn-bg); }
.qa-option.chosen-correct { background: var(--ok-bg); border-color: var(--ok); color: var(--leaf-dk); font-weight: 700; }
.qa-option.chosen-wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); font-weight: 700; }
.qa-option.is-answer { background: var(--ok-bg); border-color: var(--ok); }
.qa-option.dim { opacity: .5; }
.qa-feedback {
  margin-top: 10px; font-size: 13px; line-height: 1.6;
  border-radius: 8px; padding: 9px 12px;
}
.qa-feedback.right { background: var(--ok-bg); color: var(--leaf-dk); }
.qa-feedback.wrong { background: var(--warn-bg); color: var(--ink); border: 1px solid var(--honey); }
.qa-feedback b { font-weight: 800; }

/* the plain frame reading shown once the teaching Q&A is done with */
.frame-reading {
  background: var(--info-bg); border-left: 4px solid var(--info);
  border-radius: 0 8px 8px 0; padding: 10px 13px; margin-top: 14px;
  font-size: 13px; line-height: 1.6;
}
.frame-reading b { color: var(--info); }
.find-result {
  padding: 10px; border-radius: 8px; font-size: 14px; font-weight: 600; margin-top: 8px;
}
.find-result.found { background: var(--ok-bg); color: var(--leaf-dk); }
.find-result.miss  { background: var(--warn-bg); color: var(--honey-dk); }

.inspect-summary { background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 12px; }
.inspect-summary h4 { color: var(--honey-dk); margin-bottom: 6px; }
.inspect-summary ul { margin-left: 18px; }
.inspect-summary li { margin: 3px 0; font-size: 13px; }

/* ====================================================================
   MARKET
   ==================================================================== */

.shop-item {
  display: flex; gap: 10px; padding: 9px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--paper); align-items: center; margin-bottom: 7px;
}
.shop-item .ico { font-size: 26px; flex: none; width: 34px; text-align: center; }
.shop-item .meta { flex: 1; min-width: 0; }
.shop-item .meta b { font-size: 13.5px; }
.shop-item .meta p { font-size: 12px; color: var(--ink-soft); line-height: 1.4; }
.shop-item .price { font-family: var(--serif); font-weight: 700; color: var(--honey-dk); white-space: nowrap; }
.shop-item .shop-action { flex: none; }
.shop-buy { white-space: nowrap; }
.shop-buy .shop-price { margin-left: 7px; font-weight: 700; opacity: .95; }
.shop-list { display: flex; flex-direction: column; gap: 8px; }

/* market — help banner, tabs, kit strip */
.market-help {
  background: var(--warn-bg); border: 1px solid var(--honey); border-radius: 10px;
  padding: 12px 15px; font-size: 13.5px; line-height: 1.55; margin-bottom: 16px;
}
.market-help b { color: var(--honey-dk); }
.market-help.soft { background: var(--info-bg); border-color: var(--info); }
.market-help.soft b { color: var(--info); }
.market-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.market-tab {
  border: 1px solid var(--line-dk); background: var(--paper); color: var(--ink-soft);
  font-size: 13px; font-weight: 700; padding: 8px 15px; border-radius: 9px;
  display: flex; align-items: center; gap: 6px;
}
.market-tab:hover { background: var(--paper-2); }
.market-tab.active {
  background: linear-gradient(180deg, var(--honey), var(--honey-deep));
  border-color: var(--honey-dk); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.2);
}
.kit-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.kit-item {
  flex: 1; min-width: 110px; background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 10px; text-align: center;
}
.kit-item b { display: block; font-family: var(--serif); font-size: 17px; color: var(--honey-dk); }
.kit-item small { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); }
.apiary-line {
  display: flex; align-items: center; gap: 11px; padding: 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper-2); margin-bottom: 8px;
}
.apiary-line .ico { font-size: 24px; flex: none; }
.apiary-line .meta { flex: 1; min-width: 0; }
.apiary-line .meta b { font-size: 13.5px; }
.apiary-line .meta p { font-size: 12px; color: var(--ink-soft); }

/* apiary yard — illustrated countryside scene behind the hives */
.yard { position: relative; background: #9bb766; }
.yard-scene { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.yard-scene svg { width: 100%; height: 100%; display: block; }
.yard-row { position: relative; z-index: 1; }

/* ====================================================================
   HANDBOOK
   ==================================================================== */

.book { display: flex; gap: 16px; height: 100%; }
.book-toc { width: 250px; flex: none; overflow-y: auto; }
.book-cat { margin-bottom: 8px; }
.book-cat > b { font-family: var(--serif); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--honey-dk); display: block; padding: 6px 4px 2px; }
.book-link { display: block; padding: 5px 10px; font-size: 13px; border-radius: 6px; color: var(--ink-soft); cursor: pointer; }
.book-link:hover { background: var(--paper-2); }
.book-link.active { background: var(--honey); color: #fff; font-weight: 600; }
.book-article { flex: 1; overflow-y: auto; background: var(--paper); border: 1px solid var(--line-dk); border-radius: 10px; padding: 22px 28px; box-shadow: var(--shadow); }
.book-article h2 { font-size: 23px; color: var(--honey-dk); margin-bottom: 4px; }
.book-article .acat { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-faint); margin-bottom: 14px; }
.book-article p { margin: 9px 0; }
.book-article h4 { margin: 14px 0 4px; color: var(--ink); font-size: 15px; }
.book-article ul { margin: 6px 0 6px 22px; }
.book-article li { margin: 3px 0; }
.book-search { width: 100%; padding: 7px 10px; border: 1px solid var(--line-dk); border-radius: 7px; margin-bottom: 8px; font-size: 13px; background: var(--paper); }

/* ====================================================================
   JOURNAL / LEDGER
   ==================================================================== */

.log-entry {
  display: flex; gap: 9px; padding: 7px 8px; border-bottom: 1px solid var(--line);
  font-size: 13px; border-radius: 5px; margin: 1px 0;
}
.log-entry .when { color: var(--ink-faint); font-size: 11px; white-space: nowrap; width: 92px; flex: none; }
.log-entry .ico { flex: none; }
.log-entry.good { background: var(--ok-bg); }
.log-entry.good .txt { color: var(--leaf-dk); }
.log-entry.bad  { background: var(--bad-bg); }
.log-entry.bad  .txt { color: var(--bad); font-weight: 600; }
.log-entry.warn { background: var(--warn-bg); }
.log-entry.warn .txt { color: var(--warn); }

.ledger-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ledger-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--line-dk); font-size: 11px; text-transform: uppercase; color: var(--ink-soft); }
.ledger-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ledger-table .amt.pos { color: var(--ok); font-weight: 700; }
.ledger-table .amt.neg { color: var(--bad); font-weight: 700; }
.ledger-table .desc-cell { color: var(--ink); max-width: 260px; word-break: break-word; }

/* ====================================================================
   TITLE / NEW GAME SCREEN
   ==================================================================== */

.title-screen {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 30%, #f6e6b8, var(--parch) 70%);
  overflow-y: auto; padding: 30px;
}
.title-card {
  background: var(--paper); border: 2px solid var(--honey-dk); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 32px 38px; max-width: 560px; width: 100%;
  text-align: center;
}
.title-card .game-name {
  font-family: var(--serif); font-size: 44px; color: var(--honey-dk);
  letter-spacing: 1px; line-height: 1;
}
.title-card .tagline { font-style: italic; color: var(--ink-soft); margin: 6px 0 4px; }
.title-card .bee-crest { font-size: 52px; margin-bottom: 6px; }
.title-card .field { text-align: left; margin: 14px 0; }
.title-card label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); display: block; margin-bottom: 5px; }
.title-card input[type=text] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-dk); border-radius: 8px;
  font-size: 15px; background: var(--paper-2);
}
.diff-picks { display: flex; gap: 8px; }
.diff-pick {
  flex: 1; border: 2px solid var(--line-dk); border-radius: 10px; padding: 10px;
  cursor: pointer; background: var(--paper-2); text-align: center;
}
.diff-pick:hover { border-color: var(--honey); }
.diff-pick.sel { border-color: var(--honey-dk); background: var(--warn-bg); }
.diff-pick .dn { font-family: var(--serif); font-weight: 700; font-size: 15px; }
.diff-pick .dd { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.diff-pick .di { font-size: 22px; }

/* ====================================================================
   DIALOG CONTENT HELPERS
   ==================================================================== */

.choice {
  display: flex; gap: 10px; padding: 11px; border: 1px solid var(--line-dk);
  border-radius: 9px; background: var(--paper-2); cursor: pointer; margin-bottom: 8px;
  align-items: flex-start;
}
.choice:hover { border-color: var(--honey); background: var(--warn-bg); }
.choice.disabled { opacity: .5; cursor: not-allowed; }
.choice .ci { font-size: 22px; flex: none; }
.choice .cb b { font-size: 14px; }
.choice .cb p { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.choice .cprice { margin-left: auto; font-weight: 700; color: var(--honey-dk); white-space: nowrap; }

.explain {
  background: var(--info-bg); border-left: 4px solid var(--info);
  border-radius: 0 8px 8px 0; padding: 10px 12px; font-size: 13px; margin: 10px 0;
}
.explain b { color: var(--info); }
.explain.lesson { background: var(--warn-bg); border-color: var(--honey-dk); }
.explain.lesson b { color: var(--honey-dk); }

/* teaching explainer modal — a clean note with a honeycomb-cell icon badge */
.explainer-art {
  width: 70px; height: 70px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  background: radial-gradient(circle at 38% 30%, #f8e4ad, var(--honey-deep));
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 3px 5px rgba(120,90,30,0.35));
}
.explainer-body { font-size: 14px; line-height: 1.62; color: var(--ink); }
.explainer-body p { margin: 9px 0; }
.explainer-body p:first-child { margin-top: 0; }
.explainer-body b, .explainer-body strong { color: var(--honey-dk); }
.explainer-body .explain { margin: 12px 0; }

/* toast notifications */
.toast-stack { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: var(--wax); padding: 9px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toastIn .2s, toastOut .3s 4.1s forwards;
}
.toast.good { background: var(--leaf-dk); }
.toast.bad { background: var(--bad); }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-8px); opacity: 0; } }

/* tooltip */
.tooltip {
  position: fixed; z-index: 300; max-width: 240px; pointer-events: none;
  background: var(--ink); color: var(--wax); font-size: 12px; line-height: 1.4;
  padding: 7px 10px; border-radius: 7px; box-shadow: var(--shadow-lg);
}
.gloss { border-bottom: 1px dotted var(--honey-dk); cursor: help; }

/* season tint of the yard */
.yard.spring { background: linear-gradient(180deg,#cfe0e6 0%,#dbe7cf 38%,#bcd083 38%,#a9c172 100%); }
.yard.summer { background: linear-gradient(180deg,#bcd9e6 0%,#d3e3c3 38%,#aec06d 38%,#9bb05f 100%); }
.yard.autumn { background: linear-gradient(180deg,#d3d8cf 0%,#e0d3ab 38%,#c9a85e 38%,#b9974f 100%); }
.yard.winter { background: linear-gradient(180deg,#d6dde0 0%,#e6e6e0 38%,#dfe2df 38%,#cfd4cf 100%); }

.empty-state { text-align: center; color: var(--ink-faint); padding: 40px 20px; }
.empty-state .big { font-size: 44px; }

@media (max-width: 860px) {
  .apiary-side { width: 250px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hive-detail { flex-direction: column; }
}

/* ====================================================================
   MOBILE — phones and narrow windows
   ==================================================================== */
@media (max-width: 640px) {
  * { -webkit-tap-highlight-color: rgba(0,0,0,0); }
  /* keep form fields at 16px+ so iOS Safari does not zoom in on focus */
  input, select, textarea { font-size: 16px; }

  /* --- top bar: weather + week + cash only (drop brand name) --- */
  .topbar { height: 52px; gap: 8px; padding: 0 10px; }
  .topbar .brand { display: none; }  /* reclaim space on mobile */
  .topbar-clock { gap: 6px; min-width: 0; }
  .topbar-clock .weather-ico { font-size: 20px; }
  .topbar-clock .when { min-width: 0; }
  .topbar-clock .when b { font-size: 13px; }
  .topbar-clock .when small { display: none; } /* year label too small to be useful */
  .topbar-stat b { font-size: 13px; }
  .topbar-stat small { font-size: 9px; letter-spacing: .3px; }
  .topbar-stat.ev { display: none; }
  .topbar-stat.skill { display: none; }
  .topbar-btn { min-width: 44px; min-height: 44px; font-size: 18px; border-radius: 10px; }

  /* --- nav: iOS-style bottom bar --- */
  .navbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    gap: 0; padding: 4px 0 env(safe-area-inset-bottom, 4px);
    border-top: 1px solid var(--line-dk); border-bottom: none;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.10);
    background: var(--parch-2);
  }
  .nav-btn {
    position: relative; flex: 1 1 0; min-width: 0; min-height: 52px;
    flex-direction: column; gap: 2px;
    padding: 6px 2px; font-size: 11px; letter-spacing: 0; text-align: center;
    border-radius: 0; border: none;
  }
  .nav-btn.active {
    background: var(--warn-bg); color: var(--honey-dk);
    border: none; border-bottom: none; margin-bottom: 0;
  }
  .nav-btn .ico { font-size: 18px; }
  .nav-btn .pip { position: absolute; top: 3px; right: 8px; }

  /* push content above the fixed bottom navbar + iOS home bar */
  .stage { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }

  /* toast floats above the FAB (56px) which sits 68px above navbar */
  .toast-stack { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }

  /* --- apiary: stack the scene above the adviser panel --- */
  .apiary-view { flex-direction: column; }
  .apiary-side {
    width: 100%; flex: 0 0 44%;
    border-left: none; border-top: 2px solid var(--line-dk);
  }
  .apiary-head { padding: 8px 12px; gap: 6px 10px; flex-wrap: wrap; }
  .apiary-head h2 { font-size: 16px; }
  .apiary-head .forage-note { width: 100%; }
  .yard { padding: 12px; }
  .yard-row { padding: 16px 6px 34px; gap: 14px 12px; }

  /* smaller hives so several colonies fit a phone-sized yard */
  .hive { width: 100px; }
  .hive-roof { width: 88px; height: 13px; }
  .hive-box { width: 79px; }
  .hive-box.brood { height: 33px; }
  .hive-box.super { height: 18px; }
  .hive-box::before { width: 30px; }
  .hive-floor { width: 88px; height: 10px; }
  .hive-floor::after { width: 56px; }
  .hive-stand { width: 72px; height: 13px; }
  .hive-plaque { min-width: 86px; padding: 3px 7px; margin-top: 6px; }
  .hive-plaque .nm { font-size: 12px; }
  .hive-plaque .st { font-size: 11px; }
  .hive-plaque .st-age { font-size: 10px; }
  .hive-badge { font-size: 15px; }
  .add-hive-slot { width: 100px; min-height: 104px; font-size: 12px; }
  .add-hive-slot .plus { font-size: 24px; }

  /* --- panels: tighter gutters --- */
  .panel-view { padding: 14px 13px; }
  .panel-view.narrow { max-width: 100%; }

  /* --- market: tabs scroll horizontally, no wrap --- */
  .market-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
                 padding-bottom: 4px; gap: 4px; }
  .market-tab { flex: none; padding: 8px 12px; font-size: 12px; }
  .kit-item { min-width: 0; flex: 1 1 45%; }
  .shop-item .ico { font-size: 22px; width: 28px; }

  /* --- handbook: the contents list stacks above the article --- */
  .book { flex-direction: column; gap: 10px; }
  .book-toc {
    width: 100%; flex: none; max-height: 34%;
    border-bottom: 1px solid var(--line-dk); padding-bottom: 6px;
  }
  .book-article { padding: 16px 15px; }
  .book-article h2 { font-size: 20px; }

  /* --- title / new game --- */
  .title-screen { padding: 16px 12px; }
  .title-card { padding: 22px 18px; border-radius: 13px; }
  .title-card .game-name { font-size: 31px; }
  .title-card .bee-crest { font-size: 40px; }
  .diff-picks { flex-direction: column; }

  /* --- modals: near full-screen, body scrolls independently --- */
  .modal, .modal.wide, .modal.xwide {
    width: 96vw; max-height: 88dvh;
    display: flex; flex-direction: column;
  }
  .modal-body {
    padding: 14px; overflow-y: auto; flex: 1;
    -webkit-overflow-scrolling: touch;
  }
  .modal-head { padding: 11px 14px; flex: none; }
  .modal-head h3 { font-size: 16px; }
  .modal-foot { padding: 10px 14px; flex: none; }

  /* --- save/load action buttons: stack vertically on mobile --- */
  .sl-actions { flex-direction: column; }
  .sl-actions .btn { min-width: 0; width: 100%; justify-content: center; }

  /* --- hive detail: stack on mobile --- */
  .hive-detail { flex-direction: column; height: auto; }
  .hive-cross, .hive-right-col { max-height: none; overflow-y: visible; }
  .hive-tab-panel { overflow-y: visible; }

  /* --- inspection: frames scroll sideways, detail stacks --- */
  .inspect-box-inner { justify-content: flex-start; overflow-x: auto; padding-bottom: 4px; }
  .inspect-detail { flex-direction: column; }
  /* bigger frame touch targets */
  .box-frame { width: 44px; height: 120px; }

  /* --- statusbar: compact on mobile --- */
  .statusbar { height: 36px; padding: 0 8px; gap: 0; }
  .sb-stat { padding: 0 6px; }
  .sb-lbl { display: none; }
  .sb-val { font-size: 12px; }
  .sb-divider { margin: 0 2px; }

  /* --- spare hive slot: match hive card width on mobile --- */
  .spare-hive-slot { width: 100px; min-height: 104px; }
  .spare-hive-icon { font-size: 24px; }
  .spare-hive-label { font-size: 11px; }
  .spare-hive-sub { font-size: 9px; }

  /* --- minimum 44px touch targets everywhere --- */
  .btn { padding: 10px 15px; min-height: 44px; }
  .btn-sm { padding: 7px 11px; min-height: 40px; }
  .book-link { padding: 10px; min-height: 44px; display: flex; align-items: center; }
  .ag-option { padding: 12px 14px; }

  /* map grid: single column on mobile */
  .map-grid { grid-template-columns: 1fr; }
}

/* action education dialog — every action explained as you take it */
.action-guide { display: flex; flex-direction: column; gap: 0; }
.ag-art {
  width: 60px; height: 60px; margin: 2px auto 16px;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  background: radial-gradient(circle at 38% 30%, #f8e4ad, var(--honey-deep));
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 2px 5px rgba(120,90,30,0.32));
}
.ag-sec { margin-bottom: 11px; }
.ag-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--honey-dk); margin-bottom: 2px;
}
.ag-text { font-size: 13.5px; line-height: 1.55; color: var(--ink); }
.ag-context {
  background: var(--info-bg); border-left: 4px solid var(--info);
  border-radius: 0 8px 8px 0; padding: 9px 12px; font-size: 13px; margin: 13px 0 2px;
}
.ag-context b { color: var(--info); }
.ag-options { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.ag-option {
  text-align: left; border: 1px solid var(--line-dk); background: var(--paper-2);
  border-radius: 9px; padding: 10px 13px; cursor: pointer; font-family: var(--sans);
}
.ag-option:hover { border-color: var(--honey); background: var(--warn-bg); }
.ag-option-label { display: block; font-weight: 700; font-size: 13.5px; color: var(--ink); }
.ag-option-note { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.action-group {
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper-2);
  padding: 9px 11px; margin-top: 10px;
}
.action-group-title { font-size: 12px; font-weight: 700; color: var(--honey-dk); margin-bottom: 7px; }
.ag-cost {
  background: var(--paper-2); border: 1px solid var(--line-dk);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; line-height: 1.5; margin: 12px 0 2px;
}
.ag-cost b { color: var(--honey-dk); }
.ag-cost.bad { background: var(--bad-bg); border-color: var(--bad); }
.ag-cost.bad b { color: var(--bad); }

.shop-held { display: inline-block; font-size: 11px; font-weight: 700; color: var(--honey-dk); margin-top: 3px; }

/* hive detail — explained, colour-coded last-known state */
.known-list { display: flex; flex-direction: column; }
.known-row { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.known-row:last-child { border-bottom: none; }
.known-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.known-lbl { font-size: 13px; color: var(--ink-soft); }
.known-val { font-size: 13px; font-weight: 700; }
.known-val.good { color: var(--ok); }
.known-val.warn { color: var(--warn); }
.known-val.bad { color: var(--bad); }
.known-val.neutral { color: var(--ink); }
.known-explain { font-size: 12px; color: var(--ink-faint); line-height: 1.45; margin-top: 1px; }

/* inspection — lift frames out of the brood box */
.inspect-intro {
  background: var(--info-bg); border-left: 4px solid var(--info);
  border-radius: 0 8px 8px 0; padding: 10px 13px; font-size: 13px; line-height: 1.55;
  margin-bottom: 14px;
}
.inspect-intro b { color: var(--info); }
.inspect-box {
  background: linear-gradient(180deg, #8a6a3c, #6a5030);
  border: 3px solid #574226; border-radius: 9px; padding: 14px 12px 12px; margin-bottom: 18px;
}
.inspect-box-label {
  color: #f1ddab; font-size: 12px; font-weight: 700; text-align: center; margin-bottom: 12px;
}
.inspect-box-inner {
  display: flex; gap: 5px; align-items: flex-start; justify-content: center;
  min-height: 162px; padding-top: 32px;
}
.box-frame {
  position: relative; width: 48px; height: 130px; flex: none; cursor: pointer;
  background: var(--wax); border: 2px solid #9a7b44; border-radius: 3px;
  overflow: hidden; transition: transform .26s cubic-bezier(.34,1.18,.64,1), box-shadow .2s;
}
.box-frame:hover { transform: translateY(-10px); }
.box-frame.lifted {
  transform: translateY(-32px); box-shadow: 0 12px 20px rgba(0,0,0,0.42);
  border-color: var(--honey-dk); outline: 2px solid var(--honey);
}
.box-frame.seen::after {
  content: '✓'; position: absolute; top: 1px; right: 2px; font-size: 9px; color: var(--ok);
  z-index: 3; text-shadow: 0 0 2px #fff;
}
/* a frame not yet lifted shows plain comb — no contents revealed */
.box-frame.unseen {
  background:
    repeating-linear-gradient(0deg, rgba(150,118,62,0.13) 0 3px, transparent 3px 8px),
    var(--wax);
}
.box-frame-q {                  /* small drawn queen on an examined frame */
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 9px; height: 16px; z-index: 3;
  border-radius: 50% 50% 48% 48% / 26% 26% 70% 70%;
  background: repeating-linear-gradient(165deg, #2c2010 0 2px, #e8a92e 2px 4.3px);
  border: 1px solid #241a0c;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.box-frame-n {
  position: absolute; bottom: 1px; left: 0; right: 0; text-align: center;
  font-size: 9px; font-weight: 700; color: #6a4f28; z-index: 3;
}
.inspect-detail { display: flex; gap: 16px; margin-bottom: 14px; align-items: flex-start; }
.inspect-detail-read { flex: 1; min-width: 0; }
.inspect-frame-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.frame-note {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; font-size: 13px; margin: 8px 0;
}
.inspect-findings {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 14px; margin-bottom: 12px;
}
.inspect-findings h4, .inspect-next h4 { color: var(--honey-dk); margin-bottom: 7px; font-size: 15px; }
.inspect-next {
  background: var(--warn-bg); border: 1px solid var(--honey);
  border-radius: 9px; padding: 11px 14px; margin-top: 12px;
}
.inspect-rec {
  display: flex; align-items: center; gap: 9px; font-size: 13px;
  padding: 7px 0; border-top: 1px dashed var(--line-dk);
}
.inspect-rec:first-child { border-top: none; }
.inspect-rec .ico { flex: none; font-size: 14px; }
.inspect-rec .rec-text { flex: 1; }
.inspect-rec button { flex: none; }
.inspect-summary li.sum-urgent { color: var(--bad); font-weight: 700; }

/* ====================================================================
   GUIDED ACTION LIST (sidebar)
   ==================================================================== */

.action-count {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px;
  background: var(--bad-bg); color: var(--bad);
}
.action-count.tone-warn { background: var(--warn-bg); color: var(--warn); }
.action-count.tone-ok   { background: var(--ok-bg); color: var(--ok); }
.action-count.tone-info { background: var(--info-bg); color: var(--info); }

.action-item {
  padding: 9px 10px; border-radius: 8px; margin-bottom: 7px;
  border-left: 3px solid transparent;
}
.action-item.tone-bad  { background: var(--bad-bg);  border-left-color: var(--bad); }
.action-item.tone-warn { background: var(--warn-bg); border-left-color: var(--warn); }
.action-item.tone-ok   { background: var(--ok-bg);   border-left-color: var(--ok); }
.action-item.tone-info { background: var(--info-bg); border-left-color: var(--info); }

.action-urgency {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 4px;
}
.action-urgency.tone-bad  { color: var(--bad); }
.action-urgency.tone-warn { color: var(--warn); }
.action-urgency.tone-ok   { color: var(--ok); }
.action-urgency.tone-info { color: var(--info); }
.action-urgency .ico { font-size: 13px; }
.urgency-label { }

.action-text { font-size: 12.5px; line-height: 1.5; color: var(--ink); }
.action-open-btn {
  margin-top: 7px; font-size: 11.5px; padding: 3px 9px;
  background: rgba(255,255,255,0.7); border: 1px solid var(--line-dk);
}
.action-open-btn:hover { background: var(--honey); color: #fff; border-color: var(--honey-deep); }

.action-list { display: flex; flex-direction: column; }
.advisor-empty { font-size: 13px; color: var(--ink-faint); font-style: italic; padding: 6px 2px; }

/* Time controls moved to bottom */
.time-controls {
  padding: 12px 14px; background: var(--parch-2);
  border-top: 1px solid var(--line-dk);
  flex: none;
}
.time-controls .btn { width: 100%; justify-content: center; margin-bottom: 6px; }
.time-controls .btn:last-child { margin-bottom: 0; }

/* ====================================================================
   HONEY COLOR SWATCHES (sell tab)
   ==================================================================== */

.honey-swatch {
  width: 42px; height: 42px; border-radius: 6px; flex: none;
  border: 2px solid rgba(0,0,0,0.12); box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}
.honey-note {
  font-size: 11.5px; color: var(--warn); font-style: italic; margin-top: 2px;
}

/* ====================================================================
   TERRITORY MAP VIEW
   ==================================================================== */

.map-season-strip {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  padding: 10px 16px; border-radius: 8px; margin-bottom: 18px;
  background: var(--parch-2); border: 1px solid var(--line);
}
.map-season-strip.spring { background: #e8f4e0; border-color: #a8cc88; }
.map-season-strip.summer { background: #fffae0; border-color: #d4c060; }
.map-season-strip.autumn { background: #f8ece0; border-color: #c8a060; }
.map-season-strip.winter { background: #e8eef4; border-color: #a8b8cc; }

.map-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.map-territory {
  background: var(--paper); border: 1px solid var(--line-dk);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  border-top: 4px solid var(--territory-color, var(--leaf));
  transition: box-shadow 0.15s;
}
.map-territory:hover { box-shadow: var(--shadow-lg); }
.map-territory-active { border-width: 1px; border-top-width: 4px; }

.map-territory-header {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px 8px; border-bottom: 1px solid var(--line);
}
.map-site-ico { font-size: 28px; flex: none; }
.map-site-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.map-site-info b { font-size: 14px; font-family: var(--serif); }
.map-site-honey { font-size: 12px; color: var(--ink-soft); }
.map-active-badge {
  flex: none; font-size: 11px; font-weight: 700; padding: 3px 9px;
  background: var(--territory-color, var(--leaf)); color: var(--territory-text, #fff);
  border-radius: 12px; white-space: nowrap;
}

.map-forage-strip {
  font-size: 12px; color: var(--ink-soft); font-style: italic;
  padding: 6px 14px; background: var(--parch-2); border-bottom: 1px solid var(--line);
}

.map-apiaries-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.map-apiary-line {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 7px 10px; background: var(--parch-2); border-radius: 7px;
}
.map-ap-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--territory-color, var(--ok));
}
.map-ap-cols { flex: 1; color: var(--ink-soft); font-size: 12px; }
.map-apiary-line b { flex: none; font-size: 13px; }

.map-empty-site {
  padding: 14px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 13px; color: var(--ink-faint); font-style: italic;
}

/* ====================================================================
   QUEEN STATE SUMMARY (action tab header)
   ==================================================================== */
.queen-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px; border-radius: 8px; margin-bottom: 12px;
  font-size: 13px; font-weight: 600; border: 1px solid transparent;
}
.queen-summary .qs-ico { font-size: 16px; flex: none; }
.queen-summary .qs-text { flex: 1; }
.queen-summary.qs-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: rgba(74,158,92,0.25); }
.queen-summary.qs-warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(212,130,10,0.25); }
.queen-summary.qs-bad  { background: var(--bad-bg);  color: var(--bad);  border-color: rgba(192,48,48,0.25); }
.queen-summary.qs-dead { background: var(--parch-2); color: var(--ink-soft); border-color: var(--line-dk); }

/* ====================================================================
   DANGER ZONE (destructive colony actions)
   ==================================================================== */
.action-danger-zone {
  border: 1px solid var(--bad); border-radius: 9px;
  background: var(--bad-bg); padding: 9px 11px; margin-top: 14px;
}
.action-danger-zone .action-group-title { color: var(--bad); }
.action-danger-zone .btn-row { gap: 6px; }

/* ====================================================================
   MOBILE ACTION BUTTONS — stack vertically for easier tapping
   ==================================================================== */
@media (max-width: 640px) {
  .action-primary-row { display: flex; flex-direction: column; gap: 8px; }
  .action-primary-row .btn { width: 100%; justify-content: center; }
  .action-group .btn-row { flex-direction: column; gap: 6px; }
  .action-group .btn-row .btn { width: 100%; justify-content: center; }
  .action-danger-zone .btn-row { flex-direction: column; gap: 6px; }
  .action-danger-zone .btn-row .btn { width: 100%; justify-content: center; }
}

/* ====================================================================
   ADVANCE-WEEK FAB — floating primary action on mobile
   ==================================================================== */
.advance-fab {
  display: none; /* hidden on desktop; shown via media query below */
}
@keyframes fab-pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 4px 14px rgba(0,0,0,0.28); }
  50%       { transform: scale(1.07); box-shadow: 0 6px 22px rgba(180,120,20,0.45); }
}
@keyframes week-flash {
  0%   { background: rgba(227,165,42,0.18); }
  100% { background: transparent; }
}
.stage.week-flash { animation: week-flash 0.45s ease-out; }

/* ====================================================================
   HIVE PLAQUE — two-line layout for population + age
   ==================================================================== */
.hive-plaque .st-age {
  display: block; font-size: 10px; color: var(--ink-faint); margin-top: 1px;
}

/* ====================================================================
   RECORDS VIEW
   ==================================================================== */
.records-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.records-tab {
  padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-dk); background: var(--paper-2); color: var(--ink-soft); cursor: pointer;
}
.records-tab.active { background: var(--honey); border-color: var(--honey-dk); color: #fff; }
.ledger-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ledger-table { min-width: 380px; }

@media (max-width: 640px) {
  /* Advance week FAB */
  .advance-fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    right: 16px; z-index: 90;
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(145deg, var(--honey), var(--honey-deep));
    border: none; box-shadow: 0 4px 14px rgba(0,0,0,0.28);
    font-size: 22px; color: #fff;
    transition: transform 0.1s;
  }
  .advance-fab:active { transform: scale(0.93); }
  .advance-fab.pulse  { animation: fab-pulse 2s ease-in-out infinite; }
  .advance-fab.urgent { animation: fab-urgent 1.2s ease-in-out infinite; }
@keyframes fab-urgent {
  0%, 100% { transform: scale(1);    box-shadow: 0 4px 14px rgba(180,40,40,0.35); background: linear-gradient(145deg, #d4582a, #b03010); }
  50%       { transform: scale(1.06); box-shadow: 0 6px 22px rgba(180,40,40,0.6);  background: linear-gradient(145deg, #e06030, #c03818); }
}

  /* btn-xs gets the same 44px floor as btn-sm */
  .btn-xs { min-height: 44px; padding: 10px 12px; }
}

/* ====================================================================
   DEAD COLONY PANEL
   ==================================================================== */
.dead-colony-panel {
  padding: 16px; background: var(--paper-2); border-radius: 12px;
  border: 1px solid var(--line-dk);
}
.dead-col-header {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px;
}
.dead-col-icon { font-size: 32px; flex-shrink: 0; }
.dead-col-title { font-weight: 700; font-size: 15px; color: var(--ink); }
.dead-col-cause { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.dead-col-tip {
  font-size: 13px; color: var(--ink); background: rgba(180,120,20,0.08);
  border-left: 3px solid var(--honey); padding: 8px 10px;
  border-radius: 0 6px 6px 0; margin: 0 0 14px;
}
.dead-col-actions { margin-top: 4px; }

/* ====================================================================
   EXTRACT & BOTTLE
   ==================================================================== */
.bottle-list { display: flex; flex-direction: column; gap: 12px; }
.bottle-row {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.bottle-row:first-child { border-top: none; padding-top: 0; }
.bottle-meta { flex: 1; min-width: 0; }
.bottle-meta b { display: block; font-size: 14px; color: var(--ink); }
.bottle-kg { display: block; font-size: 13px; color: var(--honey-deep); font-weight: 600; margin-top: 1px; }
.bottle-note { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.bottle-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.bottle-input {
  width: 60px; padding: 8px 6px; border: 1px solid var(--line-dk);
  border-radius: 8px; font-size: 14px; text-align: center;
  background: var(--paper); color: var(--ink);
}
