/* ---------- Design tokens (light + dark) ---------- */
:root {
  --bg: #ffffff;
  --card: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --accent: #1fb57b;
  --accent-2: #3aa0ff;
  --accent-3: #8b5cf6;
  --danger: #ef4444;
  --danger-2: #b91c1c;
  --grid: #e6edf3;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(16, 24, 40, .06);
  --nav-height: 64px;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --card: #0f1724;
  --muted: #98a2b3;
  --text: #e6eef6;
  --accent: #22c55e;
  --accent-2: #60a5fa;
  --accent-3: #a78bfa;
  --danger: #ff6b6b;
  --danger-2: #dc2626;
  --grid: #111827;
  --shadow: 0 12px 30px rgba(2, 6, 23, .6);
  /* tells the browser to render native form controls (the <select>
     dropdown arrow, etc.) in dark styling instead of always defaulting
     to a light-mode icon that's hard to see on our dark background */
  color-scheme: dark;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased
}

.container {
  max-width: 900px;
  /* smaller than 1080px to fit nicely */
  margin: 24px auto;
  /* slightly less top/bottom margin */
  padding: 12px;
  /* reduce padding so calendar fits vertically */
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--grid);
  overflow: clip;
}

/* Site navbar */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--grid);
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
  transition: transform .25s ease;
}

/* Hides the navbar on scroll-down; only its visual position moves
   (transform), never its box height — changing height here would
   reflow the content below it and fight with the browser's scroll
   anchoring, which reintroduces the exact scroll it's reacting to. */
body.nav-hidden .site-nav {
  transform: translateY(-100%);
}

.nav-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-logo img {
  display: block;
  height: 46px;
  width: auto;
}

/* patro-light-nav.png has noticeably less transparent padding around the
   wordmark than logo-main.svg's viewBox does, so matching the raw image
   height (46px) actually renders the dark-mode logo mark visibly larger.
   Sized down so the visible mark reads the same size in both themes. */
[data-theme="dark"] .nav-logo img {
  height: 40px;
}

/* Header */
.cal-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 18px 20px;
  position: sticky;
  top: var(--nav-height);
  background: var(--card);
  z-index: 10;
  border-bottom: 1px solid var(--grid);
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
  transition: top .25s ease;
}

/* when the navbar slides away, let the calendar header stick
   right at the top instead of leaving its reserved gap behind */
body.nav-hidden .cal-header {
  top: 0;
}

.header-left {
  font-weight: 700;
  font-size: 20px;
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
  text-align: left
}

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

.header-right {
  font-weight: 700;
  text-align: right;
  color: var(--muted);
  font-size: 14px
}

.select {
  background: transparent;
  border: 1px solid var(--grid);
  padding: 9px 34px 9px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  position: relative;
  outline: none;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--grid);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  box-sizing: border-box;
  text-decoration: none;
}

.btn:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
  transform: translateY(-1px)
}

.btn-icon {
  padding: 8px 12px;
  font-size: 16px;
  line-height: 1;
  border-radius: 999px;
}

/* --grid is nearly the same navy as --card in dark mode, so a plain
   1px solid var(--grid) border on the month/year selects and the
   prev/next/theme icon buttons was effectively invisible there. */
[data-theme="dark"] .select,
[data-theme="dark"] .btn {
  border-color: rgba(255, 255, 255, 0.18);
}

/* Today buttons — light green accent, same tint/opacity treatment as
   the Sat/Sun weekend columns, just on --accent instead of --danger */
.btn-today {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--card) 94%);
  background: rgba(31, 181, 123, 0.06);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--grid) 80%);
  border: 1px solid rgba(31, 181, 123, 0.20);
  /* fallback */
}

.btn-today:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--card) 90%);
  background: rgba(31, 181, 123, 0.10);
  /* fallback */
}

[data-theme="dark"] .btn-today {
  background: color-mix(in srgb, var(--accent) 10%, var(--card) 90%);
  background: rgba(34, 197, 94, 0.10);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--grid) 75%);
  border: 1px solid rgba(34, 197, 94, 0.25);
  /* fallback */
}

