:root {
  --ink: #101828;
  --slate: #475467;
  --faint: #667085;
  --border: #d0d5dd;
  --paper: #f8fafc;
  --paper-soft: #ffffff;
  --warm-paper: #f3f1ed;
  --teal: #0f766e;
  --teal-hover: #115e59;
  --teal-bg: #ccfbf1;
  --rust: #b54708;
  --rust-bg: #fffaeb;
  --dark: #101828;
  --dark-2: #182230;
  --plum: #2e155b;
  --black: #0a0a0a;
  --gold: #d4af37;
  --cream: #f2efeb;
  --radius: .5rem;
  --header-h: 54px;
  --rail-space: 24px;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; min-width: 0; }
html { scroll-behavior: smooth; overscroll-behavior-x: none; }
html {
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #e8e6e1;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}
body:has(#view-setup.is-active .welcome-step.is-active) {
  overflow: hidden;
  background: var(--dark);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1.5px solid rgba(15,118,110,.48); outline-offset: 2px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 24px;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(16,24,40,.78), rgba(15,118,110,.30)),
    url("assets/household-table-threshold.png") center center / cover no-repeat;
}

body.is-authenticated .auth-gate {
  display: none;
}

.auth-card {
  display: grid;
  width: min(470px, 100%);
  gap: 14px;
  margin: auto 0;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(248,250,252,.18);
  border-radius: var(--radius);
  background: rgba(248,250,252,.96);
  box-shadow: 0 24px 70px rgba(16,24,40,.32);
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 54px);
  line-height: .98;
  letter-spacing: 0;
}

.auth-card p {
  margin: 0;
  color: var(--slate);
  line-height: 1.55;
}

.auth-status,
.auth-boundary {
  font-size: 13px;
  color: var(--slate);
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mfa-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
}

.mfa-panel[hidden],
.mfa-panel [hidden] {
  display: none;
}

.mfa-panel img {
  width: 180px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px;
}

.mfa-secret {
  overflow-wrap: anywhere;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 12px;
}

.arrival-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(6,78,73,.48) 0%, rgba(15,118,110,.20) 42%, rgba(10,10,10,.34) 100%),
    linear-gradient(0deg, rgba(10,10,10,.52), rgba(10,10,10,.14) 52%),
    url("assets/household-table-threshold.png") center center / cover no-repeat;
  color: var(--paper);
  transition: opacity .55s ease, visibility .55s ease;
}

.arrival-screen.is-gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.arrival-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,10,10,.30), transparent 30%, rgba(10,10,10,.32));
  pointer-events: none;
}

.arrival-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
}

.arrival-mark {
  position: absolute;
  top: calc(50% - clamp(176px, 20vw, 244px));
  width: clamp(128px, 16vw, 216px);
  height: auto;
  opacity: 0;
  transform: none;
  animation: arrivalMarkSettle 1.85s ease .08s forwards;
}

.arrival-prompt {
  position: absolute;
  top: calc(50% - clamp(16px, 2vw, 22px));
  width: min(760px, calc(100vw - 44px));
  color: var(--paper);
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(38px, 6.6vw, 84px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: .95;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  animation: arrivalPromptSettle 1.6s ease .18s forwards, arrivalPromptExit .65s ease 1.9s forwards;
}

.arrival-word {
  position: absolute;
  top: calc(50% - clamp(22px, 2vw, 30px));
  left: 50%;
  width: max-content;
  color: var(--paper);
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(38px, 8vw, 108px);
  font-weight: 800;
  letter-spacing: .02em;
  line-height: .9;
  text-transform: uppercase;
  opacity: 0;
  transform: translateX(calc(-50% - 112vw));
  white-space: nowrap;
  animation: arrivalTitlePass 3.9s cubic-bezier(.7, 0, .2, 1) 1.65s forwards;
}

@keyframes arrivalMarkSettle {
  0% { opacity: 0; transform: translateY(8px) scale(.96); }
  42% { opacity: 1; transform: translateY(0) scale(1); }
  78% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-5px) scale(.98); }
}

