/* LJA Build Control: the new tabs, tab bar and Map add-ons, in the build
   map's own style and tokens (index.html :root). The map's look is unchanged.
   New text uses rem so it follows the iPhone and iPad text size. */
@supports (-webkit-touch-callout: none) {
  html { font: -apple-system-body; }
}
html { scroll-padding-bottom: 120px; }
/* Keep the status bar and tab bar still on iPhone and iPad: the page frame never
   moves (so Safari's own bars don't slide it around); the content scrolls inside
   body instead. Scripts scroll document.body, not window. */
html { height: 100%; overflow: hidden; }
body { position: fixed; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; -webkit-overflow-scrolling: touch; }
body { padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important; }
.bc-wrap { padding-top: env(safe-area-inset-top, 0px); }
.bc-tab[hidden] { display: none !important; }

/* the old agent box on the map is replaced by the Now tab */
#tab-map #agent { display: none; }

/* ---------- page header ---------- */
.bc-page { font-size: 1rem; }
.bc-head { padding-block: 28px 14px; border-bottom: 2px solid var(--text); margin-bottom: 18px; }
.bc-head .eyebrow { margin-bottom: 6px; }
.bc-title { font-family: var(--display); font-weight: 700; font-size: clamp(2.4rem, 8vw, 3.6rem); line-height: .95; text-transform: uppercase; margin: 0; }
.bc-sub { color: var(--text-mid); font-size: 1.05rem; margin: 10px 0 0; max-width: 60ch; }

/* ---------- cards and text ---------- */
.bc-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 16px 18px; margin: 0 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.bc-card > * { min-width: 0; }
.bc-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; min-width: 0; }
.bc-k { display: block; font-family: var(--mono); font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); }
.bc-strong { display: block; font-weight: 600; font-size: 1.1rem; line-height: 1.3; overflow-wrap: anywhere; }
.bc-body { margin: 0; font-size: 1rem; line-height: 1.45; overflow-wrap: anywhere; }
.bc-detail { margin: 0; font-size: .95rem; color: var(--text-mid); line-height: 1.4; overflow-wrap: anywhere; }
.bc-note { margin: 4px 0 14px; }
.bc-warn { margin: 0; font-size: .95rem; color: var(--partial); line-height: 1.4; overflow-wrap: anywhere; }
.bc-empty { color: var(--text-dim); font-size: 1rem; margin: 6px 0 12px; list-style: none; }
.bc-mono { font-family: var(--mono); font-size: .85rem; }
.bc-section { margin: 0 0 26px; }
.bc-h2 { font-family: var(--display); font-weight: 700; font-size: 1.6rem; text-transform: uppercase; margin: 0 0 10px; line-height: 1.05; }
.bc-h3 { font-weight: 600; font-size: 1.15rem; margin: 0; line-height: 1.3; }
.bc-link, .bc-linkbtn { color: var(--text); text-decoration: underline; text-underline-offset: 3px; font: inherit; font-size: .95rem; background: none; border: 0; padding: 10px 2px; min-height: 44px; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.bc-link:focus-visible, .bc-linkbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- status chips: dot + wash + word, never color alone ---------- */
.bc-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 8px; border-radius: 3px; font-family: var(--mono); font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; background: var(--c-soft, var(--surface-2)); color: var(--c, var(--text-mid)); max-width: 100%; overflow-wrap: anywhere; }
.bc-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
[data-k="building"], [data-k="starting"], [data-k="ok"] { --c: var(--built); --c-soft: var(--built-soft); }
[data-k="stopping"], [data-k="warn"], [data-k="xcode"], [data-k="starts"] { --c: var(--partial); --c-soft: var(--partial-soft); }
[data-k="stalled"], [data-k="missed"], [data-k="bad"] { --c: var(--build); --c-soft: var(--build-soft); }
[data-k="phase"], [data-k="info"] { --c: var(--deploy); --c-soft: var(--deploy-soft); }
[data-k="stopped"] { --c: var(--parked); --c-soft: var(--parked-soft); }
.bc-chip[data-k="status"] { --c: var(--s); --c-soft: var(--s-soft); }