[data-theme="dark"] .btn-today:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--card) 84%);
  background: rgba(34, 197, 94, 0.16);
  /* fallback */
}

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

/* Theme toggle — sun shows in light mode (click to go dark), moon shows
   in dark mode (click to go light); swapped via the data-theme attribute
   set in initThemeToggle(). */
.theme-toggle {
  color: var(--muted);
}

.theme-icon {
  width: 18px;
  height: 18px;
}

.theme-icon-moon {
  display: none;
}

[data-theme="dark"] .theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-icon-moon {
  display: block;
}

/* Convert nav button — same tint recipe as .btn-today, on --accent-2
   (blue) instead, so it reads as a distinct action next to Today */
.btn-convert {
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 6%, var(--card) 94%);
  background: rgba(58, 160, 255, 0.06);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--accent-2) 20%, var(--grid) 80%);
  border: 1px solid rgba(58, 160, 255, 0.20);
  /* fallback */
}

.btn-convert:hover {
  background: color-mix(in srgb, var(--accent-2) 10%, var(--card) 90%);
  background: rgba(58, 160, 255, 0.10);
  /* fallback */
}

.btn-convert[aria-current="page"] {
  color: #fff;
  background: var(--accent-2);
  border-color: var(--accent-2);
}

[data-theme="dark"] .btn-convert {
  background: color-mix(in srgb, var(--accent-2) 10%, var(--card) 90%);
  background: rgba(96, 165, 250, 0.10);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--accent-2) 25%, var(--grid) 75%);
  border: 1px solid rgba(96, 165, 250, 0.25);
  /* fallback */
}

[data-theme="dark"] .btn-convert:hover {
  background: color-mix(in srgb, var(--accent-2) 16%, var(--card) 84%);
  background: rgba(96, 165, 250, 0.16);
  /* fallback */
}

[data-theme="dark"] .btn-convert[aria-current="page"] {
  color: #0b1220;
  background: var(--accent-2);
  border-color: var(--accent-2);
}

/* "Find DOB" nav link + the tithi finder's own primary elements — same
   tint recipe as .btn-convert, just on --accent-3 (a calmer violet)
   instead of --accent-2, so the tithi tool reads as its own distinct
   identity next to Convert/Today rather than blending into Convert's
   blue. */
.btn-dob {
  color: var(--accent-3);
  background: color-mix(in srgb, var(--accent-3) 6%, var(--card) 94%);
  background: rgba(139, 92, 246, 0.06);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--accent-3) 20%, var(--grid) 80%);
  border: 1px solid rgba(139, 92, 246, 0.20);
  /* fallback */
}

.btn-dob:hover {
  background: color-mix(in srgb, var(--accent-3) 10%, var(--card) 90%);
  background: rgba(139, 92, 246, 0.10);
  /* fallback */
}

.btn-dob[aria-current="page"] {
  color: #fff;
  background: var(--accent-3);
  border-color: var(--accent-3);
}

[data-theme="dark"] .btn-dob {
  background: color-mix(in srgb, var(--accent-3) 10%, var(--card) 90%);
  background: rgba(167, 139, 250, 0.10);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--accent-3) 25%, var(--grid) 75%);
  border: 1px solid rgba(167, 139, 250, 0.25);
  /* fallback */
}

[data-theme="dark"] .btn-dob:hover {
  background: color-mix(in srgb, var(--accent-3) 16%, var(--card) 84%);
  background: rgba(167, 139, 250, 0.16);
  /* fallback */
}

[data-theme="dark"] .btn-dob[aria-current="page"] {
  color: #0b1220;
  background: var(--accent-3);
  border-color: var(--accent-3);
}

/* Today strip — persistent, clickable summary of today's date/event
   above the grid (see #todayStrip in index.html / renderTodayStrip()).
   Reuses the same green "today" / red "day off" language as the rest of
   the calendar (.is-today / .is-holiday) instead of inventing a new
   palette. */
.today-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 20px;
  cursor: pointer;
  background: color-mix(in srgb, var(--accent) 6%, var(--card) 94%);
  background: rgba(31, 181, 123, 0.06);
  /* fallback */
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
  transition: background .12s ease;
}

