/*
 * Same visual language as the iOS app (C22 «Síntesis», C20 parity): warm paper grey and ink, IBM Plex Sans
 * and Mono (SIL OFL 1.1, self-hosted), hairlines instead of cards, and one signal orange that only fills the
 * main action, always with a dark label. Colour never encodes a state.
 */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-Medium.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-Bold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/IBMPlexMono-SemiBold.woff2") format("woff2"); }

:root {
  --canvas: #f6f5f2;
  --card: #f6f5f2;
  --word-surface: #f6f5f2;
  --ink: #171717;
  --body: #171717;
  --word-ink: #171717;
  --secondary: #464542;
  --word-secondary: #464542;
  --primary: #ff8a3d;
  --primary-pressed: #ff9a55;
  --on-primary: #171717;
  --line: #7a7872;
  --control-line: #7a7872;
  --hairline: #d8d6d0;
  --pressed: #e8e6e1;
  --error: #9b2c1f;
  --on-error: #ffffff;
  --warn-soft: #efebe4;
  --font-text: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #151515;
    --card: #151515;
    --word-surface: #151515;
    --ink: #ecebe7;
    --body: #ecebe7;
    --word-ink: #ecebe7;
    --secondary: #b5b3ad;
    --word-secondary: #b5b3ad;
    --primary: #ff8a3d;
    --primary-pressed: #ff9a55;
    --on-primary: #171717;
    --line: #8c8a84;
    --control-line: #8c8a84;
    --hairline: #33322f;
    --pressed: #262625;
    --error: #ffb4a8;
    --on-error: #171717;
    --warn-soft: #24211e;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--body);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.has-tabbar { padding-bottom: calc(7rem + env(safe-area-inset-bottom)); }
a { color: var(--ink); }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--card); padding: 0.75rem 1rem; border-radius: 12px; z-index: 10; }
.skip:focus { left: 1rem; }

/* Inline navigation bar, like the app's: centered title, optional leading and trailing actions. */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--canvas);
  padding: env(safe-area-inset-top) 0 0;
}
.topbar-inner {
  max-width: 660px; margin: 0 auto; min-height: 3.5rem; padding: 0.5rem 1rem;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.5rem;
}
.topbar-title {
  margin: 0; grid-column: 2; text-align: center;
  font-size: 1.0625rem; font-weight: 600; color: var(--ink);
  overflow-wrap: anywhere;
}
.topbar-leading { grid-column: 1; justify-self: start; }
.topbar-trailing { grid-column: 3; justify-self: end; }
.bar-button, .topbar details > summary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-width: 2.75rem; min-height: 2.75rem; padding: 0 1rem;
  border-radius: 12px; border: 1px solid var(--control-line); background: var(--card);
  color: var(--ink); font: inherit; font-size: 1.0625rem; text-decoration: none; cursor: pointer;
}
.bar-button.icon-only, .topbar details > summary.icon-only { padding: 0; width: 2.75rem; }
.topbar details { position: relative; }
.topbar details > summary { list-style: none; }
.topbar details > summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); width: min(20rem, calc(100vw - 2rem));
  background: var(--card); border-radius: 12px; border: 1px solid var(--control-line);
  padding: 1rem; display: grid; gap: 0.75rem;
}

.screen { max-width: 660px; margin: 0 auto; padding: 0.5rem 1.25rem 2rem; display: grid; gap: 1.5rem; }

/* Type */
.display {
  margin: 0; font-weight: 600; color: var(--ink); letter-spacing: -0.01em;
  font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.125rem); line-height: 1.15; text-wrap: balance;
}
.display-xl { font-size: clamp(2.125rem, 1.7rem + 2vw, 2.75rem); }
.title { margin: 0; font-size: 1.375rem; font-weight: 600; line-height: 1.25; color: var(--ink); }
.headline { margin: 0; font-size: 1.0625rem; font-weight: 600; color: var(--ink); }
.lead { color: var(--secondary); }
.secondary { color: var(--secondary); }
.footnote { font-size: 0.8125rem; color: var(--secondary); }
.intro { display: grid; gap: 0.625rem; }
.caption { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--secondary); margin-top: 0.625rem; }
.caption svg { width: 1.1rem; height: 1.1rem; flex: none; }