/* ---------- buttons (44pt targets) ---------- */
.bc-btn { font: 600 1rem/1.2 var(--body); min-height: 48px; padding: 12px 18px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; text-align: center; max-width: 100%; overflow-wrap: anywhere; }
.bc-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.bc-btn:disabled { opacity: .55; cursor: default; }
.bc-btn:active:not(:disabled) { transform: scale(.97); }
.bc-primary { background: var(--text); color: var(--ground); border-color: var(--text); }
.bc-secondary { background: var(--surface-2); }
.bc-ghost { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; padding-inline: 4px; }
.bc-danger { color: var(--build); border-color: var(--build); background: var(--build-soft); }
.bc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.bc-actions > .bc-btn { flex: 1 1 auto; }

/* ---------- Now ---------- */
.bc-control { gap: 12px; padding: 18px; }
.bc-big { width: 100%; min-height: 76px; font-family: var(--display); font-weight: 700; font-size: clamp(1.8rem, 7vw, 2.4rem); text-transform: uppercase; letter-spacing: .01em; border-radius: 8px; }
.bc-start { background: var(--text); color: var(--ground); border-color: var(--text); }
.bc-stop { background: var(--build-soft); color: var(--build); border: 2px solid var(--build); }
.bc-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.bc-status .bc-chip { font-size: .85rem; }
.bc-timer { font-family: var(--mono); font-size: 1rem; font-variant-numeric: tabular-nums; color: var(--text); }
.bc-workers { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; font-family: var(--mono); font-size: .8rem; color: var(--text-dim); }
.bc-nowbuilding { border-color: var(--built); }
.bc-what { display: grid; gap: 4px; text-align: left; font: inherit; color: var(--text); background: none; border: 0; padding: 4px 0; min-height: 44px; cursor: pointer; }
.bc-what .bc-step { font-family: var(--display); font-weight: 700; font-size: 1.6rem; line-height: 1.05; text-transform: uppercase; overflow-wrap: anywhere; }
.bc-what .bc-item { font-weight: 600; font-size: 1.1rem; overflow-wrap: anywhere; }
.bc-what:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.bc-pct { font-family: var(--display); font-weight: 700; font-size: clamp(2.8rem, 10vw, 4rem); line-height: .9; color: var(--built); font-variant-numeric: tabular-nums; }
.bc-meter { position: relative; height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bc-meter > i { display: block; height: 100%; background: var(--built); border-radius: 6px; }
.bc-meter-xc > i { background: var(--deploy); }
.bc-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 14px; }
.bc-count { display: grid; gap: 4px; align-content: start; text-align: left; padding: 14px; min-height: 88px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.bc-count[data-hot="1"] { border-color: var(--partial); background: var(--partial-soft); }
.bc-count .bc-num { font-family: var(--display); font-weight: 700; font-size: 2.2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.bc-count .bc-countlabel { font-size: .9rem; color: var(--text-mid); overflow-wrap: anywhere; }
.bc-count:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Approvals ---------- */
.bc-approval { border-color: var(--partial); }
.bc-label { display: block; font-weight: 600; font-size: .95rem; margin-top: 2px; }
.bc-input { width: 100%; min-width: 0; font: inherit; font-size: max(16px, 1rem); color: var(--text); background: var(--ground); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; resize: vertical; min-height: 48px; }
.bc-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.bc-past { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.bc-summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-family: var(--display); font-weight: 700; font-size: 1.3rem; text-transform: uppercase; }
.bc-summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.bc-pastrow { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }

/* ---------- Messages ---------- */
.bc-thread { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 14px; }
.bc-msg { display: grid; gap: 6px; max-width: min(42rem, 92%); }
.bc-msg.mine { justify-self: end; }
.bc-msg.theirs { justify-self: start; }
.bc-bubble { padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 6px; min-width: 0; }
.bc-msg.mine > .bc-bubble:first-child { background: var(--surface-2); }
.bc-reply { border-color: var(--built); }
.bc-text { margin: 0; font-size: 1rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.bc-msgmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .85rem; color: var(--text-dim); }
.bc-ctx { justify-self: start; font: 600 .8rem/1.2 var(--mono); color: var(--text-mid); background: none; border: 0; padding: 8px 0; min-height: 44px; cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.bc-ctxline { margin: 0; font-family: var(--mono); font-size: .85rem; color: var(--text-mid); overflow-wrap: anywhere; }
.bc-composer { display: grid; gap: 8px; }
/* body is the scroller and its bottom padding (112px + safe area) counts against sticky,
   so -28px puts the box right on top of the tab bar, where it sat before. */
.bc-composer-host { position: sticky; bottom: -28px; background: var(--ground); padding: 12px 0 4px; border-top: 1px solid var(--line-soft); }

/* ---------- Activity ---------- */
.bc-feed { list-style: none; margin: 0; padding: 0; display: grid; }
.bc-event { padding: 10px 0 10px 14px; border-left: 3px solid var(--c, var(--line)); border-bottom: 1px solid var(--line-soft); display: grid; gap: 3px; }
.bc-event[data-k="checked_off"], .bc-event[data-k="built"] { --c: var(--built); }
.bc-event[data-k="error"] { --c: var(--build); }
.bc-event[data-k="approval"] { --c: var(--partial); }
.bc-event[data-k="started"], .bc-event[data-k="phase"] { --c: var(--deploy); }
.bc-eventtop { display: flex; flex-wrap: wrap; gap: 4px 12px; font-family: var(--mono); font-size: .78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.bc-eventkind { color: var(--text-mid); font-weight: 600; }
.bc-runs { list-style: none; margin: 0; padding: 0; }
.bc-run { gap: 6px; }
.bc-donelist { margin: 0; padding-left: 1.2em; font-size: .95rem; color: var(--text-mid); }
.bc-switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; font-size: 1.05rem; cursor: pointer; }
.bc-switch input { width: 26px; height: 26px; accent-color: var(--built); flex: none; }
.bc-field { display: grid; gap: 4px; flex: 1 1 8rem; }
.bc-time { font-family: var(--mono); }

/* ---------- tab bar ---------- */
.bc-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px max(8px, env(safe-area-inset-left, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.bc-tabbtn { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 58px; padding: 6px 2px; background: none; border: 0; border-radius: 8px; color: var(--text-dim); font: 600 13px/1.1 var(--body); cursor: pointer; min-width: 0; }
.bc-tabbtn[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.bc-tabbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.bc-tablabel { overflow-wrap: anywhere; text-align: center; }
.bc-ico { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bc-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--build); color: var(--ground); font: 700 12px/20px var(--mono); text-align: center; }

/* quick message button, above the tab bar on every tab but Messages */
.bc-fab { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 41; display: inline-flex; align-items: center; gap: 8px; min-height: 52px; border-radius: 26px; padding: 12px 18px; background: var(--text); color: var(--ground); border-color: var(--text); box-shadow: 0 10px 28px rgba(0,0,0,.35); }
.bc-fab .bc-ico { width: 22px; height: 22px; }
.bc-fab[hidden] { display: none; }

/* ---------- Map add-ons ---------- */
.bc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.bc-tags .bc-chip { font-size: 9.5px; padding: 3px 6px 3px 5px; gap: 5px; }
.bc-tags .bc-dot { width: 7px; height: 7px; }
.bc-agentnote { display: block; font-size: 13px; color: var(--decide); line-height: 1.4; margin-top: 4px; }
.bc-proof { display: flex; flex-wrap: wrap; gap: 2px 10px; font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.bc-proof .bc-link { font-size: inherit; padding: 0; min-height: 0; }
.leaf .bc-more { flex: none; width: 32px; height: 32px; margin: -6px -8px -6px 0; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--text-dim); font: 700 18px/1 var(--body); cursor: pointer; position: relative; }
.leaf .bc-more::after { content: ""; position: absolute; inset: -6px; }
.leaf .bc-more:hover { color: var(--text); background: var(--surface-2); }
.leaf .bc-more:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.leaf.bc-here, .step-node.bc-here { box-shadow: 0 0 0 2px var(--built); }
.leaf.bc-held { opacity: .72; }
.step-node.bc-focus { box-shadow: 0 0 0 2px var(--deploy); }
.step-node.bc-here.bc-focus { box-shadow: 0 0 0 2px var(--built), 0 0 0 5px var(--deploy); }
.bc-steptag { display: block; margin-top: 8px; }
.bc-steptag .bc-chip { font-size: 10px; }
.bc-panelbox { display: grid; gap: 8px; padding: 12px; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.leaf.bc-flash { animation: bc-flash 2.4s ease-out; }
@keyframes bc-flash { 0%, 40% { box-shadow: 0 0 0 4px var(--text); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) {
  .leaf.bc-flash { animation: none; box-shadow: 0 0 0 4px var(--text); }
  .bc-btn:active:not(:disabled) { transform: none; }
}

/* phones */
@media (max-width: 560px) {
  .bc-counts { grid-template-columns: 1fr; }
  .bc-count { grid-template-columns: auto 1fr; align-items: center; min-height: 64px; gap: 14px; }
  .bc-tabbtn { font-size: 11.5px; }
  .bc-msg { max-width: 100%; }
}

/* ---------- status bar (top of every tab) ---------- */
body { padding-top: var(--bc-sb-h, 0px); }
.bc-sb {
  position: fixed; top: 0; left: 0; right: 0; z-index: 45;
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  min-height: 44px; text-align: left; font: inherit; font-size: .9rem; color: var(--text-mid); cursor: pointer;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 0; border-bottom: 1px solid var(--line);
}
.bc-sb.on { color: var(--text); border-bottom-color: var(--c, var(--line)); }
.bc-sb:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }
.bc-sb-text { display: grid; gap: 1px; min-width: 0; }
.bc-sb-l1 b { font-weight: 700; }
.bc-sb-l1, .bc-sb-l2 { overflow-wrap: anywhere; line-height: 1.3; }
.bc-sb-l2 { color: var(--text-mid); font-size: .85rem; }
.bc-sb .bc-timer { font-size: inherit; }
.bc-sb[data-phase="reading"], .bc-sb[data-phase="planning"] { --c: var(--deploy); }
.bc-sb[data-phase="coding"], .bc-sb[data-phase="committing"], .bc-sb[data-phase="merging"] { --c: var(--built); }
.bc-sb[data-phase="testing"] { --c: var(--partial); }
.bc-sb[data-phase="waiting"] { --c: var(--decide); }
.bc-sb[data-phase="stopping"], .bc-sb[data-phase="stalled"] { --c: var(--build); }
.bc-sb[data-phase="idle"] { --c: var(--parked); }

/* three blocks that act out the phase */
.bc-sb-anim { position: relative; flex: none; width: 34px; height: 22px; }
.bc-sb-anim i { position: absolute; bottom: 0; width: 9px; height: 9px; border-radius: 2px; background: var(--c, var(--parked)); }
.bc-sb-anim .b1 { left: 0; } .bc-sb-anim .b2 { left: 12px; } .bc-sb-anim .b3 { left: 24px; }
.bc-sb.on .bc-sb-anim i { animation: bc-hop .9s ease-in-out infinite; }
.bc-sb.on .bc-sb-anim .b2 { animation-delay: .15s; } .bc-sb.on .bc-sb-anim .b3 { animation-delay: .3s; }
@keyframes bc-hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-9px); } }
/* reading and planning: the blocks scan side to side, like eyes */
.bc-sb.on[data-phase="reading"] .bc-sb-anim i, .bc-sb.on[data-phase="planning"] .bc-sb-anim i { animation: bc-scan 1.6s ease-in-out infinite; }
@keyframes bc-scan { 0%, 100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
/* testing: they spin like gears */
.bc-sb.on[data-phase="testing"] .bc-sb-anim i { animation: bc-spin 1.2s linear infinite; border-radius: 3px; }
@keyframes bc-spin { to { transform: rotate(360deg); } }
/* waiting on the check: a slow, sleepy breathe */
.bc-sb.on[data-phase="waiting"] .bc-sb-anim i { animation: bc-doze 2.4s ease-in-out infinite; }
@keyframes bc-doze { 0%, 100% { transform: scaleY(1); opacity: .9; } 50% { transform: scaleY(.45); opacity: .45; } }
/* committing and merging: the blocks stack into a tower */
.bc-sb.on[data-phase="committing"] .bc-sb-anim i, .bc-sb.on[data-phase="merging"] .bc-sb-anim i { animation: bc-stack 1.8s ease-in-out infinite; }
.bc-sb.on[data-phase="committing"] .bc-sb-anim .b1, .bc-sb.on[data-phase="merging"] .bc-sb-anim .b1 { animation-name: bc-stack1; }
.bc-sb.on[data-phase="committing"] .bc-sb-anim .b3, .bc-sb.on[data-phase="merging"] .bc-sb-anim .b3 { animation-name: bc-stack3; }
@keyframes bc-stack1 { 0%, 20% { transform: none; } 50%, 80% { transform: translateX(12px) translateY(-11px); } 100% { transform: none; } }
@keyframes bc-stack { 0%, 100% { transform: none; } }
@keyframes bc-stack3 { 0%, 35% { transform: none; } 65%, 85% { transform: translateX(-12px) translateY(-22px); } 100% { transform: none; } }
/* stopping: winding down */
.bc-sb.on[data-phase="stopping"] .bc-sb-anim i { animation: bc-hop 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .bc-sb .bc-sb-anim i { animation: none !important; }
}