.today-strip[hidden] {
  display: none;
}

.today-strip:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--card) 90%);
  background: rgba(31, 181, 123, 0.10);
  /* fallback */
}

.today-strip-label {
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .04em;
}

.today-strip-date {
  font-weight: 800;
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
  color: var(--text);
}

.today-strip-weekday {
  color: var(--muted);
  font-weight: 600;
}

.today-strip-arrow {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

[data-theme="dark"] .today-strip {
  border-bottom-color: rgba(255, 255, 255, 0.18);
  background: rgba(34, 197, 94, 0.08);
}

[data-theme="dark"] .today-strip:hover {
  background: rgba(34, 197, 94, 0.14);
}

/* Weekend/holiday variant — same red "day off" treatment used for
   .cell.is-holiday and the day-modal's "आज" pill, for consistency. */
.today-strip.is-dayoff {
  background: color-mix(in srgb, var(--danger) 6%, var(--card) 94%);
  background: rgba(239, 68, 68, 0.06);
  /* fallback */
}

.today-strip.is-dayoff:hover {
  background: color-mix(in srgb, var(--danger) 10%, var(--card) 90%);
  background: rgba(239, 68, 68, 0.10);
  /* fallback */
}

.today-strip.is-dayoff .today-strip-label,
.today-strip.is-dayoff .today-strip-arrow {
  color: var(--danger);
}

[data-theme="dark"] .today-strip.is-dayoff {
  background: rgba(255, 107, 107, 0.10);
}

[data-theme="dark"] .today-strip.is-dayoff:hover {
  background: rgba(255, 107, 107, 0.16);
}

@media (max-width: 760px) {
  .today-strip {
    padding: 8px 14px;
    font-size: 12px;
  }
}

/* Weekdays */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 10px;
  background: var(--grid)
}

.weekday {
  background: color-mix(in srgb, var(--card) 94%, #fff 6%);
  padding: 10px 6px;
  text-align: center;
  border-radius: 10px;
  min-height: 56px
}

.weekday .np {
  display: block;
  font-weight: 800;
  font-family: "Noto Sans Devanagari", Inter, sans-serif
}

.weekday .en {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 12px
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 18px;
  background: transparent;
  /* let the browser handle vertical page scroll natively; the swipe JS
     takes over (via preventDefault) only once a horizontal drag is detected */
  touch-action: pan-y;
}

.cell {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: 12px;
  min-height: 110px;
  padding: 12px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform .08s ease
}

/* --grid is nearly the same navy as --card in dark mode, so a plain cell's
   border was effectively invisible there (weekend/holiday cells already get
   their own tinted dark border further below — this covers everyday cells,
   including dimmed leading/trailing ones from adjacent months). */
[data-theme="dark"] .cell {
  border-color: rgba(255, 255, 255, 0.18);
}

.cell:hover {
  transform: translateY(-4px)
}

.cell.dim {
  opacity: .45
}

.cell.is-today {
  box-shadow: 0 8px 30px rgba(31, 181, 123, .12);
  border: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
}

/* Deep-linked date from convert.html's "View on calendar" — set via
   state.highlightIso in index.html. Uses --accent-2 (blue) rather than
   the --today green so the two meanings ("today" vs "the date you just
   converted") stay visually distinct even if they land on the same cell. */
.cell.is-highlighted {
  box-shadow: 0 8px 30px color-mix(in srgb, var(--accent-2) 25%, transparent);
  border: 2px solid var(--accent-2);
  animation: highlightPulse 1s ease-out 2;
}

@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 45%, transparent);
  }

  100% {
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent-2) 0%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell.is-highlighted {
    animation: none;
  }
}

.np-date {
  font-size: 26px;
  font-weight: 800;
  font-family: "Noto Sans Devanagari", Inter, sans-serif
}

