/*
 * Costa MLS components. Every value is a token from tokens.css; the two media queries
 * repeat --bp-phone and --bp-table because custom properties cannot be read there.
 * Class names follow docs/design/screens/*.dc.html so a board maps 1:1 to markup.
 */

/* ---- Layout helpers ------------------------------------------------------------------ */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--sp-4));
  min-width: 0;
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--sp-3));
}

.cluster-end {
  justify-content: flex-end;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr));
  gap: var(--sp-4);
}

.grid-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--field-min), 100%), 1fr));
  gap: var(--sp-4);
}

/* ---- Header, logo, main nav, phone menu ------------------------------------------------ */

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.top-in {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-3) max(var(--gutter), env(safe-area-inset-right, 0px)) var(--sp-3)
    max(var(--gutter), env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-5);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  border-radius: var(--r-sm);
}

.logo-mark {
  flex: none;
  stroke: var(--c-gold);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.wm {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--text-strong);
  letter-spacing: var(--tracking-tighter);
}

.wm em {
  font-style: italic;
  font-weight: var(--fw-regular);
  color: var(--c-gold);
}

.sub {
  margin-top: var(--sp-1);
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.sub b {
  color: var(--accent-text);
}

.nav {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h);
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--text);
  font-weight: var(--fw-medium);
  font-size: var(--fs-md);
}

.nav a:hover {
  background: var(--bg);
  color: var(--text-strong);
}

.nav a[aria-current] {
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: var(--fw-semibold);
}

/* One-row main nav on desktop: in a signed-in header the brand tagline drops and the gaps
   tighten so the row holds for every nav (Spanish or English, agent or the 7-link admin)
   at 1280 and up without wrapping. A visitor's logo-only header keeps its tagline.
   Link min-height stays --control-h (44px targets). All values are tokens. */
@media (min-width: 64rem) {
  .top-in:has(.nav) .logo .sub {
    display: none;
  }

  .top-in:has(.nav) {
    gap: var(--sp-3);
  }

  .nav a {
    padding-inline: var(--sp-1);
  }
}

.who {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text);
}

.av {
  width: var(--avatar);
  height: var(--avatar);
  border-radius: 50%;
  background: var(--dark);
  color: var(--on-dark-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
}

/* The menu button exists only when the script that drives it is running (html.js). */
.btn.menu {
  display: none;
}

@media (max-width: 760px) {
  .top-in {
    gap: var(--sp-3);
  }

  /* The logo takes what the initials and the menu button leave; the tagline wraps before
     the header does. */
  .logo {
    flex: 1 1 0;
    min-width: 0;
  }

  .who-name {
    display: none;
  }

  .js .btn.menu {
    display: inline-flex;
  }

  .js .nav {
    display: none;
  }

  .js .top[data-open] .nav {
    display: flex;
    flex-direction: column;
    flex: 1 0 100%;
    order: 10;
    padding-top: var(--sp-2);
    border-top: 1px solid var(--line-soft);
  }
}

/* On the narrowest phones the tagline drops its capitals and spacing so it still fits
   beside the initials and the menu button on one line. */
@media (max-width: 480px) {
  .sub {
    letter-spacing: 0;
    text-transform: none;
    text-wrap: balance;
  }
}

/* ---- Buttons ----------------------------------------------------------------------------
   Variants: .btn-p primary, .btn-s secondary, .btn-a accent (on dark), .btn-d destructive.
   States: hover, keyboard focus (global ring), :disabled / aria-disabled, aria-busy. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.btn-p {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-p:hover {
  background: var(--primary-hover);
  color: var(--on-primary);
}

.btn-s {
  background: var(--surface);
  color: var(--text-strong);
  border-color: var(--line-strong);
}

.btn-s:hover {
  background: var(--bg);
  border-color: var(--text-muted);
  color: var(--text-strong);
}

.btn-a {
  background: var(--accent-on-dark);
  color: var(--text-strong);
}

.btn-a:hover {
  background: var(--accent-on-dark-hover);
  color: var(--text-strong);
}

.btn-d {
  background: var(--danger);
  color: var(--on-primary);
}

.btn-d:hover {
  background: var(--danger-hover);
  color: var(--on-primary);
}

.btn-icon {
  width: var(--control-h);
  padding: 0;
}

.btn-block {
  width: 100%;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--disabled-bg);
  border-color: var(--line);
  color: var(--disabled-fg);
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  cursor: progress;
  pointer-events: none;
}

.btn[aria-busy="true"]::before {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---- Filter chips ----------------------------------------------------------------------- */

.flt {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-strong);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}

