:root {
  --sp-bg: #f5f7fb;
  --sp-surface: #ffffff;
  --sp-surface-2: #eef2f7;
  --sp-border: rgba(24, 36, 54, .12);
  --sp-border-strong: rgba(24, 36, 54, .2);
  --sp-text: #172235;
  --sp-muted: #5b697e;
  --sp-soft: #5f6d82;
  --sp-blue: #3567d6;
  --sp-blue-soft: #e9f0ff;
  --sp-green: #267455;
  --sp-green-soft: #eaf6ef;
  --sp-amber: #8a5d19;
  --sp-amber-soft: #fff4dc;
  --sp-shadow: 0 20px 60px rgba(30, 43, 64, .08);
  --sp-radius: 24px;
  --sp-max: 1420px;
}

html[data-theme="dark"] {
  --sp-bg: #0d131d;
  --sp-surface: #141c28;
  --sp-surface-2: #192330;
  --sp-border: rgba(229, 237, 248, .1);
  --sp-border-strong: rgba(229, 237, 248, .18);
  --sp-text: #edf3fb;
  --sp-muted: #a0adbf;
  --sp-soft: #8f9db0;
  --sp-blue: #79a0ff;
  --sp-blue-soft: rgba(71, 112, 205, .18);
  --sp-green: #77c9a4;
  --sp-green-soft: rgba(58, 142, 103, .15);
  --sp-amber: #e2b865;
  --sp-amber-soft: rgba(157, 108, 31, .16);
  --sp-shadow: 0 26px 80px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--sp-bg); color: var(--sp-text); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--sp-bg); color: var(--sp-text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--sp-blue) 48%, transparent); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; top: 10px; left: 10px; z-index: 1000; transform: translateY(-150%); padding: 10px 14px; border-radius: 10px; background: var(--sp-text); color: var(--sp-bg); text-decoration: none; }
.skip-link:focus { transform: translateY(0); }

.spaces-topbar { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 28px; min-height: 72px; padding: 0 max(24px, calc((100vw - var(--sp-max)) / 2)); border-bottom: 1px solid var(--sp-border); background: color-mix(in srgb, var(--sp-bg) 92%, transparent); backdrop-filter: blur(18px); }
.spaces-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.spaces-brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--sp-text); color: var(--sp-bg); font-size: 15px; font-weight: 850; }
.spaces-brand > span:last-child { display: grid; gap: 1px; line-height: 1; }
.spaces-brand strong { font-size: 13px; letter-spacing: -.01em; }
.spaces-brand small { color: var(--sp-muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.spaces-primary-nav { display: flex; align-items: center; gap: 4px; }
.spaces-primary-nav a { padding: 9px 11px; border-radius: 10px; color: var(--sp-muted); font-size: 13px; font-weight: 700; text-decoration: none; }
.spaces-primary-nav a:hover, .spaces-primary-nav a[aria-current="page"] { background: var(--sp-surface-2); color: var(--sp-text); }
.spaces-top-actions { display: flex; align-items: center; gap: 8px; }
.account-link { min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--sp-border); border-radius: 11px; background: var(--sp-surface); color: var(--sp-muted); font-size: 12px; font-weight: 750; text-decoration: none; }
.spaces-theme-button { width: 42px; height: 42px; border: 1px solid var(--sp-border); border-radius: 12px; background: var(--sp-surface); color: var(--sp-text); cursor: pointer; }
.spaces-theme-button span { display: block; width: 15px; height: 15px; margin: auto; border: 2px solid currentColor; border-radius: 50%; box-shadow: 6px -5px 0 -4px currentColor; }

.spaces-main { width: min(var(--sp-max), calc(100% - 48px)); margin: 0 auto; padding: 58px 0 88px; }
.space-view { animation: spaceIn .28s ease both; }
@keyframes spaceIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.eyebrow { margin: 0 0 9px; color: var(--sp-blue); font-size: 10px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }

.spaces-home-intro { padding: 18px 0 42px; }
.spaces-home-heading { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 56px; align-items: end; }
.spaces-home-heading h1, .space-context-header h1, .context-blueprint h1 { max-width: 900px; margin: 0; font-size: clamp(42px, 5.8vw, 76px); line-height: .98; letter-spacing: -.055em; font-weight: 760; }
.spaces-home-heading > div > p:last-child { max-width: 780px; margin: 22px 0 0; color: var(--sp-muted); font-size: 18px; line-height: 1.65; }
.truth-note { display: flex; gap: 13px; align-items: flex-start; padding: 18px 20px; border: 1px solid var(--sp-border); border-radius: 18px; background: var(--sp-surface); box-shadow: var(--sp-shadow); }
.truth-dot { width: 9px; height: 9px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--sp-green); box-shadow: 0 0 0 5px var(--sp-green-soft); }
.truth-note strong { font-size: 13px; }
.truth-note p { margin: 5px 0 0; color: var(--sp-muted); font-size: 12px; line-height: 1.5; }

