:root {
  --bg: #fdf6f8;
  --card: #ffffff;
  --text: #2b2230;
  --muted: #7a6d80;
  --line: #eadfe5;
  --accent: #c2185b;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b161d; --card: #262029; --text: #f3eef5; --muted: #a99cae;
    --line: #3a3140; --accent: #f06292; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
#app { max-width: 640px; margin: 0 auto; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); }
#app:has(.tabs) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
button {
  font: inherit; color: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none;
}
button:active { opacity: .75; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h3 { margin: 22px 0 10px; font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hidden { display: none !important; }
.loading { text-align: center; margin-top: 30vh; color: var(--muted); }

.banner {
  margin: 12px 0 0; padding: 8px 12px; border-radius: 10px;
  background: #fff3cd; color: #6b4e00; font-size: .85rem;
}

/* Inicio */
.hero { text-align: center; padding: 28px 0 8px; }
.hero-icon {
  width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%;
  display: grid; place-items: center; font-size: 34px; color: #fff; background: var(--accent);
}
.hero h1 { font-size: 1.6rem; }
.today { margin: 10px 0 0; }
.pick { text-align: center; font-weight: 600; margin: 22px 0 10px; }
.people { display: grid; gap: 10px; }
.person-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); font-size: 1.15rem; font-weight: 600; text-align: left;
  border-left: 8px solid var(--c);
}
.person-btn:active { transform: scale(.99); }
.person-btn .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.person-btn .lock { margin-left: auto; font-size: 1rem; }
.install {
  display: block; width: 100%; margin-top: 22px; padding: 14px; border: 0;
  border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 600;
}
#ios-hint { text-align: center; }

/* Cabecera de persona */
.bar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  margin-top: calc(-1 * env(safe-area-inset-top));
  border-bottom: 4px solid var(--c);
}
.bar h2 { font-size: 1.4rem; }
.back {
  border: 0; background: none; font-size: 2.2rem; line-height: 1;
  min-width: 48px; min-height: 48px; margin-left: -8px; padding: 0 0 4px;
}
.badge {
  font-size: .7rem; vertical-align: middle; padding: 3px 8px; border-radius: 99px;
  background: var(--accent); color: #fff; font-weight: 600;
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.tabs button {
  flex: 1 1 0; max-width: 128px; min-height: 60px; border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px; color: var(--muted);
}
.tabs .ti { font-size: 1.35rem; line-height: 1; }
.tabs .tl { font-size: .72rem; font-weight: 600; }
.tabs button.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.card {
  margin-top: 14px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
}
.card.hl { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }

.shifts, .week, .hist { list-style: none; margin: 0; padding: 0; }
.shifts li, .week li, .hist li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px;
}
.week li { justify-content: space-between; }
.week li.is-today { outline: 2px solid var(--accent); }
.week li.mine .wd::after { content: " ★"; color: var(--accent); }
.wn { font-weight: 700; }
.hist li { display: block; }
.hdate { font-size: .8rem; color: var(--muted); }
.note { font-style: italic; color: var(--muted); }
.chip {
  font-size: .75rem; padding: 2px 8px; border-radius: 99px;
  background: #fde2b0; color: #6b4300;
}
.today-chip { background: var(--accent); color: #fff; }

/* Calendario */
.month-nav { user-select: none; display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.month-nav h3 { margin: 0; }
.month-nav button {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); font-size: 1.5rem; line-height: 1;
}
.month-nav button:disabled { opacity: .3; }
.link { border: 0; background: none; color: var(--accent); padding: 6px 0; font-weight: 600; }
.today-link { display: block; margin: 4px auto 6px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.grid.head div { text-align: center; font-size: .75rem; color: var(--muted); padding-bottom: 2px; }
.cell {
  position: relative; min-height: 62px; padding: 4px 2px 3px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: default;
  border-bottom: 5px solid var(--c);
}
.cell.empty { border: 0; background: none; }
.cell.out { opacity: .35; }
.cell.editable { cursor: pointer; }
.cell .num { font-size: .85rem; font-weight: 600; }
.cell .who { font-size: .62rem; line-height: 1.1; text-align: center; word-break: break-word; }
.cell.mine { background: color-mix(in srgb, var(--c) 22%, var(--card)); }
.cell.is-today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cell.changed::after {
  content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px;
  border-radius: 50%; background: #f0a000;
}
.cell.unassigned { border-style: dashed; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: .85rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .lg-changed { border-radius: 50%; background: #f0a000; width: 9px; height: 9px; }

/* Formularios y diálogos */
dialog {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  margin: auto auto 0; border: 0; border-radius: 22px 22px 0 0;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--card); color: var(--text);
  animation: sheet-up .22s ease-out;
}
dialog::before {
  content: ""; display: block; width: 40px; height: 5px; border-radius: 3px;
  background: var(--line); margin: 0 auto 12px;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.form { display: grid; gap: 12px; }
.form h3 { margin: 0; }
.form label { display: grid; gap: 4px; font-size: .95rem; }
.form input:not([type=radio]) {
  font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
.form input[name=pin] { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.row { display: flex; gap: 10px; justify-content: flex-end; }
.row button, .primary {
  min-height: 50px; padding: 12px 20px; flex: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
.primary { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff; font-weight: 600; }
.msg { margin: 0; min-height: 1.2em; font-size: .9rem; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  display: flex !important; grid-template-columns: none; align-items: center; gap: 8px;
  min-height: 50px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); border-left: 6px solid var(--c, var(--line));
}
.choice:has(input:checked) { background: color-mix(in srgb, var(--accent) 14%, var(--card)); border-color: var(--accent); }
.restore { justify-self: center; min-height: 44px; }
.choice input { width: 20px; height: 20px; accent-color: var(--accent); }
.form input:not([type=radio]) { font-size: 17px; min-height: 50px; }
.toast { bottom: calc(90px + env(safe-area-inset-bottom)) !important; }
.person-btn { min-height: 64px; }
.shifts li, .week li { min-height: 52px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2b2230; color: #fff; padding: 10px 16px; border-radius: 99px; font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; text-align: center; z-index: 10;
}

.cell.blank { border-bottom-color: var(--line); opacity: .55; }
#mycal .month-nav { margin-top: 0; }
.month-count { margin: 10px 0 0; }
