:root {
  color-scheme: light;
  --color-navy-900: #0f172a;
  --color-navy-800: #172554;
  --color-navy-700: #1d4ed8;
  --color-blue-50: #eff6ff;
  --color-blue-100: #dbeafe;
  --color-emerald-50: #ecfdf5;
  --color-emerald-100: #d1fae5;
  --color-emerald-700: #047857;
  --color-amber-50: #fffbeb;
  --color-amber-100: #fef3c7;
  --color-amber-700: #a16207;
  --color-red-50: #fef2f2;
  --color-red-700: #b91c1c;
  --color-slate-50: #f8fafc;
  --color-slate-100: #f1f5f9;
  --color-slate-200: #e2e8f0;
  --color-slate-300: #cbd5e1;
  --color-slate-500: #64748b;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: var(--color-navy-900);
  --muted: #5b6678;
  --line: var(--color-slate-200);
  --primary: var(--color-navy-800);
  --primary-hover: #1e3a8a;
  --accent: var(--color-emerald-700);
  --accent-soft: var(--color-emerald-50);
  --warning: var(--color-amber-700);
  --warning-soft: var(--color-amber-50);
  --danger: var(--color-red-700);
  --danger-soft: var(--color-red-50);
  --focus-ring: rgba(29, 78, 216, 0.28);
  --focus-glow: rgba(29, 78, 216, 0.08);
  --hover-border: rgba(29, 78, 216, 0.34);
  --primary-border: rgba(29, 78, 216, 0.24);
  --success-border: rgba(4, 120, 87, 0.24);
  --warning-border: rgba(161, 98, 7, 0.3);
  --danger-border: rgba(185, 28, 28, 0.34);
  --on-primary: #ffffff;
  --page-background:
    linear-gradient(180deg, rgba(29, 78, 216, 0.1), rgba(247, 249, 252, 0) 260px),
    var(--bg);
  --control-bg: #ffffff;
  --control-hover-bg: var(--color-blue-50);
  --panel-bg: rgba(255, 255, 255, 0.82);
  --panel-strong-bg: rgba(255, 255, 255, 0.94);
  --glass-bg: rgba(255, 255, 255, 0.74);
  --glass-border: rgba(226, 232, 240, 0.78);
  --glass-blur: 22px;
  --sheet-backdrop: rgba(15, 23, 42, 0.54);
  --logo-bg: var(--color-blue-100);
  --avatar-bg: var(--color-emerald-100);
  --chip-bg: var(--color-blue-50);
  --meter-bg: var(--color-slate-100);
  --summary-bg:
    linear-gradient(135deg, rgba(29, 78, 216, 0.08), rgba(5, 150, 105, 0.06) 58%, rgba(255, 255, 255, 0) 100%),
    var(--panel-bg);
  --toast-bg: var(--color-navy-900);
  --toast-control-bg: rgba(255, 255, 255, 0.1);
  --toast-border: rgba(255, 255, 255, 0.28);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --control-height: 48px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.2);
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 160ms;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #101d2e;
  --surface-soft: #15243a;
  --ink: #f8fafc;
  --muted: #b7c3d5;
  --line: #31435d;
  --primary: #8bb8ff;
  --primary-hover: #b6d0ff;
  --accent: #54d6a7;
  --accent-soft: rgba(20, 184, 130, 0.14);
  --warning: #facc15;
  --warning-soft: rgba(250, 204, 21, 0.14);
  --danger: #fca5a5;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --focus-ring: rgba(139, 184, 255, 0.48);
  --focus-glow: rgba(139, 184, 255, 0.16);
  --hover-border: rgba(139, 184, 255, 0.52);
  --primary-border: rgba(139, 184, 255, 0.36);
  --success-border: rgba(84, 214, 167, 0.34);
  --warning-border: rgba(250, 204, 21, 0.42);
  --danger-border: rgba(252, 165, 165, 0.42);
  --page-background:
    linear-gradient(180deg, rgba(139, 184, 255, 0.12), rgba(7, 17, 31, 0) 270px),
    var(--bg);
  --control-bg: #0c1726;
  --control-hover-bg: rgba(139, 184, 255, 0.12);
  --panel-bg: rgba(16, 29, 46, 0.78);
  --panel-strong-bg: rgba(16, 29, 46, 0.94);
  --glass-bg: rgba(13, 25, 42, 0.72);
  --glass-border: rgba(148, 163, 184, 0.24);
  --sheet-backdrop: rgba(0, 0, 0, 0.68);
  --logo-bg: rgba(139, 184, 255, 0.18);
  --avatar-bg: rgba(84, 214, 167, 0.18);
  --chip-bg: rgba(139, 184, 255, 0.12);
  --meter-bg: #1d2d43;
  --summary-bg:
    linear-gradient(135deg, rgba(139, 184, 255, 0.12), rgba(84, 214, 167, 0.1) 58%, rgba(16, 29, 46, 0) 100%),
    var(--panel-bg);
  --toast-bg: #f8fafc;
  --toast-control-bg: rgba(15, 23, 42, 0.08);
  --toast-border: rgba(15, 23, 42, 0.22);
  --on-primary: #04111f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 16px 38px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.48);
}