@keyframes arrivalPromptSettle {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes arrivalPromptExit {
  to { opacity: 0; transform: translateX(18vw); }
}

@keyframes arrivalTitlePass {
  0% { opacity: 0; transform: translateX(calc(-50% - 112vw)); }
  7% { opacity: 1; }
  22% { opacity: 1; transform: translateX(-50%); }
  42% { opacity: 1; transform: translateX(-50%); }
  100% { opacity: 0; transform: translateX(calc(-50% + 112vw)); }
}

.app-shell {
  display: grid;
  height: 100dvh;
  min-height: 100dvh;
  grid-template-columns: 1fr;
  max-width: 100vw;
  overflow: hidden;
  padding-bottom: 0;
}

.app-shell:has(#view-setup.is-active .welcome-step.is-active) {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding-bottom: 0;
}

.side-rail {
  display: none;
  position: fixed;
  right: auto;
  bottom: calc(26px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 20;
  display: flex;
  width: fit-content;
  max-width: calc(100vw - 20px);
  height: 56px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(248,250,252,.16);
  border-radius: var(--radius);
  background: var(--black);
  color: var(--paper);
  padding: 6px 10px;
  box-shadow: 0 12px 34px rgba(16,24,40,.24);
  transform: translateX(-50%);
}

.side-rail {
  display: none !important;
}

.rail-nav {
  display: flex;
  align-content: center;
  justify-content: center;
  gap: 8px;
  margin-top: 0;
}

.nav-item {
  display: grid;
  min-width: 68px;
  min-height: 44px;
  place-items: center;
  gap: 2px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(248,250,252,.68);
  padding: 4px 10px 5px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
}
.nav-item:hover, .nav-item.is-active {
  border-color: rgba(212,175,55,.5);
  background: rgba(212,175,55,.12);
  color: var(--paper);
}
.nav-home {
  color: rgba(248,250,252,.86);
}
.nav-home .nav-icon {
  width: 22px;
  height: 22px;
}
.nav-home .nav-icon svg {
  width: 22px;
  height: 22px;
}
.nav-home.is-active {
  border-color: rgba(248,250,252,.56);
  background: rgba(248,250,252,.12);
}
.nav-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
}
.nav-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.nav-label {
  line-height: 1;
}

.rail-status {
  display: none;
  border: 1px solid rgba(248,250,252,.14);
  border-radius: var(--radius);
  padding: 12px;
}
.rail-status span, .eyebrow, .progress-top, .preview-stack span, .status-strip span,
.summary-panel span, .record-field h4 {
  color: var(--teal);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.rail-status strong { display: block; margin-top: 6px; font-size: 14px; }

.workspace {
  display: grid;
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  max-width: 100vw;
  overflow: hidden;
}

.workspace-header {
  display: flex;
  min-height: var(--header-h);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(248,250,252,.92);
  padding: 10px clamp(12px, 2vw, 22px);
  position: sticky;
  top: 0;
  z-index: 12;
  backdrop-filter: blur(12px);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: clamp(18px, 2vw, 24px); line-height: 1.05; }
h2 { margin-bottom: 14px; font-size: clamp(24px, 2.6vw, 36px); line-height: 1.07; }
h3 { margin-bottom: 12px; font-size: 22px; line-height: 1.12; }
.workspace-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.workspace-heading h1 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-home {
  display: inline-grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 0;
}
.header-home:hover {
  background: var(--teal-bg);
}
.header-back {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 0;
}
.header-back[hidden] {
  display: none;
}
.header-back:hover {
  background: var(--teal-bg);
}
.header-back svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.app-heading-mark {
  display: block;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  background: var(--ink);
  -webkit-mask: url("images/icon-organic-rings-white.svg") center / contain no-repeat;
  mask: url("images/icon-organic-rings-white.svg") center / contain no-repeat;
}
.app-heading-mark-img {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.workspace-header:has(+ #view-setup.is-active .welcome-step.is-active) .app-heading-mark {
  background: var(--paper);
}
.header-action { display: flex; align-items: center; gap: 10px; color: var(--slate); font-size: 13px; }
.header-tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(280px, 34vw);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 5px 10px 5px 6px;
}
.profile-chip[hidden] {
  display: none;
}
.profile-chip:hover {
  background: var(--teal-bg);
}
.profile-avatar {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #111827;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--paper);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
}
.profile-avatar-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}
.profile-avatar-large {
  width: 104px;
  height: 104px;
  border-radius: var(--radius);
  font-size: 24px;
  cursor: grab;
  touch-action: none;
}
.profile-avatar-upload {
  position: absolute;
  right: 6px;
  bottom: 28px;
  z-index: 2;
  min-height: 24px;
  border: 0;
  border-radius: 4px;
  background: rgba(16,24,40,.24);
  color: rgba(255,255,255,.72);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 0 8px;
  cursor: pointer;
  opacity: .28;
  transition: opacity .16s ease, background .16s ease, color .16s ease;
}
.profile-photo-stack:hover .profile-avatar-upload,
.profile-avatar-upload:focus-visible {
  background: rgba(16,24,40,.58);
  color: rgba(255,255,255,.86);
  opacity: .82;
}
.profile-avatar-large:active {
  cursor: grabbing;
}
.profile-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.profile-copy strong,
.profile-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-copy strong {
  font-size: 13px;
  line-height: 1.15;
}
.profile-copy small {
  color: var(--slate);
  font-size: 11px;
  line-height: 1.2;
}
.header-primary-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-icon-action {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 0;
}
.header-icon-action:hover,
.header-icon-action.is-active {
  background: var(--teal-bg);
  color: var(--teal-hover);
}
.header-nav {
  position: relative;
  display: flex;
  align-items: center;
}
.header-nav-trigger,
.utility-menu {
  position: relative;
  display: flex;
  align-items: center;
}
.header-nav-trigger,
.utility-trigger {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  color: var(--ink);
  padding: 8px 0;
}
.header-nav-trigger {
  gap: 4px;
}
.header-nav-trigger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: currentColor;
}
.utility-trigger span {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}
.header-nav-trigger:hover,
.header-nav-trigger[aria-expanded="true"],
.utility-trigger:hover,
.utility-trigger[aria-expanded="true"] {
  background: var(--teal-bg);
}
.header-nav-popover,
.utility-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 22;
  display: grid;
  width: 220px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 16px 40px rgba(16,24,40,.18);
}
.header-nav-popover {
  width: 230px;
}
.header-nav-popover[hidden],
.utility-popover[hidden] {
  display: none;
}
.header-nav-popover button,
.utility-popover button {
  min-height: 42px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  padding: 0 14px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}
.header-nav-popover button:last-child,
.utility-popover button:last-child {
  border-bottom: 0;
}
.header-nav-popover button:hover,
.utility-popover button:hover {
  background: var(--teal-bg);
}
.header-nav-popover button.is-active {
  background: var(--teal-bg);
  color: var(--teal-hover);
}
.header-nav-popover hr {
  width: 100%;
  height: 1px;
  border: 0;
  background: var(--border);
}

.view {
  display: none;
  height: calc(100dvh - var(--header-h));
  min-height: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(12px, 2vw, 22px) clamp(12px, 2vw, 22px) var(--rail-space);
}
.view.is-active { display: block; }

.threshold-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: stretch;
}

.setup-card, .setup-preview, .command-main, .next-panel, .return-card,
.summary-panel, .export-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
}

.threshold-layout:has(.welcome-step.is-active) {
  grid-template-columns: 1fr;
  gap: 0;
}

.threshold-layout:has(.welcome-step.is-active) .setup-preview {
  display: none;
}

.setup-card:has(.welcome-step.is-active) {
  padding: 0;
  border: 0;
  background: var(--dark);
}

.setup-card:has(.welcome-step.is-active) .progress-top {
  display: none;
}