.en-date {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

.badges {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.badge.holiday {
  background: var(--danger)
}

.badge.community {
  background: var(--danger-2)
}

.events {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px
}

.event {
  background: color-mix(in srgb, var(--grid) 60%, transparent);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

/* ------------------------------
   Weekend columns — pale red style
   Saturday (7th column) has long been Nepal's weekly holiday; Sunday
   (1st column) was added as a second weekly holiday more recently, so
   both get the same accent treatment.
   ------------------------------ */

/* Saturday + Sunday weekday header (7th and 1st columns) */
.weekdays .weekday:nth-child(7),
.weekdays .weekday:nth-child(1) {
  color: var(--danger);
  font-weight: 800;
  /* subtle red-tinted background that respects light/dark card color */
  background: color-mix(in srgb, var(--danger) 6%, var(--card) 94%);
  /* fallback for browsers that don't support color-mix */
  background: rgba(239, 68, 68, 0.06);
  border-radius: 10px;
}

/* Saturday + Sunday cells: every 7th grid child, and every 7th child + 1 */
.grid .cell:nth-child(7n),
.grid .cell:nth-child(7n+1) {
  /* text tint */
  color: color-mix(in srgb, var(--danger) 90%, var(--text) 10%);
  /* pale red background that blends with the card */
  background: color-mix(in srgb, var(--danger) 6%, var(--card) 94%);
  background: rgba(239, 68, 68, 0.04);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--danger) 20%, var(--grid) 80%);
  border: 1px solid rgba(239, 68, 68, 0.12);
  /* fallback */
}

/* Make the Nepali + English dates appear red/stronger on Saturday + Sunday */
.grid .cell:nth-child(7n) .np-date,
.grid .cell:nth-child(7n) .en-date,
.grid .cell:nth-child(7n+1) .np-date,
.grid .cell:nth-child(7n+1) .en-date {
  color: var(--danger);
  font-weight: 800;
}

/* Ensure badges/events inside Saturday + Sunday cells look consistent */
.grid .cell:nth-child(7n) .badge,
.grid .cell:nth-child(7n+1) .badge {
  background: var(--danger) !important;
  color: #fff !important;
}

/* Slightly stronger hover for Saturday + Sunday cells (optional feel) */
.grid .cell:nth-child(7n):hover,
.grid .cell:nth-child(7n+1):hover {
  background: color-mix(in srgb, var(--danger) 10%, var(--card) 90%);
  background: rgba(239, 68, 68, 0.06);
  /* fallback */
}

/* Dark theme tweaks (uses same variables so usually fine, but increase tint for visibility) */
[data-theme="dark"] .weekdays .weekday:nth-child(7),
[data-theme="dark"] .weekdays .weekday:nth-child(1),
[data-theme="dark"] .grid .cell:nth-child(7n),
[data-theme="dark"] .grid .cell:nth-child(7n+1) {
  background: color-mix(in srgb, var(--danger) 10%, var(--card) 90%);
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--grid) 75%);
  border: 1px solid rgba(239, 68, 68, 0.18);
  /* fallback */
}

/* Days with an official बिदा (holiday/tithi) get the same "day off" red
   treatment as Saturday/Sunday, regardless of which weekday they land on
   — reddit feedback: this should NOT apply to सामुदायिक-only days, since
   those aren't an actual day off (see isHoliday in buildCell()). Badge
   colors are left alone here (unlike the weekend rule below) so a mixed
   day showing both a बिदा and a सामुदायिक badge keeps each its own color. */
.grid .cell.is-holiday {
  color: color-mix(in srgb, var(--danger) 90%, var(--text) 10%);
  background: color-mix(in srgb, var(--danger) 6%, var(--card) 94%);
  background: rgba(239, 68, 68, 0.04);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--danger) 20%, var(--grid) 80%);
  border: 1px solid rgba(239, 68, 68, 0.12);
  /* fallback */
}

.grid .cell.is-holiday .np-date,
.grid .cell.is-holiday .en-date {
  color: var(--danger);
  font-weight: 800;
}

.grid .cell.is-holiday:hover {
  background: color-mix(in srgb, var(--danger) 10%, var(--card) 90%);
  background: rgba(239, 68, 68, 0.06);
  /* fallback */
}

[data-theme="dark"] .grid .cell.is-holiday {
  background: color-mix(in srgb, var(--danger) 10%, var(--card) 90%);
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--grid) 75%);
  border: 1px solid rgba(239, 68, 68, 0.18);
  /* fallback */
}