.space-switcher { margin-top: 28px; }
.section-heading-row { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 18px; }
.section-heading-row.compact { align-items: center; }
.section-heading-row h2 { max-width: 780px; margin: 0; font-size: clamp(24px, 3vw, 36px); line-height: 1.1; letter-spacing: -.035em; }
.section-support { max-width: 470px; margin: 0; color: var(--sp-muted); font-size: 12px; line-height: 1.55; }
.space-list { overflow: hidden; border: 1px solid var(--sp-border); border-radius: var(--sp-radius); background: var(--sp-surface); box-shadow: var(--sp-shadow); }
.space-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) minmax(160px, 220px) 28px; gap: 18px; align-items: center; min-height: 112px; padding: 20px 24px; border-bottom: 1px solid var(--sp-border); text-decoration: none; transition: background .18s ease; }
.space-row:last-child { border-bottom: 0; }
.space-row:hover { background: var(--sp-surface-2); }
.space-row.is-primary { background: linear-gradient(90deg, var(--sp-blue-soft), transparent 50%); }
.space-icon { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--sp-border-strong); border-radius: 14px; background: var(--sp-bg); color: var(--sp-blue); font-size: 14px; font-weight: 850; }
.space-copy { display: grid; gap: 4px; min-width: 0; }
.space-copy small { color: var(--sp-soft); font-size: 9px; font-weight: 850; letter-spacing: .1em; }
.space-copy strong { font-size: 19px; letter-spacing: -.02em; }
.space-copy p { margin: 0; color: var(--sp-muted); font-size: 13px; line-height: 1.45; }
.space-status { display: grid; gap: 4px; }
.space-status b { font-size: 11px; }
.space-status small { color: var(--sp-muted); font-size: 10px; }
.space-arrow { color: var(--sp-soft); font-size: 20px; }

.future-projections { display: grid; grid-template-columns: 1fr auto; gap: 42px; align-items: center; margin-top: 38px; padding: 28px; border-top: 1px solid var(--sp-border); border-bottom: 1px solid var(--sp-border); }
.future-projections h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.future-projections p:last-child { max-width: 820px; margin: 10px 0 0; color: var(--sp-muted); font-size: 13px; line-height: 1.6; }
.future-actions { display: flex; gap: 10px; }
.future-actions button { min-width: 160px; min-height: 60px; padding: 10px 14px; border: 1px solid var(--sp-border); border-radius: 14px; background: var(--sp-surface); color: var(--sp-muted); text-align: left; }
.future-actions button span { display: block; margin-top: 4px; font-size: 9px; opacity: .75; }

