/* Layout and component styles. Colours come only from theme.css custom properties. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface-page); color: var(--text);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-2); }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; margin-top: var(--space-4); }
a { color: var(--link); }
.muted { color: var(--text-muted); }
.error { color: var(--status-act-now); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-4) var(--gutter) var(--space-6); }
.page.narrow { max-width: 420px; }

.topbar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--gutter); border-bottom: 1px solid var(--rule); background: var(--surface-card); }
.brand { font-weight: 800; text-decoration: none; color: var(--text); min-height: 44px; display: inline-flex; align-items: center; }
.who { margin-left: auto; font-size: 0.9rem; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 160px; background: var(--surface-card); border: 1px solid var(--rule); border-radius: var(--radius); display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; min-height: 44px; padding: 0 var(--space-4); color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
.menu-item:hover { text-decoration: underline; }

.btn { min-height: 44px; min-width: 44px; padding: 0 var(--space-4); border-radius: var(--radius); border: 1px solid var(--rule); background: var(--surface-card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--chalk); border-color: var(--chalk); color: var(--on-accent); }
.btn.icon { font-size: 1.3rem; padding: 0; }
.btn:disabled { opacity: 0.6; cursor: default; }
.linklike { background: none; border: 0; padding: var(--space-2) 0; min-height: 44px; color: var(--link); font: inherit; text-align: left; cursor: pointer; text-decoration: underline; }

.login { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-6); }
.login label { font-weight: 600; margin-top: var(--space-2); }
.login input { min-height: 44px; padding: 0 var(--space-3); font: inherit; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface-card); color: var(--text); }

.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; font-size: 0.8rem; font-weight: 700; border: 2px solid currentColor; }
.chip-a { color: var(--owner-a); } .chip-c { color: var(--owner-c); } .chip-ac { color: var(--owner-ac); }
.idtag { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }

.section-title { font-size: 1rem; margin-bottom: var(--space-2); }
.home { display: grid; gap: var(--space-5); grid-template-columns: 1fr; }
.side { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
@media (min-width: 960px) { .home { grid-template-columns: 380px 1fr; align-items: start; } .map-svg { height: 72vh; } }

.milestones .ms-track { position: relative; height: 52px; margin: var(--space-2) 14px var(--space-3); border-bottom: 3px solid var(--rule); }
.ms-dot { position: absolute; bottom: -12px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: var(--chalk); color: var(--on-accent); font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.ms-dot.ms-hi { bottom: 14px; }
.ms-dot.ms-hi::after { content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 14px; background: var(--rule); }
.ms-today { position: absolute; bottom: -3px; left: 0; width: 3px; height: 14px; background: var(--text); }
.ms-list { margin: var(--space-3) 0 0; padding-left: 20px; font-size: 0.9rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.momentum, .next-up { margin-bottom: var(--space-4); }
.stat.mine { border-width: 2px; }
.stat.mo-cell { align-items: center; text-align: center; }
.next-lanes { display: flex; flex-direction: column; gap: var(--space-4); }
.lane-list { min-width: 0; flex: 1; }
.lane-list[hidden] { display: none; }
.lane-list.mine { order: -1; }
.lane-list-title { font-size: 0.95rem; margin: 0 0 var(--space-2); }
@media (min-width: 720px) { .next-lanes { flex-direction: row; } .lane-list.mine { order: 0; } }
.stat { background: var(--surface-card); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-2) var(--space-3); display: flex; flex-direction: column; }
.stat-num { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.rows { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.row { width: 100%; min-height: 48px; display: flex; flex-direction: column; gap: var(--space-1); text-align: left; padding: var(--space-2) var(--space-3); background: var(--surface-card); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--text); font: inherit; cursor: pointer; }
.row-meta { display: flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: 0.9rem; }
.state { margin-left: auto; font-weight: 700; }
.next-up .rows { counter-reset: n; }

.seg-wrap { display: inline-flex; margin-bottom: var(--space-2); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.seg { min-height: 44px; min-width: 80px; border: 0; background: var(--surface-card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.seg.on { background: var(--text); color: var(--surface-page); }

.map-wrap { position: relative; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--map-bg); overflow: hidden; }
.map-svg { display: block; width: 100%; height: 68vh; min-height: 420px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.map-svg.panning { cursor: grabbing; }
.map-controls { position: absolute; left: var(--space-2); bottom: var(--space-2); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.lane-a { fill: var(--lane-a-tint); } .lane-c { fill: var(--lane-c-tint); } .lane-s { fill: var(--lane-seam-tint); stroke: var(--lane-seam-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.me-A .lane-a { fill: var(--lane-a-tint-me); } .me-C .lane-c { fill: var(--lane-c-tint-me); }
/* owner zones are an optional toggle in the Menu, off by default */
.lanes, .lane-headers { display: none; }
.zones .lanes, .zones .lane-headers { display: inline; }
.lane { pointer-events: none; }
.lane-head { pointer-events: none; }
.lane-head-1 { fill: var(--text); font-size: 13px; font-weight: 800; }
.lane-head-2 { fill: var(--text-muted); font-size: 11px; font-weight: 600; }
.head-a .lane-head-1 { fill: var(--owner-a); } .head-c .lane-head-1 { fill: var(--owner-c); } .head-s .lane-head-1 { fill: var(--owner-ac); }
.cell-body { fill: var(--cell); animation: cell-wobble 5.5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes cell-wobble { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(1.035, 0.97); } 65% { transform: scale(0.975, 1.03); } }
.cell-text { fill: var(--cell-text); font-weight: 800; font-size: 14px; pointer-events: none; }
.map-svg.dragging { cursor: grabbing; }
.bubble { cursor: pointer; }
.bubble .hit { fill: transparent; }
/* the thin edge shows the owner; the fill shows the state */
.bubble .body { stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke: var(--owner-ac); }
.own-A .body { stroke: var(--owner-a); } .own-C .body { stroke: var(--owner-c); } .own-AC .body { stroke: var(--owner-ac); }
.kind-eatable .body { fill: var(--bubble-eatable); }
.kind-open .body { fill: var(--bubble-open); }
.kind-container .body { fill: var(--bubble-container); }
.kind-sealed .body { fill: var(--bubble-sealed); }
.count { fill: var(--bubble-sealed-text); font-weight: 800; pointer-events: none; }
.kind-container .count { fill: var(--bubble-container-text); }
.label { fill: var(--text); font-size: 7px; pointer-events: none; opacity: 0; paint-order: stroke; stroke: var(--map-bg); stroke-width: 3px; stroke-linejoin: round; }
.labels .label, .size-large .label, .size-medium .label { opacity: 1; }
.deadline { fill: none; stroke-width: 1.5; pointer-events: none; vector-effect: non-scaling-stroke; opacity: 0.85; }
.deadline.ring-calm { stroke: var(--ring-calm); opacity: 0.55; }
.deadline.ring-warm { stroke: var(--ring-warm); }
.deadline.ring-urgent { stroke: var(--ring-urgent); stroke-width: 2.2; }
.deadline.ring-overdue { stroke: var(--ring-overdue); stroke-width: 2.6; animation: ring-throb 1.4s ease-in-out infinite; }
@keyframes ring-throb { 0%, 100% { opacity: 1; stroke-width: 2.6px; } 50% { opacity: 0.3; stroke-width: 5px; } }
/* zoomed far out, tiny bubbles are plain circles */
.lod-low .size-small .deadline, .lod-low .size-small .count, .lod-low .size-mediumSmall .deadline { display: none; }
.bubble.dim { opacity: 0.22; }
.bubble:focus-visible .body { stroke: var(--focus-ring); stroke-width: 4; }

