:root {
  --bg: #111615;
  --bg-elevated: #1a211f;
  --bg-soft: #222b28;
  --bg-input: #151b19;
  --border: rgba(242, 240, 234, 0.08);
  --text: #f2f0ea;
  --text-muted: #9aa5a0;
  --text-dim: #697570;
  --study: #8fbc94;
  --study-soft: rgba(143, 188, 148, 0.14);
  --read: #e2b87e;
  --read-soft: rgba(226, 184, 126, 0.14);
  --future: #b8c0d4;
  --future-soft: rgba(184, 192, 212, 0.14);
  --danger: #e07a7a;
  --radius-lg: 22px;
  --radius-md: 15px;
  --radius-sm: 12px;
  --serif: "New York", "Iowan Old Style", ui-serif, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.45;
  min-height: 100%;
  overscroll-behavior-y: contain;
}

/* Resplandor cálido orgánico estilo Medito */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 280px;
  background: radial-gradient(ellipse at 50% -20%, rgba(143, 188, 148, 0.14), rgba(226, 184, 126, 0.05) 55%, transparent 78%);
  pointer-events: none;
  z-index: 0;
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  border: 0;
  background: none;
}

/* Mínimo 16px en inputs para evitar zoom automático en iOS Safari */
input, textarea, select {
  font-size: 16px;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(108px + env(safe-area-inset-bottom));
}

.view {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeSlide 180ms ease;
}

