/* Simplemente — estilos. Colores del sistema iOS en claro/oscuro; pantallas de meditación siempre oscuras. */
:root {
  --blue: #007AFF; --green: #34C759; --purple: #AF52DE; --orange: #FF9500; --yellow: #FFCC00;
  --gray: #8E8E93; --gray5: #E5E5EA;
  --bg: #FFFFFF; --grouped: #F2F2F7; --cell: #FFFFFF;
  --label: #000000; --secondary: rgba(60, 60, 67, 0.6); --separator: rgba(60, 60, 67, 0.29);
  --bar: rgba(249, 249, 249, 0.94);
  --shadow: rgba(0, 0, 0, 0.2);
  --night: #1A1A4D; --violet: #4D3399;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --tabbar-h: 50px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --blue: #0A84FF; --green: #30D158; --purple: #BF5AF2; --orange: #FF9F0A; --yellow: #FFD60A;
    --gray5: #2C2C2E;
    --bg: #000000; --grouped: #000000; --cell: #1C1C1E;
    --label: #FFFFFF; --secondary: rgba(235, 235, 245, 0.6); --separator: rgba(84, 84, 88, 0.6);
    --bar: rgba(22, 22, 22, 0.94);
    --shadow: rgba(255, 255, 255, 0.12);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--label);
  overflow: hidden; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.ic { width: 1em; height: 1em; display: block; }
.spacer { flex: 1 1 0; min-height: 0; }

/* ---------- Estructura y barra de pestañas ---------- */
#app { position: fixed; inset: 0; }
#screens { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; overflow-y: auto; padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
.screen.light { background: var(--bg); }
.screen.grouped { background: var(--grouped); }

#tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--bar); border-top: 0.5px solid var(--separator);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
#tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--gray); font-size: 10px; font-weight: 500; }
#tabbar button .ic { font-size: 25px; }
#tabbar button.active { color: var(--blue); }
#app.on-dark #tabbar { background: transparent; border-top-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.sidebar-title { display: none; }

@media (min-width: 768px) {
  #tabbar {
    top: 0; right: auto; width: 260px; height: auto; padding: 16px 12px;
    flex-direction: column; gap: 2px; background: var(--grouped);
    border-top: 0; border-right: 0.5px solid var(--separator);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  #app.on-dark #tabbar { background: var(--grouped); border-right-color: var(--separator); }
  .sidebar-title { display: block; font-size: 34px; font-weight: 700; padding: 28px 8px 14px; }
  #tabbar button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--label); font-size: 17px; font-weight: 400; }
  #tabbar button .ic { font-size: 22px; color: var(--blue); }
  #tabbar button.active { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }
  #screens { left: 260px; }
  .screen { padding-bottom: 0; }
}