.welcome-step {
  position: relative;
  align-content: center;
  min-height: 100dvh;
  overflow: hidden;
  max-width: none;
  padding: clamp(28px, 5vw, 64px);
  background:
    linear-gradient(90deg, rgba(6,78,73,.48) 0%, rgba(15,118,110,.24) 43%, rgba(10,10,10,.18) 100%),
    linear-gradient(0deg, rgba(10,10,10,.48), rgba(10,10,10,.08) 48%),
    url("assets/household-table-threshold.png") center center / cover no-repeat;
  color: var(--paper);
}

#view-setup:has(.welcome-step.is-active) {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding: 0;
}

.workspace-header:has(+ #view-setup.is-active .welcome-step.is-active) {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  border-bottom: 0;
  background: linear-gradient(180deg, rgba(10,10,10,.42), transparent);
  color: var(--paper);
}

.workspace-header:has(+ #view-setup.is-active .welcome-step.is-active) h1 {
  display: none;
}

.workspace-header:has(+ #view-setup.is-active .welcome-step.is-active) .header-tools,
.workspace-header:has(+ #view-setup.is-active .welcome-step.is-active) .utility-menu {
  display: none;
}

.welcome-step::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 28%, rgba(248,250,252,.13), transparent 32%);
  pointer-events: none;
}

.threshold-hero {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: inherit;
  align-items: center;
}

.threshold-invite {
  display: grid;
  gap: 18px;
  width: min(560px, 100%);
}

.threshold-mark {
  width: clamp(58px, 8vw, 96px);
  height: auto;
  opacity: .94;
}

.threshold-mark-b {
  width: clamp(54px, 7.4vw, 86px);
  margin-left: -2px;
}

.threshold-invite h2 {
  max-width: 520px;
  margin: 0;
  font-size: clamp(36px, 5.2vw, 72px);
  line-height: .92;
  color: var(--paper);
}

.threshold-doors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.door-action {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(248,250,252,.44);
  border-radius: var(--radius);
  background: rgba(248,250,252,.14);
  color: var(--paper);
  padding: 0 16px;
  text-align: center;
  backdrop-filter: blur(10px);
  font-weight: 800;
}

.door-action:hover {
  border-color: var(--paper);
  background: rgba(248,250,252,.92);
  color: var(--teal-hover);
}

.text-action {
  justify-self: start;
  min-height: 36px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(248,250,252,.76);
  padding: 0;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.text-action:hover {
  color: var(--paper);
}

.step-copy.large {
  color: var(--ink);
  font-size: clamp(22px, 2.8vw, 34px);
  line-height: 1.18;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.setup-card {
  min-height: calc(100dvh - 166px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(18px, 3vw, 30px);
}
.progress-top { display: grid; gap: 8px; margin-bottom: 22px; }
.progress-track { height: 6px; background: var(--warm-paper); }
.progress-track span { display: block; width: 20%; height: 100%; background: var(--teal); transition: width .18s ease; }

.setup-step { display: none; max-width: 780px; }
.setup-step.is-active { display: grid; gap: 14px; align-content: center; }
.welcome-step.is-active {
  width: 100%;
  max-width: none;
}
.step-copy { max-width: 680px; color: var(--slate); line-height: 1.55; }

label { display: grid; gap: 8px; }
label span { font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  color: var(--ink);
  padding: 11px 12px;
}
input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15,118,110,.38);
  box-shadow: 0 0 0 2px rgba(15,118,110,.08);
  outline: 0;
}
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--rust);
  background: var(--rust-bg);
}
textarea { min-height: 92px; resize: vertical; }

.role-confirm, .account-form, .account-list, .cadence-grid, .evidence-grid, .allocation-grid {
  display: grid;
  gap: 12px;
}
.role-confirm { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--warm-paper); }
.role-confirm p { margin: 4px 0 0; color: var(--slate); }

.account-builder {
  display: grid;
  gap: 12px;
}
.account-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 14px;
}
.account-editor-head {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
}
.account-editor-head span {
  color: var(--teal);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.account-editor-head strong {
  font-size: 18px;
}
.account-editor-head p {
  margin: 0;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.45;
}
.account-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.account-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.account-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}
.account-chip {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 12px;
  color: var(--ink);
  text-align: left;
}
.account-chip:hover,
.account-chip.is-editing {
  border-color: var(--teal);
  background: var(--teal-bg);
}
.account-chip strong { display: block; margin-bottom: 4px; }
.account-chip p { margin: 0; color: var(--slate); font-size: 13px; }
.cadence-grid, .evidence-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.allocation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.allocation-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
}
.allocation-card strong { color: var(--ink); }
.allocation-card p { margin: 0; color: var(--slate); }
.status-note { padding-top: 4px; font-size: 13px; }
.carry-forward {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
}
.carry-forward ul {
  margin: 0;
  padding-left: 18px;
  color: var(--slate);
}

.setup-actions, .return-actions, .modal-actions, .export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.setup-actions[hidden] {
  display: none;
}

.primary-action, .secondary-action, .icon-button, .secondary-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
}
.primary-action { border: 1px solid var(--teal); background: var(--teal); color: var(--paper); }
.primary-action:hover { background: var(--teal-hover); border-color: var(--teal-hover); }
.secondary-action, .icon-button, .secondary-link { border: 1px solid var(--border); background: var(--paper-soft); color: var(--ink); }
.secondary-action:hover, .icon-button:hover, .secondary-link:hover { background: var(--teal-bg); }
.secondary-link { text-decoration: none; }
.danger-action {
  border-color: rgba(181,71,8,.38);
  color: var(--rust);
}
.danger-action:hover {
  background: var(--rust-bg);
}

