/* Suéltalo — estilos.
   Idea: un único bloque grande con lo que toca AHORA; todo lo demás, en voz baja y ordenado en un hilo.
   Cada área de tu vida tiene su color (se mantiene igual en toda la app). */

@font-face {
  font-family: "Bricolage";
  src: url(fonts/bricolage-latin-ext.woff2) format("woff2");
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage";
  src: url(fonts/bricolage-latin.woff2) format("woff2");
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #E9EEEE;
  --paper: #F7F9F8;
  --ink: #14202A;
  --ink2: #4A5B67;
  --line: #CBD6D8;
  --late: #B3261E;
  --backdrop: rgba(10, 16, 20, .46);

  --amber: #E0A21E;    --on-amber: #14202A;
  --orange: #DD5F2E;   --on-orange: #14202A;
  --red: #C4342A;      --on-red: #FFFFFF;
  --pink: #C93D78;     --on-pink: #FFFFFF;
  --violet: #7448BE;   --on-violet: #FFFFFF;
  --blue: #2F6EB8;     --on-blue: #FFFFFF;
  --teal: #12787E;     --on-teal: #FFFFFF;
  --green: #268350;    --on-green: #FFFFFF;
  --brown: #8B5636;    --on-brown: #FFFFFF;
  --gray: #5E7280;     --on-gray: #FFFFFF;

  --safe-t: env(safe-area-inset-top, 0px);
  --edge-l: max(14px, env(safe-area-inset-left, 0px));
  --edge-r: max(14px, env(safe-area-inset-right, 0px));
  --safe-b: env(safe-area-inset-bottom, 0px);
  --dock-h: 190px;
  color-scheme: light dark;   /* sin elección manual, sigue al dispositivo */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121A20; --paper: #1B252D; --ink: #E8EEF1; --ink2: #9DADB8; --line: #2D3A44;
    --late: #FF8F85; --backdrop: rgba(0, 0, 0, .6);
    --red: #EE6B60;    --on-red: #14202A;
    --pink: #E26A9C;   --on-pink: #14202A;
    --violet: #A98BE3; --on-violet: #14202A;
    --blue: #5B9BE0;   --on-blue: #14202A;
    --teal: #3BB0B7;   --on-teal: #14202A;
    --green: #44B67A;  --on-green: #14202A;
    --brown: #C99169;  --on-brown: #14202A;
    --gray: #8EA3B1;   --on-gray: #14202A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121A20; --paper: #1B252D; --ink: #E8EEF1; --ink2: #9DADB8; --line: #2D3A44;
  --late: #FF8F85; --backdrop: rgba(0, 0, 0, .6);
  --red: #EE6B60;    --on-red: #14202A;
  --pink: #E26A9C;   --on-pink: #14202A;
  --violet: #A98BE3; --on-violet: #14202A;
  --blue: #5B9BE0;   --on-blue: #14202A;
  --teal: #3BB0B7;   --on-teal: #14202A;
  --green: #44B67A;  --on-green: #14202A;
  --brown: #C99169;  --on-brown: #14202A;
  --gray: #8EA3B1;   --on-gray: #14202A;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

.a-amber   { --c: var(--amber); --on: var(--on-amber); }
.a-orange  { --c: var(--orange); --on: var(--on-orange); }
.a-red     { --c: var(--red); --on: var(--on-red); }
.a-pink    { --c: var(--pink); --on: var(--on-pink); }
.a-violet  { --c: var(--violet); --on: var(--on-violet); }
.a-blue    { --c: var(--blue); --on: var(--on-blue); }
.a-teal    { --c: var(--teal); --on: var(--on-teal); }
.a-green   { --c: var(--green); --on: var(--on-green); }
.a-brown   { --c: var(--brown); --on: var(--on-brown); }
.a-gray    { --c: var(--gray); --on: var(--on-gray); }

* { 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 17px/1.4 "Bricolage", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
body.lock { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ───── Arranque y acceso ───── */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.boot img { border-radius: 24px; }
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--safe-t) + 24px) max(24px, env(safe-area-inset-right, 0px)) calc(var(--safe-b) + 24px) max(24px, env(safe-area-inset-left, 0px)); }
.auth-card { width: min(380px, 100%); display: grid; gap: 18px; text-align: center; justify-items: center; }
.auth-logo { width: 88px; height: 88px; border-radius: 22px; }
.auth-title { font-size: 34px; line-height: 1.05; font-weight: 760; letter-spacing: -.02em; }
.auth-sub { color: var(--ink2); }
.auth-msg { min-height: 1.4em; color: var(--late); font-weight: 600; }
.auth-form { display: grid; gap: 12px; width: 100%; }
.dots { display: flex; justify-content: center; gap: 14px; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.dot.on { background: var(--ink); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; justify-content: center; }
.pad-key { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--paper); font-size: 30px; font-weight: 600; display: grid; place-items: center; }
.pad-key:active { background: var(--line); }
.pad-key.is-blank { visibility: hidden; }

