:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #edf7f4;
  --ink: #17231f;
  --muted: #63706b;
  --line: #dfe6e1;
  --primary: #176b5d;
  --primary-2: #0f4d43;
  --accent: #d68a2f;
  --danger: #b83232;
  --success: #238052;
  --warning: #a66a00;
  --shadow: 0 12px 32px rgba(23, 35, 31, 0.09);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 750;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  background: var(--surface-2);
  color: var(--primary-2);
}

.danger {
  background: #f8e7e7;
  color: var(--danger);
}

.ghost {
  background: transparent;
  color: var(--ink);
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(247, 244, 238, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar h1,
.modal h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.4rem;
}

.content {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px;
}

.stack {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 2px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.program-card,
.panel,
.book-row,
.stat-card,
.quick-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.program-card {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 16px;
  color: var(--ink);
  text-align: left;
}

.program-card:focus-visible,
.nav-item:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(214, 138, 47, 0.42);
  outline-offset: 2px;
}

.card-top,
.card-actions,
.meta-row,
.book-main,
.chapter-toolbar,
.quick-actions,
.import-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-actions,
.chapter-toolbar,
.quick-actions,
.import-row {
  flex-wrap: wrap;
}

.card-top,
.meta-row {
  justify-content: space-between;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

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

.small {
  font-size: 0.86rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary-2);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.good {
  background: #e5f5ed;
  color: var(--success);
}

.pill.warn {
  background: #fff1d6;
  color: var(--warning);
}

.pill.bad {
  background: #f8e7e7;
  color: var(--danger);
}

.progress {
  width: 100%;
  height: 9px;
  margin: 6px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ece8;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: linear-gradient(90deg, var(--primary), #42a57f);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.stat-card {
  padding: 12px;
  box-shadow: none;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
}

.panel,
.quick-panel {
  padding: 16px;
}

.quick-panel {
  display: grid;
  gap: 16px;
}

.panel > .progress {
  margin: 14px 0 18px;
}

.program-card > .progress {
  margin: 8px 0 4px;
}

.program-card .card-actions,
.panel .card-actions {
  margin-top: 8px;
}

.panel h2,
.panel h3,
.quick-panel h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0;
}

.today-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.today-history {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(35, 128, 82, 0.22);
  border-radius: var(--radius);
  background: #f0faf5;
}

.today-history strong,
.today-history small {
  display: block;
}

.today-history small {
  margin-top: 2px;
  line-height: 1.35;
}

.schedule-list {
  display: grid;
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
  padding-right: 2px;
}

.schedule-day {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.schedule-day[open] {
  border-color: rgba(23, 107, 93, 0.36);
}

.schedule-day.today {
  box-shadow: inset 3px 0 0 var(--accent);
}

.schedule-day.completed,
.today-panel.completed {
  background: #f0faf5;
  border-color: rgba(35, 128, 82, 0.34);
}

.schedule-day.completed summary strong::before {
  content: "✓ ";
  color: var(--success);
}

.schedule-day summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.schedule-day summary::-webkit-details-marker {
  display: none;
}

.schedule-day summary small {
  display: block;
  margin-top: 3px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 10px;
}

.schedule-actions button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.84rem;
}

.schedule-chapters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

.schedule-check {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.schedule-check:active {
  transform: scale(0.98);
}

.schedule-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.schedule-check small {
  color: var(--muted);
  font-weight: 800;
}

.schedule-check span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.jesus-portion-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.jesus-portion-group em,
.jesus-portion-group strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.jesus-portion-group > small,
.jesus-portion-group em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 750;
}

.jesus-portion-group strong {
  font-size: 0.84rem;
  line-height: 1.35;
}

.jesus-ref-check {
  box-shadow: none;
}

.schedule-check:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.schedule-check:has(input:checked) small {
  color: rgba(255, 255, 255, 0.82);
}

.schedule-check:has(input:checked) span::before {
  content: "✓ ";
}

.today-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.book-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  box-shadow: none;
}

.planned-book.completed {
  background: #f0faf5;
  border-color: rgba(35, 128, 82, 0.28);
}

.jesus-life-list {
  display: grid;
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
  padding-right: 2px;
}

.jesus-life-list h3 {
  margin: 12px 0 2px;
  color: var(--primary-2);
}

.life-event {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.life-event.completed {
  background: #f0faf5;
  border-color: rgba(35, 128, 82, 0.28);
}

.life-event-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.life-event p {
  margin: 4px 0;
  line-height: 1.4;
}

.life-event small {
  display: block;
  overflow-wrap: anywhere;
}

.book-row .progress {
  grid-column: 1 / -1;
}

.book-title {
  margin: 0;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.chapter-check,
.book-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.chapter-check input,
.book-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chapter-check:has(input:checked),
.book-chip:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  max-height: 260px;
  overflow: auto;
  padding: 4px 2px;
}

.filters,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters button,
.segmented button,
.card-actions button,
.chapter-toolbar button,
.quick-actions button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.card-actions button,
.quick-actions button {
  flex: 1 1 104px;
}

.range-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input[type="range"] {
  min-height: 44px;
  padding: 0;
  accent-color: var(--primary);
}

.duration-control {
  align-content: start;
}

.duration-control span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.duration-control strong {
  color: var(--primary-2);
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(23, 35, 31, 0.08);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 58px;
  padding: 4px 2px;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
}

.nav-item span {
  font-size: 1.15rem;
  line-height: 1;
}

.nav-item small {
  font-size: 0.72rem;
  font-weight: 800;
}

.nav-item.active {
  background: var(--surface-2);
  color: var(--primary-2);
}

.modal {
  width: min(calc(100% - 24px), 560px);
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(23, 35, 31, 0.24);
}

.modal::backdrop {
  background: rgba(13, 22, 19, 0.48);
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.modal-actions {
  justify-content: flex-end;
}

.confirm-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.confirm-box p {
  margin: 0;
}

.confirm-box strong {
  overflow-wrap: anywhere;
}

.preview-box {
  min-height: 56px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--primary-2);
  font-size: 0.9rem;
}

.empty-state {
  padding: 28px 18px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 30;
  display: none;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .content {
    padding: 24px;
  }
}