.space-context-header { display: flex; align-items: end; justify-content: space-between; gap: 32px; padding: 6px 0 34px; border-bottom: 1px solid var(--sp-border); }
.context-identity { min-width: 0; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--sp-muted); font-size: 12px; font-weight: 750; text-decoration: none; }
.back-link:hover { color: var(--sp-text); }
.context-summary { max-width: 780px; margin: 16px 0 0; color: var(--sp-muted); font-size: 16px; line-height: 1.55; }
.context-header-state { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
.session-pill { display: inline-flex; align-items: center; min-height: 34px; padding: 0 11px; border-radius: 999px; background: var(--sp-surface-2); color: var(--sp-muted); font-size: 10px; font-weight: 800; }
body[data-owner-session="authenticated"] .session-pill { background: var(--sp-green-soft); color: var(--sp-green); }
body[data-owner-session="unavailable"] .session-pill { background: var(--sp-amber-soft); color: var(--sp-amber); }
.quiet-link { color: var(--sp-muted); font-size: 11px; font-weight: 700; text-decoration: none; }

.personal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 34px; padding-top: 32px; }
.personal-primary { min-width: 0; }
.personal-brief { position: relative; overflow: hidden; padding: 30px; border: 1px solid var(--sp-border); border-radius: 28px; background: var(--sp-surface); box-shadow: var(--sp-shadow); }
.personal-brief::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--sp-blue); }
.brief-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.brief-topline h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.04em; }
.brief-mode { flex: 0 0 auto; padding: 7px 9px; border-radius: 999px; background: var(--sp-green-soft); color: var(--sp-green); font-size: 9px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.brief-message { display: flex; gap: 16px; align-items: flex-start; min-height: 104px; margin-top: 30px; padding: 22px 0; border-top: 1px solid var(--sp-border); border-bottom: 1px solid var(--sp-border); }
.brief-message strong { display: block; margin-bottom: 7px; font-size: 18px; letter-spacing: -.02em; }
.brief-message p { max-width: 760px; margin: 0; color: var(--sp-muted); font-size: 13px; line-height: 1.6; }
.brief-loader { width: 20px; height: 20px; flex: 0 0 auto; border: 2px solid var(--sp-border-strong); border-top-color: var(--sp-blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.brief-truth-mark { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px; background: var(--sp-green-soft); color: var(--sp-green); font-weight: 850; }
.brief-truth-mark.is-warning { background: var(--sp-amber-soft); color: var(--sp-amber); }
.inline-brief-link { display: inline-block; margin-top: 12px; color: var(--sp-blue); font-size: 12px; font-weight: 800; text-decoration: none; }
.brief-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding-top: 22px; }
.brief-facts > div { display: grid; gap: 3px; }
.brief-facts small { color: var(--sp-soft); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.brief-facts strong { font-size: 13px; }
.brief-facts span { color: var(--sp-muted); font-size: 10px; }

.attention-section, .world-section { margin-top: 40px; }
.attention-empty { display: flex; gap: 18px; align-items: flex-start; padding: 22px 24px; border: 1px dashed var(--sp-border-strong); border-radius: 18px; background: color-mix(in srgb, var(--sp-surface) 65%, transparent); }
.empty-symbol { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 10px; background: var(--sp-surface-2); color: var(--sp-muted); }
.attention-empty strong { font-size: 14px; }
.attention-empty p { margin: 6px 0 0; color: var(--sp-muted); font-size: 12px; line-height: 1.55; }

.domain-list { overflow: hidden; border: 1px solid var(--sp-border); border-radius: 22px; background: var(--sp-surface); }
.domain-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--sp-border); }
.domain-row:last-child { border-bottom: 0; }
.domain-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--sp-surface-2); color: var(--sp-blue); font-size: 11px; font-weight: 900; }
.domain-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.domain-title strong { font-size: 14px; }
.state-chip { padding: 4px 6px; border-radius: 999px; font-size: 8px; font-weight: 850; letter-spacing: .06em; }
.state-real { background: var(--sp-green-soft); color: var(--sp-green); }
.domain-copy p { max-width: 800px; margin: 5px 0 0; color: var(--sp-muted); font-size: 11px; line-height: 1.5; }
.domain-row > a { color: var(--sp-blue); font-size: 11px; font-weight: 800; text-decoration: none; white-space: nowrap; }