/* "Today" must keep its green border even when it lands on a weekend or a
   बिदा — those rules match with equal/higher specificity and are defined
   later, so without this override the border gets silently replaced by
   the weekend/holiday red border (e.g. today being a Saturday). The red
   background/text fill from the weekend/holiday rules is intentionally
   left alone — a weekend/holiday "today" should still read as red inside,
   just with the green today-border around it. */
.grid .cell.is-today {
  border: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
}

[data-theme="dark"] .grid .cell.is-today {
  border: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
}

/* Responsive: Mobile (max-width 760px) */
@media (max-width:760px) {

  :root {
    --nav-height: 52px;
  }

  .nav-logo img {
    height: 46px;
  }

  /* Two nav buttons + the theme toggle don't fit at their desktop size on
     a phone-width screen — same compacting recipe already used for
     .header-center .btn below. */
  .site-nav {
    padding: 0 12px;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-actions .btn:not(.btn-icon) {
    padding: 7px 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Calendar header: left, center, right in one row */
  .cal-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0;
  }

  .header-left,
  .header-center,
  .header-right {
    /* flex-basis:100% forces each onto its own row every time, regardless
       of how wide that month's BS/AD label happens to be — with the
       previous auto basis, some months' shorter labels left just enough
       room to squeeze onto a shared line with part of the next section,
       so the header stacked into 3 clean rows for some months but not
       others (e.g. भदौ vs आश्विन). */
    flex: 1 1 100%;
    text-align: center;
    /* keep centered for all items */
    font-size: 14px;
  }

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

  .header-center .select {
    padding: 6px 22px 6px 8px;
    font-size: 12px;
  }

  .header-center .btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .header-center .btn-icon {
    padding: 6px 10px;
  }

  /* Weekday font smaller */
  .weekdays div {
    font-size: 12px;
  }

  .weekdays div div:first-child {
    font-size: 14px;
    /* Nepali day */
  }

  .weekdays div div:last-child {
    font-size: 10px;
    /* English day */
  }

  /* Grid adjustments */
  .grid {
    padding: 8px;
    grid-gap: 6px;
  }

  .cell {
    min-height: 76px;
    padding: 8px 6px;
    font-size: 14px;
    /* Nepali date */
  }

  .cell .en-date {
    right: 4px;
    bottom: 6px;
    font-size: 9.5px;
    /* English date smaller */
  }

  /* At mobile cell widths (~50-60px) there isn't room for a full
     text pill ("बिदा"/"सामुदायिक") next to the date number without
     it overlapping — see .badges below. Collapse each badge to a
     small color dot instead: still communicates "something's on this
     day" and its type via color, full label is one tap away in the
     day-detail modal. */
  .badges {
    top: 6px;
    right: 6px;
    gap: 4px;
  }

  .cell .badge {
    width: 8px;
    height: 8px;
    padding: 0;
    font-size: 0;
    line-height: 0;
    overflow: hidden;
  }

  /* Full event-label list is unreadable at this width and was the
     other half of the squeeze — the day-detail modal (tap any date)
     already shows it in full, so skip rendering it in the cell. */
  .cell .events {
    display: none;
  }

  /* Day night toggle smaller */
  .toggle-wrapper {
    transform: scale(0.8);
  }
}

/* Smallest phones (e.g. 320px-wide legacy devices) need a bit more room
   still for the nav bar — trimmed further here instead of in the general
   760px rule above, so the common 375-430px phone range keeps the
   roomier buttons. */
@media (max-width:340px) {
  .site-nav {
    padding: 0 8px;
  }

  .nav-logo img {
    height: 38px;
  }

  .nav-actions {
    gap: 4px;
  }

  .nav-actions .btn:not(.btn-icon) {
    padding: 6px 7px;
    font-size: 11px;
  }

  /* Grid columns are narrower still at this width — a couple more px
     off .en-date closes out the last bit of left-edge overhang on
     2-digit-day dates (e.g. "26 Sep"). */
  .cell .en-date {
    right: 3px;
    font-size: 9px;
  }
}

/* Site footer (layout matches syndi.khudra.asia, light variant) */
.site-footer {
  background: var(--card);
  margin-top: 3rem;
  padding: 4.5rem 4rem;
  border-radius: 32px 32px 0 0;
  /* shadow above the curved top edge so it reads as a distinct
     surface from the page background instead of blending flat */
  box-shadow: 0 -16px 32px -20px rgba(16, 24, 40, .18);
  position: relative;
}

.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2rem;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.footer-logo img {
  display: block;
  height: 92px;
  width: auto;
}

.footer-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.85rem;
}