.flt:hover {
  background: var(--bg);
}

.flt-on {
  border-color: var(--primary);
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: var(--fw-semibold);
}

.flt-on:hover {
  background: var(--primary-tint);
}

/* ---- Pills: one status each ------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  height: var(--pill-h);
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  white-space: nowrap;
}

.p-av {
  background: var(--st-available-bg);
  color: var(--st-available-fg);
}

.p-res {
  background: var(--st-reserved-bg);
  color: var(--st-reserved-fg);
}

.p-sold {
  background: var(--st-sold-bg);
  color: var(--st-sold-fg);
}

.p-ex {
  background: var(--st-exclusive-bg);
  color: var(--st-exclusive-fg);
}

.p-att {
  background: var(--st-attention-bg);
  color: var(--st-attention-fg);
}

.p-new {
  background: var(--st-new-bg);
  color: var(--st-new-fg);
}

.p-plain {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

/* ---- Forms: field, label, hint, error, input, select, checkbox, switch ------------------- */

.fld {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

/* A label is one line tall whatever it carries, so inputs side by side start at the same
   height. The badge is shorter than the label line for the same reason. */
.lb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-body);
  color: var(--text-strong);
}

.opt {
  font-weight: var(--fw-regular);
  color: var(--text-muted);
}

.hint {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.err {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--danger);
}

.in {
  width: 100%;
  height: var(--control-h-field);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-strong);
  font-family: var(--font-body);
  font-size: var(--fs-base);
}

.in::placeholder {
  color: var(--text-placeholder);
}

textarea.in {
  height: auto;
  min-height: 7rem;
  padding: var(--sp-3) var(--sp-4);
  line-height: var(--lh-body);
  resize: vertical;
}

.in:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-fg);
  cursor: not-allowed;
}

.in[readonly] {
  background: var(--bg);
  color: var(--text);
}

.in[aria-invalid="true"] {
  border-color: var(--danger-strong);
  box-shadow: 0 0 0 1px var(--danger-strong);
}

.in-wrap {
  position: relative;
}

.in-wrap > svg {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  stroke: var(--text-muted);
  pointer-events: none;
}

.in-wrap > .in {
  padding-left: var(--sp-7);
}

.lock {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-2);
  line-height: 1;
  border-radius: var(--r-pill);
  background: var(--primary-tint);
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: var(--control-h);
  padding: var(--sp-2) 0;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: var(--sp-0) 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.check-text {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  color: var(--text-strong);
}

/* The switch is the checkbox itself, drawn as a track and knob. */
.switch input {
  appearance: none;
  position: relative;
  width: 2.75rem;
  height: 1.5rem;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  transition: background-color var(--dur-base) var(--ease);
}

.switch input::after {
  content: "";
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: var(--surface);
  transition: transform var(--dur-base) var(--ease);
}

.switch input:checked {
  background: var(--primary);
}

.switch input:checked::after {
  transform: translateX(1.25rem);
}

.switch input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Surfaces: box (section), card (listing), split (commission line) -------------------- */

.box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition:
    box-shadow var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
}

.card:hover {
  color: var(--text);
  border-color: var(--primary);
  box-shadow: var(--shadow-lift);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
}