html[data-contrast="high"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #ffffff;
  --ink: #000000;
  --muted: #000000;
  --line: #000000;
  --primary: #0000ee;
  --primary-hover: #000000;
  --accent: #005a32;
  --accent-soft: #ffffff;
  --warning: #7a4b00;
  --warning-soft: #ffffff;
  --danger: #b00020;
  --danger-soft: #ffffff;
  --focus-ring: #ffbf00;
  --focus-glow: transparent;
  --hover-border: #000000;
  --primary-border: #000000;
  --success-border: #000000;
  --warning-border: #000000;
  --danger-border: #000000;
  --on-primary: #ffffff;
  --page-background: #ffffff;
  --control-bg: #ffffff;
  --control-hover-bg: #ffffff;
  --panel-bg: #ffffff;
  --panel-strong-bg: #ffffff;
  --glass-bg: #ffffff;
  --glass-border: #000000;
  --glass-blur: 0px;
  --sheet-backdrop: rgba(0, 0, 0, 0.78);
  --logo-bg: #ffffff;
  --avatar-bg: #ffffff;
  --chip-bg: #ffffff;
  --meter-bg: #ffffff;
  --summary-bg: #ffffff;
  --toast-bg: #000000;
  --toast-control-bg: #ffffff;
  --toast-border: #ffffff;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
}

html[data-theme="dark"][data-contrast="high"] {
  --bg: #000000;
  --surface: #000000;
  --surface-soft: #000000;
  --ink: #ffffff;
  --muted: #ffffff;
  --line: #ffffff;
  --primary: #8ab4ff;
  --primary-hover: #ffffff;
  --accent: #74ffd1;
  --accent-soft: #000000;
  --warning: #ffe066;
  --warning-soft: #000000;
  --danger: #ff8a8a;
  --danger-soft: #000000;
  --on-primary: #000000;
  --page-background: #000000;
  --control-bg: #000000;
  --control-hover-bg: #000000;
  --panel-bg: #000000;
  --panel-strong-bg: #000000;
  --glass-bg: #000000;
  --glass-border: #ffffff;
  --sheet-backdrop: rgba(255, 255, 255, 0.24);
  --logo-bg: #000000;
  --avatar-bg: #000000;
  --chip-bg: #000000;
  --meter-bg: #000000;
  --summary-bg: #000000;
  --toast-bg: #ffffff;
  --toast-control-bg: #000000;
  --toast-border: #000000;
}

html[data-transparency="solid"] {
  --glass-bg: var(--surface);
  --panel-bg: var(--surface);
  --panel-strong-bg: var(--surface);
  --summary-bg: var(--surface);
  --glass-blur: 0px;
}

