:root {
  --bg: #0f141b;
  --ink: #efe6da;
  --muted: #c5b8a8;
  --ring: #2a3542;
  --accent: #e8c08d;
  --accent-2: #79a8c7;
  --card: rgba(18, 25, 34, 0.78);
  --panel: rgba(13, 19, 27, 0.88);
  --touch: 54px;
  --radius: 16px;
  --gutter: max(16px, calc(env(safe-area-inset-left) + 14px));
  --gutter-r: max(16px, calc(env(safe-area-inset-right) + 14px));
  --gutter-b: max(10px, env(safe-area-inset-bottom));
  --content-max: 980px;
}

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

html,
body {
  height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(950px 520px at 105% -8%, rgba(232, 192, 141, 0.15), transparent 62%),
    radial-gradient(900px 520px at -8% -4%, rgba(121, 168, 199, 0.16), transparent 62%),
    linear-gradient(180deg, #0c1118 0%, #121a24 40%, #101822 100%);
  background-attachment: fixed;
  font: 16px/1.58 "Avenir Next", "Segoe UI Variable", "Trebuchet MS", "Gill Sans", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  padding: 0 var(--gutter-r) 0 var(--gutter);
}

.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  min-width: 0;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-left: calc(-1 * var(--gutter));
  margin-right: calc(-1 * var(--gutter-r));
  padding: 10px var(--gutter-r) calc(env(safe-area-inset-top)) var(--gutter);
  background: var(--panel);
  border-bottom: 1px solid var(--ring);
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: blur(14px) saturate(125%);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  flex: 0 0 auto;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  letter-spacing: 0.2px;
  transform: translateY(-1px);
}

.mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ring);
  background: linear-gradient(160deg, #232e3b, #1a2430);
  position: relative;
  top: -3px;
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.date {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.header-tools {
  gap: 6px;
  flex-wrap: nowrap;
}

.icon-btn {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 0 10px 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 22px;
  padding: 19px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  min-width: 0;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.3px;
  background: linear-gradient(92deg, #f3e8da 2%, #efc590 58%, #c99a67 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  color: #e8dbcd;
  font-size: 13px;
}

.verse {
  font-size: 30px;
  line-height: 1.45;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  letter-spacing: 0.15px;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.42);
}

.ref.sr-only {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
}

.ref {
  color: #e8e1d7;
}

.tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--ring);
  border-radius: 999px;
  color: #e8e1d7;
  background: rgba(255, 255, 255, 0.02);
}

.bar {
  position: relative;
  z-index: 4;
  background: var(--panel);
  border-top: 1px solid var(--ring);
  padding: 8px 0 calc(8px + var(--gutter-b)) 0;
  backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 -12px 26px rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
}

.bar .inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

button,
.inputlike {
  appearance: none;
  border: 1px solid #314151;
  background: linear-gradient(180deg, #131c27, #101720);
  color: var(--ink);
  padding: 0 14px;
  height: var(--touch);
  border-radius: calc(var(--radius) - 2px);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms ease, border-color 160ms ease, background 180ms ease, box-shadow 180ms ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tags button,
.row button {
  min-height: 50px;
}

button:hover {
  border-color: #50667a;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:focus-visible,
.inputlike:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent) 72%, white 12%);
  outline-offset: 2px;
}

.ghost {
  background: rgba(255, 255, 255, 0.02);
}