.ph {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  aspect-ratio: 16 / 10;
  background: var(--placeholder-fill);
  color: var(--placeholder-text);
  font-size: var(--fs-sm);
}

.ph img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tags {
  position: absolute;
  left: var(--sp-3);
  top: var(--sp-3);
  z-index: 1;
  display: flex;
  gap: var(--sp-1);
}

.price {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  line-height: var(--lh-tight);
  color: var(--text-strong);
}

.ttl {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  color: var(--text-strong);
}

.facts {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.split {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-soft);
  font-size: var(--fs-sm);
  color: var(--text-strong);
}

.split strong {
  color: var(--primary);
  font-size: var(--fs-md);
}

.card-foot {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ---- Page header ------------------------------------------------------------------------ */

.pagehead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sp-3);
}

.pagehead-text {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--control-h);
  font-weight: var(--fw-semibold);
  text-decoration: none;
}

.back:hover {
  text-decoration: underline;
}

/* ---- Table; below 640px each row becomes a card ------------------------------------------ */

.tablewrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow-x: auto;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}

.tbl th {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
  white-space: nowrap;
}

.tbl td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-strong);
  vertical-align: middle;
}

.tbl tbody tr:last-child td {
  border-bottom: 0;
}

.tbl .cell-hint {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .tablewrap {
    background: none;
    border: 0;
    overflow: visible;
  }

  .tbl,
  .tbl tbody,
  .tbl tr,
  .tbl td {
    display: block;
    width: 100%;
  }

  .tbl thead {
    display: none;
  }

  .tbl tr {
    margin-bottom: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }

  .tbl td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-4);
    padding: var(--sp-2) 0;
    text-align: right;
  }

  .tbl td::before {
    content: attr(data-label);
    flex: none;
    text-align: left;
    font-size: var(--fs-sm);
    color: var(--text-muted);
  }

  .tbl td:first-child {
    display: block;
    text-align: left;
    font-weight: var(--fw-semibold);
  }

  .tbl td:first-child::before {
    content: none;
  }

  .tbl tbody tr:last-child td {
    border-bottom: 1px solid var(--line-soft);
  }

  .tbl td:last-child,
  .tbl tbody tr:last-child td:last-child {
    border-bottom: 0;
  }
}

/* ---- Commission box: always dark, always the same shape -------------------------------- */

.cbox {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--dark);
  color: var(--on-dark);
}

.cbox-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--accent-on-dark);
}

.cbox-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-1) var(--sp-3);
}

.cbox-rate {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
}

.cbox-amount {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--on-dark-strong);
}

.cbox-note {
  font-size: var(--fs-sm);
}

/* ---- Warning: inline text, and the banner that asks for a decision ----------------------- */

.warn {
  color: var(--danger);
  font-weight: var(--fw-semibold);
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3) var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--warn-line);
  border-radius: var(--r-lg);
  background: var(--warn-tint);
  color: var(--text-strong);
}

.banner > svg {
  flex: none;
  stroke: var(--warn-fg);
}

.banner-text {
  flex: 1 1 20rem;
  min-width: 0;
}

/* ---- Choices: segmented control, radio cards, tab strip ---------------------------------- */

.seg {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
}

.seg button {
  flex: 1;
  height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 0;
  background: var(--surface);
  color: var(--text-strong);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

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

.seg button[aria-pressed="true"],
.seg button[aria-pressed="true"]:hover {
  background: var(--primary);
  color: var(--on-primary);
}

.seg button:focus-visible {
  outline-offset: calc(-1 * var(--ring-w));
}

/* Main's List/Map switch: shown on a phone only, where the map has no room beside the list. */
.seg-phone {
  display: none;
}

@media (max-width: 760px) {
  .seg-phone {
    display: flex;
  }
}

.group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.group legend {
  margin-bottom: var(--sp-2);
  padding: 0;
}

.radio {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
}

.radio input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: var(--sp-0) 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.radio-text {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.radio-text strong {
  color: var(--text-strong);
}

/* The chosen card gets a second pixel of border drawn as a ring, so nothing moves. */
.radio:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  background: var(--surface-soft);
}

.radio:has(input:focus-visible) {
  outline: var(--ring-w) solid var(--focus);
  outline-offset: var(--ring-offset);
}

.radio:has(input:disabled) {
  border-color: var(--line);
  color: var(--disabled-fg);
  cursor: not-allowed;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-strong);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}

