/* =========================================================================
   Paella en casa — estilos
   Superficies limpias, un solo acento (el rojo de la senyera) para lo que
   se pulsa y el oro para lo que está elegido. Todo el color pasa por tokens
   para que el tema claro y el oscuro salgan del mismo sitio.
   ========================================================================= */

:root {
  --bg: #FAF4E8;
  --surface: #FFFFFF;
  --sunken: #F4EAD3;
  --ink: #2A1E12;
  --ink-soft: #6F5E48;
  --border: #E6D8B8;
  --saffron: #FFC72C;
  --saffron-soft: #FFF1C2;
  --star: #D99A00;
  --accent: #D0102A;
  --accent-hover: #B00D22;
  --accent-ink: #B00D22;
  --on-accent: #FFFFFF;
  --blue: #16478E;
  --whatsapp: #0E7C42;
  --ok-bg: #E4EFDD; --ok-ink: #3A662B;
  --warn-bg: #FBF0DC; --warn-ink: #855700;
  --danger-bg: #FAE4E0; --danger-ink: #A2331F;
  --scrim: rgba(24, 14, 6, 0.6);
  --pan-rim: #B7C3C7;
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17110B; --surface: #211910; --sunken: #2C2115;
    --ink: #F3E9DA; --ink-soft: #BBA98C; --border: #3A2D1D;
    --saffron: #FFD24D; --saffron-soft: #4A3A12; --star: #FFD24D;
    --accent: #D93248; --accent-hover: #E5475B; --accent-ink: #FF8292; --on-accent: #FFFFFF;
    --blue: #8FC1F0; --whatsapp: #128A4B;
    --ok-bg: #253621; --ok-ink: #9FD48A;
    --warn-bg: #3A2E12; --warn-ink: #F0C878;
    --danger-bg: #3B211D; --danger-ink: #F0958A;
    --scrim: rgba(0, 0, 0, 0.7);
    --pan-rim: #7C878A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17110B; --surface: #211910; --sunken: #2C2115;
  --ink: #F3E9DA; --ink-soft: #BBA98C; --border: #3A2D1D;
  --saffron: #FFD24D; --saffron-soft: #4A3A12; --star: #FFD24D;
  --accent: #D93248; --accent-hover: #E5475B; --accent-ink: #FF8292; --on-accent: #FFFFFF;
  --blue: #8FC1F0; --whatsapp: #128A4B;
  --ok-bg: #253621; --ok-ink: #9FD48A;
  --warn-bg: #3A2E12; --warn-ink: #F0C878;
  --danger-bg: #3B211D; --danger-ink: #F0958A;
  --scrim: rgba(0, 0, 0, 0.7);
  --pan-rim: #7C878A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  text-wrap: balance;
  line-height: 1.15;
  margin: 0;
}
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Cabecera: la Senyera ---------- */

/* Nueve barras (cinco oro, cuatro rojas) a todo el ancho y, en el asta, la
   franja azul con la corona real. La franja es un recorte de la bandera a
   la altura de la cabecera: con aspect-ratio 80/200 mide justo lo que le
   toca en la bandera, y las barras de detrás encajan con las suyas. */
.app-header {
  --flag-gold: #FFCE00;
  --flag-red: #E31B23;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 112px;
  padding-block: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: repeating-linear-gradient(180deg, var(--flag-gold) 0 11.111%, var(--flag-red) 11.111% 22.222%);
}
.flag-hoist {
  position: absolute; left: 0; top: 0; bottom: 0;
  aspect-ratio: 80 / 200;
  background: #1D4F91 url("../img/senyera.svg") left top / auto 100% no-repeat;
  box-shadow: 2px 0 0 rgba(0, 0, 0, 0.18);
}
.brand {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 6px 20px rgba(42, 30, 18, 0.28);
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; flex: none;
}
.brand-mark .icon { width: 26px; height: 26px; }
.brand h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em; }
.tagline { font-size: 0.86rem; color: var(--ink-soft); }

/* ---------- Pestañas ---------- */