.personal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; }
.capability-panel { display: flex; gap: 16px; min-height: 230px; padding: 24px; border: 1px solid var(--sp-border); border-radius: 20px; background: var(--sp-surface); }
.panel-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 12px; background: var(--sp-surface-2); color: var(--sp-blue); font-weight: 800; }
.capability-panel h2 { margin: 0; font-size: 20px; line-height: 1.12; letter-spacing: -.03em; }
.capability-panel p:not(.eyebrow) { margin: 10px 0 16px; color: var(--sp-muted); font-size: 12px; line-height: 1.55; }
.state-line { display: inline-block; padding-top: 12px; border-top: 1px solid var(--sp-border); color: var(--sp-soft); font-size: 10px; font-weight: 750; }

.personal-rail { display: grid; align-content: start; gap: 16px; position: sticky; top: 96px; }
.rail-panel { padding: 22px; border: 1px solid var(--sp-border); border-radius: 20px; background: var(--sp-surface); }
.rail-panel h2 { margin: 0; font-size: 18px; line-height: 1.15; letter-spacing: -.025em; }
.rail-panel p:not(.eyebrow) { color: var(--sp-muted); font-size: 11px; line-height: 1.55; }
.rail-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.live-dot { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: var(--sp-soft); }
body[data-continuity-state="safe"] .live-dot { background: var(--sp-green); box-shadow: 0 0 0 5px var(--sp-green-soft); }
body[data-continuity-state="due_soon"] .live-dot, body[data-continuity-state="grace"] .live-dot { background: var(--sp-amber); box-shadow: 0 0 0 5px var(--sp-amber-soft); }
.continuity-state { display: grid; gap: 4px; margin: 16px 0; padding: 14px; border-radius: 14px; background: var(--sp-surface-2); }
.continuity-state strong { font-size: 13px; }
.continuity-state span { color: var(--sp-muted); font-size: 10px; line-height: 1.45; }
.rail-panel > a { color: var(--sp-blue); font-size: 11px; font-weight: 800; text-decoration: none; }
.boundary-panel ul { display: grid; gap: 13px; margin: 18px 0 0; padding: 0; list-style: none; }
.boundary-panel li { display: flex; gap: 10px; align-items: flex-start; }
.boundary-panel li > span { display: grid; place-items: center; width: 20px; height: 20px; flex: 0 0 auto; border-radius: 7px; background: var(--sp-green-soft); color: var(--sp-green); font-size: 10px; font-weight: 900; }
.boundary-panel li.is-blocked > span { background: var(--sp-surface-2); color: var(--sp-soft); }
.boundary-panel li div { display: grid; gap: 2px; }
.boundary-panel li strong { font-size: 11px; }
.boundary-panel li small { color: var(--sp-muted); font-size: 9px; line-height: 1.4; }
.ai-heading { display: flex; gap: 10px; align-items: center; }
.ai-heading > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--sp-blue-soft); color: var(--sp-blue); }
.ai-heading .eyebrow { margin-bottom: 4px; }
.ai-panel button { width: 100%; min-height: 44px; margin: 14px 0 9px; border: 1px solid var(--sp-border); border-radius: 12px; background: var(--sp-surface-2); color: var(--sp-soft); font-weight: 800; }
.ai-panel > small { display: block; color: var(--sp-soft); font-size: 9px; line-height: 1.45; }