/* Surfaces */
/* A block of the screen, set off by a hairline above it instead of a card. */
.panel {
  border-top: 1px solid var(--hairline); padding: 1rem 0 0;
  display: grid; gap: 1rem;
}
.panel > .divider, .rows > .divider { height: 1px; background: var(--hairline); margin: 0; border: 0; }
.notice {
  display: flex; gap: 0.75rem; align-items: flex-start;
  border: 1px solid var(--control-line); border-radius: 12px; padding: 1rem;
}
.notice svg { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; color: var(--ink); }
.notice.error { background: var(--warn-soft); }
.label-row { display: flex; gap: 0.6rem; align-items: center; }
.label-row svg { flex: none; width: 1.35rem; height: 1.35rem; }

/* The four shared words, exactly as in the app. */
.word-card { border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.words { list-style: none; margin: 0; padding: 0; color: var(--word-ink); counter-reset: word; }
.words li {
  font-family: var(--font-text);
  font-weight: 600;
  font-size: clamp(2rem, 1.6rem + 2.2vw, 2.5rem);
  line-height: 1.15;
  min-height: 4rem; display: flex; align-items: baseline; gap: 1rem;
  padding: 0.75rem 0;
  overflow-wrap: anywhere;
  counter-increment: word;
}
/* Position only helps the eye; the empty alternative text keeps screen readers on the words alone. */
.words li::before {
  content: counter(word); content: counter(word) / "";
  font-family: var(--font-mono); font-weight: 400; font-size: 1.0625rem; color: var(--word-secondary);
  min-width: 0.75rem;
}
.words li + li { border-top: 1px solid var(--hairline); }
.word-meta { font-size: 0.8125rem; color: var(--word-secondary); margin-top: 0.875rem; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; min-height: 3.5rem; padding: 0.5rem 1.25rem;
  border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-size: 1.0625rem; font-weight: 600; text-align: center; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 1.3rem; height: 1.3rem; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-pressed); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--control-line); }
