:root {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --bg-elevated-2: #2c2c2e;
  --text-primary: #ffffff;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --separator: rgba(84, 84, 88, 0.48);
  --accent: #4dbeb8;
  --accent-soft-10: rgba(77, 190, 184, 0.1);
  --accent-soft-15: rgba(77, 190, 184, 0.15);
  --accent-soft-20: rgba(77, 190, 184, 0.2);
  --accent-soft-40: rgba(77, 190, 184, 0.4);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", var(--font-sans);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

@media (min-width: 481px) {
  #app {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
    border-left: 1px solid var(--separator);
    border-right: 1px solid var(--separator);
  }
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen[hidden] {
  display: none;
}

h1, h2, h3, p {
  margin: 0;
}

button {
  font-family: inherit;
  color: inherit;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 12px 12px;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 8px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--bg-elevated);
}

.icon-btn-spacer {
  width: 40px;
  height: 40px;
}

/* ---------- Buttons ---------- */

.btn {
  font-size: 16px;
  font-weight: 600;
  border-radius: 16px;
  padding: 14px 18px;
  border: none;
  cursor: pointer;
  text-align: center;
}

.btn-block {
  display: block;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:active {
  opacity: 0.85;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-soft-40);
}

.btn-outline:active {
  background: var(--accent-soft-10);
}

.btn.is-active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Onboarding ---------- */

.screen-onboarding {
  padding: 24px;
  text-align: center;
}

.onboarding-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.onboarding-spacer {
  flex: 1;
}

.onboarding-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.screen-onboarding h1 {
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 20px;
}

.body-text {
  font-size: 16px;
  color: var(--text-secondary);
  padding: 0 12px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.footnote {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 12px;
  line-height: 1.4;
}

.screen-onboarding .btn {
  width: 100%;
  margin-top: 24px;
}

/* ---------- Home ---------- */

.home-content {
  flex: 1;
  padding: 8px 20px calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.week-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: none;
}

.day-number {
  font-family: var(--font-rounded);
  font-size: 48px;
  font-weight: 700;
}

.day-title {
  font-size: 19px;
  font-weight: 700;
}

.day-phrase {
  margin: 0;
  padding: 0 16px;
  font-size: 16px;
  font-style: italic;
  color: var(--text-secondary);
}

.player-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.progress-ring-wrap {
  position: relative;
  width: 148px;
  height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 148px;
  height: 148px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--accent-soft-15);
  stroke-width: 10;
}

.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 402.1;
  stroke-dashoffset: 402.1;
  transition: stroke-dashoffset 0.2s linear;
}

.play-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 56px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.play-btn:active {
  opacity: 0.8;
}

.time-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.soundwave {
  height: 28px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.soundwave span {
  width: 4px;
  min-height: 6px;
  border-radius: 2px;
  background: var(--accent);
  height: 35%;
  transition: height 0.25s ease-out;
}

.seek-slider {
  width: 100%;
  accent-color: var(--accent);
  margin: 0;
}

.post-listen-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 4px;
}

.challenge-card {
  background: var(--accent-soft-10);
  border-radius: 16px;
  padding: 16px;
  text-align: left;
}

.challenge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.challenge-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.challenge-minutes {
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-soft-20);
  padding: 4px 10px;
  border-radius: 999px;
}

.challenge-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.challenge-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.night-reflection-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-soft-10);
  border: none;
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.night-icon {
  font-size: 22px;
}

.night-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.night-title {
  font-size: 15px;
  font-weight: 600;
}

.night-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.chevron {
  color: var(--text-secondary);
  font-size: 18px;
}