.tabs {
  display: flex; gap: 4px;
  width: min(440px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 4px;
  background: var(--sunken);
  border-radius: 999px;
}
.tab-btn {
  flex: 1; min-height: 42px; padding: 0 10px;
  border: none; border-radius: 999px; background: none;
  font-weight: 700; font-size: 0.95rem; color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tab-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(42, 30, 18, 0.14); }
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- Estructura ---------- */

.shell {
  max-width: 1080px; margin: 0 auto;
  padding-block: 16px 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 14px;
}
.shell > * { min-width: 0; }
.shell.narrow { max-width: 600px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}
.card-title { font-size: 1.3rem; font-weight: 800; }
.section-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 12px; }
.lead { color: var(--ink-soft); font-size: 0.95rem; margin: 6px 0 14px; }
.eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
}
.hint { font-size: 0.85rem; color: var(--ink-soft); margin-top: 8px; }
.hint:empty { display: none; }
.hint.ok { color: var(--ok-ink); }
.hint.warning { color: var(--warn-ink); }

@media (min-width: 900px) {
  .calc-grid { grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
  .memories-grid { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
  .result { position: sticky; top: 12px; }
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 0.95rem; line-height: 1.2; text-decoration: none; text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--ink-soft); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: #FFFFFF; }
.btn-whatsapp:hover { border-color: var(--whatsapp); filter: brightness(1.08); }
.btn.is-on { background: var(--ok-bg); border-color: var(--ok-ink); color: var(--ok-ink); }
.btn-icon { width: 46px; padding: 0; flex: none; }
.btn-block { display: flex; width: 100%; }
.btn-big { min-height: 60px; font-size: 1.08rem; }
.btn-small { min-height: 38px; padding: 0 12px; font-size: 0.88rem; }
.btn-small .icon { width: 17px; height: 17px; }

.link-btn {
  background: none; border: none; padding: 6px 0;
  color: var(--blue); font-weight: 700; font-size: 0.88rem;
  text-decoration: underline; text-underline-offset: 3px;
}
.link-btn.danger { color: var(--danger-ink); }
.link-btn.center { display: block; margin: 8px auto 0; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 auto; }
.actions .btn-icon { flex: none; }

/* ---------- Ajustes de la paella ---------- */

.settings { padding-block: 6px; }
.row { padding: 14px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: none; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-label { font-weight: 700; display: block; }
.row-label small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.82rem; }
.row-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 12px; margin-top: 6px; }
.row-foot .hint { margin-top: 0; flex: 1 1 230px; }
.row-foot .link-btn { flex: none; }

.number-stepper { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.stepper {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.stepper:hover { border-color: var(--ink-soft); }
.number-stepper input {
  width: 3.1em; border: none; background: none; text-align: center;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.number-stepper input::-webkit-outer-spin-button,
.number-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type="range"] { width: 100%; margin: 10px 0 0; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; flex: none; margin: 0; }
.range-ends { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--ink-soft); }

.value-pill {
  background: var(--sunken); border-radius: 999px; padding: 3px 12px;
  font-weight: 700; font-size: 0.92rem; font-variant-numeric: tabular-nums; flex: none;
}

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; margin-top: 8px; }
.segmented.wrap-2 { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented button, .layer-options button {
  min-height: 44px; padding: 6px 4px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); font-weight: 600; font-size: 0.92rem;
}
.segmented button:hover, .layer-options button:hover { border-color: var(--ink-soft); }
.segmented button.active, .layer-options button.active {
  background: var(--saffron-soft); border-color: var(--saffron); font-weight: 700;
}

.layer-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.layer-options button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 8px; }
.layer-options small { color: var(--ink-soft); font-weight: 400; font-size: 0.78rem; }
/* Corte de la paella: un fondo y, encima, el arroz con su espesor. */
.pan-section {
  width: 46px; height: 14px; margin-bottom: 4px;
  border-bottom: 3px solid var(--pan-rim); border-radius: 0 0 6px 6px;
  display: flex; align-items: flex-end;
}
.pan-section i { display: block; width: 100%; background: var(--saffron); border-radius: 2px 2px 0 0; }
.pan-section.thin i { height: 3px; }
.pan-section.medium i { height: 6px; }
.pan-section.thick i { height: 10px; }