html[data-contrast="high"] .app-topbar,
html[data-contrast="high"] .summary-panel,
html[data-contrast="high"] .setup-panel,
html[data-contrast="high"] .person-card,
html[data-contrast="high"] .night-panel,
html[data-contrast="high"] .sheet-panel,
html[data-contrast="high"] .bottom-tabs {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

html[data-contrast="high"] .primary-button,
html[data-contrast="high"] .readiness-dot {
  box-shadow: none;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --glass-bg: var(--surface);
    --glass-blur: 0px;
  }
}

@media (forced-colors: active) {
  :root {
    --glass-blur: 0px;
  }

  .app-topbar,
  .summary-panel,
  .setup-panel,
  .person-card,
  .night-panel,
  .sheet-panel,
  .bottom-tabs,
  .sheet-callout,
  .sheet-note,
  .install-card,
  .apartment-card,
  .history-row,
  .night-row,
  .stay-row,
  .field input,
  .field select,
  .field textarea,
  button {
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .primary-button,
  .toast {
    background: CanvasText;
    color: Canvas;
  }

  .meter-track span,
  .readiness-dot {
    background: CanvasText;
    box-shadow: none;
  }
}

* {
  box-sizing: border-box;
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--page-background);
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-140%);
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--on-primary);
  padding: 10px 12px;
  font-weight: 900;
  text-decoration: none;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: var(--control-height);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease),
    opacity var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}

button:active {
  transform: scale(0.985);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 14px calc(36px + env(safe-area-inset-bottom));
}

.app-section {
  scroll-margin-top: 86px;
}

.loading {
  padding: 24px;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 -14px 12px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.45);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.45);
}

.app-mark {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}

.app-logo,
.person-avatar {
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--logo-bg);
  color: var(--primary);
  font-weight: 950;
}

.app-logo {
  width: 40px;
  height: 40px;
  box-shadow: inset 0 0 0 1px var(--primary-border);
}

.app-mark strong,
.app-mark small {
  display: block;
}

.app-mark strong {
  line-height: 1.1;
}

.app-mark small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.icon-label-button,
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  padding: 0 13px;
  white-space: nowrap;
  font-weight: 900;
}

.icon-label-button {
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.button-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.icon-settings::before,
.icon-settings::after,
.icon-download::before,
.icon-download::after,
.icon-home::before,
.icon-home::after {
  position: absolute;
  content: "";
}

.icon-settings::before {
  top: 4px;
  left: 2px;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    0 5px 0 currentColor,
    0 10px 0 currentColor;
}

.icon-settings::after {
  top: 2px;
  left: 10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow:
    -7px 5px 0 currentColor,
    2px 10px 0 currentColor;
}

.icon-download::before {
  top: 2px;
  left: 8px;
  width: 2px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
}

.icon-download::after {
  right: 3px;
  bottom: 2px;
  left: 3px;
  height: 7px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 3px 3px;
}

.icon-home::before {
  top: 7px;
  left: 3px;
  width: 12px;
  height: 10px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 3px 3px;
}

.icon-home::after {
  top: 1px;
  left: 4px;
  width: 10px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
}

.app-hero {
  display: grid;
  gap: 14px;
  padding: 4px 0 14px;
}

.brand-block h1,
.section-heading h2,
.setup-summary h2,
.setup-group h3,
.summary-head h2,
.person-name-block h3,
.sheet-header h2,
.sheet-section-head h3,
.saved-people h3 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

.brand-block h1 {
  max-width: 760px;
  font-size: 2.05rem;
}

.hero-lede,
.section-note,
.summary-rule,
.setup-group p,
.sheet-section-head p,
.person-name-block p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.38;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hero-facts,
.setup-chips,
.person-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-panel,
.setup-panel,
.person-card,
.night-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.18);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.18);
}

.hero-facts div {
  display: grid;
  flex: 1 1 112px;
  gap: 3px;
  min-height: 66px;
  align-content: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong-bg);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.18);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.18);
}

.hero-facts span,
.meter-block span,
.field span,
.person-total span,
.total-tile span,
.total-tile small,
.night-row span,
.night-row small,
.empty-note,
.sheet-stat-grid span,
.setup-chips span,
.inline-alert span,
.empty-state span {
  color: var(--muted);
}

