/* Taka — A · Salvia + coral (docs/branding.md). Every colour, font and size is a token here;
   the rules below never use a raw hex value or font size. Light/dark follows the OS. */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("/fonts/archivo-latin.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-600-latin.woff2") format("woff2");
}

:root {
  /* Colour (branding §2) */
  --bg: #F2F2F2;
  --card: #FFFFFF;
  --ink: #2B2B2B;
  --muted: #5E5E5E;
  --line: #DADADA;
  --soft: #EBEBEB;
  --primary: #B7CCB0;          /* salvia: the one main action, "Pagó" */
  --on-primary: #1F2A1C;
  --secondary: #D7897F;        /* coral: people and progress */
  --on-secondary: #2B2B2B;
  --secondary-tint: #F7E6E3;   /* coral claro: row actions, "Ya pagué", Pagado card */
  --on-secondary-tint: #2B2B2B;
  --error: #B42318;

  /* Type (branding §3): five sizes, two widths */
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --fs-amount: clamp(44px, 14vw, 56px);
  --fs-amount-xl: clamp(48px, 16vw, 64px); /* payer page: the money is the biggest thing */
  --fs-title: 26px;
  --fs-lead: 18px;
  --fs-body: 16px;
  --fs-small: 14px;
  --wide: 112.5%;              /* Archivo SemiExpanded: amounts */
  --wider: 125%;               /* Archivo Expanded: wordmark */

  /* Shape and space (branding §4) */
  --radius: 18px;
  --radius-sm: 14px;
  --gutter: 16px;
  --pad: 18px;
  --button-h: 56px;
  --touch: 44px;
  --row-action-w: 120px;
  --bar-h: 96px;               /* space kept free under content for the bottom bar */

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --card: #1E1E1E;
    --ink: #EDEDED;
    --muted: #A8A8A8;
    --line: #333333;
    --soft: #2A2A2A;
    --on-primary: #121212;
    --error: #FF8A80;
  }
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body)/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }
p { margin: 0; }
h1, h2 { margin: 0; }
button, input { font: inherit; color: inherit; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }
.strong { font-weight: 600; }
.center { text-align: center; }
.error { color: var(--error); font-weight: 600; }
.mono, .alias { font-family: var(--mono); font-weight: 600; }

.title { font-size: var(--fs-title); font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; }
.amount { font-size: var(--fs-amount); line-height: 1; font-weight: 800; font-stretch: var(--wide); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.wordmark { font-size: var(--fs-title); font-weight: 900; font-stretch: var(--wider); letter-spacing: -0.05em; line-height: 1; text-decoration: none; }

.wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(var(--bar-h) + env(safe-area-inset-bottom));
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.gap-top { margin-top: 12px; }
.gap-top-sm { margin-top: 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: var(--pad); }

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  max-width: 34rem;
  margin: 0 auto;
  padding: 16px var(--gutter) 8px;
  min-height: 68px;
}
.top.back { justify-content: flex-start; padding-left: 8px; }
.top h1 { font-size: var(--fs-lead); font-weight: 700; }

.icon-btn {
  width: var(--touch);
  height: var(--touch);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn.boxed { border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }

.avatar {
  width: var(--touch);
  height: var(--touch);
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--fs-lead);
  text-decoration: none;
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--button-h);
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  font-size: var(--fs-lead);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: .6; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.soft { background: var(--secondary-tint); color: var(--on-secondary-tint); }
.btn.outline { background: transparent; color: var(--ink); border: 2px solid var(--ink); font-size: var(--fs-body); }
.btn.dashed { background: transparent; color: var(--ink); border: 1.5px dashed var(--muted); border-radius: var(--radius-sm); min-height: 48px; font-size: var(--fs-body); font-weight: 600; }

.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, .pick:focus-visible, .row-tap:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent);
  outline-offset: 2px;
}

/* Main action sits in a bar at the bottom (one salvia button per screen). */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px var(--gutter) calc(26px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.bottom-bar > * { max-width: calc(34rem - 2 * var(--gutter)); margin: 0 auto; }
.bottom-bar[hidden] { display: none; }

/* Row action / status badge (120 × 44) */
.pill {
  width: var(--row-action-w);
  height: var(--touch);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  font-size: var(--fs-small);
  font-weight: 700;
  text-decoration: none;
}
button.pill { cursor: pointer; padding: 0; }
.pill.action { background: var(--secondary-tint); color: var(--on-secondary-tint); }
.pill.paid { background: var(--primary); color: var(--on-primary); }
.pill.note { color: var(--muted); font-weight: 400; }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: var(--fs-small); font-weight: 600; }
.wa-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px var(--gutter); }
.field input {
  height: 54px;
  padding: 0 var(--gutter);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: var(--fs-body);
  outline: none;
}
.field input:focus { border: 2px solid var(--ink); }
.field input.mono { font-size: var(--fs-body); }

/* Segmented choice */
.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.segmented label {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.segmented label:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); }

/* ---------- Progress (one segment per friend) ---------- */

.progress { display: flex; gap: 4px; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.progress span.on { background: var(--secondary); }

/* ---------- Inicio ---------- */

.owed { display: flex; flex-direction: column; gap: 4px; padding: 20px 4px 24px; }
.section-label { font-size: var(--fs-small); font-weight: 600; color: var(--muted); margin: 0 4px 10px; }

.request-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.request-card { display: flex; flex-direction: column; gap: 12px; text-decoration: none; }
.request-card.closed { opacity: .6; }
.request-card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: var(--fs-lead); font-weight: 700; }
.request-card .head .num { white-space: nowrap; }