.setup-preview {
  position: sticky;
  top: 66px;
  align-self: start;
  max-height: calc(100dvh - 154px);
  overflow: auto;
  padding: 18px;
}
.setup-preview p { color: var(--slate); line-height: 1.55; }
.preview-stack { display: grid; gap: 8px; margin-top: 16px; }
.preview-stack div { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.preview-stack strong { display: block; margin-top: 8px; }

.command-grid,
.home-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  min-height: 310px;
}
.command-main,
.home-primary,
.next-panel { padding: clamp(18px, 3vw, 30px); }
.command-main,
.home-primary {
  display: grid;
  align-content: center;
}
.command-main h2,
.home-primary h2 { max-width: 720px; font-size: clamp(32px, 5vw, 60px); }
.home-primary {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  min-height: 360px;
  background:
    linear-gradient(90deg, rgba(6,78,73,.55) 0%, rgba(15,23,42,.22) 46%, rgba(10,10,10,.54) 100%),
    linear-gradient(0deg, rgba(10,10,10,.52), rgba(10,10,10,.08) 48%),
    url("assets/household-table-threshold.png") center center / cover no-repeat;
  color: var(--paper);
}
.home-primary h2 {
  color: var(--paper);
  text-shadow: 0 1px 18px rgba(0,0,0,.26);
}
.home-question {
  max-width: 560px;
  margin: -4px 0 0;
  color: rgba(248,250,252,.86);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.25;
}
.home-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.home-action {
  display: grid;
  min-height: 76px;
  align-content: center;
  justify-content: start;
  gap: 5px;
  padding: 12px 14px;
  text-align: left;
}
.home-primary .home-action.secondary-action {
  border-color: rgba(248,250,252,.42);
  background: rgba(248,250,252,.14);
  color: var(--paper);
  backdrop-filter: blur(10px);
}
.home-primary .home-action.secondary-action:hover {
  background: rgba(248,250,252,.22);
}
.home-action strong {
  font-size: 15px;
}
.home-action span {
  font-size: 12px;
  font-weight: 500;
  opacity: .78;
}
.next-panel { display: grid; align-content: center; background: var(--dark); color: var(--paper); }
.next-panel span { color: var(--teal); font-family: "DM Mono", ui-monospace, monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.next-panel strong { display: block; margin: 14px 0; font-size: 28px; }
.next-panel p { margin: 0; border: 1px solid rgba(248,250,252,.16); border-radius: var(--radius); padding: 12px; color: rgba(248,250,252,.72); }

.home-lookup {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  padding: 14px;
}
.home-lookup .recent-records {
  grid-column: auto;
}
.label-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.label-with-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.workspace-search-control {
  position: relative;
}
.workspace-search-control input[type="date"] {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 42px;
  height: 42px;
  opacity: 0;
  pointer-events: none;
}
.calendar-search-action {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
  color: var(--slate);
  padding: 0;
}
.calendar-search-action:hover {
  background: var(--teal-bg);
  color: var(--teal-hover);
}
.calendar-search-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.workspace-search-control input#home-search {
  padding-right: 44px;
}
.recent-records {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.recent-record {
  display: grid;
  gap: 6px;
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}
.recent-record:hover,
.recent-record:focus-visible {
  border-color: var(--teal);
  background: var(--teal-bg);
  outline: none;
}
.recent-record span {
  color: var(--teal);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.eyebrow {
  display: none;
}
.recent-record strong {
  font-size: 17px;
}
.recent-record p,
.compact-empty p {
  margin: 0;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.45;
}
.compact-empty {
  padding: 16px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  overflow: hidden;
}
.status-strip article { min-height: 132px; border-right: 1px solid var(--border); padding: 14px; }
.status-strip article:last-child { border-right: 0; }
.status-strip strong { display: block; margin: 18px 0 8px; font-size: 20px; }
.status-strip p { margin: 0; color: var(--slate); font-size: 13px; line-height: 1.5; }

.local-boundary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  padding: 14px;
}
.local-boundary strong { display: block; margin: 6px 0; font-size: 18px; }
.local-boundary p:not(.eyebrow) { margin: 0; color: var(--slate); font-size: 13px; line-height: 1.45; }
.local-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.return-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: start;
}

.return-start {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  min-height: auto;
  display: grid;
  align-content: start;
  padding: clamp(16px, 2vw, 24px);
}

.return-mode-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.return-mode-card {
  min-height: 146px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 18px;
  text-align: left;
}

.return-mode-card.is-active,
.return-mode-card:hover,
.return-mode-card:focus-visible {
  border-color: var(--teal);
  background: var(--teal-bg);
  outline: none;
}

.return-mode-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 24px;
}

.return-mode-card span {
  color: var(--teal);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.return-mode-card p {
  margin: 16px 0 0;
  color: var(--slate);
}
.return-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 18px;
  overflow-x: auto;
}
.return-step {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  color: var(--slate);
  padding: 0 10px;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
}
.return-step.is-active { background: var(--teal-bg); border-color: var(--teal); color: var(--ink); }

.return-card {
  min-height: calc(100dvh - 166px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(18px, 3vw, 28px);
}
.return-pane { display: none; gap: 18px; }
.return-pane.is-active { display: grid; }
.is-submit { display: none; }
.return-actions.is-final .is-submit { display: inline-flex; }
.return-actions.is-final #return-next { display: none; }

.summary-panel {
  position: sticky;
  top: 66px;
  display: grid;
  gap: 10px;
  padding: 18px;
  max-height: calc(100dvh - 154px);
  overflow: auto;
}
.summary-panel div { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.summary-panel p { margin: 10px 0 0; color: var(--slate); font-size: 13px; line-height: 1.5; }

.recovery-banner {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--rust);
  border-radius: var(--radius);
  background: var(--rust-bg);
  padding: 16px;
}
.recovery-banner[hidden] { display: none; }
.recovery-banner p { margin: 4px 0 0; color: var(--slate); }
.recovery-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.recovery-actions button { border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper-soft); padding: 0 10px; min-height: 36px; font-weight: 700; }

