/* Bible Race PWA — single-file CSS, mobile-first, paper aesthetic */
:root {
  --bg: #f5efe4;
  --paper: #fbf7ee;
  --ink: #2b2017;
  --ink-soft: #6a584a;
  --line: #d9cdb7;
  --accent: #b4632b;
  --accent-soft: #e9b487;
  --danger: #b13a2a;
  --shadow: 0 1px 2px rgba(43, 32, 23, 0.06), 0 4px 12px rgba(43, 32, 23, 0.05);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b160f;
    --paper: #261f16;
    --ink: #f0e6d3;
    --ink-soft: #b6a48a;
    --line: #3a3024;
    --accent: #e09257;
    --accent-soft: #6a3f1c;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC", "Hiragino Sans GB",
    "Source Han Sans SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(220px + var(--safe-bottom));
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
input,
select {
  font: inherit;
  color: inherit;
}

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  font-size: 28px;
  line-height: 1;
}
.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-sub {
  font-size: 12px;
  color: var(--ink-soft);
}

.btn,
.btn-ghost {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn {
  background: var(--accent);
  color: #fff;
}
.btn-ghost {
  border: 1px solid var(--line);
  background: var(--paper);
}
.btn-ghost.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn:active,
.btn-ghost:active {
  opacity: 0.7;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 56px;
  z-index: 9;
}
.tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.content {
  padding: 16px;
}
.view {
  animation: fade 0.2s ease;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== Today ===== */
.today-date {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.today-list {
  display: grid;
  gap: 12px;
}
.today-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.today-card .year-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.today-card .day-num {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.today-card .passage {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: 0.5px;
}
.today-card .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.skeleton {
  padding: 30px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

/* ===== Episode list ===== */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
#search {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  outline: none;
}
#search:focus {
  border-color: var(--accent);
}
.year-picker {
  display: flex;
  gap: 6px;
}
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.ep-list {
  display: grid;
  gap: 6px;
}
.ep-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.1s;
}
.ep-row:active {
  transform: scale(0.99);
}
.ep-row.is-today {
  border-color: var(--accent);
  background: linear-gradient(0deg, var(--paper), var(--paper)), var(--accent-soft);
}
.ep-row.is-cached .ep-cached {
  display: inline;
}
.ep-cached {
  display: none;
  font-size: 11px;
  color: var(--accent);
  margin-left: 4px;
}
.ep-day {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.ep-meta {
  min-width: 0;
}
.ep-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ep-sub {
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  gap: 8px;
  align-items: center;
}
.ep-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
}

/* ===== Calendar ===== */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-title {
  font-size: 18px;
  font-weight: 700;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-grid .cal-head {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 4px 0;
}
.cal-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 6px;
  font-size: 13px;
  cursor: pointer;
  position: relative;
}
.cal-cell.is-today {
  border-color: var(--accent);
  border-width: 2px;
}
.cal-cell.has-ep::after {
  content: "";
  position: absolute;
  bottom: 5px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-cell.is-empty {
  background: transparent;
  border: 0;
  cursor: default;
}

/* ===== Settings ===== */
.view[data-view="settings"] h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin: 20px 0 8px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
}
.row > select,
.row > input[type="time"] {
  background: transparent;
  border: 0;
  text-align: right;
  outline: none;
}
.hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 8px 4px 0;
}

/* ===== Player ===== */
.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  box-shadow: 0 -4px 16px rgba(43, 32, 23, 0.08);
  z-index: 20;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-info {
  flex: 1;
  min-width: 0;
}
.player-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-sub {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-close {
  font-size: 22px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--ink-soft);
}
.player-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.time {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--ink-soft);
  min-width: 36px;
  text-align: center;
}
#p-seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
}
#p-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
}
#p-seek::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
}
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 4px;
}
.ctrl {
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--ink-soft);
}
.ctrl-play {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  display: grid;
  place-items: center;
}
.ctrl-play:active {
  transform: scale(0.95);
}

@media (min-width: 720px) {
  .content {
    max-width: 720px;
    margin: 0 auto;
  }
  .filter-bar {
    flex-direction: row;
    align-items: center;
  }
  .filter-bar #search {
    flex: 1;
  }
  .player {
    max-width: 720px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
    border-radius: 16px 16px 0 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