.solid {
  background: linear-gradient(180deg, #2b3a49, #1d2935);
  border-color: #516980;
  box-shadow: 0 8px 16px rgba(9, 12, 16, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

mark {
  background: #ffe9a9;
}

@media (min-width: 920px) {
  .verse {
    font-size: 36px;
  }

  .bar .inner .row {
    justify-content: flex-end;
  }
}

dialog#searchDlg,
dialog#favDlg,
dialog#collectionsDlg {
  border: none;
  border-radius: 16px;
  width: min(880px, 95%);
  max-height: 80vh;
  padding: 0;
  background: #121b27;
  color: var(--ink);
  box-shadow: 0 30px 64px rgba(0, 0, 0, 0.48);
}

dialog#quickActionsDlg,
dialog#settingsDlg {
  border: none;
  border-radius: 16px;
  width: min(680px, 95%);
  max-height: 84vh;
  padding: 0;
  background: #121b27;
  color: var(--ink);
  box-shadow: 0 30px 64px rgba(0, 0, 0, 0.48);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.search-input {
  flex: 1;
  padding: 0 12px;
  height: var(--touch);
  border: 1px solid var(--ring);
  border-radius: 12px;
  background: transparent;
  color: inherit;
}

.search-input::placeholder {
  color: #d9d1c6;
}

#searchResults {
  padding: 4px;
}

.result {
  padding: 12px;
  border: 1px solid var(--ring);
  border-radius: 12px;
  margin: 8px 0;
  background: #121a26;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.result:hover {
  border-color: var(--accent);
  background: #162030;
  transform: translateY(-1px);
}

.result .verse {
  color: #fff;
  font-size: 20px;
  line-height: 1.5;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.result .ref {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}

#favList p {
  color: var(--ink);
}

.quick-action-list {
  display: grid;
  gap: 8px;
}

.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-chip {
  border: 1px solid var(--ring);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
}

.theme-chip.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(232, 192, 141, 0.35);
}

.verse-skeleton {
  height: 96px;
  border-radius: 14px;
  border: 1px solid var(--ring);
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 20%, rgba(255, 255, 255, 0.14) 35%, rgba(255, 255, 255, 0.04) 55%);
  background-size: 300% 100%;
  animation: shimmer 1.25s linear infinite;
}

.moments-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.moment-card {
  min-width: 210px;
  max-width: 210px;
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  scroll-snap-align: start;
  cursor: pointer;
}

.moment-card .ref {
  font-size: 12px;
}

.moment-card .txt {
  font-size: 13px;
  color: #e2d6c8;
  margin-top: 6px;
}

.card-enter {
  animation: cardIn 280ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.panel-muted {
  background: rgba(14, 21, 30, 0.86);
}

.daily-prompt {
  color: #dcd0c0;
  margin-top: -2px;
  background: linear-gradient(180deg, rgba(232, 192, 141, 0.17), rgba(232, 192, 141, 0.04));
  border: 1px solid rgba(232, 192, 141, 0.34);
  border-radius: 12px;
  padding: 10px 12px;
}

.daily-loop {
  gap: 10px;
}

.quick-actions {
  align-items: center;
}

.quick-actions button {
  min-height: 52px;
}

.yesterday-wrap {
  border-top: 1px solid var(--ring);
  padding-top: 8px;
}

.yesterday-wrap summary {
  cursor: pointer;
  color: var(--muted);
}

.activity-strip {
  display: flex;
  overflow-x: auto;
  padding-bottom: 4px;
  gap: 8px;
  scroll-snap-type: x mandatory;
}

.activity-day {
  border: 1px solid var(--ring);
  border-radius: 10px;
  padding: 6px;
  background: #0e141c;
  min-height: 68px;
  min-width: 78px;
  scroll-snap-align: start;
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 2px;
}

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

.activity-day .day-num {
  font-size: 14px;
  font-weight: 700;
  color: #f3e8db;
}

.activity-day .day-flags {
  display: flex;
  gap: 4px;
  margin-top: 3px;
}

.activity-day.is-selected {
  border-color: var(--accent);
  background: #151d28;
  box-shadow: 0 0 0 1px rgba(232, 192, 141, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.activity-day.has-viewed {
  box-shadow: inset 0 0 0 1px rgba(90, 145, 200, 0.35);
}

.activity-day.has-noted {
  box-shadow: inset 0 0 0 1px rgba(125, 200, 145, 0.35);
}

.activity-day.has-favorited {
  box-shadow: inset 0 0 0 1px rgba(230, 190, 120, 0.45);
}

#activityDetail {
  min-height: 20px;
  color: #d4c7b7;
}

.state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3f4957;
  border: 1px solid #545f70;
}

.state-dot.is-on.viewed {
  background: #68a8df;
  border-color: #68a8df;
}

.state-dot.is-on.noted {
  background: #69c38a;
  border-color: #69c38a;
}

.state-dot.is-on.favorited {
  background: #e3ba74;
  border-color: #e3ba74;
}

.activity-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: #d2c4b2;
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.viewed {
  background: #68a8df;
}

.legend-dot.noted {
  background: #69c38a;
}

.legend-dot.favorited {
  background: #e3ba74;
}

.collection-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.collection-choice {
  border: 1px solid var(--ring);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}

.collection-choice input {
  margin-right: 6px;
}

.collection-group {
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 10px;
  margin: 10px 0;
  background: rgba(255, 255, 255, 0.02);
}

.collection-group h4 {
  margin: 0 0 8px 0;
}

body.theme-warm-paper {
  --bg: #19140f;
  --ink: #f0e3d0;
  --muted: #c9b297;
  --ring: #4a3a2a;
  --accent: #d8a26b;
  --accent-2: #b67f58;
  --card: rgba(36, 27, 18, 0.84);
  --panel: rgba(29, 21, 15, 0.9);
}

body.theme-ocean-calm {
  --bg: #0c1720;
  --ink: #e6f0f7;
  --muted: #adc2d0;
  --ring: #2e4a5d;
  --accent: #7ab3d1;
  --accent-2: #77c8b6;
  --card: rgba(16, 32, 43, 0.84);
  --panel: rgba(13, 26, 35, 0.9);
}

body.mode-focus #uxRow,
body.mode-focus #insights,
body.mode-focus .bar,
body.mode-focus #activityStrip,
body.mode-focus #activityDetail,
body.mode-focus #momentsStrip,
body.mode-focus #weeklyRecap {
  display: none !important;
}