.context-blueprint { max-width: 980px; margin: 0 auto; padding: 50px 0 100px; }
.context-blueprint .blueprint-lead { max-width: 820px; margin: 22px 0 32px; color: var(--sp-muted); font-size: 18px; line-height: 1.6; }
.blueprint-state { margin: 28px 0; padding: 24px; border: 1px dashed var(--sp-border-strong); border-radius: 20px; background: var(--sp-surface); }
.blueprint-state strong { font-size: 15px; }
.blueprint-state p { margin: 8px 0 0; color: var(--sp-muted); font-size: 12px; line-height: 1.55; }
.primary-link { display: inline-flex; min-height: 44px; align-items: center; padding: 0 15px; border-radius: 12px; background: var(--sp-text); color: var(--sp-bg); font-size: 11px; font-weight: 850; text-decoration: none; }

.spaces-footer { display: flex; justify-content: space-between; gap: 20px; width: min(var(--sp-max), calc(100% - 48px)); margin: 0 auto; padding: 24px 0 36px; border-top: 1px solid var(--sp-border); color: var(--sp-soft); font-size: 10px; }
.spaces-footer a { color: var(--sp-muted); font-weight: 700; text-decoration: none; }

@media (max-width: 1050px) {
  .spaces-home-heading { grid-template-columns: 1fr; gap: 28px; }
  .truth-note { max-width: 560px; }
  .personal-layout { grid-template-columns: 1fr; }
  .personal-rail { grid-template-columns: repeat(3, 1fr); position: static; }
  .future-projections { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .spaces-topbar { grid-template-columns: 1fr auto; gap: 12px; min-height: 64px; padding: 0 16px; }
  .spaces-primary-nav, .account-link { display: none; }
  .spaces-main { width: min(100% - 28px, var(--sp-max)); padding: 34px 0 64px; }
  .spaces-home-intro { padding-top: 4px; }
  .spaces-home-heading h1, .space-context-header h1, .context-blueprint h1 { font-size: clamp(40px, 13vw, 58px); }
  .spaces-home-heading > div > p:last-child, .context-summary, .context-blueprint .blueprint-lead { font-size: 15px; }
  .section-heading-row { display: grid; gap: 10px; }
  .section-support { max-width: none; }
  .space-row { grid-template-columns: 44px minmax(0, 1fr) 20px; min-height: 108px; gap: 12px; padding: 18px 16px; }
  .space-status { grid-column: 2; margin-top: 2px; }
  .space-arrow { grid-column: 3; grid-row: 1 / span 2; }
  .future-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .future-actions button { min-width: 0; }
  .space-context-header { display: grid; gap: 20px; align-items: start; }
  .context-header-state { justify-content: space-between; padding-bottom: 0; }
  .personal-brief { padding: 22px 20px; border-radius: 22px; }
  .brief-topline { display: grid; }
  .brief-mode { width: fit-content; }
  .brief-facts { grid-template-columns: 1fr; gap: 12px; }
  .brief-facts > div { padding-top: 10px; border-top: 1px solid var(--sp-border); }
  .domain-row { grid-template-columns: 38px 1fr; gap: 12px; padding: 18px 16px; }
  .domain-copy p { font-size: 12px; line-height: 1.55; }
  .domain-row > a { grid-column: 2; justify-self: start; min-height: 36px; display: inline-flex; align-items: center; font-size: 12px; }
  .rail-panel p:not(.eyebrow) { font-size: 12px; }
  .rail-panel > small, .boundary-panel li small { font-size: 10px; }
  .personal-grid, .personal-rail { grid-template-columns: 1fr; }
  .capability-panel { min-height: 0; }
  .spaces-footer { width: calc(100% - 28px); display: grid; }
}

@media (max-width: 430px) {
  .spaces-main { width: calc(100% - 24px); }
  .spaces-home-heading h1, .space-context-header h1, .context-blueprint h1 { font-size: 42px; }
  .truth-note { padding: 15px; }
  .space-row { padding-left: 14px; padding-right: 14px; }
  .space-copy p { font-size: 12px; }
  .future-projections { padding: 22px 0; }
  .future-actions { grid-template-columns: 1fr; }
  .brief-message { gap: 12px; }
  .attention-empty { padding: 18px; }
  .capability-panel { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
