/* ApneApp — tema oceanico scuro */
:root {
  --bg: #041018;
  --bg-2: #071a24;
  --surface: rgba(8, 32, 46, 0.72);
  --surface-2: rgba(12, 42, 58, 0.88);
  --line: rgba(103, 232, 249, 0.14);
  --text: #e7f6fb;
  --muted: #8aa4b3;
  --cyan: #22d3ee;
  --teal: #2dd4bf;
  --blue: #38bdf8;
  --hold: #0369a1;
  --hold-glow: #22d3ee;
  --rest: #0f766e;
  --rest-glow: #5eead4;
  --warn: #f59e0b;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
  --nav-h: calc(72px + env(safe-area-inset-bottom, 0px));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Segoe UI", "SF Pro Text", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

img {
  max-width: 100%;
}

a {
  color: var(--cyan);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(14, 116, 144, 0.35), transparent 55%),
    radial-gradient(900px 600px at -10% 110%, rgba(15, 118, 110, 0.28), transparent 50%),
    linear-gradient(180deg, #041018 0%, #06202c 55%, #041018 100%);
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%, rgba(34, 211, 238, 0.08), transparent 42%);
  animation: tide 12s ease-in-out infinite;
}

@keyframes tide {
  0%,
  100% { opacity: 0.55; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-12px); }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px var(--nav-h);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img,
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text);
}

.lang-switch {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.lang-switch-sheet {
  margin-bottom: 4px;
}

.lang-btn {
  min-width: 38px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.lang-btn.active {
  background: rgba(34, 211, 238, 0.18);
  color: var(--cyan);
}

.view {
  display: none;
  animation: rise 0.45s var(--ease);
}

.view.active {
  display: block;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.card + .card,
.stack > * + * {
  margin-top: 12px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 20px 18px 18px;
}

.hero h2 {
  margin: 0 0 6px;
  font-size: 1.45rem;
}

.kicker {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.week-label {
  margin: 18px 0 8px;
}

.muted {
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 1.2rem;
  color: var(--cyan);
}

.stat span {
  color: var(--muted);
  font-size: 0.75rem;
}

.progress-ring {
  width: 92px;
  height: 92px;
}

.progress-wrap {
  display: flex;
  gap: 14px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #22d3ee, #0891b2);
  color: #04202a;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.22);
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  color: var(--cyan);
  box-shadow: none;
  border: 1px solid var(--line);
}

.btn.danger {
  background: linear-gradient(180deg, #fb7185, #e11d48);
  color: #fff;
  box-shadow: none;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--cyan);
  font-size: 0.78rem;
}

.chip.warn {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.week-track {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.day-dot {
  aspect-ratio: 1;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.72rem;
  display: grid;
  place-items: center;
}

.day-dot.done {
  background: rgba(45, 212, 191, 0.2);
  color: var(--ok);
  border-color: rgba(45, 212, 191, 0.45);
}

.day-dot.current {
  background: rgba(34, 211, 238, 0.22);
  color: var(--cyan);
  border-color: var(--cyan);
}

.day-dot.locked {
  opacity: 0.4;
}

.list-item,
.nav-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  color: inherit;
}

.nav-card .grow {
  flex: 1;
}

.nav-card h3,
.list-item h3 {
  margin: 0 0 2px;
  font-size: 0.98rem;
}

.nav-card p,
.list-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  min-width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(34, 211, 238, 0.12);
  color: var(--cyan);
  font-weight: 700;
}

.badge.teal { background: rgba(45, 212, 191, 0.14); color: var(--teal); }
.badge.warn { background: rgba(245, 158, 11, 0.16); color: var(--warn); }
.badge.rose { background: rgba(251, 113, 133, 0.14); color: var(--danger); }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(4, 16, 24, 0.88);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 52px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
}

.bottom-nav button.active {
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
}

.field input,
.field select {
  min-height: 46px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #04141c;
}

.table-preview {
  margin-top: 12px;
  max-height: 280px;
  overflow: auto;
}

.table-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table-preview th,
.table-preview td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.prose h3 {
  margin: 18px 0 8px;
}

.prose p,
.prose li {
  color: #c5dbe4;
}

.prose ul {
  padding-left: 18px;
}

.callout {
  border-left: 3px solid var(--danger);
  background: rgba(251, 113, 133, 0.08);
  padding: 12px 14px;
  border-radius: 12px;
  margin: 12px 0;
}

.callout.info {
  border-left-color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
}

.callout.warn {
  border-left-color: var(--warn);
  background: rgba(245, 158, 11, 0.1);
}

/* Timer overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px));
  background: #031018;
}

.overlay.open {
  display: flex;
}

.overlay.phase-prepare { background: radial-gradient(circle at 50% 40%, #1e3a5f, #041018 72%); }
.overlay.phase-hold { background: radial-gradient(circle at 50% 40%, #0b3a58, #031018 70%); }
.overlay.phase-rest { background: radial-gradient(circle at 50% 40%, #0b3d36, #031018 70%); }
.overlay.phase-done { background: radial-gradient(circle at 50% 40%, #134e4a, #031018 70%); }

.overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.phase-label {
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan);
}

.clock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.clock .time {
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.4rem, 16vw, 6.4rem);
  font-weight: 720;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 0 40px rgba(34, 211, 238, 0.35);
}

.clock .sub {
  margin-top: 10px;
  color: var(--muted);
}

.ring-wrap {
  width: min(72vw, 280px);
  aspect-ratio: 1;
  margin: 8px auto 0;
  position: relative;
}

.ring-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-wrap .time-abs {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform: none;
}

.big-stop {
  min-height: 64px;
  font-size: 1.1rem;
}

.pulse {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.035); opacity: 0.86; }
}

/* Zen */
.lung {
  width: min(70vw, 280px);
  aspect-ratio: 1;
  margin: 24px auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.22), transparent 28%),
    radial-gradient(circle at 50% 50%, #67e8f9, #0e7490 62%, #04202c 100%);
  box-shadow: 0 0 60px rgba(34, 211, 238, 0.28);
  transform: scale(0.72);
  animation: none;
}

.lung.running {
  animation: lung var(--cycle, 16s) ease-in-out infinite;
}

.lung.box {
  animation: boxlung var(--cycle, 16s) linear infinite;
}

@keyframes lung {
  0%, 100% { transform: scale(0.7); }
  50% { transform: scale(1); }
}

@keyframes boxlung {
  0%, 24% { transform: scale(1); }
  25%, 49% { transform: scale(1); }
  50%, 74% { transform: scale(0.7); }
  75%, 100% { transform: scale(0.7); }
}

.zen-phase {
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.modal.open {
  display: flex;
}

.modal .sheet {
  width: min(560px, 100%);
  max-height: 90dvh;
  overflow: auto;
  background: #0b1d27;
  border: 1px solid var(--line);
  border-radius: 24px 24px 18px 18px;
  padding: 18px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (min-width: 860px) {
  .app {
    padding-top: 28px;
  }

  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    width: min(760px, calc(100% - 24px));
    border-radius: 20px 20px 0 0;
  }
}

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