body.mode-reader .verse {
  font-size: 36px;
  line-height: 1.6;
}

body.mode-reader .card {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes cardIn {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.995);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hidden {
  display: none;
}

.mb-6 {
  margin-bottom: 6px;
}

.mt-8 {
  margin-top: 8px;
}

.m-0 {
  margin: 0;
}

.w-full {
  width: 100%;
}

.h-96 {
  height: 96px;
}

.bg-transparent {
  background: transparent;
}

.row-end {
  justify-content: flex-end;
}

.row-center {
  align-items: center;
}

.row-between {
  align-items: center;
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.scroll-panel {
  margin-top: 8px;
  max-height: 60vh;
  overflow: auto;
  min-width: 0;
}

.tag-dashed {
  border-style: dashed;
  min-width: 160px;
}

.ml-auto {
  margin-left: auto;
}

.fs-12 {
  font-size: 12px;
}

.mw-64 {
  max-width: 64px;
}

.mw-120 {
  max-width: 120px;
}

.mw-140 {
  max-width: 140px;
}

.mw-160 {
  max-width: 160px;
}

.mw-200 {
  max-width: 200px;
}

@media (max-width: 920px) {
  body {
    font-size: 15px;
  }

  .card {
    border-radius: 18px;
    padding: 14px;
  }

  .verse {
    font-size: 25px;
  }

  .title {
    font-size: 21px;
  }

  .quick-actions button {
    flex: 1 1 0;
    max-width: none;
  }

  #uxRow {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #uxRow button {
    width: 100%;
    max-width: none !important;
  }

  .bar {
    padding-top: 6px;
  }

  main {
    padding-bottom: 8px;
  }

  .bar .row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }

  .bar .row button {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: 112px;
  }

  #btn-refresh-site {
    display: none;
  }

  #loadStatus {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .activity-legend {
    font-size: 11px;
    gap: 10px;
  }

  .activity-day {
    min-width: 70px;
    min-height: 64px;
    padding: 6px 5px;
  }

  dialog#searchDlg,
  dialog#favDlg,
  dialog#collectionsDlg {
    width: min(96vw, 680px);
    margin: auto;
  }

  textarea {
    resize: vertical;
  }
}

@media (min-width: 921px) {
  .quick-actions {
    justify-content: flex-start;
  }

  .quick-actions .mw-200 {
    max-width: 190px;
  }

  .activity-strip {
    flex-wrap: nowrap;
  }

  .bar .row {
    gap: 10px;
  }
}