.reveal {
  animation: reveal-in 0.4s ease-out;
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.rest-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.rest-icon {
  font-size: 56px;
}

.rest-content h2 {
  font-size: 22px;
  font-weight: 700;
}

.rest-content p {
  color: var(--text-secondary);
  padding: 0 12px;
  line-height: 1.5;
}

/* ---------- Scroll content (Progress / Settings) ---------- */

.scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

/* ---------- Progress dashboard ---------- */

.stats-row {
  display: flex;
  gap: 16px;
}

.stat-card {
  flex: 1;
  background: var(--accent-soft-10);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-cell {
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(120, 120, 128, 0.1);
  color: var(--text-primary);
}

.day-cell.is-overflow {
  background: rgba(120, 120, 128, 0.15);
  color: var(--text-secondary);
}

.day-cell.is-past {
  background: rgba(120, 120, 128, 0.25);
}

.day-cell.is-listened {
  background: var(--accent-soft-40);
}

.day-cell.is-today {
  background: var(--accent);
  color: #000;
}

.mood-chart-wrap {
  background: var(--accent-soft-10);
  border-radius: 16px;
  padding: 12px;
}

.mood-chart {
  width: 100%;
  height: 180px;
  display: block;
}

.journal-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.journal-entry {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--separator);
}

.journal-date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.journal-text {
  font-size: 15px;
  line-height: 1.4;
}

.empty-hint {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  padding: 12px 0;
}

/* ---------- Settings ---------- */

.settings-section {
  background: var(--bg-elevated);
  border-radius: 14px;
  overflow: hidden;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  padding: 12px 16px 6px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--separator);
  font-size: 15px;
}

.settings-row[hidden] {
  display: none;
}

.settings-section-title + .settings-row {
  border-top: none;
}

.settings-row input[type="time"] {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-family: inherit;
}

.settings-about-title {
  padding: 4px 16px 2px;
  font-size: 15px;
  font-weight: 600;
}

.settings-about-desc {
  padding: 2px 16px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.settings-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  padding: 0 4px;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.32);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::before {
  transform: translateX(18px);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(120, 120, 128, 0.24);
  border-radius: 10px;
  overflow: hidden;
}

.stepper-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 20px;
  width: 40px;
  height: 32px;
  cursor: pointer;
}

.stepper-btn:active {
  background: rgba(120, 120, 128, 0.3);
}

/* ---------- Dialogs / sheets ---------- */

dialog.sheet {
  border: none;
  border-radius: 20px 20px 0 0;
  padding: 0;
  width: 100%;
  max-width: 480px;
  margin: auto auto 0;
  background: var(--bg);
  color: var(--text-primary);
  max-height: min(88vh, 720px);
}

/* dialog:not([open]) { display: none } vive en la hoja de estilos del navegador
   con la misma especificidad que un selector de clase — si ponemos display:flex
   en .sheet sin condicionarlo a [open], el diálogo "cerrado" seguiría ocupando
   layout. Por eso el flex solo se activa cuando el elemento SÍ está abierto. */
dialog.sheet[open] {
  display: flex;
  flex-direction: column;
}

dialog.sheet::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

dialog.sheet-center {
  border-radius: 20px;
  margin: auto;
  max-height: min(80vh, 560px);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}

.sheet-header-minimal {
  border-bottom: none;
}

.sheet-title {
  font-size: 16px;
  font-weight: 600;
}

.text-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.text-btn-primary {
  color: var(--accent);
  font-weight: 600;
}

.sheet-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.mood-row {
  display: flex;
  justify-content: space-between;
}

.mood-btn {
  background: none;
  border: none;
  font-size: 30px;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
}

.mood-btn.is-selected {
  background: var(--accent-soft-20);
}

.textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  padding: 12px;
  resize: vertical;
}

.textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.night-body {
  align-items: center;
  text-align: center;
  padding-top: 8px;
  padding-bottom: 24px;
}

.night-icon {
  font-size: 40px;
}

.night-question {
  font-size: 19px;
  font-weight: 700;
  padding: 0 8px;
  line-height: 1.4;
}

.night-answer {
  width: 100%;
}

.night-body .btn {
  width: 100%;
  margin-top: 8px;
}

@media (prefers-color-scheme: light) {
  /* La app original fuerza modo oscuro siempre; se mantiene igual en la web
     para conservar la identidad visual, independientemente del tema del sistema. */
}