.tab:hover {
  background: var(--bg);
}

.tab[aria-selected="true"],
.tab[aria-selected="true"]:hover {
  border-color: var(--dark);
  background: var(--dark);
  color: var(--on-dark-strong);
  font-weight: var(--fw-semibold);
}

.tab-n {
  color: var(--text-muted);
  font-weight: var(--fw-regular);
}

.tab[aria-selected="true"] .tab-n {
  color: var(--on-dark);
}

/* ---- States: empty, error, stub panel; inline error; skeleton; toast; dialog -------------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: center;
}

.state h1,
.state h2 {
  font-size: var(--fs-xl);
}

.state p {
  color: var(--text);
}

.state > .icon {
  stroke: var(--primary);
}

.state-error > .icon {
  stroke: var(--danger);
}

.state-stub > .icon {
  stroke: var(--accent-text);
}

.state-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-weight: var(--fw-semibold);
}

.state-ref {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.inline-err {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--danger-tint);
  border: 1px solid var(--danger-line);
  border-radius: var(--r-md);
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.inline-err svg {
  flex: none;
  margin-top: var(--sp-0);
}

.skel {
  background: linear-gradient(90deg, var(--skel-base), var(--skel-shine), var(--skel-base));
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: shimmer 1.4s var(--ease) infinite;
}

.skel-line {
  height: 1rem;
}

.skel-line-short {
  width: 60%;
}

.skel-title {
  height: 1.5rem;
  width: 45%;
}

.skel-photo {
  aspect-ratio: 16 / 10;
  border-radius: 0;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -100% 0;
  }
}

.toasts {
  position: fixed;
  right: max(var(--sp-4), env(safe-area-inset-right, 0px));
  bottom: max(var(--sp-4), env(safe-area-inset-bottom, 0px));
  left: max(var(--sp-4), env(safe-area-inset-left, 0px));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: min(var(--toast-w), 100%);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  background: var(--dark);
  color: var(--on-dark-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  font-size: var(--fs-sm);
  pointer-events: auto;
}

.toast-msg {
  flex: 1;
  min-width: 0;
}

.toast svg {
  flex: none;
}

.toast-ok svg {
  stroke: var(--accent-on-dark);
}

.toast-bad {
  background: var(--danger);
}

.toast-x {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: inherit;
  cursor: pointer;
}

.toast-x:hover {
  background: var(--on-dark-wash);
}

.toast :focus-visible {
  outline-color: var(--focus-on-dark);
}

.dlg {
  width: min(var(--dialog-w), calc(100% - 2 * var(--sp-4)));
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dialog);
}

.dlg::backdrop {
  background: var(--scrim);
}

.dlg-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: 0;
  padding: var(--sp-5);
}

.dlg-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding-top: var(--sp-2);
}

/* A dialog drawn in the page flow, for the kit only. */
.dlg-static {
  position: static;
  margin: 0;
}

/* ---- Footer ------------------------------------------------------------------------------- */

.site-foot {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.site-foot-in {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-4) max(var(--gutter), env(safe-area-inset-right, 0px)) var(--sp-4)
    max(var(--gutter), env(safe-area-inset-left, 0px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* The language switch: two buttons posting /my/language; the current language is marked. */
.lang-switch {
  display: inline-flex;
  gap: var(--sp-1);
}

.lang-switch button {
  min-width: var(--control-h);
  min-height: var(--control-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-strong);
  font: inherit;
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary);
}

.site-foot-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-4);
}

.site-foot-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h);
}