.inline-details { margin-top: 10px; }
.inline-details summary { color: var(--blue); font-size: 0.88rem; font-weight: 700; cursor: pointer; }
.more-options > summary { font-weight: 700; cursor: pointer; }
.more-inner { display: grid; gap: 18px; padding-top: 14px; }
.sub-field { min-width: 0; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 10px; min-height: 40px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.92rem; cursor: pointer;
}
.toggle:has(input:checked) { background: var(--saffron-soft); border-color: var(--saffron); }

/* ---------- Resultado ---------- */

.result-head { display: flex; align-items: center; gap: 16px; }
.pan-visual { width: 132px; height: 124px; flex: none; display: grid; place-items: center; }
.pan-plate {
  position: relative; border-radius: 50%; max-width: 100%; max-height: 100%;
  background: radial-gradient(circle at 35% 30%, #FFE9A8 0%, #FFC72C 60%, #E8A30C 100%);
  border: 4px solid var(--pan-rim);
  display: flex; align-items: center; justify-content: center;
  transition: width 0.25s ease, height 0.25s ease, outline-color 0.2s ease;
  outline: 3px solid transparent; outline-offset: 2px;
}
.pan-plate.fit-warning { outline-color: var(--warn-ink); }
.pan-plate.fit-danger { outline-color: var(--danger-ink); }
/* Las dos asas. */
.pan-plate::before, .pan-plate::after {
  content: ""; position: absolute; top: 50%; width: 9px; height: 22px; margin-top: -11px;
  border: 3px solid var(--pan-rim); border-radius: 6px;
}
.pan-plate::before { right: 100%; border-right: none; border-radius: 6px 0 0 6px; margin-right: 3px; }
.pan-plate::after { left: 100%; border-left: none; border-radius: 0 6px 6px 0; margin-left: 3px; }
.rivet-ring { position: absolute; inset: 10%; border-radius: 50%; border: 2px dashed rgba(42, 30, 18, 0.55); }
.pan-label { display: flex; flex-direction: column; align-items: center; line-height: 1; color: #2A1E12; }
.pan-label strong { font-family: "Bricolage Grotesque", system-ui, sans-serif; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pan-label small { font-size: 0.72rem; font-weight: 700; }
.result-title { min-width: 0; }
.result-title h2 { font-size: 1.45rem; font-weight: 800; }
.result-title p { color: var(--ink-soft); font-size: 0.92rem; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 16px 0 12px; }
.stat { background: var(--sunken); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.stat dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-soft); }
.stat dd {
  margin: 2px 0 0;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.3rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stat small { display: block; font-family: "Karla", system-ui, sans-serif; font-size: 0.76rem; font-weight: 400; color: var(--ink-soft); line-height: 1.3; white-space: normal; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.status {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 12px; font-size: 0.93rem; margin-bottom: 14px;
}
.status.ok { background: var(--ok-bg); color: var(--ok-ink); }
.status.warning { background: var(--warn-bg); color: var(--warn-ink); }
.status.danger { background: var(--danger-bg); color: var(--danger-ink); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 6px; background: var(--ink-soft); }
.status-dot.ok { background: var(--ok-ink); }
.status-dot.warning { background: var(--warn-ink); }
.status-dot.danger { background: var(--danger-ink); }

.result .actions .btn-primary { flex: 2 1 170px; }

.fold { border-top: 1px solid var(--border); margin-top: 16px; }
.fold + .fold { margin-top: 0; }
.fold > summary {
  padding: 14px 0; cursor: pointer;
  font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 700; font-size: 1.08rem;
}

.ingredients-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 0.95rem; }
.ingredients-table td { padding: 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.ingredients-table td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; padding-left: 12px; }
.ingredients-table td small { display: block; font-weight: 400; font-size: 0.82rem; color: var(--ink-soft); }
.ingredients-table .section-row td {
  padding-top: 16px; border-bottom: none;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
}
.ingredients-table tr:first-child.section-row td { padding-top: 0; }
.ingredients-table .optional td { color: var(--ink-soft); }
.ingredients-table .optional td:last-child { font-weight: 400; }

.timeline { list-style: none; margin: 0; padding: 0 0 8px; }
.timeline > li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline > li:last-child { border-bottom: none; }
.step-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-weight: 700; }
.step-duration { flex: none; font-size: 0.82rem; background: var(--sunken); border-radius: 999px; padding: 2px 10px; }
.step-bullets { margin: 6px 0 0; padding-left: 20px; font-size: 0.93rem; }
.step-bullets li { margin-bottom: 4px; }

/* Resumen fijo en móvil mientras se ajusta la paella. */
.live-bar { display: none; }
@media (max-width: 899px) {
  body[data-panel="panelCalculator"]:not(.guest-mode) .live-bar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  }
  body[data-panel="panelCalculator"]:not(.guest-mode) .app-footer { padding-bottom: 92px; }
}
.live-bar-inner { display: flex; align-items: center; gap: 10px; max-width: 600px; margin: 0 auto; }
.live-bar-inner .status-dot { margin-top: 0; }
.live-bar-text { flex: 1; min-width: 0; font-size: 0.86rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }

/* ---------- Formularios ---------- */

.field { margin-bottom: 14px; min-width: 0; }
.field > label, .field-label { display: block; font-weight: 700; font-size: 0.88rem; margin-bottom: 6px; }
.field-label small { font-weight: 400; color: var(--ink-soft); }
.field > label.btn { display: inline-flex; margin-bottom: 0; cursor: pointer; }
.card-title + form { margin-top: 14px; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.text-input {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-size: 1rem;
}
.text-input::placeholder { color: var(--ink-soft); opacity: 0.75; }
textarea.text-input { min-height: 92px; resize: vertical; }
.link-field { margin-top: 10px; font-size: 0.82rem; }
.form-status { font-size: 0.9rem; margin-top: 10px; min-height: 1.3em; text-align: center; }
.form-status.ok { color: var(--ok-ink); }
.form-status.danger { color: var(--danger-ink); }

/* ---------- Evento ---------- */

.event-head h2 { font-size: 1.7rem; font-weight: 800; }
.event-meta { margin-top: 6px; font-weight: 600; }
.event-recipe { margin-top: 2px; color: var(--ink-soft); font-size: 0.9rem; }
.event-head-actions { display: flex; gap: 18px; margin-top: 8px; }

.event-steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 14px; counter-reset: paso; }
.event-steps > li { counter-increment: paso; }
.event-steps h3 { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin-bottom: 10px; }
.event-steps h3::before {
  content: counter(paso);
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--sunken); display: grid; place-items: center;
  font-size: 0.88rem; font-weight: 800;
}
.event-steps .lead { margin-top: 0; }
.live-host { margin-bottom: 12px; }
.ready-done { margin-top: 12px; display: grid; gap: 10px; font-size: 0.92rem; }