.hero-facts strong {
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  line-height: 1.1;
}

.summary-panel {
  display: grid;
  gap: 13px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--summary-bg);
  box-shadow: var(--shadow-md);
}

.summary-head,
.section-heading,
.setup-summary,
.person-topline,
.sheet-header,
.sheet-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-head h2 {
  overflow-wrap: anywhere;
  font-size: 1.86rem;
  font-variant-numeric: tabular-nums;
}

.summary-head h2 span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-actions,
.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.setup-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.setup-groups {
  display: grid;
  gap: 14px;
}

.setup-group {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.setup-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.setup-group-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.setup-group h3 {
  font-size: 1rem;
}

.meter-block {
  display: grid;
  gap: 8px;
}

.meter-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--meter-bg);
}

.meter-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.readiness-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong-bg);
}

.readiness-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.readiness-bar > div {
  min-width: 0;
}

.readiness-bar strong,
.readiness-bar span {
  display: block;
}

.readiness-bar strong {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.readiness-bar > div span {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.readiness-action {
  min-height: 38px;
  border: 1px solid var(--primary-border);
  background: var(--control-bg);
  color: var(--primary);
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.readiness-bar.success {
  border-color: var(--success-border);
  background: var(--accent-soft);
}

.readiness-bar.warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
}

.readiness-bar.warning .readiness-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 18%, transparent);
}

.readiness-bar.danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.readiness-bar.danger .readiness-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent);
}

.readiness-bar.info .readiness-dot {
  background: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
}

.totals-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
}

.total-tile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  min-height: 62px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.total-tile-head {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.total-tile-head > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.total-tile strong {
  justify-self: end;
  overflow-wrap: anywhere;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.total-tile small {
  grid-column: 1 / -1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.total-tile.warning {
  margin-top: 4px;
  padding: 10px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
}

.inline-alert {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
}

.workspace {
  display: grid;
  gap: 14px;
}

.workspace-main,
.workspace-side {
  display: grid;
  align-content: start;
  gap: 14px;
}

.setup-panel,
.night-panel {
  padding: 16px;
}

.setup-summary,
.section-heading {
  margin-bottom: 14px;
}

.section-heading h2,
.setup-summary h2 {
  font-size: 1.2rem;
}

.setup-chips span,
.person-stats span {
  min-height: 28px;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 850;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 0.82rem;
  font-weight: 850;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 1rem;
  transition:
    background-color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--hover-border);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: var(--control-bg);
  box-shadow: 0 0 0 4px var(--focus-glow);
}

.field textarea {
  resize: vertical;
  line-height: 1.45;
}

.compact input {
  min-height: var(--control-height);
  padding: 9px 10px;
}

.primary-button {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 22%, transparent);
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button {
  border: 1px solid var(--success-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.icon-label-button:hover {
  border-color: var(--hover-border);
  background: var(--control-hover-bg);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--ink);
}

.danger-text {
  color: var(--danger);
}

.danger-confirm {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.copy-button {
  min-width: 104px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 900;
  line-height: 1;
}

.icon-button.danger {
  color: var(--danger);
}

.people-section,
.people-list,
.stays {
  display: grid;
  gap: 12px;
}

.person-card {
  display: grid;
  gap: 9px;
  padding: 11px;
  background: var(--panel-bg);
}

.person-topline {
  align-items: flex-start;
}

.person-identity {
  display: grid;
  grid-template-columns: var(--control-height) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.person-avatar {
  width: var(--control-height);
  height: var(--control-height);
  flex: 0 0 var(--control-height);
  background: var(--avatar-bg);
  color: var(--accent);
  font-size: 0.96rem;
}

.person-avatar.small {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.person-name-block {
  min-width: 0;
}

.person-name-block h3 {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.person-name-block p {
  margin-top: 4px;
  font-size: 0.84rem;
}

.person-total {
  display: grid;
  flex: 0 0 132px;
  min-height: 48px;
  align-content: center;
  gap: 2px;
  color: var(--ink);
  text-align: right;
}

.person-total strong {
  overflow-wrap: anywhere;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}

.person-total span {
  font-size: 0.76rem;
  font-weight: 850;
}

.person-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.stay-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong-bg);
}

.stay-row.is-focused {
  border-color: var(--hover-border);
  background: var(--control-hover-bg);
  box-shadow: 0 0 0 4px var(--focus-glow);
}

.empty-note {
  margin: 0;
  padding: 10px 0;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.night-list {
  display: grid;
  gap: 8px;
}

.night-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong-bg);
}

.night-row time {
  display: grid;
  place-items: center;
  width: 48px;
  min-height: 44px;
  border-radius: var(--radius-md);
  background: var(--chip-bg);
  color: var(--primary);
  font-weight: 900;
}

.night-row time span {
  color: inherit;
  font-size: 1rem;
  line-height: 1;
}

.night-row time small {
  color: inherit;
  font-size: 0.66rem;
  line-height: 1;
}

.night-row div {
  min-width: 0;
}

.night-row strong,
.night-row span {
  display: block;
  overflow-wrap: anywhere;
}

.night-row span {
  margin-top: 2px;
  font-size: 0.84rem;
  line-height: 1.25;
}

.night-row > small {
  color: var(--muted);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.night-row.is-empty time {
  background: var(--warning-soft);
  color: var(--warning);
}

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  align-items: end;
  pointer-events: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  border-radius: 0;
  background: var(--sheet-backdrop);
  pointer-events: auto;
}

.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 680px);
  max-height: min(92dvh, 760px);
  overflow: auto;
  margin: 0 auto;
  padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--glass-border);
  border-radius: 16px 16px 0 0;
  background: var(--glass-bg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.35);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.35);
}