.view.active {
  display: flex;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.view-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.subhead {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hint-text {
  margin: 6px 0 12px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Botones e iconos */
.icon-btn, .icon-btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  transition: transform 150ms ease, background 150ms ease;
}

.icon-btn {
  width: 44px;
  height: 44px;
}

.icon-btn-sm {
  width: 36px;
  height: 36px;
  font-size: 18px;
}

.icon-btn:active, .btn-primary:active, .btn-soft:active, .quick-min-btn:active {
  transform: scale(0.97);
}

.btn-primary, .btn-primary-sm, .btn-soft, .btn-soft-sm, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: opacity 150ms ease, transform 150ms ease;
}

.btn-primary {
  min-height: 48px;
  padding: 0 18px;
  background: var(--study);
  color: #0e1612;
  font-size: 15px;
}

.btn-primary-sm {
  min-height: 40px;
  padding: 0 14px;
  background: var(--study);
  color: #0e1612;
  font-size: 14px;
}

.btn-soft {
  min-height: 46px;
  padding: 0 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
}

.btn-soft-sm {
  min-height: 38px;
  padding: 0 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
}

.btn-ghost {
  min-height: 42px;
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.btn-ghost-xs {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

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

.full-width { width: 100%; }
.flex-1 { flex: 1; min-width: 0; }

/* Píldoras horizontales */
.pill-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.pill-row::-webkit-scrollbar { display: none; }

.pill {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-study { background: var(--study-soft); color: var(--study); }
.badge-read { background: var(--read-soft); color: var(--read); }
.badge-future { background: var(--future-soft); color: var(--future); }
.badge-neutral { background: rgba(242, 240, 234, 0.08); color: var(--text-muted); }

/* ==================== VISTA 1: FRASE ==================== */
.quote-card {
  position: relative;
  padding: 28px 22px 22px;
  background: linear-gradient(160deg, #1d2623 0%, #171d1b 100%);
  min-height: 230px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.quote-mark {
  font-family: var(--serif);
  font-size: 54px;
  line-height: 0.7;
  color: var(--read);
  opacity: 0.5;
}

.quote-text {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.45;
  color: var(--text);
}

.quote-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quote-author {
  font-size: 15px;
  font-weight: 600;
  color: var(--read);
}

.quote-source {
  font-size: 13px;
  color: var(--text-muted);
}

.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-chip {
  flex: 1 1 auto;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-chip-accent {
  background: var(--study-soft);
  color: var(--study);
  border-color: rgba(143, 188, 148, 0.25);
}

/* ==================== VISTA 2: TIEMPO Y LIBROS ==================== */
.date-header {
  align-items: center;
}

.date-nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.date-center {
  flex: 1;
  text-align: center;
}

.date-tense-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 2px;
}

.tense-pill {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--study);
}

.tense-pill.past { color: var(--text-muted); }
.tense-pill.future { color: var(--future); }

.today-jump {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--study-soft);
  color: var(--study);
}

.date-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
}

.relay-card {
  background: linear-gradient(145deg, rgba(184, 192, 212, 0.12), var(--bg-elevated));
  border-color: rgba(184, 192, 212, 0.22);
}

.dual-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-bottom: 4px;
}

.dot-study { background: var(--study); }
.dot-read { background: var(--read); }

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

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

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.segmented.small {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 12px;
}

.seg-btn {
  min-height: 40px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 150ms ease, color 150ms ease;
}

.seg-btn.active {
  background: var(--bg-soft);
  color: var(--text);
}

.seg-btn.active[data-ses-type="study"] {
  background: var(--study-soft);
  color: var(--study);
}

.seg-btn.active[data-ses-type="read"] {
  background: var(--read-soft);
  color: var(--read);
}

.book-quick-picker {
  margin-top: 12px;
}

.picker-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.quick-mins {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 14px 0 12px;
}

.quick-min-btn {
  min-height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.manual-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manual-inputs {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.num-field {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  width: 78px;
  min-height: 46px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.num-field span {
  font-size: 12px;
  color: var(--text-muted);
}

.num-field input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.text-input, .select-input, .textarea-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  outline: none;
}

.text-input:focus, .select-input:focus, .textarea-input:focus {
  border-color: rgba(143, 188, 148, 0.5);
}

.textarea-input {
  resize: vertical;
  line-height: 1.5;
}

.timer-details {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.timer-summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  list-style: none;
  padding: 6px 0;
}

.timer-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
}

.timer-display {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.timer-controls {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.session-list, .intention-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.session-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.session-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.session-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.session-del {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 18px;
}

/* Mis Libros */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-item {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.book-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.book-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}

.book-author {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.book-time-pill {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--read-soft);
  color: var(--read);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.book-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.book-stars {
  color: var(--read);
  font-size: 13px;
  letter-spacing: 1px;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Futuro e Intenciones */
.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.intention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.intention-check {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  text-align: left;
  font-size: 14px;
}

.check-box {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--future);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex: 0 0 auto;
}

.intention-item.done .check-box {
  background: var(--study);
  border-color: var(--study);
  color: #0e1612;
}

.intention-item.done .intention-label {
  text-decoration: line-through;
  color: var(--text-dim);
}

/* Pasado: Totales, 7 días, Calendario */
.history-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}

.mini-total {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  text-align: center;
}

.mini-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.mini-total strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.week-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
  height: 112px;
  padding: 10px 4px 0;
}

.week-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.bar-track {
  width: 100%;
  max-width: 22px;
  height: 76px;
  border-radius: 8px;
  background: var(--bg-input);
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
}

.bar-seg-study { background: var(--study); width: 100%; }
.bar-seg-read { background: var(--read); width: 100%; }

.bar-day {
  font-size: 11px;
  color: var(--text-muted);
}

.week-bar-col.active .bar-day {
  color: var(--text);
  font-weight: 700;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 8px;
}

.cal-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
}

.cal-weekdays, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-weekdays span {
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0;
}

.cal-day {
  min-height: 40px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.cal-day.selected {
  background: var(--bg-soft);
  border: 1px solid rgba(242, 240, 234, 0.25);
  font-weight: 700;
}

.cal-day.today {
  color: var(--study);
  font-weight: 700;
}

.cal-dots {
  display: flex;
  gap: 2px;
  height: 4px;
}

.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

/* ==================== VISTA 3: APUNTES ==================== */
.notes-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-chip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--read-soft);
  color: var(--read);
  font-size: 13px;
}

.note-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-top-actions {
  display: flex;
  gap: 8px;
}

.save-status {
  font-size: 12px;
  color: var(--study);
}

.title-field {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}

.editor-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.notes-list, .rss-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-card {
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.note-card-preview {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==================== VISTA 4: CIENCIA RSS ==================== */
.rss-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rss-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.rss-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.35;
}

.rss-summary {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.rss-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.rss-link {
  text-decoration: none;
}

/* ==================== NAVEGACIÓN INFERIOR ==================== */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(17, 22, 21, 0.86);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border);
}

.nav-item {
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color 150ms ease;
}

.nav-item.active {
  color: var(--study);
}

/* ==================== MODALES Y TOAST ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 11, 10, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-form, .settings-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--text-muted);
}

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

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.feed-manager-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.feed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.feed-row-info {
  min-width: 0;
  flex: 1;
}

.feed-row-name {
  font-size: 14px;
  font-weight: 600;
}

.feed-row-url {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-btn {
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 20px 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
