* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: calc(16px * var(--text-scale));
  line-height: 1.55;
  transition: background-color var(--ease-calm), color var(--ease-calm);
}

button,
a {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1060px, calc(100% - 56px));
  margin-inline: auto;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: background-color var(--ease-calm), border-color var(--ease-calm);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 24px;
  letter-spacing: -0.03em;
  background: none;
  border: 0;
  padding: 6px 0;
}

.seal {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: repeating-conic-gradient(from 4deg, var(--gold) 0 4deg, transparent 4deg 14deg);
  transition: background var(--ease-calm);
  flex: none;
}

.seal::before {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--bg);
  transition: background-color var(--ease-calm), border-color var(--ease-calm);
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.desktop-nav button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  color: var(--sub);
  transition: background-color 220ms ease, color 220ms ease;
}

.desktop-nav button:hover {
  background: var(--tint);
  color: var(--ink);
}

.desktop-nav button[aria-current='page'] {
  background: var(--tint);
  color: var(--accent);
}

.icon {
  width: 17px;
  height: 17px;
  display: inline-block;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Main */
main {
  padding: 28px 0 56px;
}

.sectionhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.sectionhead h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.date {
  font-size: 13px;
  color: var(--sub);
}

/* Quick Mood Strip */
/* The feeling row under the heading: a slimmer version of the route card below. */
.feeling-wrap {
  margin-bottom: 16px;
}

.route.feeling {
  width: 100%;
  min-height: 64px;
  padding: 11px 18px;
}

.route.feeling strong {
  font-size: 18px;
}

.mood-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.mood-cue {
  margin: 4px 0 0 2px;
  font-size: 13px;
  color: var(--sub);
  min-height: 20px;
}

/* Reading Folio Card */
.folio {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: background-color var(--ease-calm), border-color var(--ease-calm), box-shadow var(--ease-calm);
}

.spread {
  display: grid;
  grid-template-columns: 1.42fr 1fr;
  align-items: stretch;
  transition: opacity 240ms ease, transform 240ms ease;
}

.spread.is-fading {
  opacity: 0.28;
  transform: translateY(3px);
}

.reading {
  padding: 34px 34px 28px 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.eyebrow::before {
  content: '';
  width: 20px;
  border-top: 2px solid var(--gold);
}

.quote {
  margin: 16px 0 12px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(22px, 2.3vw, 31px);
  line-height: 1.34;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-wrap: pretty;
}

/* A doha card: the couplet in its own script, then a smaller English meaning. */
.original {
  margin: 16px 0 14px;
  font-family: var(--deva);
  /* Scales with the screen so a doha line fits on one row on most phones. */
  font-size: calc(clamp(17px, 4.7vw, 28px) * var(--text-scale));
  line-height: 1.65;
  color: var(--ink);
}

.verse-line {
  display: block;
  padding-left: 1.2em;
  text-indent: -1.2em;
}

.meaning-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.quote.is-meaning {
  margin: 3px 0 12px;
  font-size: calc(17px * var(--text-scale));
  line-height: 1.5;
  letter-spacing: 0;
}

.preview-quote.is-original {
  font-family: var(--deva);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-line;
  -webkit-line-clamp: 4;
}

.source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 4px 0;
  text-align: left;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sub);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: color-mix(in srgb, var(--sub) 45%, transparent);
}

.source:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.divider {
  width: 48px;
  height: 1px;
  background: var(--line);
  margin: 20px 0 16px;
}

.reflection-block {
  border-left: 2px solid var(--gold);
  padding-left: 16px;
}

.reflection-text {
  margin: 0 0 10px;
  font-size: calc(15px * var(--text-scale));
  line-height: 1.58;
  color: var(--sub);
}

.question-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 3px;
}

.question-text {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: calc(18px * var(--text-scale));
  line-height: 1.44;
  color: var(--ink);
}

/* Arched landscape art */
.art {
  margin: 22px 22px 22px 0;
  border-radius: 150px 150px 10px 10px;
  overflow: hidden;
  position: relative;
  min-height: 300px;
  background: var(--tint);
}

.art canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Action bar */
.actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 13px 28px;
  border-top: 1px solid var(--line);
  gap: 10px;
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pill,
.textbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.pill {
  padding: 8px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}

.pill:hover {
  background: var(--tint);
}

.pill[aria-pressed='true'] {
  background: var(--tint);
  border-color: var(--accent);
  color: var(--accent);
}

.textbtn {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  color: var(--ink);
}

.textbtn:hover {
  background: var(--tint);
}

.deck-counter {
  font-size: 13px;
  color: var(--sub);
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

/* Secondary routes below card */
.routes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}