.sheet-root { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: var(--scrim); }
.sheet { position: relative; width: 100%; max-width: 640px; max-height: 80vh; overflow-y: auto; background: var(--surface-card); border-radius: 14px 14px 0 0; padding: var(--space-4) var(--gutter) var(--space-6); border: 1px solid var(--rule); }
.sheet-head { display: flex; justify-content: flex-end; }
.sheet-title { display: flex; align-items: center; gap: var(--space-2); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); margin: var(--space-3) 0; }
.facts dt { color: var(--text-muted); } .facts dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.mark { display: inline-block; width: 1.4em; font-weight: 800; }
.mark-done { color: var(--status-on-target); }
.sheet-actions { margin-top: var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.why { width: 100%; font-weight: 600; margin: 0; }
.notes { font-style: italic; color: var(--text-muted); }

.rules-list dt { font-weight: 800; margin-top: var(--space-4); }
.rules-list dd { margin: var(--space-1) 0 0; }
.list-host h3 { margin-top: var(--space-4); }

@media (prefers-reduced-motion: reduce) { .deadline.ring-overdue { animation: none; } .cell-body { animation: none; } * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; } }

/* Filter bar */
.filter-wrap { display: inline-flex; margin: 0 0 var(--space-2) var(--space-2); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; vertical-align: top; }
.filter-label { display: inline-flex; align-items: center; margin-left: var(--space-3); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2); margin-bottom: var(--space-2); }
.toolbar .seg-wrap, .toolbar .filter-wrap { margin: 0; }
.ring-text { font-weight: 700; }
.ring-tag { font-weight: 700; font-size: 0.85rem; }