.btn-secondary:active { background: var(--pressed); }
.btn-plain { background: transparent; color: var(--ink); min-height: 2.75rem; text-decoration: underline; text-underline-offset: 0.2em; }
.btn-destructive { background: transparent; color: var(--error); min-height: 2.75rem; }
.btn-destructive-fill { background: var(--error); color: var(--on-error); }
.btn:disabled { background: transparent; color: var(--secondary); border-color: var(--hairline); cursor: default; }
.stack { display: grid; gap: 0.75rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* Two-step confirmations: the first tap opens the question, the second does it (like the app's dialogs). */
details.confirm > summary { list-style: none; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { display: none; }
.confirm-panel { display: grid; gap: 0.875rem; border: 1px solid var(--control-line); border-radius: 12px; padding: 1.25rem; text-align: center; }
.confirm-panel .headline { font-size: 1.125rem; }
details.confirm .cancel { justify-self: center; }

/* Check-in rows */
.rows { display: grid; gap: 0.75rem; }
.row { display: flex; align-items: center; gap: 0.875rem; min-height: 3.25rem; }
.row-icon { flex: none; width: 2rem; height: 2rem; display: grid; place-items: center; }
.row-icon svg { width: 1.75rem; height: 1.75rem; }
.row-icon.ok { color: var(--ink); }
.row-icon.waiting { color: var(--secondary); }
.row-text { display: grid; gap: 0.15rem; }
.row-title { font-weight: 600; color: var(--ink); }
.status.none, .row-sub { color: var(--secondary); }
.row-sub { font-size: 0.875rem; }

/* Grouped lists for the Family tab, like an inset grouped list */
.group-section { display: grid; gap: 0.5rem; }
.group-header { margin: 0; font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 400; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.group-footer { margin: 0; font-size: 0.8125rem; color: var(--secondary); }
.group-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.group-list > li { padding: 0.875rem 0; display: grid; gap: 0.75rem; }
.group-list:has(.swipe-row) { overflow: hidden; }
.group-list > li + li { border-top: 1px solid var(--hairline); }
.member { display: flex; align-items: center; gap: 0.875rem; min-height: 2.75rem; }
.member svg { flex: none; width: 1.5rem; height: 1.5rem; color: var(--secondary); }

/* Swipe left to reveal «Remove», like the app's list rows. Plain scroll-snap, no script; the action stays focusable. */
.swipe-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: none; margin: 0; border-radius: 0;
}
.swipe-track::-webkit-scrollbar { display: none; }
.swipe-main { flex: 0 0 100%; scroll-snap-align: start; padding: 0; box-sizing: border-box; }
.swipe-action {
  flex: 0 0 auto; scroll-snap-align: end; display: flex; align-items: center; justify-content: center;
  min-width: 7.5rem; min-height: 2.75rem; padding: 0 1rem; background: var(--error); color: var(--on-error);
  font-weight: 600; text-decoration: none;
}
.swipe-action:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }
.code { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 600; letter-spacing: 0.04em; }
.code-large { font-family: var(--font-mono); font-size: clamp(2.25rem, 2rem + 2vw, 2.75rem); font-weight: 600; letter-spacing: 0.15em; color: var(--ink); }
.group-list details > summary { list-style: none; cursor: pointer; color: var(--ink); font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
.group-list details > summary::-webkit-details-marker { display: none; }
.option-list { display: grid; gap: 0.5rem; padding-bottom: 0.25rem; }
.list-button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 0.75rem; width: 100%; min-height: 2.75rem; color: var(--ink); font-weight: 600; cursor: pointer; }
.list-button.destructive { color: var(--error); }
.list-button svg { width: 1.4rem; height: 1.4rem; }

/* Fields */
.field { display: grid; gap: 0.5rem; }
.field label { font-weight: 600; color: var(--ink); }
.field input, .field textarea {
  width: 100%; min-height: 3.5rem; padding: 0.875rem 1rem;
  font: inherit; font-size: 1.25rem; color: var(--ink);
  background: transparent; border: 1px solid var(--control-line); border-radius: 12px;
}
.field textarea { font-size: 1.0625rem; min-height: 6rem; resize: vertical; }
.link-text {
  width: 100%; border: 0; background: transparent; color: var(--secondary); font: inherit;
  font-size: 0.8125rem; resize: none; padding: 0; overflow-wrap: anywhere;
}
.check-row { display: flex; gap: 0.75rem; align-items: flex-start; min-height: 2.75rem; }
.check-row input { width: 1.5rem; height: 1.5rem; margin: 0.15rem 0 0; accent-color: var(--ink); flex: none; }

/* Example map for the preview: an illustration, not a real place. */
.map-sketch { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--hairline); background: #ebe9e4; }
.map-sketch svg { display: block; width: 100%; height: auto; }
.place-head { display: grid; gap: 0.35rem; }

/* Floating four-tab bar, like the app's */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(0.75rem + env(safe-area-inset-bottom)); z-index: 6;
  width: min(calc(100% - 1.5rem), 26rem);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem;
  padding: 0.375rem; border-radius: 16px;
  background: var(--card); border: 1px solid var(--control-line);
}
.tab {
  display: grid; justify-items: center; gap: 0.1rem; padding: 0.4rem 0.25rem 0.35rem;
  border-radius: 12px; color: var(--secondary); text-decoration: none; font-size: 0.75rem; font-weight: 500;
  min-height: 3.25rem; position: relative;
}
.tab svg { width: 1.6rem; height: 1.6rem; }
/* Long labels («Palabras clave», «Schlüsselwörter») wrap centred instead of overflowing the pill. */
.tab > span:last-child { text-align: center; line-height: 1.15; hyphens: auto; }
.tab[aria-current="page"] { background: var(--pressed); color: var(--ink); font-weight: 600; }
.tab-icon { position: relative; display: inline-flex; }
.tab-dot { position: absolute; top: -0.1rem; right: -0.35rem; min-width: 0.65rem; height: 0.65rem; border-radius: 999px; background: #d33b2c; }
.tab-badge {
  position: absolute; top: -0.35rem; right: -0.7rem; min-width: 1.15rem; height: 1.15rem; padding: 0 0.3rem;
  border-radius: 999px; background: #d33b2c; color: #fff; font-size: 0.6875rem; font-weight: 700; display: grid; place-items: center;
}

/* Platform-specific offers. The server guesses; app.js corrects iPadOS and installed web apps. */
.platform-ios .only-installable, .platform-android .only-ios, .platform-other .only-ios { display: none; }
.is-standalone .install-offer { display: none; }
.install-steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.35rem; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .tab, .bar-button { transition: background-color 120ms ease-out, color 120ms ease-out; }
}
@media (min-width: 720px) {
  .screen { padding-top: 1rem; }
}