.empty { text-align: center; padding: 40px 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }

/* ---------- Nuevo pedido ---------- */

.amount-card { display: flex; flex-direction: column; gap: 6px; padding-bottom: 14px; }
.amount-input-row { display: flex; align-items: baseline; gap: 6px; }
.amount-input-row .currency { font-size: var(--fs-amount); font-weight: 800; font-stretch: var(--wide); color: var(--muted); line-height: 1; }
.amount-input-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  outline: none;
  font-size: var(--fs-amount);
  font-weight: 800;
  font-stretch: var(--wide);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.amount-card hr { border: 0; height: 1px; background: var(--line); margin: 6px 0 4px; }
.amount-card .concept-input { border: 0; background: transparent; padding: 6px 0; font-size: var(--fs-lead); font-weight: 600; outline: none; }
input::placeholder { color: var(--muted); }

.list-head { display: flex; justify-content: space-between; align-items: baseline; padding: 20px 4px 6px; }
.list-card { list-style: none; margin: 0; padding: 0 14px; background: var(--card); border-radius: var(--radius); }
.list-card > li + li { border-top: 1px solid var(--line); }

.person { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto var(--touch); align-items: center; gap: 0 12px; padding: 8px 0; }
.person .avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-small);
  font-weight: 800;
}
.person.me .avatar-sm { background: var(--secondary); color: var(--on-secondary); }
.person .fields { display: flex; flex-direction: column; min-width: 0; }
.person input { border: 0; background: transparent; padding: 4px 0; outline: none; min-width: 0; }
.person .name { font-size: var(--fs-body); font-weight: 600; }
.person .phone { font-size: var(--fs-small); color: var(--muted); }
.person .share { font-weight: 600; color: var(--muted); white-space: nowrap; }
.person .amount-input { width: 6.5em; text-align: right; font-weight: 600; border-bottom: 1.5px solid var(--line); }
.person.me { grid-template-columns: 32px minmax(0, 1fr) auto var(--touch); min-height: 50px; }

.link-btn { border: 0; background: none; padding: 8px 4px; color: var(--ink); font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ---------- Detalle ---------- */

.summary-card { padding: 0; }
.summary-card .top-part { padding: var(--pad) var(--pad) 16px; display: flex; flex-direction: column; gap: 4px; }
.summary-card .bottom-part { padding: 14px var(--pad) 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.summary-card .facts { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.participants { margin-top: 14px; }
.participant { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 0; }
.participant .row-tap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.participant .row-tap:disabled { cursor: default; }
.participant .name { font-weight: 700; }

/* ---------- Payer ---------- */

.payer .wrap { padding-top: 0; }
.payer .wrap:has(.pay.is-done) { padding-bottom: calc(2 * var(--bar-h) + env(safe-area-inset-bottom)); }
.pay-top { padding: 18px 4px 0; }
.pay-head { display: flex; flex-direction: column; gap: 6px; padding: 26px 4px 20px; }
.amount-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.amount.xl { font-size: var(--fs-amount-xl); }
.alias-card { display: flex; flex-direction: column; gap: 2px; padding: 14px var(--gutter); }
.alias { font-size: var(--fs-lead); word-break: break-all; }
.alias.selectable { user-select: all; -webkit-user-select: all; outline: 2px dashed var(--ink); }
.hint { color: var(--muted); font-size: var(--fs-small); padding: 4px; }

.done-card { background: var(--secondary-tint); color: var(--on-secondary-tint); display: flex; flex-direction: column; gap: 14px; padding: 24px 20px; border-radius: var(--radius); }
.check-dot { width: 52px; height: 52px; border-radius: 999px; background: var(--secondary); color: var(--on-secondary); display: flex; align-items: center; justify-content: center; }

/* One of three states: pay (default) · done (payer tapped "Ya pagué") · cash (requester marked it) */
.pay .state { display: none; }
.pay:not(.is-done):not(.is-cash) .state-pay,
.pay.is-done .state-done,
.pay.is-cash .state-cash { display: block; }

/* ¿Quién sos? */
.payer-header {
  margin: 0 calc(-1 * var(--gutter));
  padding: 22px 20px 26px;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.payer-header .wordmark { margin-bottom: 10px; }
.payer-header .who, .payer-header .meta { font-weight: 500; }
.payer-header .concept { font-size: var(--fs-title); line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.page-title { margin: 24px 4px 14px; }

.pick-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pick {
  min-height: 60px;
  padding: 0 14px 0 18px;
  border-radius: 16px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-lead);
  font-weight: 700;
  text-decoration: none;
}
.pick.paid { background: transparent; border: 1.5px solid var(--line); color: var(--muted); font-weight: 600; }
.pick-end { display: inline-flex; align-items: center; gap: 6px; }

.foot { text-align: center; color: var(--muted); font-size: var(--fs-small); padding: 32px var(--gutter) 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 24px + env(safe-area-inset-bottom));
  z-index: 10;
  transform: translate(-50%, 1rem);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: var(--fs-small);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  max-width: calc(100% - 2 * var(--gutter));
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.visually-hidden {
  position: fixed; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0;
  opacity: 0; overflow: hidden; clip-path: inset(50%); font-size: 16px;
}

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Payer page: requester verified with "Ingresar con WhatsApp" (PRD FR-1.5) */
.verified { color: var(--on-primary); background: var(--primary); align-self: flex-start; padding: 2px 10px; border-radius: 999px; font-weight: 600; }