.social-links {
  display: flex;
  align-items: center;
  list-style: none;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.social-links a:hover {
  background: var(--grid);
  color: var(--text);
}

.social-links svg {
  width: 24px;
  height: 24px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.footer-copyright {
  font-size: 12px;
  color: var(--muted);
}

.footer-copyright a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-copyright a:hover {
  color: var(--accent);
}

@media (max-width:600px) {
  .footer-top {
    justify-content: center;
    text-align: center;
  }

  .footer-right {
    align-items: center;
  }

  .site-footer {
    border-radius: 20px 20px 0 0;
    padding: 3rem 1.5rem;
  }
}

/* Day detail modal — opened by clicking a calendar cell, shows the
   day's full, untruncated info since the grid cell itself has to
   clip long/multiple event labels to stay compact. */
.day-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.day-modal-overlay[hidden] {
  display: none;
}

.day-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  animation: day-modal-in .18s ease;
}

@keyframes day-modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.day-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--grid);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Replaced by the intentional, theme-matched :focus-visible ring below
     instead of the browser's default outline (typically blue). */
  outline: none;
}


/* --grid is nearly the same navy as --card in dark mode, so the plain
   var(--grid) border/border-bottom on the modal, its close button, and
   its header divider (all below) were effectively invisible there. */
[data-theme="dark"] .day-modal {
  border-color: rgba(255, 255, 255, 0.18);
}

[data-theme="dark"] .day-modal-close {
  border-color: rgba(255, 255, 255, 0.18);
}

[data-theme="dark"] .day-modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.18);
}

.day-modal-close:hover {
  background: var(--grid);
  color: var(--text);
}

.day-modal-header {
  position: relative;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 14px;
  row-gap: 4px;
  padding: 0 32px 16px 0;
  border-bottom: 1px solid var(--grid);
  margin-bottom: 16px;
}

.day-modal-np {
  /* Always takes the full row so the weekday/English-date meta below it
     wraps onto its own line consistently — without this, a short Nepali
     date (e.g. single-digit day) left enough room for .day-modal-meta to
     sit beside it instead of stacking below, unlike longer dates. */
  flex: 0 0 100%;
  font-size: 42px;
  font-weight: 800;
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
  color: var(--text);
  line-height: 1;
}

.day-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.day-modal-weekday {
  font-weight: 700;
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
  font-size: 15px;
  color: var(--text);
}

.day-modal-en {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.day-modal-today-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
}

/* A weekend or an official बिदा (holiday/tithi) is a day off, so "today"
   on one of those reads with the same red as a regular बिदा badge instead
   of the default green — see isDayOff in openDayModal(). */
.day-modal-today-pill.is-dayoff {
  background: var(--danger);
}

.day-modal-events {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-modal-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--grid) 60%, transparent);
}

.day-modal-event .badge {
  flex-shrink: 0;
  margin-top: 1px;
}

.day-modal-event-label {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
  line-height: 1.4;
}

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

body.modal-open {
  overflow: hidden;
}

/* ------------------------------
   Convert page — AD <-> BS date converter
   ------------------------------ */
.convert-body {
  padding: 28px 24px 32px;
}

.convert-tabs {
  display: flex;
  gap: 4px;
  background: var(--grid);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.convert-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.convert-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(16, 24, 40, .08);
}

/* --card and --grid (the tabs' track) are nearly the same dark navy in
   dark mode, so the plain .card background above barely reads as
   "selected" — give the active tab an accent-tinted background + border
   instead, same recipe already used for .btn-today/.btn-convert. */
