/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; min-height: 100dvh; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }

/* Variables */
:root {
  /* Tema claro (por defecto) */
  --bg: #e6e9ee;
  --column-bg: #f6f7f9;
  --column-shadow: 0 0 40px rgba(20, 28, 40, 0.12);
  --bg-elevated: #ffffff;
  --surface: #eef1f5;
  --border: #dde2ea;
  --text: #1b2330;
  --text-main: #1b2330;
  --text-muted: #5d6b7e;
  --accent: #2f6fe0;
  --accent-strong: #2f6fe0;
  --accent-contrast: #ffffff;
  --success: #2f9e6b;
  --danger: #d64550;

  --appbar-bg: rgba(255, 255, 255, 0.92);
  --appbar-border: #dde2ea;
  --item-bg: #ffffff;
  --item-text: #1b2330;
  --item-border: rgba(27, 35, 48, 0.08);
  --item-past-bg: #e3ecf8;
  --item-past-text: #1b2330;
  --item-today-bg: #cfe0f7;
  --item-done-mark: #2f9e6b;
  --progress-track: #dde2ea;
  --progress-fill: linear-gradient(90deg, #2f6fe0, #6ea8fe);
  --passage-read: #8a95a5;
  --check-mark: #ffffff;
  --modal-overlay: rgba(20, 28, 40, 0.55);
  --shadow: 0 20px 50px rgba(20, 28, 40, 0.18);
  --pending-bg: #e0e7ff;
  --pending-text: #3730a3;
  --pending-border: #c7d2fe;
  --ok-bg: #e6f5ee;
  --ok-text: #17603f;
  --ok-border: #b9e0cc;
  --verse-text: #6b7a90;
  --card-bg: #ffffff;
  --card-text: #1b2330;
  --btn-secondary-bg: #ffffff;
  --btn-secondary-border: #c9d1dc;

  --radius: 12px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;

  /* Tipografía responsiva */
  --fs-sm: clamp(0.8rem, 0.77rem + 0.15vw, 0.9rem);
  --fs-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --fs-lg: clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
  --fs-xl: clamp(1.5rem, 1.3rem + 1vw, 2.25rem);

  color-scheme: light;
}

/* Tema oscuro */
[data-theme="dark"] {
  --bg: #08090c;
  --column-bg: #111;
  --column-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  --bg-elevated: #171e2a;
  --surface: #1e2736;
  --border: #2a3547;
  --text: #e6ebf2;
  --text-main: #ffffff;
  --text-muted: #97a3b6;
  --accent: #6ea8fe;
  --accent-strong: #4b8df0;
  --accent-contrast: #0f141c;
  --success: #5ec28f;
  --danger: #ef6b73;

  --appbar-bg: rgba(10, 12, 16, 0.92);
  --appbar-border: #222;
  --item-bg: #000;
  --item-text: #d8dde5;
  --item-border: rgba(255, 255, 255, 0.08);
  --item-past-bg: #4b5c71;
  --item-past-text: #fff;
  --item-today-bg: #5b7290;
  --item-done-mark: #9be3bc;
  --progress-track: #222;
  --progress-fill: linear-gradient(90deg, #2f6fe0, #6ea8fe);
  --passage-read: #6b7686;
  --modal-overlay: rgba(8, 11, 16, 0.85);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  --pending-bg: #1e2a4a;
  --pending-text: #c7d2fe;
  --pending-border: #2f3f6e;
  --ok-bg: rgba(94, 194, 143, 0.14);
  --ok-text: #8fe0b6;
  --ok-border: rgba(94, 194, 143, 0.3);
  --verse-text: #9aa8bd;
  --card-bg: #171e2a;
  --card-text: #e6ebf2;
  --btn-secondary-bg: transparent;
  --btn-secondary-border: #3a4860;

  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  transition: background-color 0.2s, color 0.2s;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3 { line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
small { font-size: var(--fs-sm); color: var(--text-muted); }

.hidden { display: none !important; }

#main-view, #detail-view { max-width: 700px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; background: var(--column-bg); }
@media (min-width: 740px) {
  #main-view, #detail-view { box-shadow: var(--column-shadow); }
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.75rem var(--space-3);
  background: var(--appbar-bg);
  color: var(--text-main);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--appbar-border);
}
.app-bar h1 { font-size: var(--fs-lg); flex: 1; }

#day-list { list-style: none; margin: 0; padding: 0; }
.day-item {
  padding: 1rem var(--space-3);
  min-height: 64px;
  background: var(--item-bg);
  color: var(--item-text);
  border-bottom: 1px solid var(--item-border);
  cursor: pointer;
}
.day-item.past { background: var(--item-past-bg); color: var(--item-past-text); }
.day-item.today { background: var(--item-today-bg); box-shadow: inset 4px 0 0 var(--accent); }
.day-item small { display: block; color: inherit; opacity: 0.75; text-transform: capitalize; letter-spacing: 0.03em; line-height: 1.4; }
.day-item .passages { display: block; margin-top: 2px; font-size: var(--fs-lg); font-weight: 600; line-height: 1.35; letter-spacing: 0.005em; }
.day-item:active { filter: brightness(1.15); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
  background: var(--modal-overlay);
}
.modal[hidden] { display: none; }
.modal__card {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal__card h2 { font-size: var(--fs-xl); text-align: center; color: var(--text); }
.modal__card > p { margin-top: calc(var(--space-2) * -1); text-align: center; color: var(--text-muted); font-size: var(--fs-base); }
.modal__card input[type="date"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.modal__card input[type="date"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  padding: 0.8rem 1.25rem;
  background: var(--accent-strong);
  color: var(--accent-contrast);
  font-weight: 600;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.btn:hover, .btn:focus-visible { background: var(--accent); color: var(--accent-contrast); filter: brightness(1.1); }

.app-bar--detail { justify-content: space-between; }
.app-bar--detail h1 { flex: 1; text-align: center; }
.back-btn, .app-bar__spacer { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }

.list-message { padding: var(--space-4) var(--space-3); text-align: center; color: var(--text-muted); }
.day-item.done::after { content: "✓"; float: right; margin-top: -2.4rem; font-size: var(--fs-lg); color: var(--item-done-mark); }

#passages-container { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.passage {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 1rem;
  min-height: 60px;
  background: var(--card-bg);
  color: var(--card-text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-lg);
  line-height: 1.4;
  letter-spacing: 0.01em;
  cursor: pointer;
}
.passage input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 28px;
  height: 28px;
  margin: 0;
  border: 2px solid var(--text-muted);
  border-radius: 8px;
  background: transparent;
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.passage input::after {
  content: "";
  width: 7px;
  height: 13px;
  border: solid var(--check-mark, #fff);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg) scale(0);
  margin-top: -2px;
  transition: transform 0.12s;
}
.passage input:checked { background: var(--success); border-color: var(--success); }
.passage input:checked::after { transform: rotate(45deg) scale(1); }
.passage input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.passage input:checked + span { color: var(--passage-read); text-decoration: line-through; }

.install-btn {
  padding: 0.45rem 0.9rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent-contrast);
  background: var(--accent-strong);
  border-radius: 999px;
}
.progress-wrap { display: flex; align-items: center; gap: var(--space-3); padding: 0.6rem var(--space-3); }
.progress-track { flex: 1; height: 8px; border-radius: 999px; overflow: hidden; background: var(--progress-track); }
#progress-percentage { min-width: 3ch; text-align: right; font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-muted); }
#progress-fill {
  width: 0;
  height: 100%;
  background: var(--progress-fill);
  transition: width 0.4s ease;
}
.status-banner { padding: 0.6rem var(--space-3); font-size: var(--fs-sm); font-weight: 600; text-align: center; }
.status-banner--pending { background: var(--pending-bg); color: var(--pending-text); border-bottom: 1px solid var(--pending-border); }
.status-banner--ok { background: var(--ok-bg); color: var(--ok-text); border-bottom: 1px solid var(--ok-border); }

/* Botón de tema */
.theme-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  border-radius: 50%;
}
.theme-btn:hover, .theme-btn:focus-visible { background: var(--surface); }
.theme-btn svg { width: 22px; height: 22px; }
.theme-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-btn .icon-moon { display: none; }

/* Acciones */
.actions { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-3); }
.btn-secondary {
  flex: 1;
  padding: 0.65rem 0.9rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover, .btn-secondary:focus-visible { background: var(--surface); border-color: var(--accent); }
.btn-secondary--danger { color: var(--danger); }
.btn-secondary--danger:hover, .btn-secondary--danger:focus-visible { border-color: var(--danger); }

/* Versículo */
.verse-container {
  padding: var(--space-4) var(--space-4) var(--space-2);
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: var(--fs-base);
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: var(--verse-text);
}
.verse-container cite { display: block; margin-top: var(--space-1); font-size: var(--fs-sm); font-style: normal; letter-spacing: 0.06em; opacity: 0.85; }
.verse-container--modal { padding: 0 var(--space-2); }

/* Barra superior fija */
.sticky-top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-bottom: var(--space-1);
  background-color: var(--column-bg);
  border-bottom: 1px solid var(--appbar-border);
  box-shadow: 0 4px 12px -6px rgba(0, 0, 0, 0.25);
}
.sticky-top-bar .app-bar { position: static; }