/* Editing forms */
.edit-form { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.edit-form label, .edit-form .legend { font-weight: 700; margin-top: var(--space-2); }
.edit-form input[type=text], .edit-form input[type=date], .edit-form input[type=search], .edit-form select, .edit-form textarea {
  min-height: 48px; padding: var(--space-2) var(--space-3); font: inherit; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface-card); color: var(--text); width: 100%;
}
.edit-form textarea { min-height: 96px; resize: vertical; }
.radio-row { display: flex; gap: var(--space-2); }
.radio-row label { margin: 0; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 48px; border: 1px solid var(--rule); border-radius: var(--radius); cursor: pointer; font-weight: 600; }
.radio-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio-row label:has(input:checked) { background: var(--text); color: var(--surface-page); }
.radio-row label:has(input:focus-visible) { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.needs-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.needs-list label { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; margin: 0; padding: 0 var(--space-3); font-weight: 400; border-bottom: 1px solid var(--rule); cursor: pointer; }
.needs-list input { width: 24px; height: 24px; flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.notice { border: 1px solid var(--rule); border-left-width: 6px; border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0; }
.notice.warn { border-left-color: var(--status-watch); }
.notice.ok { border-left-color: var(--status-on-target); }
.pad { padding: var(--space-2); }
.flush { margin: 0; }
.warn-line { margin: var(--space-1) 0 0; }
.ring-tag-calm { color: var(--ring-calm); } .ring-tag-warm { color: var(--ring-warm); } .ring-tag-urgent, .ring-tag-overdue { color: var(--ring-urgent); }
.lane-head text { paint-order: stroke; stroke: var(--map-bg); stroke-width: 3px; }

/* Plain-English additions: waiting-on lines, why it matters, glossary links, ad results */
.waiting-line { margin: var(--space-2) 0 0; font-weight: 600; }
.row-wait { font-size: 0.9rem; }
.why-matters { margin: var(--space-2) 0; }
.notes { white-space: pre-wrap; }
.gloss { color: var(--glossary-link); text-decoration: underline dotted; }
.gloss-focus { background: var(--surface-page); outline: 2px solid var(--focus-ring); }
.ad-card { margin-top: var(--space-3); padding: var(--space-3); background: var(--surface-card); border: 1px solid var(--rule); border-left: 6px solid var(--owner-c); border-radius: var(--radius); }
.ad-title { margin: 0 0 var(--space-2); font-size: 0.95rem; }
.ad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.ad-stat { display: flex; flex-direction: column; }
.ad-num { font-size: 1.3rem; font-weight: 800; line-height: 1.15; }
.ad-form { margin-top: 0; }