[data-theme="dark"] .convert-tab.active {
  background: color-mix(in srgb, var(--accent-2) 20%, var(--card) 80%);
  background: rgba(96, 165, 250, 0.18);
  /* fallback */
  border: 1px solid color-mix(in srgb, var(--accent-2) 35%, transparent);
  border: 1px solid rgba(96, 165, 250, 0.35);
  /* fallback */
  box-shadow: none;
}

.convert-panel[hidden] {
  display: none;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.bs-select-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 8px;
}

.bs-select-row .select {
  width: 100%;
  padding: 11px 30px 11px 12px;
  font-size: 15px;
}

.convert-result {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in srgb, var(--grid) 55%, transparent);
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 20px 16px;
}

/* --grid is nearly the same navy as --card in dark mode, so the plain
   1px solid var(--grid) border above was effectively invisible there
   (same issue as the month/year selects and icon buttons on index.html). */
[data-theme="dark"] .convert-result {
  border-color: rgba(255, 255, 255, 0.18);
}

.convert-result-side {
  flex: 1;
  min-width: 0;
  text-align: center;
}

/* Default order: source (BS) first, converted (AD) second — matches the
   BS -> AD tab. On the AD -> BS tab, .is-reversed flips it so the side
   you're typing into still reads first, left-to-right. */
.convert-result-side.is-bs {
  order: 1;
}

.convert-result-side.is-en {
  order: 3;
}

.convert-result.is-reversed .convert-result-side.is-bs {
  order: 3;
}

.convert-result.is-reversed .convert-result-side.is-en {
  order: 1;
}

.convert-result-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.convert-result-date {
  font-size: 22px;
  font-weight: 800;
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
}

.convert-result-side.is-bs .convert-result-date {
  color: var(--accent);
}

.convert-result-side.is-en .convert-result-date {
  color: var(--accent-2);
}

.convert-result-weekday {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
}

.convert-result-arrow {
  order: 2;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 20px;
}

.convert-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.convert-actions .btn-convert {
  padding: 10px 18px;
}

@media (max-width:600px) {
  .convert-body {
    padding: 20px 16px 24px;
  }

  .bs-select-row {
    grid-template-columns: 1fr;
  }

  .convert-result {
    flex-direction: column;
  }

  .convert-result-arrow {
    transform: rotate(90deg);
  }
}

/* FAQ accordion */
/* About panel — gives the intro copy the same card treatment as the
   calendar above and the FAQ items below, instead of floating as bare
   text on the page background. */
.about-section {
  max-width: 900px;
  margin: 3rem auto 0;
  padding: 0 12px;
}

.about-panel {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 680px;
  margin: 0 auto;
  padding: 32px clamp(20px, 5vw, 48px);
}

.about-eyebrow,
.faq-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.faq-eyebrow {
  text-align: center;
}

.about-heading {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.about-text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  text-align: left;
}

.about-text:last-child {
  margin-bottom: 0;
}

.about-text strong {
  color: var(--text);
  font-weight: 700;
}

.faq-section {
  max-width: 800px;
  margin: 2.5rem auto;
  padding: 0 12px;
}

.faq-section h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin: 0 0 1.25rem;
}

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