/* ---------- Invitado ---------- */

.invite-card h2 { font-size: 2rem; font-weight: 800; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin: 16px 0 18px; }
.facts dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.facts dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }

.ready-banner { background: var(--accent); border-color: var(--accent); color: var(--on-accent); text-align: center; padding-block: 26px; }
.ready-banner h2 { font-size: 1.9rem; font-weight: 800; }
.ready-banner p { margin-top: 6px; font-size: 1.05rem; }
.ready-banner .ready-time { font-size: 0.86rem; opacity: 0.85; }
.ready-banner .ready-time:empty { display: none; }

.live-card h3 { font-size: 1.2rem; }
.live-detail { color: var(--ink-soft); font-size: 0.95rem; }
.guest-timer {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 2.8rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: 8px;
}
.live-card .actions { margin-top: 16px; }

.progress { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; margin: 12px 0; }
.progress-bar { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 0.4s ease; }

.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); flex: none; display: inline-block; }
.pulse-dot.on { background: var(--accent); animation: pulso 1.6s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: 0.35; } }

.guest-foot { text-align: center; margin-top: 6px; }
.guest-foot a { color: var(--blue); font-weight: 700; text-underline-offset: 3px; }

.guest-mode .tabs { display: none; }

/* ---------- Recuerdos ---------- */