.sheet-handle {
  display: block;
  width: 42px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: var(--line);
}

.sheet-header {
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-header h2 {
  overflow-wrap: anywhere;
  font-size: 1.28rem;
}

.sheet-header h2:focus {
  outline: none;
}

.sheet-body {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.sheet-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sheet-stat-grid div {
  display: grid;
  gap: 3px;
  min-height: 62px;
  align-content: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.sheet-stat-grid strong {
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
}

.sheet-callout,
.sheet-note,
.install-card {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong-bg);
}

.sheet-callout {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.sheet-callout strong,
.sheet-callout span,
.sheet-note strong,
.sheet-note span,
.install-card strong,
.install-card span {
  display: block;
}

.sheet-callout span,
.sheet-note span,
.install-card span {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.converter-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
}

.converter-card div {
  min-width: 0;
}

.converter-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.converter-card strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.converter-arrow {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--accent);
  font-weight: 950;
}

.sheet-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--chip-bg);
  color: var(--primary);
  font-weight: 850;
  line-height: 1.35;
}

.install-card {
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
}

.install-icon {
  display: inline-grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--logo-bg);
  color: var(--primary);
  font-weight: 950;
}

.install-steps {
  margin: 0;
  padding: 12px 12px 12px 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong-bg);
  color: var(--ink);
  font-weight: 800;
  line-height: 1.55;
}

.apartment-list,
.history-list {
  display: grid;
  gap: 8px;
}

.apartment-card,
.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong-bg);
}

.apartment-card.is-active {
  border-color: var(--success-border);
  background: var(--accent-soft);
}

.apartment-card strong,
.apartment-card span,
.apartment-card small,
.history-row strong,
.history-row span,
.history-row small {
  display: block;
  overflow-wrap: anywhere;
}

.apartment-card span,
.history-row span {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.apartment-card small,
.history-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.apartment-badge {
  min-height: 34px;
  align-content: center;
  border: 1px solid var(--success-border);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--accent);
  padding: 0 10px;
  font-weight: 900;
}

.sheet-section-head {
  align-items: flex-end;
}

.sheet-section-head h3,
.saved-people h3 {
  font-size: 1rem;
}