.record-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}
.record-list { display: grid; gap: 12px; }
.empty-record, .record-card { width: 100%; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper-soft); overflow: hidden; }
.empty-record { padding: 28px; color: var(--slate); }
.record-card { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.record-card-action {
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.record-card-action:hover,
.record-card-action:focus-visible {
  border-color: var(--teal);
  background: var(--teal-bg);
  outline: none;
}
.record-meta { border-right: 1px solid var(--border); padding: 16px; }
.record-meta strong { display: block; margin: 12px 0 8px; font-size: 20px; }
.record-meta span { display: block; color: var(--slate); font-size: 13px; }
.record-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.record-field { min-height: 108px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 12px; }
.record-field:nth-child(3n) { border-right: 0; }
.record-field:nth-last-child(-n+3) { border-bottom: 0; }
.record-field p { margin: 10px 0 0; color: var(--slate); font-size: 13px; line-height: 1.5; }

.record-detail {
  display: grid;
  gap: 12px;
}
.record-detail[hidden] { display: none; }
.record-receipt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  padding: 14px;
}
.record-receipt h2 { margin-bottom: 6px; font-size: clamp(22px, 2.2vw, 32px); }
.record-receipt p:not(.eyebrow) { margin: 0; color: var(--slate); font-size: 13px; line-height: 1.45; }
.record-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.record-detail-card {
  grid-template-columns: 1fr;
}

.export-card { max-width: 780px; padding: clamp(22px, 4vw, 42px); }
.export-card p { color: var(--slate); line-height: 1.55; }

.activity-list {
  display: grid;
  gap: 10px;
}
.activity-row {
  display: grid;
  grid-template-columns: minmax(130px, .7fr) minmax(0, 1.45fr) minmax(90px, .55fr);
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  padding: 14px;
}
.activity-row span {
  color: var(--teal);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.activity-row strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}
.activity-row p {
  margin: 8px 0 0;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.45;
}

.rule-template-grid,
.rules-grid,
.score-grid,
.mini-account-list {
  display: grid;
  gap: 12px;
}

.rule-template-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rule-template,
.empty-state,
.score-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  color: var(--ink);
  padding: 16px;
}

.rule-template {
  min-height: 72px;
  text-align: left;
  font-weight: 700;
}

.rule-template.is-selected,
.rule-template:hover,
.rule-template:focus-visible {
  border-color: var(--teal);
  background: var(--teal-bg);
  outline: none;
}

.rules-grid {
  grid-template-columns: minmax(0, .78fr) minmax(0, 1fr);
  min-height: calc(100dvh - 166px);
}

.score-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
}

.score-intro {
  width: 100%;
  max-width: 100%;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper-soft);
  padding: 18px;
}

.score-intro h2 {
  margin-bottom: 8px;
}

.score-intro p:last-child {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--slate);
}

.score-card {
  width: 100%;
  max-width: 100%;
  min-height: 152px;
}

.score-card span {
  color: var(--teal);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.score-card strong {
  display: block;
  margin: 22px 0 10px;
  font-size: 24px;
}

.score-card p,
.empty-state p {
  margin: 0;
  color: var(--slate);
  font-size: 13px;
  line-height: 1.5;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(16,24,40,.62);
  padding: 18px;
}
.modal[hidden] { display: none; }
.modal-card { position: relative; width: min(560px, 100%); border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper-soft); padding: 28px; }
.modal-card p:not(.eyebrow) { color: var(--slate); }
.avatar-editor-card {
  display: grid;
  gap: 14px;
  width: min(780px, 100%);
  padding: 20px;
}
.avatar-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 44px;
}
.avatar-editor-head h2 {
  margin: 0;
  font-size: 20px;
}
.avatar-editor-stage {
  display: grid;
  min-height: 330px;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, #e5e7eb 0 8%, #111827 8% 92%, #e5e7eb 92% 100%);
  padding: clamp(28px, 5vw, 52px);
}
.avatar-editor-frame {
  display: grid;
  position: relative;
  width: min(330px, 68vw);
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.88);
  border-radius: var(--radius);
  background: #1f2937;
  box-shadow: 0 0 0 999px rgba(17,24,39,.34);
  padding: 42px;
  cursor: grab;
  touch-action: none;
}
.avatar-editor-frame:active {
  cursor: grabbing;
}
.avatar-editor-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
  pointer-events: none;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
.avatar-save-boundary {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: var(--radius);
  box-shadow:
    inset 0 0 0 1px rgba(16,24,40,.34),
    0 0 0 999px rgba(17,24,39,.16);
  pointer-events: none;
}
.avatar-editor-card label {
  width: min(360px, 100%);
  justify-self: center;
}
.avatar-editor-card input {
  width: 100%;
}
.avatar-editor-card p {
  justify-self: center;
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}
.profile-card {
  display: grid;
  gap: 18px;
  width: min(680px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  overflow: auto;
}
.profile-page-card {
  margin: 0 auto;
  max-height: none;
  overflow: visible;
  border: 0;
  background: transparent;
  padding: clamp(10px, 2vw, 18px) 0;
}
.profile-cover {
  position: relative;
  width: 100%;
  max-height: 220px;
  aspect-ratio: 820 / 260;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(16,24,40,.20), rgba(15,118,110,.10)),
    url("assets/household-table-threshold.png") center 48% / cover no-repeat;
  overflow: visible;
}
.profile-hero {
  display: flex;
  justify-content: flex-start;
  padding-right: 12px;
  padding-left: 12px;
  margin-top: -2px;
  min-height: 74px;
}
.profile-photo-stack {
  display: grid;
  justify-items: center;
  gap: 8px;
  position: absolute;
  right: 18px;
  bottom: 0;
  z-index: 1;
  transform: translateY(60%);
}
.profile-photo-stack strong {
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  font-weight: 800;
  color: var(--ink);
}
.profile-identity-stack {
  width: min(320px, 58%);
  margin-top: 22px;
}
.profile-household-title {
  display: block;
  width: 100%;
  min-height: 28px;
  border: 1px solid transparent;
  background: transparent;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  padding: 0;
  box-shadow: none;
}
.profile-household-title:focus {
  outline: 0;
  border-color: var(--border);
}
.profile-household-title::placeholder {
  color: var(--faint);
  opacity: .62;
}
.profile-hero p {
  margin: 0 0 4px;
  color: var(--slate);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.profile-hero p span {
  display: inline-block;
  min-width: 42px;
  color: var(--faint);
  font-size: 11px;
}
.profile-hero p strong {
  color: var(--slate);
  font-size: 12px;
  font-weight: 600;
}
.profile-identity-line {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.profile-identity-line span,
.profile-hero p span {
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
}
.profile-identity-line input {
  min-height: 24px;
  border: 0;
  background: transparent;
  color: var(--slate);
  font-size: 12px;
  padding: 0;
  font-weight: 600;
}
.profile-section {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.profile-save-section {
  padding: 12px 0 4px;
}
.profile-save-section .modal-actions {
  margin-top: 0;
}
.profile-device-section {
  border-top: 0;
  padding-top: 4px;
}
.profile-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}
.profile-section label {
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}
.profile-section label span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.profile-section input,
.profile-section select {
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--slate);
  font-size: 12px;
  padding: 6px 0;
  font-weight: 500;
}
.profile-record-lines input,
.profile-record-lines select {
  color: var(--faint);
}
.profile-section input:focus,
.profile-section select:focus {
  outline: 0;
}
.profile-section input::placeholder {
  color: var(--faint);
  opacity: .62;
}
.profile-command-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.profile-return-summary {
  display: grid;
  gap: 12px;
}
.profile-next-return-row {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}
.profile-next-return-row > span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.profile-next-return-row .next-return-line {
  justify-content: flex-start;
}
.profile-next-return-row #profile-next-return {
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}
.profile-next-return-row > .secondary-action {
  justify-self: end;
  min-height: 34px;
  padding: 0 14px;
}
.profile-next-return-line .next-return-confirm .primary-action,
.profile-next-return-line .next-return-confirm .secondary-action {
  display: none;
}
.profile-file-name {
  margin: 0;
  color: var(--slate);
  font-size: 12px;
}
.profile-image-name {
  display: none;
}
.profile-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 142px;
}
.profile-upload-action {
  min-height: auto;
  border: 0;
  color: var(--teal-hover);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}