.route {
  border: 1px solid var(--line);
  background: var(--route-bg);
  color: var(--route-ink);
  border-radius: 18px;
  text-align: left;
  padding: 18px 22px;
  display: flex;
  gap: 15px;
  align-items: center;
  min-height: 88px;
  transition: background-color var(--ease-calm), border-color var(--ease-calm), transform 180ms ease;
}

.route.evening {
  background: var(--evening-bg);
  color: var(--evening-ink);
  border-color: var(--evening-line);
}

.route:hover {
  transform: translateY(-1px);
}

.route .symbol {
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}

.route strong {
  display: block;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 21px;
  line-height: 1.2;
}

.route small {
  display: block;
  font-size: 13px;
  opacity: 0.86;
  margin-top: 3px;
}

.route > .icon {
  margin-left: auto;
  opacity: 0.72;
}

/* Explore & Saved lists */
.filter-bar {
  display: grid;
  /* minmax(0, …) lets the chip rows scroll inside the bar instead of widening the page */
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.filter-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

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

.filter-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sub);
  margin-bottom: 4px;
  display: block;
}

.filter-chip {
  white-space: nowrap;
  min-height: 36px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--sub);
  font-size: 13.5px;
  font-weight: 600;
}

.filter-chip[aria-pressed='true'] {
  background: var(--tint);
  border-color: var(--accent);
  color: var(--accent);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.preview-card {
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 200ms ease, background-color 200ms ease, transform 180ms ease;
}

.preview-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.preview-meta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.preview-quote {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.38;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-source {
  font-size: 13px;
  color: var(--sub);
  margin-top: auto;
}

.empty {
  padding: 36px 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  max-width: 560px;
}

.empty h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  margin: 0 0 8px;
}

.empty p {
  color: var(--sub);
  margin: 0 0 18px;
}

/* Settings */
.settings-stack {
  display: grid;
  gap: 16px;
  max-width: 680px;
}

.settings-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 24px;
}

.settings-card h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 23px;
}

.settings-card p {
  margin: 0 0 14px;
  font-size: 14.5px;
  color: var(--sub);
}

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

.source-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--sub);
  font-size: 14.5px;
  line-height: 1.65;
}

.back-btn {
  margin-bottom: 12px;
}

.status {
  color: var(--sub);
  font-size: 13px;
  min-height: 22px;
  margin: 14px 0 0;
}

/* Dialog / Modal */
dialog {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  width: min(470px, calc(100% - 28px));
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  max-height: 84dvh;
  overflow: auto;
}

dialog::backdrop {
  background: rgba(18, 28, 23, 0.56);
  backdrop-filter: blur(3px);
}

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

dialog h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 27px;
  line-height: 1.24;
  margin: 12px 0 10px;
}

dialog p {
  line-height: 1.62;
  color: var(--sub);
  margin: 0 0 14px;
}

.close {
  border: 0;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  background: var(--tint);
  color: var(--ink);
  font-size: 22px;
  display: grid;
  place-items: center;
  flex: none;
}

dialog a {
  color: var(--accent);
  font-weight: 600;
  text-underline-offset: 4px;
}

.choices {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.choice {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding: 13px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
  gap: 12px;
}

.choice strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.choice small {
  display: block;
  font-size: 12.5px;
  color: var(--sub);
  margin-top: 2px;
}

.choice[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--tint);
}

/* Mobile bottom navigation */
.mobile-nav {
  display: none;
}

@media (max-width: 760px) {
  .shell {
    width: min(600px, calc(100% - 28px));
  }

  .top {
    min-height: 60px;
  }

  .brand {
    font-size: 21px;
    gap: 9px;
  }

  .seal {
    width: 27px;
    height: 27px;
  }

  .seal::before {
    width: 15px;
    height: 15px;
  }

  .desktop-nav {
    display: none;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--paper) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    transition: background-color var(--ease-calm), border-color var(--ease-calm);
  }

  .mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--sub);
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px;
  }

  .mobile-nav button[aria-current='page'] {
    color: var(--accent);
    background: var(--tint);
  }

  main {
    padding: 18px 0 98px;
  }

  .sectionhead {
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
  }

  .spread {
    grid-template-columns: 1fr;
  }

  /* Preserve gentle signature arch on mobile */
  .art {
    order: -1;
    margin: 16px 16px 0;
    border-radius: 130px 130px 10px 10px;
    min-height: 154px;
    max-height: 154px;
  }

  .reading {
    padding: 20px 20px 22px;
  }

  .quote {
    font-size: clamp(22px, 6.2vw, 27px);
    margin: 12px 0 10px;
  }

  .actionbar {
    padding: 12px 16px;
  }

  .routes {
    gap: 10px;
  }

  .route {
    min-height: 76px;
    padding: 15px 18px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