.star-input { display: flex; gap: 2px; }
.star-btn { background: none; border: none; padding: 0; width: 42px; height: 42px; font-size: 1.9rem; line-height: 1; color: var(--border); }
.star-btn.on { color: var(--star); }

.photo-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-preview:empty { display: none; }
.photo-thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, 0.65); color: #FFFFFF; font-size: 0.75rem; line-height: 1;
}
#memoryForm > .toggle { display: flex; border-radius: 12px; margin-bottom: 14px; }

.empty-message { color: var(--ink-soft); text-align: center; padding: 28px 20px; border: 1px dashed var(--border); border-radius: var(--radius); }
.memories-gallery { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.memory-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.memory-cover { aspect-ratio: 16 / 10; background: var(--sunken); }
.memory-cover:has(.memory-cover-placeholder) { aspect-ratio: 16 / 6; }
.memory-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.memory-cover-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--ink-soft); }
.memory-cover-placeholder .icon { width: 48px; height: 48px; stroke-width: 1.2; }
.memory-body { padding: 14px 16px 12px; }
.memory-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.memory-meta h3 { font-size: 1.1rem; min-width: 0; overflow-wrap: anywhere; }
.memory-stars { color: var(--star); flex: none; letter-spacing: 1px; }
.memory-stars i { color: var(--border); font-style: normal; }
.memory-date { color: var(--ink-soft); font-size: 0.85rem; margin: 2px 0 6px; }
.memory-facts { font-size: 0.88rem; }
.memory-notes { font-size: 0.92rem; font-style: italic; margin-top: 6px; }
.memory-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }

/* ---------- Modales ---------- */

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.modal-card {
  position: relative; width: 100%; max-width: 460px; max-height: 100%; overflow: auto;
  background: var(--surface); border-radius: 20px; padding: 18px;
}
.modal-close {
  float: right; width: 40px; height: 40px; border-radius: 50%; flex: none;
  border: none; background: var(--sunken); color: var(--ink); font-size: 1rem; line-height: 1;
  margin: 0 0 8px 8px;
}
.modal-preview { clear: both; display: block; width: 100%; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 14px; }
.theme-picker {
  clear: both; display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px;
  scrollbar-width: thin;
}
.theme-picker.busy { opacity: 0.6; pointer-events: none; }
.theme-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-weight: 700; font-size: 0.88rem;
}
.theme-chip:hover { border-color: var(--ink-soft); }
.theme-chip.active { background: var(--saffron-soft); border-color: var(--saffron); }
.theme-dots { display: inline-flex; }
.theme-dots i {
  width: 14px; height: 14px; border-radius: 50%; margin-left: -4px;
  border: 1.5px solid var(--surface);
}
.theme-dots i:first-child { margin-left: 0; box-shadow: 0 0 0 1px var(--border); }
.modal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* ---------- Nivelador ---------- */

.level-card { max-width: 420px; text-align: center; }
.level-card .card-title { text-align: left; padding-top: 6px; }
.level-card .lead { text-align: left; }
.level-ring {
  position: relative; width: 220px; height: 220px; margin: 14px auto 12px;
  border-radius: 50%; border: 3px solid var(--border); background: var(--sunken);
  transition: border-color 0.2s ease;
}
.level-ring.ok { border-color: var(--ok-ink); }
.level-ring.warning { border-color: var(--warn-ink); }
.level-ring.danger { border-color: var(--danger-ink); }
.level-cross-h, .level-cross-v { position: absolute; background: var(--border); }
.level-cross-h { left: 8%; right: 8%; top: 50%; height: 1px; }
.level-cross-v { top: 8%; bottom: 8%; left: 50%; width: 1px; }
.level-target {
  position: absolute; top: 50%; left: 50%; width: 46px; height: 46px;
  transform: translate(-50%, -50%); border-radius: 50%; border: 2px dashed var(--ink-soft); opacity: 0.5;
}
.level-bubble {
  position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; border-radius: 50%;
  background: var(--danger-ink); transition: transform 0.08s linear, background 0.2s ease;
}
.level-bubble.ok { background: var(--ok-ink); }
.level-bubble.warning { background: var(--warn-ink); }
.level-bubble.danger { background: var(--danger-ink); }
/* Flecha que apunta al lado que hay que levantar. Sin rotar apunta a la
   derecha; el JS la gira hacia el lado bajo. */