.sheet-section-head p {
  font-size: 0.84rem;
}

.preset-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.preset-actions .ghost-button {
  min-height: 42px;
  padding: 0 8px;
  background: var(--chip-bg);
  color: var(--primary);
  font-size: 0.82rem;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sheet-actions.split {
  justify-content: space-between;
  flex-wrap: wrap;
}

.sheet-actions.split > span:empty {
  flex: 1 1 auto;
}

.share-field textarea {
  min-height: 220px;
}

.saved-people {
  display: grid;
  gap: 10px;
}

.saved-people > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-person-chip {
  min-height: 40px;
  border: 1px solid var(--success-border);
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 12px;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 14px;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--toast-bg);
  color: var(--on-primary);
  box-shadow: var(--shadow-lg);
  font-weight: 850;
}

.toast button {
  min-height: 36px;
  border: 1px solid var(--toast-border);
  background: var(--toast-control-bg);
  color: inherit;
  padding: 0 10px;
  font-weight: 900;
}

.bottom-tabs {
  display: none;
}

@media (min-width: 680px) {
  .app-shell {
    padding-right: 18px;
    padding-left: 18px;
  }

  .app-topbar {
    margin-right: -18px;
    margin-left: -18px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .app-hero {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr);
    align-items: end;
  }

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

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

@media (min-width: 760px) {
  .sheet-layer {
    align-items: center;
    padding: 24px;
  }

  .sheet-panel {
    border-radius: var(--radius-lg);
    padding: 12px 18px 18px;
  }

  .toast {
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (min-width: 980px) {
  .app-shell {
    padding-bottom: 42px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    align-items: start;
  }

  .summary-panel {
    grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
  }

  .summary-head,
  .meter-block,
  .inline-alert {
    grid-column: 1;
  }

  .totals-grid {
    grid-column: 2;
    grid-row: 1 / span 4;
  }

  .workspace-side {
    position: sticky;
    top: 86px;
  }

  .night-list {
    max-height: calc(100dvh - 190px);
    overflow: auto;
    padding: 1px 2px 1px 1px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .app-topbar {
    margin-right: -10px;
    margin-bottom: 8px;
    margin-left: -10px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .app-logo {
    width: 36px;
    height: 36px;
  }

  .topbar-actions .icon-label-button span:last-child {
    display: none;
  }

  .app-hero {
    display: none;
  }

  .brand-block h1 {
    font-size: 1.58rem;
  }

  .hero-lede {
    font-size: 0.9rem;
  }

  .summary-head,
  .setup-summary,
  .setup-group-head,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .summary-actions,
  .setup-actions,
  .copy-button,
  .section-heading .primary-button,
  .setup-group .secondary-button,
  .setup-group .ghost-button {
    width: 100%;
  }

  .summary-actions > *,
  .setup-actions > * {
    flex: 1 1 0;
  }

  .summary-panel,
  .setup-panel,
  .night-panel {
    padding: 12px;
  }

  .summary-head h2 {
    font-size: 1.56rem;
  }

  .meter-block {
    gap: 6px;
  }

  .readiness-bar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 9px;
  }

  .readiness-action {
    grid-column: 1 / -1;
    width: 100%;
  }

  .person-topline {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .person-total {
    width: 100%;
    text-align: left;
    min-height: auto;
  }

  .person-card {
    gap: 8px;
    padding: 10px;
  }

  .person-avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .person-identity {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .people-section,
  .people-list,
  .stays,
  .workspace,
  .workspace-main,
  .workspace-side {
    gap: 10px;
  }

  .stay-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .stay-row .compact:nth-child(2) {
    grid-column: 1;
  }

  .night-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .night-row > small {
    grid-column: 2;
    justify-self: start;
  }

  .sheet-stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0 10px;
  }

  .sheet-actions {
    flex-direction: column-reverse;
  }

  .sheet-actions.split {
    flex-direction: column;
  }

  .sheet-actions.split > span:empty {
    display: none;
  }

  .sheet-actions > * {
    width: 100%;
  }

  .preset-actions {
    grid-template-columns: 1fr;
  }

  .apartment-card,
  .history-row {
    grid-template-columns: 1fr;
  }

  .apartment-card > button,
  .history-row > button,
  .apartment-badge {
    width: 100%;
  }

  .sheet-callout,
  .converter-card {
    grid-template-columns: 1fr;
  }

  .converter-arrow {
    transform: rotate(90deg);
  }
}

@media (max-width: 720px) {
  .app-section {
    scroll-margin-top: 82px;
    scroll-margin-bottom: calc(146px + env(safe-area-inset-bottom));
  }

  .app-shell {
    padding-bottom: calc(154px + env(safe-area-inset-bottom));
  }

  #app[data-active-view="result"] .workspace,
  #app[data-active-view="setup"] #result,
  #app[data-active-view="setup"] #people,
  #app[data-active-view="setup"] .workspace-side,
  #app[data-active-view="people"] #result,
  #app[data-active-view="people"] #setup,
  #app[data-active-view="people"] .workspace-side,
  #app[data-active-view="plan"] #result,
  #app[data-active-view="plan"] .workspace-main {
    display: none;
  }

  #app[data-active-view="setup"] .workspace,
  #app[data-active-view="people"] .workspace,
  #app[data-active-view="plan"] .workspace {
    display: grid;
  }

  #app[data-active-view="setup"] .workspace-main,
  #app[data-active-view="people"] .workspace-main,
  #app[data-active-view="plan"] .workspace-side {
    display: grid;
  }

  .night-panel {
    margin-bottom: calc(98px + env(safe-area-inset-bottom));
  }

  .toast {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .bottom-tabs {
    position: fixed;
    right: 12px;
    bottom: 10px;
    left: 12px;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--glass-bg);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.35);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.35);
  }

  .bottom-tabs a {
    display: grid;
    min-width: 0;
    min-height: 56px;
    place-items: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    text-decoration: none;
  }

  .bottom-tabs a.is-active {
    background: var(--chip-bg);
    color: var(--primary);
  }

  .tab-icon {
    position: relative;
    display: block;
    width: 22px;
    height: 22px;
  }

  .tab-result::before {
    position: absolute;
    inset: 4px 3px;
    content: "";
    border: 2px solid currentColor;
    border-top: 0;
    border-radius: 2px;
  }

  .tab-result::after {
    position: absolute;
    right: 5px;
    bottom: 5px;
    left: 5px;
    height: 3px;
    content: "";
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 -5px 0 currentColor;
  }

  .tab-entry::before {
    position: absolute;
    inset: 3px;
    content: "";
    border: 2px solid currentColor;
    border-radius: 5px;
  }

  .tab-entry::after {
    position: absolute;
    top: 8px;
    right: 7px;
    left: 7px;
    height: 2px;
    content: "";
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 5px 0 currentColor;
  }

  .tab-plan::before {
    position: absolute;
    inset: 3px;
    content: "";
    border: 2px solid currentColor;
    border-radius: 50%;
  }

  .tab-plan::after {
    position: absolute;
    top: 9px;
    left: 9px;
    width: 4px;
    height: 4px;
    content: "";
    border-radius: 50%;
    background: currentColor;
    box-shadow:
      0 -7px 0 currentColor,
      0 7px 0 currentColor,
      -7px 0 0 currentColor,
      7px 0 0 currentColor;
  }

  .tab-setup::before {
    position: absolute;
    top: 4px;
    left: 3px;
    width: 16px;
    height: 2px;
    content: "";
    border-radius: 999px;
    background: currentColor;
    box-shadow:
      0 7px 0 currentColor,
      0 14px 0 currentColor;
  }

  .tab-setup::after {
    position: absolute;
    top: 2px;
    left: 12px;
    width: 5px;
    height: 5px;
    content: "";
    border-radius: 50%;
    background: currentColor;
    box-shadow:
      -8px 7px 0 currentColor,
      2px 14px 0 currentColor;
  }
}
