:root {
  color-scheme: dark;
  --bg: #191410;
  --surface: #211a14;
  --surface-raised: #2a2119;
  --surface-soft: #30251b;
  --text: #f7ede0;
  --dim: #ad9a84;
  --muted: #796a5b;
  --line: rgba(247, 237, 224, .11);
  --accent: #f2a65a;
  --accent-deep: #c9701e;
  --green: #7fd8a6;
  --red: #e0763f;
  --blue: #8ec5d6;
  --shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(90% 48% at 8% -8%, rgba(242, 166, 90, .13), transparent 68%),
    radial-gradient(70% 45% at 100% 28%, rgba(116, 73, 39, .12), transparent 70%),
    var(--bg);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.5rem;
  padding: calc(.8rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) .8rem calc(1rem + env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: .025em;
  text-decoration: none;
}

.persona-chrome {
  display: inline-flex;
  align-items: center;
  gap: .48rem;
  min-width: 0;
  margin: 0 auto;
  padding: .34rem .55rem .34rem .38rem;
  border: 1px solid rgba(142, 197, 214, .2);
  border-radius: 99rem;
  color: var(--text);
  background: rgba(142, 197, 214, .06);
}

.persona-initial {
  display: grid;
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  place-items: center;
  border-radius: 50%;
  color: #132027;
  background: var(--blue);
  font-size: .72rem;
  font-weight: 800;
}

.persona-chrome strong, .persona-chrome small { display: block; white-space: nowrap; }
.persona-chrome strong { overflow: hidden; max-width: 8rem; font-size: .7rem; text-overflow: ellipsis; }
.persona-chrome small { margin-top: .08rem; color: var(--dim); font-size: .52rem; letter-spacing: .035em; }

.mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: .68rem;
  background: linear-gradient(155deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 24px rgba(201, 112, 30, .18);
}

.mark span {
  display: block;
  width: .72rem;
  height: .72rem;
  border: .18rem solid #2a1708;
  border-radius: 50%;
}

.net {
  display: flex;
  align-items: center;
  max-width: 13rem;
  margin: 0;
  color: var(--dim);
  font-size: .69rem;
  line-height: 1.15;
  text-align: right;
}

.net .dot {
  flex: 0 0 auto;
  width: .5rem;
  height: .5rem;
  margin-right: .42rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 .2rem rgba(127, 216, 166, .08);
}

.net.off .dot { background: var(--red); box-shadow: 0 0 0 .2rem rgba(224, 118, 63, .08); }

main {
  width: min(100%, 44rem);
  min-height: calc(100dvh - 8rem);
  margin: 0 auto;
  padding: 2.25rem calc(1.1rem + env(safe-area-inset-right)) 2rem calc(1.1rem + env(safe-area-inset-left));
}

.hero { max-width: 34rem; margin: 7vh auto 0; }
.hero h1, .organization-heading h1 { margin: 0; font-size: clamp(2rem, 9vw, 3.15rem); line-height: 1.04; letter-spacing: -.035em; }
.lede { margin: 1rem 0 1.7rem; color: var(--dim); font-size: 1.03rem; line-height: 1.62; }
.eyebrow, .card-kicker { margin: 0 0 .55rem; color: var(--accent); font-size: .7rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow.danger { color: var(--red); }

.pulse {
  width: 2.1rem;
  height: 2.1rem;
  margin-top: 2rem;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.gate-note, .verification-card {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  margin: 1.4rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, .025);
}

.gate-note strong, .verification-card strong { display: block; margin-bottom: .2rem; font-size: .9rem; }
.gate-note p { margin: 0; color: var(--dim); font-size: .82rem; line-height: 1.45; }
.gate-icon, .status-glyph { color: var(--accent); font-size: 1.35rem; line-height: 1; }
.verification-card code { color: var(--dim); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .72rem; }

.primary, .secondary {
  width: 100%;
  min-height: 3.25rem;
  padding: .85rem 1rem;
  border-radius: .9rem;
  font-weight: 720;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.primary { border: 1px solid transparent; color: #2b1707; background: linear-gradient(155deg, #f5b36f, var(--accent)); box-shadow: 0 12px 30px rgba(201, 112, 30, .14); }
.secondary { border: 1px solid rgba(242, 166, 90, .34); color: var(--text); background: rgba(242, 166, 90, .08); }
.primary:active, .secondary:active { transform: translateY(1px); }
.primary:focus-visible, .secondary:focus-visible, .tab:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(142, 197, 214, .55); outline-offset: 2px; }
.primary[disabled], .secondary[disabled] { cursor: wait; opacity: .55; }

.fineprint, .risk-line { margin: .9rem 0; color: var(--muted); font-size: .72rem; text-align: center; }

.seat { padding-bottom: 2rem; }
.organization-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.organization-heading h1 { overflow-wrap: anywhere; font-size: clamp(2rem, 8vw, 2.8rem); }
.seat-badge { flex: 0 0 auto; margin-top: 1.5rem; padding: .42rem .65rem; border: 1px solid rgba(242, 166, 90, .22); border-radius: 99rem; color: var(--accent); background: rgba(242, 166, 90, .06); font-size: .64rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }

.storage-strip { margin: 1.25rem 0; padding: .7rem .8rem; border-radius: .72rem; color: var(--dim); background: rgba(255, 255, 255, .025); font-size: .72rem; line-height: 1.4; }
.storage-strip.safe { color: var(--green); }
.storage-strip.risk { color: #e6bd8f; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; margin: 1.4rem 0 1rem; padding: .25rem; border-radius: .9rem; background: rgba(255, 255, 255, .035); }
.tab { min-height: 2.65rem; border: 0; border-radius: .68rem; color: var(--dim); background: transparent; font-weight: 700; cursor: pointer; }
.tab.active { color: var(--text); background: var(--surface-raised); box-shadow: 0 8px 20px rgba(0, 0, 0, .13); }
.count { display: inline-grid; min-width: 1.25rem; height: 1.25rem; margin-left: .25rem; place-items: center; border-radius: 99rem; background: rgba(255, 255, 255, .08); font-size: .68rem; }

.panel { display: grid; gap: .9rem; }
.card { padding: 1.15rem; border: 1px solid var(--line); border-radius: 1.05rem; background: linear-gradient(150deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .015)); box-shadow: var(--shadow); }
.card h2, .ledger-intro h2 { margin: 0; font-size: 1.15rem; line-height: 1.25; }
.card-copy, .ledger-intro p { margin: .6rem 0 1rem; color: var(--dim); font-size: .84rem; line-height: 1.5; }

label { display: block; margin: 1.1rem 0 .45rem; color: var(--text); font-size: .8rem; font-weight: 650; }
input, textarea { width: 100%; min-height: 3.2rem; margin-bottom: .75rem; padding: .75rem .85rem; border: 1px solid rgba(247, 237, 224, .16); border-radius: .8rem; color: var(--text); background: rgba(0, 0, 0, .18); }
textarea { min-height: 6.5rem; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); }

.status-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.status { display: inline-flex; align-items: center; min-height: 1.6rem; padding: .25rem .55rem; border-radius: 99rem; font-size: .63rem; font-weight: 780; letter-spacing: .045em; text-transform: uppercase; }
.staged-status { color: #e9c595; background: rgba(242, 166, 90, .1); }
.preview-status { color: var(--blue); background: rgba(142, 197, 214, .1); }
.proposed-value { margin: .7rem 0; color: var(--text); font-size: 1.45rem; font-weight: 680; overflow-wrap: anywhere; }
.change-line { display: grid; gap: .2rem; margin: 1rem 0; padding: .9rem; border-radius: .8rem; background: rgba(127, 216, 166, .06); }
.change-line span { color: var(--dim); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.change-line strong { color: var(--green); overflow-wrap: anywhere; }

.section-title-row { display: flex; align-items: center; justify-content: space-between; }
.number-badge { display: grid; min-width: 2.1rem; height: 2.1rem; padding: 0 .4rem; place-items: center; border-radius: 99rem; color: var(--dim); background: rgba(255, 255, 255, .05); font-size: .78rem; }
.value-list { display: grid; gap: .25rem; margin: .9rem 0 0; padding: 0; list-style: none; }
.value-list li { display: flex; justify-content: space-between; gap: .75rem; padding: .64rem .2rem; border-top: 1px solid rgba(247, 237, 224, .07); color: var(--dim); font-size: .8rem; }
.value-list li::after { content: "Open"; flex: 0 0 auto; color: var(--accent); font-size: .64rem; font-weight: 740; text-transform: uppercase; }
.value-list .more { color: var(--muted); font-style: italic; }
.value-list .more::after { content: ""; }

.counsel-card { border-color: rgba(142, 197, 214, .2); }
.counsel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.counsel-status { flex: 0 0 auto; padding: .36rem .55rem; border-radius: 99rem; color: var(--blue); background: rgba(142, 197, 214, .09); font-size: .58rem; font-weight: 760; letter-spacing: .045em; text-transform: uppercase; }
.counsel-status.unreachable { color: #ffc09d; background: rgba(224, 118, 63, .11); }
.counsel-persona { display: flex; align-items: center; gap: .7rem; margin: .9rem 0; padding: .75rem; border: 1px solid rgba(142, 197, 214, .18); border-radius: .8rem; background: rgba(142, 197, 214, .045); }
.counsel-persona-initial { display: grid; flex: 0 0 auto; width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 50%; color: #132027; background: var(--blue); font-size: .82rem; font-weight: 800; }
.counsel-persona strong { display: block; font-size: .88rem; }
.counsel-persona p { margin: .2rem 0 0; color: var(--dim); font-size: .65rem; line-height: 1.35; }
.counsel-boundary { margin: .75rem 0; padding: .72rem; border-radius: .68rem; color: #c7b7a4; background: rgba(255, 255, 255, .025); font-size: .72rem; line-height: 1.48; }
.counsel-status-copy { min-height: 1.15rem; margin: .65rem 0; color: var(--blue); font-size: .72rem; line-height: 1.42; }
.counsel-response { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.counsel-say { margin: 0 0 .75rem; color: var(--text); font-size: .85rem; line-height: 1.55; }
.counsel-proposals { display: grid; gap: .65rem; }
.counsel-proposal { padding: .8rem; border: 1px solid rgba(247, 237, 224, .1); border-radius: .78rem; background: rgba(0, 0, 0, .12); }
.counsel-proposal h3 { margin: 0; font-size: .9rem; }
.counsel-proposal p { margin: .4rem 0 .7rem; color: var(--dim); font-size: .74rem; line-height: 1.45; }
.counsel-stage { min-height: 2.7rem; padding: .62rem .75rem; font-size: .72rem; }
.counsel-settings { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.counsel-settings summary { color: var(--dim); font-size: .7rem; font-weight: 680; cursor: pointer; }
.counsel-settings > p { color: var(--muted); font-size: .68rem; line-height: 1.45; }
.counsel-settings-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.counsel-settings-actions .secondary { min-height: 2.8rem; padding: .6rem; font-size: .67rem; }

.persona-binding-status { margin: -.2rem 0 .9rem; color: var(--blue); font-size: .74rem; line-height: 1.45; }
.persona-list { display: grid; gap: .7rem; }
.persona-option { padding: .9rem; border: 1px solid rgba(247, 237, 224, .09); border-radius: .9rem; background: rgba(0, 0, 0, .1); }
.persona-option.current { border-color: rgba(142, 197, 214, .34); background: rgba(142, 197, 214, .045); }
.persona-option-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; }
.persona-option-heading h3 { margin: 0; font-size: 1rem; }
.persona-option-heading span { flex: 0 0 auto; color: var(--green); font-size: .56rem; font-weight: 760; letter-spacing: .055em; text-transform: uppercase; }
.persona-presentation { margin: .65rem 0 .8rem; }
.persona-presentation p { margin: .28rem 0; color: var(--dim); font-size: .72rem; line-height: 1.42; }
.persona-presentation strong { color: var(--text); font-weight: 650; }
.persona-action { min-height: 2.6rem; padding: .62rem .8rem; font-size: .74rem; }
.persona-action.current { color: var(--green); border-color: rgba(127, 216, 166, .22); background: rgba(127, 216, 166, .05); cursor: default; }

.recovery-entry {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, .02);
}
.recovery-entry h2 { margin: 0; font-size: 1.05rem; }
.recovery-entry > p:not(.card-kicker, .operation-status) { color: var(--dim); font-size: .8rem; line-height: 1.48; }
.optional { color: var(--muted); font-size: .65rem; font-weight: 500; }

.backup-mode { flex: 0 0 auto; padding: .35rem .55rem; border-radius: 99rem; color: var(--green); background: rgba(127, 216, 166, .08); font-size: .58rem; font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
.backup-mode.danger { color: #ffc09d; background: rgba(224, 118, 63, .12); }
.backup-staleness { margin: .8rem 0; padding: .75rem; border-radius: .75rem; color: #e6bd8f; background: rgba(242, 166, 90, .07); font-size: .75rem; line-height: 1.48; }
.backup-staleness.fresh { color: var(--green); background: rgba(127, 216, 166, .06); }
.backup-receipt, .backup-save { margin: .8rem 0; padding: .8rem; border: 1px solid rgba(247, 237, 224, .09); border-radius: .8rem; background: rgba(0, 0, 0, .12); }
.backup-receipt p, .backup-save p { margin: .25rem 0 .5rem; color: var(--dim); font-size: .73rem; line-height: 1.45; }
.backup-receipt code, .backup-save code { display: block; color: var(--blue); font-size: .65rem; overflow-wrap: anywhere; }
.backup-save .secondary { margin-top: .55rem; }
.backup-plan { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.backup-plan h3 { margin: 0 0 .7rem; font-size: .9rem; }
.backup-facts { display: grid; gap: .35rem; margin: 0 0 1rem; }
.backup-facts div { display: flex; justify-content: space-between; gap: .7rem; padding: .5rem .6rem; border-radius: .55rem; background: rgba(255, 255, 255, .025); }
.backup-facts dt { color: var(--dim); font-size: .68rem; }
.backup-facts dd { margin: 0; color: var(--text); font-size: .68rem; text-align: right; }
.passphrase-warning { margin: .8rem 0; padding: .85rem; border: 1px solid rgba(242, 166, 90, .32); border-radius: .75rem; color: #efc99f; background: rgba(242, 166, 90, .07); font-size: .78rem; line-height: 1.5; }
.passphrase-warning strong { display: block; margin-bottom: .25rem; color: #ffd4a5; }
.plaintext-override, .restore-details { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.plaintext-override summary, .restore-details summary { color: var(--dim); font-size: .74rem; font-weight: 680; cursor: pointer; }
.danger-copy { color: #ffc09d; font-size: .76rem; line-height: 1.5; }
.check-line { display: flex; align-items: flex-start; gap: .6rem; color: #f0c3a7; font-size: .75rem; line-height: 1.45; }
.check-line input { flex: 0 0 auto; width: 1.15rem; min-height: 1.15rem; margin: .1rem 0 0; padding: 0; accent-color: var(--red); }
.danger-button { color: #ffc09d; border-color: rgba(224, 118, 63, .38); background: rgba(224, 118, 63, .08); }
.location-honesty { margin-top: .7rem !important; color: var(--muted) !important; }
.operation-status { min-height: 1.2rem; margin: .75rem 0 0; color: var(--green); font-size: .7rem; line-height: 1.45; overflow-wrap: anywhere; }
.operation-status.error { color: #ffc09d; }
.restore-details form { margin-top: .6rem; }

.ledger-intro { padding: .5rem .2rem .2rem; }
.ledger { display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.record { display: grid; grid-template-columns: 2.25rem 1fr; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(255, 255, 255, .025); }
.record-seq { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border-radius: .72rem; color: var(--accent); background: rgba(242, 166, 90, .09); font-size: .75rem; font-weight: 800; }
.record h3 { margin: .08rem 0 .25rem; font-size: .92rem; }
.record p { margin: 0; color: var(--dim); font-size: .75rem; line-height: 1.4; }
.record time { display: block; margin-top: .55rem; color: var(--muted); font-size: .65rem; }
.record.committed h3::after { content: "Persisted"; margin-left: .5rem; color: var(--green); font-size: .55rem; letter-spacing: .06em; text-transform: uppercase; }

.blocked { margin-top: 4vh; }
.error-facts { display: grid; gap: .55rem; margin: 1.2rem 0; }
.error-facts div { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem .8rem; border-radius: .7rem; background: rgba(224, 118, 63, .06); }
.error-facts dt { color: var(--dim); font-size: .72rem; }
.error-facts dd { margin: 0; color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .68rem; text-align: right; overflow-wrap: anywhere; }
.blocking-law { margin: 1rem 0 1.4rem; color: #e6bd8f; font-size: .8rem; line-height: 1.5; }

footer { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; padding: 1.2rem calc(1rem + env(safe-area-inset-right)) calc(1.3rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left)); color: var(--muted); font-size: .63rem; text-align: center; }
footer a { color: var(--blue); }

.verify-header-label { margin: 0 0 0 auto; color: var(--dim); font-size: .68rem; font-weight: 680; letter-spacing: .04em; text-transform: uppercase; }
.verify-main { display: grid; gap: 1rem; width: min(100%, 58rem); }
.verify-intro { padding: 2vh 0 .4rem; }
.verify-intro h1 { max-width: 14ch; }
.verify-rerun { width: auto; min-height: 2.8rem; margin-bottom: .9rem; }
.verify-facts { display: grid; gap: .45rem; margin: .6rem 0; }
.verify-facts div { display: grid; gap: .25rem; padding: .65rem .7rem; border-radius: .65rem; background: rgba(255, 255, 255, .025); }
.verify-facts dt { color: var(--muted); font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; }
.verify-facts dd { margin: 0; color: var(--blue); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .68rem; overflow-wrap: anywhere; }
.verify-trust-note { margin: .8rem 0 0; padding: .75rem; border-radius: .7rem; font-size: .74rem; line-height: 1.48; }
.verify-trust-note.same-origin { color: #e6bd8f; background: rgba(242, 166, 90, .07); }
.verify-trust-note.independent { color: var(--green); background: rgba(127, 216, 166, .06); }
.verify-table-wrap { margin-top: .65rem; overflow-x: auto; }
.verify-table { width: 100%; border-collapse: collapse; font-size: .7rem; }
.verify-table th, .verify-table td { padding: .75rem .55rem; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.verify-table thead th { color: var(--muted); font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; }
.verify-table tbody th { width: 4.5rem; font-size: .65rem; letter-spacing: .04em; }
.verify-table td strong, .verify-table td code, .verify-error { display: block; overflow-wrap: anywhere; }
.verify-table td strong { margin-bottom: .35rem; color: var(--text); }
.verify-table td code { color: var(--muted); font-size: .61rem; white-space: pre-wrap; }
.verify-pass > th { color: var(--green); }
.verify-fail > th, .verify-error { color: #ffc09d; }
.verify-error { margin-top: .35rem; line-height: 1.4; }

@media (min-width: 42rem) {
  .topbar { padding-left: 1.5rem; padding-right: 1.5rem; }
  main { padding-top: 3rem; }
  .card { padding: 1.35rem; }
}

@media (max-width: 30rem) {
  .topbar { gap: .45rem; }
  .persona-chrome { margin-left: auto; padding-right: .42rem; }
  .persona-chrome small { display: none; }
  .persona-chrome strong { max-width: 5.5rem; }
  .net { max-width: 6.6rem; font-size: .6rem; }
}

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