.level-arrow {
  position: absolute; top: 50%; left: 50%; width: 96px; height: 0;
  border-top: 4px solid var(--accent); transform-origin: 0 50%; opacity: 0.8;
}
.level-arrow::after {
  content: ""; position: absolute; right: -2px; top: -9px;
  border-left: 14px solid var(--accent); border-top: 9px solid transparent; border-bottom: 9px solid transparent;
}
.level-readout { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.level-readout strong {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 2.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
}
.level-readout span { font-size: 0.86rem; color: var(--ink-soft); font-weight: 600; }
.level-status {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 12px 14px; border-radius: 12px; margin-top: 12px; background: var(--sunken);
}
.level-status.ok { background: var(--ok-bg); color: var(--ok-ink); }
.level-status.warning { background: var(--warn-bg); color: var(--warn-ink); }
.level-status.danger { background: var(--danger-bg); color: var(--danger-ink); }
.level-status strong { font-size: 1.02rem; }
.level-status span { font-size: 0.86rem; }
.level-card > .hint { text-align: left; }

/* ---------- Modo cocina ---------- */

.cook-modal { padding: 0; }
.cook-card {
  position: relative; width: 100%; max-width: 620px; height: 100%;
  background: var(--surface); display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 700px) {
  .cook-modal { padding: 20px; }
  .cook-card { max-height: 860px; border-radius: 22px; }
}
.cook-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; border-bottom: 1px solid var(--border);
}
.cook-topbar .modal-close { float: none; margin: 0; }
.cook-progress-wrap { flex: 1; min-width: 0; }
.cook-progress-label { font-size: 0.8rem; font-weight: 700; }
.cook-progress-wrap .progress { margin: 4px 0 0; height: 6px; }
.cook-auto-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; line-height: 1.15; max-width: 7.5em; cursor: pointer; }
.cook-live {
  display: flex; align-items: center; gap: 8px; padding: 7px 16px;
  background: var(--ok-bg); color: var(--ok-ink); font-size: 0.84rem; font-weight: 700;
}
.cook-timer-area { text-align: center; padding: 16px; background: var(--sunken); }
.cook-timer {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 4.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
}
.cook-timer-warn { color: var(--warn-ink); }
.cook-timer-done { color: var(--ok-ink); }
.cook-timer-controls { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.cook-timer-controls .btn-primary { min-width: 170px; }
.cook-timer-hint { font-size: 0.84rem; color: var(--ink-soft); margin-top: 8px; }
.cook-scroll { flex: 1; overflow: auto; padding: 18px 20px; }
.cook-step-title { font-size: 1.5rem; font-weight: 800; }
.cook-bullets { margin: 12px 0 0; padding-left: 22px; font-size: 1.08rem; line-height: 1.55; }
.cook-bullets li { margin-bottom: 10px; }
.cook-nav {
  display: flex; gap: 8px; border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.cook-nav .btn { flex: 1; min-height: 54px; font-size: 1.02rem; }
.cook-nav .btn-primary { flex: 1.5; }

/* ---------- Pie ---------- */

.app-footer {
  max-width: 600px; margin: 0 auto; text-align: center;
  color: var(--ink-soft); font-size: 0.8rem;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 28px max(16px, env(safe-area-inset-left, 0px));
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Impresión: solo la receta ---------- */

@media print {
  .app-header, .tabs, .settings, .actions, .status, .live-bar,
  .app-footer, .pan-visual, .modal, #panelEvent, #panelMemories, #panelGuest { display: none !important; }
  body { background: #FFFFFF; color: #000000; }
  .shell, .calc-grid { display: block; padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
  .result { position: static; }
  .stat { background: none; padding: 0; }
}