.avatar-controls {
  display: none;
  gap: 8px;
  margin-left: 142px;
}
.avatar-controls[hidden] {
  display: none;
}
.avatar-controls input {
  min-height: 22px;
  padding: 0;
}
.avatar-controls p {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}
.profile-record-lines,
.profile-source-lines,
.rhythm-lines {
  display: grid;
  gap: 12px;
}
.profile-source-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}
.profile-source-row > span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.profile-source-detail {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--faint);
  font-size: 12px;
}
#profile-account-map {
  gap: 14px;
}
.profile-goal-updated {
  margin-top: -8px;
}
.profile-goal-updated small {
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 500;
}
.profile-source-detail p {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}
.profile-source-item {
  display: grid;
  gap: 2px;
}
.profile-source-item strong {
  color: var(--slate);
  font-size: 12px;
  font-weight: 700;
}
.profile-source-item span,
.profile-source-item small {
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}
.profile-source-item small {
  font-size: 11.5px;
}
.profile-permission {
  color: var(--faint);
  font-size: 12px;
}
.rhythm-lines > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.rhythm-lines .secondary-action {
  justify-self: end;
  min-height: 34px;
  padding: 0 14px;
}
.profile-setting-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 12px;
}
.profile-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.profile-setting-row span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.profile-setting-row strong {
  color: var(--slate);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.profile-device-list {
  display: grid;
  gap: 8px;
}
.profile-device-list h3 {
  margin: 0;
  font-size: 15px;
}
.profile-device-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-top: 2px;
}
.profile-device-row div {
  display: grid;
  gap: 2px;
}
.profile-device-row strong {
  color: var(--slate);
  font-size: 12px;
  font-weight: 600;
}
.profile-device-icon {
  color: var(--faint);
}
.profile-device-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}
.profile-device-row span,
.profile-device-activity {
  color: var(--faint);
  font-size: 12px;
}
.profile-device-activity {
  justify-self: start;
  border: 0;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 500;
}
.profile-device-activity:hover {
  background: transparent;
  color: var(--slate);
}
.profile-modal-email {
  margin: 2px 0 0;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* Quiet workspace pattern: profile/source-of-truth page is the reference. */
.home-shell,
.return-layout,
.rules-grid,
.score-grid,
.record-list,
.activity-list {
  gap: 0;
}

.home-shell,
.return-layout,
.rules-grid {
  grid-template-columns: 1fr;
}

.home-primary,
.next-panel,
.home-lookup,
.status-strip,
.local-boundary,
.return-start,
.return-card,
.summary-panel,
.record-card,
.record-receipt,
.activity-row,
.score-intro,
.score-card,
.export-card,
.empty-state,
.rule-template,
.return-mode-card,
.allocation-card,
.carry-forward,
.account-editor,
.account-chip,
.setup-preview,
.summary-panel div,
.preview-stack div {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.home-primary {
  min-height: auto;
  align-content: start;
  overflow: visible;
  padding: 0 0 26px;
  color: var(--ink);
}

.home-cover {
  width: 100%;
  max-height: 312px;
  aspect-ratio: 820 / 312;
  margin-bottom: 22px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(16,24,40,.30), rgba(15,118,110,.12)),
    url("assets/household-table-threshold.png") center 48% / cover no-repeat;
  overflow: hidden;
}

.home-primary h2,
.home-question {
  color: var(--ink);
  text-shadow: none;
}

.home-primary h2,
.command-main h2 {
  font-size: 20px;
  line-height: 1.15;
}

.home-question {
  max-width: none;
  color: var(--slate);
  font-size: 12px;
  line-height: 1.45;
}

.home-actions,
.return-mode-cards,
.score-grid,
.recent-records {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-action,
.return-mode-card,
.secondary-action,
.primary-action {
  width: auto;
  min-height: 42px;
  padding: 0 14px;
}

.home-action {
  min-height: 44px;
  align-content: center;
}

.home-primary .home-action.secondary-action {
  border-color: var(--border);
  background: var(--paper-soft);
  color: var(--ink);
  backdrop-filter: none;
}

.home-primary .home-action.secondary-action:hover {
  background: var(--paper-soft);
}

.home-action span,
.return-mode-card p,
.score-card p,
.record-field p,
.activity-row p,
.summary-panel p,
.export-card p,
.local-boundary p:not(.eyebrow),
.compact-empty p,
.recent-record p {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

.home-action strong,
.return-mode-card strong,
.score-card strong,
.record-meta strong,
.activity-row strong,
.local-boundary strong,
.recent-record strong {
  font-size: 12px;
  font-weight: 800;
}

.next-panel {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  column-gap: 14px;
  row-gap: 6px;
  align-items: start;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

.next-panel {
  position: relative;
}

.next-return-date-action {
  position: static;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  background: transparent;
}

#next-return-date-picker {
  position: absolute;
  right: 0;
  top: 50%;
  width: 32px;
  height: 32px;
  opacity: 0;
  pointer-events: none;
}

.next-panel span,
.next-panel strong,
.next-panel p {
  margin: 0;
  border: 0;
  padding: 0;
  color: var(--faint);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.next-panel span {
  color: var(--ink);
  font-weight: 800;
}

.next-return-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.next-return-line.is-editing {
  gap: 0;
}

#today-next-return {
  flex: 0 1 auto;
  min-width: 0;
}

.next-return-line.is-editing #today-next-return,
.next-return-line.is-editing #profile-next-return,
.next-return-line.is-editing .next-return-date-action {
  display: none;
}

#today-rhythm {
  grid-column: 2;
}

.next-return-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 0;
}

.next-return-confirm[hidden] {
  display: none;
}

.next-return-confirm span,
.next-return-confirm select,
.next-return-confirm input {
  color: var(--faint);
  font-size: 12px;
}

.next-return-confirm select,
.next-return-confirm input {
  width: auto;
  min-height: 32px;
  padding: 0 22px 0 0;
}

.next-return-time,
.next-return-repeat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.profile-next-return-line .next-return-repeat {
  position: relative;
  width: 32px;
  height: 32px;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--teal-bg);
}
.profile-next-return-line .next-return-repeat svg {
  stroke: var(--teal-hover);
}
.profile-next-return-line .next-return-repeat select {
  position: absolute;
  inset: 0;
  width: 32px;
  min-width: 32px;
  height: 32px;
  opacity: 0;
  cursor: pointer;
}
.profile-next-return-line .next-return-time svg {
  display: none;
}