.faq-item {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: 12px;
  overflow: clip;
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  flex: none;
  font-size: 20px;
  font-weight: 400;
  color: var(--muted);
  transition: transform .15s ease;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item p {
  margin: 0;
  padding: 0 18px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.faq-item p .badge {
  display: inline-block;
  vertical-align: middle;
  margin: 0 2px;
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
}

/* Swipe hint toast — shown once to first-time mobile visitors, see
   initSwipeHint() in index.html */
.swipe-hint {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  max-width: 90vw;
  width: max-content;
  transform: translateX(-50%) translateY(10px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}

.swipe-hint.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.swipe-hint-icon {
  display: inline-block;
  margin-right: 4px;
  animation: swipeHintNudge 1.4s ease-in-out infinite;
}

/* Tap hint reuses the same pill but its icon is a static dot (echoing
   the mobile badge dot it's explaining) rather than a left-right nudge —
   a bidirectional wiggle only reads as "swipe" for the arrow glyph. */
.swipe-hint-icon--dot {
  animation: none;
  color: var(--danger);
  font-size: 10px;
  vertical-align: 2px;
}

@keyframes swipeHintNudge {

  0%,
  100% {
    transform: translateX(-3px);
  }

  50% {
    transform: translateX(3px);
  }
}

@media (min-width:761px) {
  .swipe-hint {
    display: none;
  }
}

/* Desktop/non-touch onboarding hints (initNavHint in index.html) reuse the
   same pill, but their messages are longer than the mobile swipe/tap hints
   above, so unlike those they're allowed to wrap onto a second line instead
   of forcing one long nowrap pill. Also overrides the min-width:761px rule
   above that hides .swipe-hint on desktop, since these are desktop-only. */
.swipe-hint.desktop-hint {
  display: block;
  white-space: normal;
  width: 260px;
  max-width: 90vw;
}

@media (max-width:760px) {
  .swipe-hint.desktop-hint {
    display: none;
  }
}

/* 404 page — reuses the .card/.btn visual language rather than a
   bespoke look, so it still reads as "this site" instead of a generic
   error screen. */
.error-page {
  max-width: 560px;
  margin: 4.5rem auto;
  padding: 0 12px;
  text-align: center;
}

.error-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 44px;
  margin-bottom: 28px;
}

.error-cell-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--danger);
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
}

.error-cell-number {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1;
}

.error-cell-sub {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
}

.error-heading {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 10px;
}

.error-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 24px;
}

.error-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ------------------------------
   Tithi-based date-of-birth finder (tithi-dob-finder.html)
   ------------------------------ */
.tithi-body {
  padding: 28px 24px 32px;
}

.tithi-field {
  margin-bottom: 22px;
}

.tithi-field-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.5;
}

.tithi-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tithi-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--grid);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

[data-theme="dark"] .tithi-chip {
  border-color: rgba(255, 255, 255, 0.18);
}

.tithi-chip:hover {
  background: color-mix(in srgb, var(--accent-3) 8%, var(--card) 92%);
}

/* Same transparent accent-3 tint as .tithi-candidate-card.is-highlighted
   in the results section, instead of a solid fill — --accent-3 itself
   already swaps light/dark shades, so no separate dark-mode override
   is needed here. This tool's whole "identity" color (nav link, submit
   button, chips, result highlights) is --accent-3, kept deliberately
   distinct from Convert's --accent-2 blue. */
.tithi-chip.is-active {
  background: color-mix(in srgb, var(--accent-3) 8%, var(--card) 92%);
  background: rgba(139, 92, 246, 0.08);
  /* fallback */
  border-color: var(--accent-3);
  color: var(--accent-3);
}

.tithi-select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tithi-year-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 10px;
  align-items: end;
}

.tithi-input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--grid);
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}

[data-theme="dark"] .tithi-input {
  border-color: rgba(255, 255, 255, 0.18);
}

.tithi-submit-row {
  margin-top: 8px;
}

.tithi-submit-row .btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.tithi-results {
  margin-top: 28px;
}

.tithi-result-summary {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 14px;
}

.tithi-hint {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  background: color-mix(in srgb, var(--grid) 55%, transparent);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0;
}

.tithi-candidate-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tithi-candidate-card {
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--grid) 30%, transparent);
}

[data-theme="dark"] .tithi-candidate-card {
  border-color: rgba(255, 255, 255, 0.18);
}

.tithi-candidate-card.is-highlighted {
  border: 2px solid var(--accent-3);
  background: color-mix(in srgb, var(--accent-3) 8%, var(--card) 92%);
}

.tithi-candidate-bs {
  font-size: 19px;
  font-weight: 800;
  font-family: "Noto Sans Devanagari", Inter, sans-serif;
  color: var(--text);
}

.tithi-candidate-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.tithi-candidate-festival {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-3);
}

.tithi-reset-btn {
  width: 100%;
  margin-top: 18px;
  padding: 10px;
  font-size: 14px;
}

@media (max-width: 760px) {
  .tithi-select-row,
  .tithi-year-row {
    grid-template-columns: 1fr;
  }
}