/* ---------- Fondos animados ---------- */
.dark { color: #fff; background: var(--night); }
canvas.bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.rings { position: relative; width: 220px; height: 220px; flex: none; }
.rings canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.rings .logo {
  position: absolute; left: 72.5px; top: 72.5px; width: 75px; height: 75px; color: #fff;
  filter: drop-shadow(0 0 5px rgba(175, 82, 222, 0.6)) drop-shadow(0 0 10px rgba(0, 122, 255, 0.3));
}
.rings .logo .ic, .ob-logo .ic { width: 100%; height: 100%; }

/* ---------- Splash ---------- */
#splash, #onboarding { position: fixed; inset: 0; z-index: 20; transition: opacity 0.4s ease-in-out; }
#splash { z-index: 30; }
#splash.fade { opacity: 0; pointer-events: none; transition: opacity 0.4s ease-out; }
.splash-content {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  opacity: 0; transform: scale(0.8); transition: opacity 0.7s ease-in, transform 0.7s ease-in;
}
#splash.in .splash-content { opacity: 1; transform: scale(1); }
.splash-text { text-align: center; display: flex; flex-direction: column; gap: 5px; }
.splash-text h1 { font-size: 32px; font-weight: 700; }
.splash-text .ver { font-size: 12px; opacity: 0.7; }
.splash-text .by { font-size: 16px; font-weight: 300; opacity: 0.8; }

/* ---------- Onboarding ---------- */
#onboarding { background: linear-gradient(#4D3399, #1A1A4D); color: #fff; overflow-y: auto; }
#onboarding.fade { opacity: 0; pointer-events: none; }
.ob { min-height: 100%; max-width: 560px; margin: 0 auto; padding: 60px 20px calc(50px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }
.ob h2 { font-size: 28px; font-weight: 700; }
.ob-sub { font-size: 18px; opacity: 0.9; }
.ob-logo { width: 100px; height: 100px; display: block; flex: none; }
.ob-label { font-size: 17px; font-weight: 600; }
.ob-row { display: flex; gap: 20px; justify-content: center; }
.ob-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; color: #fff; }
.ob-card .circle { width: 60px; height: 60px; border-radius: 50%; border: 1px solid #fff; display: grid; place-items: center; font-size: 30px; }
.ob-card.sel { background: rgba(255, 255, 255, 0.2); }
.ob-card.sel .circle { background: rgba(255, 255, 255, 0.3); }
.ob-card span:last-child { font-size: 15px; }
.ob-dur { width: 70px; height: 70px; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; }
.ob-dur b { font-size: 22px; }
.ob-dur small { font-size: 12px; }
.ob-dur.sel { background: rgba(255, 255, 255, 0.2); }
.ob-check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: #fff; }
.ob-check .ic { font-size: 22px; --ic-cut: #2a2070; }
.ob-start { width: 100%; padding: 15px; border-radius: 10px; background: rgba(0, 122, 255, 0.8); color: #fff; font-size: 17px; font-weight: 600; }

/* ---------- Meditar ---------- */
#tab-meditar { overflow: hidden; }
.med {
  position: relative; height: 100%; max-width: 600px; margin: 0 auto; padding: 10px 16px 0;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 25px;
}
.med-head { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.med-head h2 { font-size: 22px; font-weight: 700; text-shadow: 0 0 2px rgba(0, 0, 0, 0.35); margin-top: 10px; }
#total-meditado { font-size: 15px; opacity: 0.9; padding: 5px 0; }
.menus { display: flex; gap: 15px; }
.menu-wrap { position: relative; }
.pill {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 15px;
  background: rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.9); font-size: 15px; font-weight: 500;
}
.pill .chev .ic { font-size: 12px; }
.pill:disabled { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.4); cursor: default; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 10; min-width: 220px;
  background: rgba(242, 242, 247, 0.92); color: #000; border-radius: 13px; overflow: hidden;
  backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  animation: pop 0.18s ease-out;
}
@media (prefers-color-scheme: dark) { .menu { background: rgba(37, 37, 37, 0.92); color: #fff; } }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) scale(0.9); } }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; font-size: 17px; text-align: left; }
.menu button + button { border-top: 0.5px solid var(--separator); }
.menu button:hover { background: rgba(127, 127, 127, 0.15); }
.menu button .ic { font-size: 18px; }
.menu button .grow { flex: 1; }
.timeline { width: 100%; display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }
.times { display: flex; justify-content: space-between; font: 700 20px var(--rounded); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
#bar-fill { height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width 0.1s linear; }
.controls { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-bottom: 45px; }
.controls .row { display: flex; align-items: center; gap: 40px; }
.seek .ic { width: 35px; height: 35px; color: #fff; }
.play .ic { width: 70px; height: 70px; color: #fff; filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.33)); }
.reset { width: 100px; padding: 5px 10px; border-radius: 15px; background: rgba(255, 255, 255, 0.2); display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; color: #fff; }
.reset .ic { width: 22px; height: 22px; }
.controls button:active { opacity: 0.6; }
@media (max-height: 640px) { .med { gap: 14px; } .controls { padding-bottom: 20px; gap: 12px; } }

/* ---------- Progreso ---------- */
.dash { min-height: 100%; max-width: 640px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.dash .title { font-size: 28px; font-weight: 700; text-align: center; }
.cards { display: flex; gap: 20px; }
.stat { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; border-radius: 15px; background: var(--bg); box-shadow: 0 0 5px var(--shadow); }
.stat .ic { font-size: 30px; color: var(--blue); margin-bottom: 4px; }
.stat.orange .ic { color: var(--orange); }
.dash > .stat { flex: none; }
.stat b { font-size: 22px; font-weight: 700; }
.stat small { font-size: 12px; color: var(--secondary); }

/* ---------- Barras de navegación y formularios ---------- */
.navbar {
  position: sticky; top: 0; z-index: 2; text-align: center; font-size: 17px; font-weight: 600;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--separator);
}
.form { max-width: 700px; margin: 0 auto; padding: 0 16px 24px; }
.section-head { font-size: 13px; text-transform: uppercase; color: var(--secondary); padding: 22px 16px 7px; }
.group { background: var(--cell); border-radius: 10px; overflow: hidden; }
.group.gap { margin-top: 35px; }
.row-btn { width: 100%; text-align: left; padding: 12px 16px; font-size: 17px; color: var(--blue); }
.row-btn:active { background: var(--gray5); }

/* Selector de rueda (Picker .wheel) */
.wheel {
  --row: 34px; position: relative; height: calc(var(--row) * 5); overflow-y: scroll; scroll-snap-type: y mandatory;
  scrollbar-width: none; padding: calc(var(--row) * 2) 0;
  mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-wrap { position: relative; }
.wheel-wrap::before {
  content: ""; position: absolute; left: 8px; right: 8px; top: calc(50% - 17px); height: 34px;
  border-radius: 8px; background: rgba(120, 120, 128, 0.16); pointer-events: none;
}
.wheel button { display: block; width: 100%; height: var(--row); line-height: var(--row); text-align: center; font-size: 21px; scroll-snap-align: center; color: var(--label); }

/* ---------- Logros ---------- */
.badges-page { max-width: 900px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.summary { background: var(--cell); border-radius: 15px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.caption-head { font-size: 17px; font-weight: 600; color: var(--secondary); }
.summary-row { display: flex; align-items: center; justify-content: space-around; text-align: center; }
.summary-row > div:not(.ring) { display: flex; flex-direction: column; gap: 2px; }
.summary-row b { font-size: 28px; font-weight: 700; }
.summary-row small { font-size: 12px; color: var(--secondary); }
.ring { position: relative; width: 90px; height: 90px; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: rgba(142, 142, 147, 0.3); }
.ring .prog { stroke: var(--blue); stroke-linecap: round; stroke-dasharray: 251.33; transition: stroke-dashoffset 0.6s ease; }
.ring b { font: 700 22px var(--rounded) !important; }
.filters { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.filters::-webkit-scrollbar { display: none; }
.chip { display: flex; align-items: center; gap: 6px; flex: none; padding: 8px 16px; border-radius: 20px; background: var(--gray5); font-size: 14px; font-weight: 600; }
.chip .ic { font-size: 14px; color: var(--c); }
.chip.sel { background: var(--c); color: #fff; }
.chip.sel .ic { color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.badge-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; border-radius: 12px; background: var(--cell); box-shadow: 0 0 3px var(--shadow); }
.badge-card.locked { opacity: 0.8; }
.medal { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; --ic-cut: var(--c); }
.medal .ic { font-size: 30px; }
.locked .medal { background: rgba(142, 142, 147, 0.3); color: var(--gray); }
.locked .medal .ic { font-size: 24px; }
.badge-card .name { font-size: 14px; font-weight: 600; text-align: center; }
.badge-card .state { font-size: 12px; color: var(--c); }
.badge-card.locked .state { color: var(--gray); }

/* ---------- Hojas y modales ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.4); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.25s ease; }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: calc(100% - 40px); overflow-y: auto;
  background: var(--bg); color: var(--label); border-radius: 12px 12px 0 0;
  padding: 20px 20px calc(30px + var(--safe-b)); animation: up 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@media (min-width: 768px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 14px; max-height: 85%; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
.sheet .close { position: absolute; top: 14px; right: 14px; color: var(--gray); }
.sheet .close .ic { font-size: 28px; }
.sheet-title { text-align: center; font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.sheet-done { position: absolute; top: 18px; right: 18px; color: var(--blue); font-size: 17px; font-weight: 600; }

.detail { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 20px; text-align: center; }
.detail .medal { width: 150px; height: 150px; }
.detail .medal .ic { font-size: 70px; }
.detail.locked .medal .ic { font-size: 50px; }
.detail h3 { margin: 0; font-size: 22px; font-weight: 700; }
.cat-tag { color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); padding: 5px 10px; border-radius: 8px; font-size: 15px; }
.stars { display: flex; gap: 4px; }
.stars .ic { font-size: 20px; color: rgba(142, 142, 147, 0.3); }
.stars .on { color: var(--yellow); }
.detail .desc { font-size: 17px; line-height: 1.35; padding: 0 10px; }
.detail .cond { display: flex; flex-direction: column; gap: 4px; }
.detail .cond b { font-size: 15px; font-weight: 600; }
.detail .cond span { font-size: 15px; color: var(--secondary); }

.about { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 30px; text-align: center; }
.about .big { width: 100px; height: 100px; color: var(--blue); }
.about .big .ic { width: 100%; height: 100%; }
.about h2 { font-size: 34px; font-weight: 700; }
.about .text { font-size: 17px; color: var(--secondary); line-height: 1.4; padding: 0 10px; }
.about .version { font-size: 15px; color: var(--secondary); }
.about .links { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.about a, .about .link { display: flex; align-items: center; gap: 8px; color: var(--blue); text-decoration: none; font-size: 17px; }
.about a .ic, .about .link .ic { font-size: 18px; }

.alert-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.4); display: grid; place-items: center; animation: fade 0.2s ease; }
.alert { width: 270px; border-radius: 14px; overflow: hidden; background: rgba(242, 242, 247, 0.95); color: #000; text-align: center; backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); animation: pop2 0.2s ease-out; }
@media (prefers-color-scheme: dark) { .alert { background: rgba(37, 37, 37, 0.95); color: #fff; } }
@keyframes pop2 { from { transform: scale(1.15); opacity: 0; } }
.alert .body { padding: 19px 16px; display: flex; flex-direction: column; gap: 4px; }
.alert b { font-size: 17px; font-weight: 600; }
.alert p { font-size: 13px; }
.alert .actions { display: flex; border-top: 0.5px solid var(--separator); }
.alert .actions button { flex: 1; padding: 11px; font-size: 17px; color: var(--blue); }
.alert .actions button + button { border-left: 0.5px solid var(--separator); }
.alert .actions .destructive { color: #FF3B30; }
.alert .actions .cancel { font-weight: 600; }

/* Celebración y aviso de logro */
.celebrate-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.3); display: grid; place-items: center; padding: 0 30px; animation: fade 0.25s ease; }
.celebrate-backdrop.unlock { background: rgba(0, 0, 0, 0.5); }
.celebrate {
  width: 100%; max-width: 360px; background: var(--bg); color: var(--label); border-radius: 16px; padding: 25px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center;
  transform: translateY(50px); opacity: 0;
}
.celebrate.in { transform: none; opacity: 1; transition: transform 0.6s cubic-bezier(0.3, 1.4, 0.5, 1), opacity 0.3s ease; }
.burst { position: relative; width: 100px; height: 100px; display: grid; place-items: center; }
.burst .wave { position: absolute; inset: 15px; border-radius: 50%; border: 2px solid var(--c, var(--blue)); opacity: 0; }
.celebrate.in .wave { animation: wave 1s ease-out infinite; }
@keyframes wave { from { transform: scale(0.1); opacity: 0.7; } to { transform: scale(var(--s)); opacity: 0; } }
.burst .core { position: relative; width: 70px; height: 70px; border-radius: 50%; background: var(--c, var(--blue)); color: #fff; display: grid; place-items: center; transform: scale(0); --ic-cut: var(--c, var(--blue)); }
.celebrate.in .core { transform: scale(1); transition: transform 0.5s cubic-bezier(0.3, 1.5, 0.5, 1); }
.burst .core .ic { font-size: 30px; }
.celebrate .txt { display: flex; flex-direction: column; gap: 10px; opacity: 0; transform: translateY(10px); }
.celebrate.in .txt { opacity: 1; transform: none; transition: all 0.5s ease-out 0.3s; }
.celebrate .txt .head { font-size: 17px; font-weight: 600; color: var(--secondary); }
.celebrate .txt .big { font-size: 22px; font-weight: 700; }
.celebrate .txt p { font-size: 15px; color: var(--secondary); line-height: 1.35; }
.celebrate .go { padding: 12px 30px; border-radius: 25px; background: var(--c, var(--blue)); color: #fff; font-size: 17px; font-weight: 600; opacity: 0; }
.celebrate.in .go { opacity: 1; transition: opacity 0.5s ease-out 0.4s; }

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