*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: rgba(15, 23, 42, 0.12);
  --border-hi: rgba(15, 23, 42, 0.22);
  --text: #0f172a;
  --muted: #64748b;
  --blue: #0a66c2;
  --blue-soft: rgba(10, 102, 194, 0.08);
  --amber: #b45309;
  --green: #15803d;
  --ui: system-ui, -apple-system, "Segoe UI", sans-serif;
}
body { min-height: 100vh; background: var(--bg); color: var(--text); font-family: var(--ui); line-height: 1.55; }

.auth-gate, .app-shell { min-height: 100vh; }
.auth-gate { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-gate[hidden], .app-shell[hidden], #app-shell[hidden], #blueprint-error[hidden], #blueprint-app[hidden] { display: none !important; }

.auth-panel { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.auth-panel h1 { font-size: 24px; margin-bottom: 8px; }
.auth-panel p { color: var(--muted); margin-bottom: 18px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 650; color: inherit; text-decoration: none; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.account { color: var(--muted); font-size: 13px; }

.button { font: inherit; font-size: 14px; min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-hi); background: var(--surface); color: inherit; cursor: pointer; }
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button:focus-visible, .back-link:focus-visible, .sheet-link:focus-visible, .section-list button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

html, body { max-width: 100%; overflow-x: hidden; }
main { width: min(100% - 40px, 1120px); margin: 0 auto; padding: 28px 0 48px; }
main, .detail-panel, .wheel-panel, .inventory, .notes-panel { min-width: 0; overflow-wrap: anywhere; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.back-link { font-size: 14px; color: var(--blue); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 10px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
h1 { font-size: clamp(26px, 4vw, 34px); line-height: 1.15; }
.lede { color: var(--muted); max-width: 60ch; margin-top: 8px; }
.sheet-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; line-height: 1.4; color: var(--blue); text-decoration: none; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 10px 14px; }

.error-panel { background: #fef2f2; border: 1px solid rgba(185, 28, 28, 0.35); color: #7f1d1d; border-radius: 10px; padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.error-panel[hidden] { display: none !important; }

.controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.controls h2 { font-size: 20px; }
.controls p { color: var(--muted); font-size: 14px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; cursor: pointer; }
.toggle input { width: 24px; height: 24px; accent-color: var(--blue); }

.workspace { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 24px; align-items: start; }
.workspace > * { min-width: 0; }
.wheel-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.wheel-panel svg { width: 100%; height: auto; display: block; }
#blueprint-wheel g { cursor: pointer; }
.section-list { display: grid; gap: 14px; margin-top: 14px; }
.pillar-group { border-left: 6px solid var(--pillar, var(--border-hi)); padding-left: 10px; }
.pillar-group[data-pillar-id="elevate"] { --pillar: #f5c518; }
.pillar-group[data-pillar-id="orchestrate"] { --pillar: #0a66c2; }
.pillar-group[data-pillar-id="leverage"] { --pillar: #e23b2f; }
.pillar-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.pillar-group button { display: block; width: 100%; min-width: 44px; min-height: 44px; margin-bottom: 6px; }
.section-list button { font: inherit; font-size: 14px; text-align: left; min-height: 44px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: inherit; cursor: pointer; overflow-wrap: anywhere; }
.section-list button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; font-weight: 600; }
.section-list button[aria-pressed="true"]::after { content: " ✓"; }
.home-link { font: inherit; font-size: 13px; min-height: 44px; min-width: 44px; margin-left: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-hi); background: var(--surface); color: var(--blue); cursor: pointer; }
.home-link:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.detail-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; min-height: 320px; }
.detail-panel h2 { font-size: 22px; margin-bottom: 2px; }
.detail-panel h3 { font-size: 15px; margin: 18px 0 6px; }
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.question { margin: 10px 0 0; font-size: 16px; font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 14px; }
.fact { border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 13px; background: var(--bg); }
.fact dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.internal-note { margin-top: 14px; border-left: 4px solid var(--amber); background: rgba(180, 83, 9, 0.07); padding: 10px 12px; font-size: 13px; border-radius: 0 8px 8px 0; }
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; border: 1px solid var(--border); background: var(--bg); padding: 4px 8px; border-radius: 999px; }
.chip.borrowed { border-style: dashed; color: var(--muted); }

.inventory, .notes-panel { margin-top: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.inventory h2, .notes-panel h2 { font-size: 20px; margin-bottom: 4px; }
.inventory p, .notes-panel p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); position: sticky; top: 0; background: var(--surface); }
tbody tr:hover { background: var(--blue-soft); }

.note-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; font-size: 13px; background: var(--bg); }
.note-card h3 { font-size: 13px; margin-bottom: 4px; }
footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 24px; border-top: 1px solid var(--border); background: var(--surface); font-size: 13px; }
footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--blue); }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .account { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