/* ───── Cabecera ───── */
.app { max-width: 680px; margin: 0 auto; min-height: 100dvh; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: calc(var(--safe-t) + 18px) 4px 6px; }
.date-day { font-size: 40px; line-height: 1; font-weight: 760; letter-spacing: -.025em; text-transform: capitalize; }
.date-rest { margin-top: 6px; color: var(--ink2); font-size: 17px; }
.icon-btn { width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--paper); display: grid; place-items: center; flex: none; }
.daybar { display: flex; gap: 4px; padding: 12px 4px 0; min-height: 18px; }
.daybar i { flex: 1; height: 6px; border-radius: 3px; background: var(--c); opacity: .26; min-width: 4px; }
.daybar i.is-done { opacity: 1; }

.view { padding: 14px 4px calc(var(--dock-h) + 28px); }
.banner { margin: 14px 4px 0; padding: 14px 16px; border-radius: 18px; background: var(--paper); display: grid; gap: 10px; }
.banner p { font-weight: 600; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ───── Botones ───── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border: 0; border-radius: 999px; font-weight: 700; text-align: center; }
.btn-solid { background: var(--ink); color: var(--bg); }
.btn-line { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.btn-text { background: transparent; min-height: 44px; padding: 0 10px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { background: transparent; color: var(--late); box-shadow: inset 0 0 0 2px var(--late); }
.btn-danger.is-armed { background: var(--late); color: var(--bg); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }

/* ───── El bloque de AHORA ───── */
.now { display: grid; gap: 10px; margin: 0 0 26px; padding: 22px 22px 20px; border-radius: 30px; background: var(--c); color: var(--on); }
.now-tag { justify-self: start; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; background: color-mix(in srgb, var(--on) 16%, transparent); }
.now-title { margin: 0; padding: 0; border: 0; background: none; text-align: left; font-size: 32px; line-height: 1.08; font-weight: 750; letter-spacing: -.015em; }
.now-time { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.now-clock { font-size: 60px; line-height: 1; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.now-rel { font-size: 17px; font-weight: 700; }
.now-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.now-main { flex: 1 1 150px; min-height: 58px; font-size: 20px; background: var(--on); color: var(--c); }
.now-ghost { background: color-mix(in srgb, var(--on) 14%, transparent); color: var(--on); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--on) 55%, transparent); }
.now.is-calm { background: var(--paper); color: var(--ink); }
.now.is-calm .now-title { font-size: 28px; }
.now-note { font-size: 17px; color: var(--ink2); }

/* ───── El hilo del día ───── */
.sec { margin: 0 0 24px; }
.sec-title { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.sec-count { color: var(--ink2); font-weight: 600; }
.thread { list-style: none; margin: 0; padding: 0; position: relative; }
.thread::before { content: ""; position: absolute; left: 11px; top: 16px; bottom: 16px; width: 2px; background: var(--line); }
.row { display: grid; grid-template-columns: 24px 54px 1fr; gap: 12px; align-items: start; padding: 9px 0; position: relative; transition: opacity .2s, transform .2s; }
.row.is-leaving { opacity: 0; transform: translateX(14px); }
.node { position: relative; width: 24px; height: 24px; margin-top: 4px; padding: 0; border: 3px solid var(--c); border-radius: 50%; background: var(--bg); color: var(--on); display: grid; place-items: center; }
.node::after { content: ""; position: absolute; inset: -12px; }
.node .ic { width: 14px; height: 14px; stroke-width: 3.2; opacity: 0; }
.row.is-done .node { background: var(--c); }
.row.is-done .node .ic { opacity: 1; }
.row.is-done .row-title { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink2); }
.row-time { padding-top: 2px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row-main { display: grid; gap: 1px; padding: 2px 0; border: 0; background: none; text-align: left; min-width: 0; }
.row-title { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.row-sub { font-size: 14px; color: var(--ink2); }
.late { color: var(--late); font-weight: 700; }
details.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; font-size: 16px; font-weight: 700; min-height: 36px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "Ver"; margin-left: auto; color: var(--ink2); font-weight: 600; font-size: 15px; }
details.sec[open] > summary::after { content: "Ocultar"; }

.empty { display: grid; gap: 12px; justify-items: start; padding: 4px 0 8px; }
.empty p { color: var(--ink2); max-width: 46ch; }
.example { display: inline-block; padding: 10px 16px; border: 0; border-radius: 18px; background: var(--paper); text-align: left; font-weight: 600; }

/* ───── Rutinas y personas ───── */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 14px; }
.page-title { font-size: 30px; line-height: 1.1; font-weight: 760; letter-spacing: -.02em; }
.cards { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.card { display: grid; grid-template-columns: 12px 1fr auto; gap: 14px; align-items: center; padding: 14px 16px 14px 14px; border-radius: 20px; background: var(--paper); }
.card-bar { align-self: stretch; border-radius: 6px; background: var(--c); min-height: 38px; }
.card-main { display: grid; gap: 4px; border: 0; background: none; text-align: left; padding: 0; min-width: 0; }
.card-title { font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
.card-sub { color: var(--ink2); font-size: 15px; }
.times { display: flex; flex-wrap: wrap; gap: 6px; }
.time-chip { padding: 2px 10px; border-radius: 999px; background: var(--bg); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card.is-off .card-title, .card.is-off .card-sub, .card.is-off .times { opacity: .5; }
.card.is-due { box-shadow: inset 0 0 0 2px var(--c); }
.card .btn { min-height: 44px; padding: 0 16px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--paper); transition: transform .15s; }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--bg); }
.switch input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ───── Caja inferior ───── */
.dock { position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: center; pointer-events: none; }
.dock-in { pointer-events: auto; width: min(680px, 100%); padding: 10px var(--edge-r) calc(var(--safe-b) + 4px) var(--edge-l); background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.preview { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 0 4px 8px; font-size: 15px; font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; background: var(--paper); font-weight: 650; }
.pill-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.pill.is-warn { background: transparent; box-shadow: inset 0 0 0 2px var(--late); color: var(--late); }
.quick { display: flex; gap: 8px; align-items: center; }
.quick-input { flex: 1; min-width: 0; min-height: 54px; padding: 0 20px; border: 2px solid transparent; border-radius: 999px; background: var(--paper); font-size: 17px; }
.quick-input::placeholder { color: var(--ink2); opacity: 1; }
.quick-input:focus { outline: none; border-color: var(--ink); }
.quick-send { width: 54px; height: 54px; border: 0; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; flex: none; }
.nav { display: flex; margin-top: 6px; }
.nav-btn { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 4px 0; border: 0; background: none; color: var(--ink2); font-size: 13px; font-weight: 650; }
.nav-btn .nav-ic { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px; }
.nav-btn[aria-current="page"] { color: var(--ink); }
.nav-btn[aria-current="page"] .nav-ic { background: var(--line); }

/* ───── Hojas (ventanas desde abajo) ───── */
.sheet-back { position: fixed; inset: 0; z-index: 30; background: var(--backdrop); opacity: 0; transition: opacity .2s; }
.sheet-back.on { opacity: 1; }
.sheet { position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(680px, 100%); max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; padding: 22px max(20px, env(safe-area-inset-right, 0px)) calc(var(--safe-b) + 22px) max(20px, env(safe-area-inset-left, 0px)); border-radius: 28px 28px 0 0; background: var(--paper); transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.sheet.on { transform: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 0 0 16px; }
.sheet-title { font-size: 26px; line-height: 1.12; font-weight: 750; letter-spacing: -.015em; overflow-wrap: anywhere; }
.sheet-sub { margin-top: 4px; color: var(--ink2); }
.sheet-x { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bg); display: grid; place-items: center; flex: none; }
.stack { display: grid; gap: 10px; }
.group { margin: 18px 0 0; }
.group-title { margin: 0 0 8px; font-size: 15px; font-weight: 700; color: var(--ink2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: grid; gap: 6px; margin: 0 0 16px; }
.field > label, .field > .label { font-size: 15px; font-weight: 700; }
.field-help { font-size: 14px; color: var(--ink2); }
.input { width: 100%; min-height: 50px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); font-size: 17px; }
.input:focus { outline: none; border-color: var(--ink); }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--bg); font-weight: 650; }
.chip .pill-dot { width: 12px; height: 12px; }
.chip[aria-pressed="true"] { background: var(--c, var(--ink)); color: var(--on, var(--bg)); }
.chip[aria-pressed="true"] .pill-dot { background: var(--on); }
.chip-add { background: transparent; box-shadow: inset 0 0 0 2px var(--line); color: var(--ink2); }
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.swatch { position: relative; min-height: 48px; border: 0; border-radius: 14px; background: var(--c); color: var(--on); display: grid; place-items: center; }
.swatch svg { width: 22px; height: 22px; opacity: 0; }
.swatch[aria-pressed="true"] svg { opacity: 1; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.dows { display: flex; gap: 6px; }
.dow { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bg); font-weight: 750; }
.dow[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.times-edit { display: grid; gap: 8px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .btn { min-width: 48px; padding: 0; background: var(--bg); font-size: 24px; }
.stepper output { min-width: 72px; text-align: center; font-weight: 700; font-size: 19px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting-text { display: grid; gap: 2px; min-width: 0; }
.setting-text span { color: var(--ink2); font-size: 15px; }
.setting .input { width: auto; flex: none; }
.note-box { padding: 12px 14px; border-radius: 14px; background: var(--bg); color: var(--ink2); font-size: 15px; }
.note-box.is-warn { color: var(--late); box-shadow: inset 0 0 0 2px var(--late); }

/* ───── Aviso ───── */
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(var(--dock-h) + 12px); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: min(92vw, 560px); padding: 12px 14px 12px 18px; border-radius: 18px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); }
.toast .btn-text { color: var(--bg); min-height: 36px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (min-width: 900px) {
  .date-day { font-size: 46px; }
  .now-clock { font-size: 72px; }
}