.next-return-time svg,
.next-return-repeat svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.next-return-time input {
  min-width: 92px;
}

#next-return-pattern {
  min-width: 112px;
}

#next-return-annual-date {
  min-width: 92px;
}

.next-return-confirm .primary-action,
.next-return-confirm .secondary-action {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.home-lookup,
.status-strip,
.local-boundary,
.return-start,
.record-head,
.score-intro,
.export-card,
.profile-section {
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.status-strip {
  grid-template-columns: 1fr;
  overflow: visible;
}

.status-strip article {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  min-height: auto;
  border: 0;
  padding: 12px 0;
}

.status-strip article + article,
.activity-row + .activity-row,
.record-card + .record-card,
.score-card + .score-card {
  border-top: 1px solid rgba(208,213,221,.72);
}

.status-strip span,
.status-strip strong,
.status-strip p,
.activity-row span,
.record-meta span,
.summary-panel span,
.score-card span,
.preview-stack span,
.record-field h4 {
  margin: 0;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.status-strip strong,
.activity-row strong,
.record-meta span,
.summary-panel p,
.score-card strong,
.preview-stack strong {
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}

.local-boundary {
  align-items: flex-start;
}

.local-actions {
  justify-content: flex-start;
}

.app-shell input,
.app-shell select,
.app-shell textarea {
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--slate);
  font-size: 12px;
  padding: 6px 0;
  font-weight: 500;
}

.app-shell .profile-household-title {
  min-height: 28px;
  border: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  padding: 0;
  box-shadow: none;
}

.app-shell .profile-household-title:focus {
  border: 0;
  box-shadow: none;
  outline: 0;
}

.app-shell textarea {
  min-height: 76px;
}

.app-shell label span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.return-start h2,
.return-pane h2,
.record-head h2,
.score-intro h2,
.export-card h2,
.rules-grid h2 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.15;
}

.return-mode-card {
  min-height: 0;
  padding: 0 0 18px;
}

.return-mode-card span {
  color: var(--faint);
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0;
  text-transform: none;
}

.return-card {
  min-height: auto;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.return-steps {
  gap: 6px;
  margin-top: 24px;
}

.return-step {
  min-height: 34px;
  background: transparent;
  font-size: 12px;
}

.summary-panel {
  position: static;
  max-height: none;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.summary-panel div,
.preview-stack div {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 14px;
  padding: 10px 0;
}

.record-card {
  grid-template-columns: 1fr;
  padding: 18px 0;
}

.record-meta,
.record-field {
  border: 0;
  padding: 0;
}

.record-body {
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

.record-field {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  min-height: auto;
  gap: 14px;
}

.record-field p {
  margin: 0;
}

.activity-row {
  grid-template-columns: 140px minmax(0, 1fr) minmax(0, .7fr);
  padding: 14px 0;
}

.activity-row strong,
.activity-row p {
  margin: 0;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.score-card {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  min-height: auto;
  padding: 14px 0;
}

.score-card strong,
.score-card p {
  margin: 0;
}

.rules-grid,
.score-intro,
.export-card {
  min-height: auto;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 0;
}
.modal-close:hover { background: var(--teal-bg); }
.modal-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}
.site-invite {
  margin: 18px 0 0;
  font-size: 14px;
}
.site-invite a {
  color: var(--teal-hover);
  font-weight: 700;
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  background: var(--teal);
  color: var(--paper);
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .side-rail {
    min-height: 60px;
  }
  .threshold-layout, .command-grid, .home-shell, .return-layout { grid-template-columns: 1fr; }
  .account-form { grid-template-columns: 1fr; }
  .setup-preview, .return-steps, .summary-panel { position: static; }
  .return-steps { grid-template-columns: repeat(7, minmax(106px, 1fr)); overflow-x: auto; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-strip article:nth-child(2n) { border-right: 0; }
  .home-actions, .recent-records, .return-mode-cards, .score-grid, .rules-grid { grid-template-columns: 1fr; }
  .setup-card,
  .return-card,
  .return-start,
  .rules-grid { min-height: auto; }
}

@media (max-width: 680px) {
  :root {
    --rail-space: 18px;
  }

  .workspace-header { padding: 10px; }
  .profile-chip {
    max-width: 44px;
    padding: 5px;
  }
  .profile-copy {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .home-lookup {
    grid-template-columns: 1fr;
  }
  .home-lookup .recent-records {
    grid-column: auto;
  }
  .profile-hero {
    display: flex;
    justify-content: flex-start;
    padding-right: 12px;
    padding-left: 12px;
    min-height: 72px;
  }
  .profile-cover {
    aspect-ratio: 16 / 7;
  }
  .profile-photo-stack {
    right: 12px;
  }
  .profile-identity-stack {
    width: min(300px, 58vw);
    margin-top: 22px;
  }
  .profile-section label {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .profile-next-return-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .profile-source-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .profile-upload-row,
  .avatar-controls {
    margin-left: 0;
  }
  .rhythm-lines > div {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .profile-next-return-row > .secondary-action {
    justify-self: start;
    width: auto;
  }
  .profile-device-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .home-cover {
    aspect-ratio: 16 / 7;
    max-height: 220px;
    background-position: center 50%;
  }
  .view { padding: 10px 10px var(--rail-space); }
  .side-rail {
    right: auto;
    bottom: calc(26px + env(safe-area-inset-bottom));
    left: 50%;
    display: flex;
    width: fit-content;
    max-width: calc(100vw - 16px);
    height: 60px;
    min-height: 60px;
    align-items: center;
    gap: 6px;
    padding: 6px;
  }

  .rail-nav {
    display: grid;
    width: min(354px, calc(100vw - 28px));
    max-width: none;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
  }

  .nav-item {
    min-width: 0;
    min-height: 48px;
    padding: 0 4px;
    font-size: 10px;
  }
  .nav-icon,
  .nav-icon svg {
    width: 18px;
    height: 18px;
  }

  .workspace-header { display: flex; min-height: auto; }
  .header-action { justify-content: space-between; }
  .rail-nav { gap: 6px; }
  .nav-item { min-width: 0; text-align: center; }
  #view-setup:has(.welcome-step.is-active) {
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
  }

  .workspace-header:has(+ #view-setup.is-active .welcome-step.is-active) {
    padding: 10px;
  }

  .welcome-step {
    min-height: 100dvh;
    padding: 24px 24px 116px;
    background:
      linear-gradient(180deg, rgba(6,78,73,.18) 0%, rgba(6,78,73,.32) 46%, rgba(10,10,10,.66) 100%),
      url("assets/household-table-threshold.png") center center / cover no-repeat;
  }

  .threshold-hero {
    align-items: end;
    min-height: calc(100dvh - 286px);
  }

  .threshold-invite {
    width: 100%;
    gap: 12px;
    transform: translateY(-12px);
  }

  .threshold-invite h2 {
    max-width: 360px;
    font-size: clamp(34px, 10vw, 46px);
    line-height: .95;
  }

  .threshold-doors {
    display: flex;
    gap: 8px;
  }

  .door-action {
    min-height: 44px;
    padding: 0 15px;
  }
  .setup-card, .setup-preview, .command-main, .next-panel, .return-card, .summary-panel, .export-card { padding: 14px; }
  .setup-card:has(.welcome-step.is-active) { padding: 0; }
  .account-form, .account-list, .cadence-grid, .evidence-grid, .allocation-grid, .status-strip, .record-body, .rule-template-grid { grid-template-columns: 1fr; }
  .status-strip article, .record-field, .record-field:nth-child(3n), .record-field:nth-last-child(-n+3) { border-right: 0; border-bottom: 1px solid var(--border); }
  .status-strip article:last-child, .record-field:last-child { border-bottom: 0; }
  .record-head {
    display: grid;
    align-items: start;
    justify-content: stretch;
  }
  .record-head .secondary-action {
    justify-self: start;
  }
  .local-boundary {
    align-items: stretch;
    flex-direction: column;
  }
  .local-actions {
    justify-content: stretch;
  }
  .local-actions .secondary-action {
    flex: 1 1 140px;
  }
  .record-receipt {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .record-tools {
    justify-content: stretch;
  }
  .record-tools .secondary-action {
    flex: 1 1 100%;
  }
  .record-card { grid-template-columns: 1fr; }
  .record-meta { border-right: 0; border-bottom: 1px solid var(--border); }
  .activity-row { grid-template-columns: 1fr; }
  .return-steps { grid-template-columns: repeat(3, minmax(96px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .arrival-mark,
  .arrival-prompt,
  .arrival-word {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}

@media screen {
  .status-strip article,
  .record-field,
  .record-field:nth-child(3n),
  .record-field:nth-last-child(-n+3),
  .record-meta,
  .summary-panel div,
  .preview-stack div {
    border-right: 0;
    border-bottom: 0;
  }

  .status-strip article + article,
  .record-field + .record-field,
  .summary-panel div + div,
  .preview-stack div + div {
    border-top: 1px solid rgba(208,213,221,.72);
  }

  .setup-card,
  .setup-preview,
  .command-main,
  .next-panel,
  .return-card,
  .summary-panel,
  .export-card {
    background: transparent;
  }
}

@media print {
  body.is-printing-record {
    background: #fff;
  }
  body.is-printing-record .arrival-screen,
  body.is-printing-record .workspace-header,
  body.is-printing-record .record-head,
  body.is-printing-record .record-list,
  body.is-printing-record .toast,
  body.is-printing-record .modal {
    display: none !important;
  }
  body.is-printing-record .app-shell,
  body.is-printing-record .workspace,
  body.is-printing-record .view,
  body.is-printing-record #view-record,
  body.is-printing-record #record-detail {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 0 !important;
    background: #fff !important;
  }
  body.is-printing-record .record-tools,
  body.is-printing-record [data-record-action="back"] {
    display: none !important;
  }
  body.is-printing-record .record-receipt,
  body.is-printing-record .record-card {
    border: 1px solid #cbd5e1;
    box-shadow: none;
    break-inside: avoid;
  }
}
