:root {
  color-scheme: light;
  --navy-950: #071426;
  --navy-900: #0c2038;
  --navy-800: #183654;
  --navy-700: #315373;
  --navy-600: #57728c;
  --paper: #f6f9fc;
  --white: #fff;
  --line: #d8e2ec;
  --line-strong: #b8c8d8;
  --teal: #007f8a;
  --teal-light: #dff7f5;
  --gold: #e7b84d;
  --coral: #e66d5d;
  --violet: #6757cf;
  --violet-light: #efedff;
  --green: #19754c;
  --green-light: #e9f6ef;
  --danger: #a7293a;
  --danger-light: #fff0f2;
  --focus: #ffb524;
  --shadow: 0 22px 58px rgba(7, 20, 38, 0.13);
  --display: "Cormorant Garamond", Georgia, serif;
  --body: "Outfit", system-ui, sans-serif;
  --utility: "JetBrains Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; overflow-x: hidden; background: var(--paper); scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; overflow-x: hidden; color: var(--navy-900); background: var(--paper); font: 400 16px/1.5 var(--body); -webkit-tap-highlight-color: rgba(0,127,138,.18); }
button, input, select { font: inherit; }
button, a, input, select { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--teal); text-underline-offset: .18em; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

.skip-link { position: fixed; z-index: 300; top: .7rem; left: .7rem; min-height: 44px; padding: .7rem 1rem; color: var(--white); background: var(--navy-950); transform: translateY(-170%); transition: transform 150ms ease; }
.skip-link:focus { transform: translateY(0); }
.connection-banner { position: sticky; z-index: 200; top: 0; display: flex; min-height: 44px; align-items: center; justify-content: center; gap: .55rem; padding: .5rem max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left)); color: #fff5dc; background: #65430e; }
.connection-banner span { width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 50%; }
.topbar { display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem max(2rem, env(safe-area-inset-right)) .85rem max(2rem, env(safe-area-inset-left)); color: var(--white); background: var(--navy-900); }
.brand { display: inline-flex; min-width: 0; min-height: 44px; align-items: center; gap: .8rem; color: inherit; text-decoration: none; }
.brand:hover { color: inherit; }
.brand > span:last-child { display: grid; min-width: 0; }
.brand small { color: #abc0d2; font: 500 .68rem var(--utility); letter-spacing: .08em; text-transform: uppercase; }
.brand__mark { display: flex; width: 42px; height: 42px; flex: 0 0 42px; align-items: center; justify-content: center; gap: 3px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; }
.brand__mark i { display: block; width: 6px; border-radius: 5px; background: #5bd6d5; }
.brand__mark i:nth-child(1) { height: 12px; }
.brand__mark i:nth-child(2) { height: 22px; background: var(--gold); }
.brand__mark i:nth-child(3) { height: 16px; background: var(--coral); }
.topbar nav { display: flex; align-items: center; gap: .2rem; }
.topbar nav a { display: inline-flex; min-height: 44px; align-items: center; padding: .55rem .75rem; color: #dce8f1; font-weight: 600; text-decoration: none; }
.topbar nav a:hover { color: var(--white); background: rgba(255,255,255,.08); }

.gate { display: grid; min-height: calc(100vh - 76px); place-content: center; justify-items: center; gap: .65rem; padding: 2rem; text-align: center; }
.gate h1 { max-width: 720px; margin: 0; font: 700 clamp(2.6rem, 7vw, 5.8rem)/.92 var(--display); letter-spacing: -.045em; }
.gate p:last-of-type { max-width: 620px; color: var(--navy-600); }
.gate__mark { display: grid; width: 60px; height: 60px; place-items: center; border: 2px solid currentColor; border-radius: 50%; color: var(--danger); font: 700 1.4rem var(--utility); }
.gate__mark--neutral { color: var(--teal); }
.consent { display: flex; width: min(620px, 100%); min-height: 52px; align-items: flex-start; gap: .75rem; padding: .8rem 1rem; border: 1px solid var(--line-strong); background: var(--white); text-align: left; cursor: pointer; }
.consent input { width: 22px; height: 22px; flex: 0 0 22px; margin: .05rem 0 0; }
.loader { display: flex; height: 42px; align-items: flex-end; gap: 5px; }
.loader i { width: 7px; height: 15px; border-radius: 7px 7px 2px 2px; background: var(--teal); animation: pulse 700ms ease-in-out infinite alternate; }
.loader i:nth-child(2) { height: 34px; background: var(--gold); animation-delay: -220ms; }
.loader i:nth-child(3) { height: 23px; background: var(--coral); animation-delay: -440ms; }
@keyframes pulse { to { transform: scaleY(.55); } }

.shell { display: grid; min-height: calc(100vh - 76px); grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); }
.access-rail { min-width: 0; padding: clamp(1.2rem, 3vw, 2rem); color: var(--white); background: var(--navy-900); }
.access-rail__head { display: grid; gap: 1rem; }
.access-rail h1 { margin: 0; font: 700 2.65rem/.95 var(--display); }
.access-rail .eyebrow { color: #65dddd; }
.identity-card { display: flex; min-width: 0; align-items: center; gap: .8rem; margin: 1.7rem 0; padding: .9rem; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); }
.identity-card__avatar { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border-radius: 50%; color: var(--navy-900); background: var(--gold); font-weight: 700; }
.identity-card strong, .identity-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-card small { color: #adc2d2; }
.min-width-zero { min-width: 0; }
.workspace-list { display: grid; gap: .55rem; }
.workspace-option { width: 100%; min-height: 68px; padding: .72rem .8rem; border: 1px solid rgba(255,255,255,.17); color: var(--white); background: transparent; text-align: left; transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease; }
.workspace-option:hover { border-color: #60d8d8; background: rgba(255,255,255,.08); transform: translateX(2px); }
.workspace-option[aria-current="true"] { border-left: 6px solid var(--gold); background: var(--white); color: var(--navy-900); }
.workspace-option strong, .workspace-option small { display: block; overflow-wrap: anywhere; }
.workspace-option small { margin-top: .2rem; color: inherit; opacity: .72; }
.rail-empty { padding: 1rem; border: 1px dashed rgba(255,255,255,.3); color: #c4d4e0; }
.rail-note { display: grid; gap: .25rem; margin-top: 2rem; padding: 1rem; border-left: 4px solid var(--teal); color: #c6d6e2; background: rgba(0,0,0,.15); font-size: .82rem; }
.rail-note strong { color: var(--white); }

.control-deck { min-width: 0; padding: clamp(1rem, 4vw, 3.5rem) clamp(1rem, 5vw, 5rem) 4rem; }
.context-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.context-header h2 { max-width: 780px; margin: 0; overflow-wrap: anywhere; font: 700 clamp(2.7rem, 6vw, 5.7rem)/.9 var(--display); letter-spacing: -.045em; }
.eyebrow { margin: 0 0 .45rem; color: var(--teal); font: 600 .69rem/1.3 var(--utility); letter-spacing: .13em; text-transform: uppercase; }
.context-badges { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.badge, .privacy-pill { display: inline-flex; min-height: 32px; align-items: center; padding: .32rem .7rem; border-radius: 2rem; color: var(--violet); background: var(--violet-light); font: 600 .68rem var(--utility); text-transform: uppercase; }
.badge--status { color: var(--green); background: var(--green-light); }
.section-nav { display: flex; gap: .25rem; margin-top: 2.2rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.section-nav a { display: inline-flex; min-height: 48px; flex: 0 0 auto; align-items: center; padding: .65rem .85rem; border-bottom: 4px solid transparent; color: var(--navy-600); font-weight: 700; text-decoration: none; }
.section-nav a:hover { color: var(--navy-900); background: var(--white); }
.section-nav a[aria-current="page"] { border-color: var(--teal); color: var(--navy-900); }
.status-region { min-height: 1.5rem; margin-top: 1rem; color: var(--teal); font-weight: 700; }
.panel { scroll-margin-top: 1rem; }
.panel__heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 1.2rem 0; }
.panel h3 { margin: 0; font: 700 clamp(2rem, 4vw, 3.2rem)/1 var(--display); }
.panel h4 { margin-bottom: .4rem; font-size: 1.12rem; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-block: 1px solid var(--navy-900); background: var(--white); }
.metric { min-width: 0; padding: 1.4rem; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--navy-600); font: 600 .66rem var(--utility); letter-spacing: .07em; text-transform: uppercase; }
.metric strong { display: block; margin-top: .25rem; overflow-wrap: anywhere; font: 700 clamp(1.45rem, 3.5vw, 2.65rem)/1 var(--display); }
.empty-card { display: grid; min-height: 320px; place-content: center; justify-items: center; padding: 2rem; border: 1px dashed var(--line-strong); background: var(--white); text-align: center; }
.empty-card > span { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; color: var(--teal); background: var(--teal-light); font-size: 1.8rem; }
.empty-card p { max-width: 520px; color: var(--navy-600); }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.action-card, .lifecycle-card { min-width: 0; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-top: 6px solid var(--teal); background: var(--white); box-shadow: 0 1px 0 rgba(7,20,38,.03); }
.action-card:nth-child(2) { border-top-color: var(--gold); }
.action-card > p { color: var(--navy-600); }
.field { display: grid; gap: .35rem; margin: 1rem 0; color: var(--navy-700); font-size: .82rem; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 48px; padding: .72rem .8rem; border: 1px solid var(--line-strong); border-radius: .45rem; color: var(--navy-900); background: var(--white); font-weight: 400; }
.field input:hover, .field select:hover { border-color: var(--navy-600); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.field-error { min-height: 1.2em; color: var(--danger); font-weight: 700; }
.field-note { color: var(--navy-600); font-size: .82rem; }
.list-section { margin-top: 1.5rem; }
.list-section__heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.list-section__heading span { color: var(--navy-600); font: 500 .72rem var(--utility); }
.record-list { display: grid; gap: .65rem; }
.record { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--line); background: var(--white); }
.record > div { min-width: 0; }
.record strong, .record small { display: block; overflow-wrap: anywhere; }
.record small { color: var(--navy-600); }
.record-empty { min-height: 94px; padding: 1rem; border: 1px dashed var(--line-strong); color: var(--navy-600); background: rgba(255,255,255,.7); }
.lifecycle-card { border-top-color: var(--coral); }
.lifecycle-card__row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.lifecycle-card__row p { max-width: 680px; margin-bottom: 0; color: var(--navy-600); }
.lifecycle-card__actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: .65rem; }

.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: .4rem; padding: .7rem 1rem; border: 1px solid var(--line-strong); border-radius: .5rem; color: var(--navy-900); background: var(--white); font-weight: 700; text-decoration: none; transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease; }
.button:hover:not(:disabled) { border-color: var(--navy-700); background: #edf4f8; transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button--primary { border-color: var(--teal); color: var(--white); background: var(--teal); }
.button--primary:hover:not(:disabled) { border-color: var(--navy-900); background: var(--navy-900); }
.button--quiet { background: transparent; }
.button--danger { border-color: var(--danger); color: var(--white); background: var(--danger); }
.button--danger:hover:not(:disabled) { border-color: var(--navy-950); background: var(--navy-950); }
.button--compact { min-height: 44px; padding: .55rem .75rem; font-size: .84rem; }

.dialog { width: min(680px, calc(100% - 2rem)); max-height: min(90vh, 860px); padding: 0; overflow: hidden; overscroll-behavior: contain; border: 1px solid var(--line-strong); border-radius: .85rem; color: var(--navy-900); background: var(--white); box-shadow: var(--shadow); }
.dialog--compact { width: min(560px, calc(100% - 2rem)); }
.dialog::backdrop { background: rgba(4,13,25,.76); backdrop-filter: blur(5px); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--paper); }
.dialog__head h2 { margin: 0; font-size: 1.35rem; }
.dialog__body { max-height: calc(90vh - 154px); overflow-y: auto; overscroll-behavior: contain; padding: 1.2rem; }
.dialog__actions { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.2rem calc(.9rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.icon-button { display: grid; width: 46px; height: 46px; flex: 0 0 46px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--navy-700); background: var(--white); font-size: 1.3rem; }
.icon-button:hover { color: var(--navy-950); background: #edf3f7; }
.choice-set { display: grid; gap: .6rem; margin: 0 0 1rem; padding: 0; border: 0; }
.choice-set legend { margin-bottom: .5rem; font-weight: 700; }
.choice-set label { display: flex; min-height: 60px; align-items: center; gap: .75rem; padding: .7rem; border: 1px solid var(--line); cursor: pointer; }
.choice-set input { width: 22px; height: 22px; flex: 0 0 22px; }
.choice-set strong, .choice-set small { display: block; }
.choice-set small { color: var(--navy-600); }
.notice { padding: .8rem 1rem; border-left: 4px solid var(--teal); color: var(--navy-700); background: var(--teal-light); }
.notice--error { border-color: var(--danger); color: var(--danger); background: var(--danger-light); }
.code-output { display: block; margin: 1rem 0; padding: 1rem; border: 2px dashed var(--teal); color: var(--navy-950); background: var(--teal-light); font: 700 clamp(1.2rem, 5vw, 2rem) var(--utility); letter-spacing: .07em; overflow-wrap: anywhere; text-align: center; }
.toast-region { position: fixed; z-index: 400; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); display: grid; gap: .5rem; width: min(370px, calc(100vw - 2rem)); }
.toast { padding: .9rem 1rem; border-left: 5px solid var(--teal); color: var(--white); background: var(--navy-950); box-shadow: var(--shadow); }
.toast--error { border-left-color: var(--coral); }

@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; padding-inline: 1rem; }
  .topbar nav { width: 100%; justify-content: space-between; overflow-x: auto; }
  .brand small { display: none; }
  .shell { grid-template-columns: 1fr; }
  .access-rail { padding: 1rem; }
  .workspace-list { grid-auto-columns: minmax(230px, 78vw); grid-auto-flow: column; overflow-x: auto; padding-bottom: .4rem; }
  .rail-note { display: none; }
  .control-deck { padding: 1rem 1rem 4rem; }
  .metric-grid, .split-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .context-header, .panel__heading, .lifecycle-card__row { align-items: stretch; flex-direction: column; }
  .lifecycle-card__actions { justify-content: stretch; }
  .lifecycle-card__actions .button { width: 100%; }
  .record { align-items: stretch; flex-direction: column; }
  .record .button { width: 100%; }
}

@media (max-width: 480px) {
  .topbar nav a { padding-inline: .45rem; font-size: .82rem; }
  .context-header h2 { font-size: 2.8rem; }
  .section-nav { margin-inline: -1rem; padding-inline: 1rem; }
  .dialog__actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog__actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .loader i { animation: none; }
  .skip-link, .workspace-option, .button { transition-duration: .01ms; }
}
