/* LỊCH VIỆT — Mobile-First Warm Parchment & Son Red Design System */

:root {
  --bg: #F7F4EE;
  --surface: #FFFFFF;
  --surface-2: #EFEAE1;
  --border: #E4DCD1;
  --text: #1C1917;
  --muted: #5E574F;
  --primary: #B83B2E;
  --primary-dark: #972D22;
  --primary-soft: #FBECE9;
  --good: #2D7563;
  --good-soft: #E7F3EF;
  --info: #36557C;
  --info-soft: #EBF0F6;
  --warn: #9E5E1A;
  --warn-soft: #FBF1E3;
  --bad: #9F2F26;
  --bad-soft: #FCECEB;
  --shadow-sm: 0 2px 8px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 10px 28px rgba(28, 25, 23, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --topbar-h: 56px;
  --bottom-nav-h: 64px;
}

html.dark {
  --bg: #141210;
  --surface: #1D1A17;
  --surface-2: #27221E;
  --border: #38312B;
  --text: #F4EFE8;
  --muted: #B3A89C;
  --primary: #E06D60;
  --primary-dark: #C8584B;
  --primary-soft: #36201D;
  --good: #5FB09A;
  --good-soft: #1B302A;
  --info: #82A4D1;
  --info-soft: #1E2836;
  --warn: #E2A959;
  --warn-soft: #332718;
  --bad: #E67568;
  --bad-soft: #361F1D;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.42);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

::selection {
  background: var(--primary-soft);
  color: var(--primary);
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
  caret-color: var(--primary);
}

input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button, a, [role="button"] {
  touch-action: manipulation;
  font-family: inherit;
}

button, [role="button"], .nav-item, .bottom-tab, .seg-btn, .pill-btn, .chip-btn {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

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

.hidden {
  display: none !important;
}

.ico {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.ico-sm { width: 18px; height: 18px; }
.ico-xs { width: 16px; height: 16px; }

/* App Shell */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Sticky Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 10px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  min-height: 44px;
  padding-right: 2px;
  white-space: nowrap;
}

.brand-mark {
  border-radius: 7px;
  display: block;
}

/* Buttons */
.btn, .tool-btn, .pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease;
}

.btn:active, .tool-btn:active, .pill-btn:active, .chip-btn:active, .month-cell:active, .bottom-tab:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-good {
  background: var(--good);
  color: #FFFFFF;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger-outline {
  background: transparent;
  color: var(--bad);
  border-color: var(--bad);
}

.btn-sm {
  min-height: 40px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.tool-btn {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  min-height: 40px;
  padding: 0 10px;
  font-size: 13px;
}

.tool-btn.icon-only {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
}

.pill-btn {
  min-height: 44px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  white-space: nowrap;
}

/* Ensure touch tap comfort on topbar action buttons */
.topbar .btn-sm, .topbar .tool-btn, .topbar .pill-btn {
  min-height: 44px;
  white-space: nowrap;
}
.topbar .btn-sm {
  padding: 0 10px;
}

/* Reminder Alert Banner (sticky right under topbar, like yeubecon) */
.reminder-banner {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  z-index: 39;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-md);
}

.rb-content {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.rb-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

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

.time-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.event-row.is-done {
  opacity: 0.62;
}

.event-row.is-done .event-title {
  text-decoration: line-through;
}

.bot-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-2);
  margin-top: 10px;
}

.bot-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

@media (min-width: 720px) {
  .reminder-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
  }
}

/* Body Layout */
.app-body {
  flex: 1;
  display: flex;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

.sidebar {
  display: none;
}

.main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 14px 14px calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 22px);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* Cards & Typography */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.card-subtle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}

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

.section-head .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

/* Segmented Control */
.seg-control {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 14px;
}

.seg-btn {
  flex: 1;
  min-height: 44px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  transition: background-color 160ms var(--ease-out), color 160ms ease;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.badge-good { background: var(--good-soft); color: var(--good); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

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

.chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease;
}

.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

/* TAB 1 — TEAR-OFF CALENDAR CARD */
.tear-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
  touch-action: pan-y;
}

.tear-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--primary);
  color: #FFFFFF;
}

.tear-nav-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.tear-nav-btn:active { transform: scale(0.95); }

.tear-month-trigger {
  flex: 1;
  min-height: 44px;
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
}

.tear-month-sub {
  font-size: 11.5px;
  font-weight: 500;
  opacity: 0.9;
}

.tear-body {
  padding: 18px 16px 16px;
  text-align: center;
}

.tear-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tear-weekday {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tear-solar-day {
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(64px, 18vw, 88px);
  font-weight: 700;
  line-height: 1.02;
  color: var(--text);
  margin: 4px 0 12px;
  font-variant-numeric: tabular-nums;
}

.tear-solar-day.is-sunday {
  color: var(--primary);
}

.tear-lunar-box {
  display: grid;
  grid-template-columns: 1fr 1px 1.25fr;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: left;
  margin-bottom: 12px;
}

.tear-divider {
  width: 1px;
  height: 100%;
  min-height: 52px;
  background: var(--border);
}

.lunar-big-num {
  font-family: 'Lora', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.lunar-month-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

.canchi-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.canchi-lines strong {
  color: var(--text);
  font-weight: 600;
}

.tear-quote {
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 13.5px;
  color: var(--muted);
}

/* 12 Hours Grid */
.hours-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hour-cell {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hour-cell.is-hd {
  background: var(--good-soft);
  border-color: color-mix(in srgb, var(--good) 35%, var(--border));
}

.hour-cell.is-now {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.hour-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
}

.hour-range {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hour-star {
  font-size: 11.5px;
  color: var(--muted);
}
.hour-cell.is-hd .hour-star {
  color: var(--good);
  font-weight: 600;
}

/* Info Key-Value Grid */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kv-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.kv-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}

.kv-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.kv-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.advice-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
}
.advice-list li {
  margin-bottom: 5px;
}

/* TAB 2 — MONTH CALENDAR */
.month-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.month-picker-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.month-picker-row select {
  min-height: 44px;
  padding: 8px 8px;
  font-weight: 600;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.weekday-row span:last-child {
  color: var(--primary);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  touch-action: pan-y;
}

.month-cell {
  min-height: 54px;
  padding: 4px 2px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  position: relative;
  font-variant-numeric: tabular-nums;
  transition: transform 120ms var(--ease-out), border-color 120ms ease, background-color 120ms ease;
}

.month-cell.out-month {
  opacity: 0.42;
  background: var(--surface-2);
}

.month-cell.is-today {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.month-cell.is-selected {
  border: 2px solid var(--text);
  background: var(--surface-2);
}

.month-cell.is-today.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #FFFFFF;
}

.mc-solar {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
}

.month-cell.is-sun .mc-solar {
  color: var(--primary);
}
.month-cell.is-today.is-selected .mc-solar,
.month-cell.is-today.is-selected .mc-lunar {
  color: #FFFFFF;
}

.mc-lunar {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.1;
  white-space: nowrap;
}

.mc-lunar.is-key-lunar {
  color: var(--primary);
  font-weight: 700;
}

.mc-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 5px;
  margin-top: 2px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.dot-hd { background: var(--good); }
.dot-ev { background: var(--primary); }
.dot-hol { background: var(--warn); }

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

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

/* Forms & Grids */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

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

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 22px;
  accent-color: var(--primary);
  margin: 0;
  flex-shrink: 0;
}

/* Countdown Cards */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.countdown-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.cd-num {
  font-family: 'Lora', Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.cd-label {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.cd-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Good Days List */
.good-day-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 10px;
}

.gd-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gd-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Events List */
.event-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 8px;
}

.event-meta {
  min-width: 0;
  flex: 1;
}

.event-title {
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 2px;
}

.event-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Lo Ban Ruler */
.ruler-card {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 12px;
}

.ruler-bar {
  display: flex;
  width: 100%;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  margin: 10px 0 8px;
}

.ruler-seg {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  line-height: 1.12;
  font-weight: 700;
  color: #FFFFFF;
  text-align: center;
  padding: 2px;
  border-right: 1px solid rgba(255, 255, 255, 0.25);
}

.ruler-card .badge {
  white-space: nowrap;
  flex-shrink: 0;
}
.ruler-seg:last-child { border-right: none; }
.ruler-seg.is-good { background: var(--primary); }
.ruler-seg.is-bad { background: #524B45; }
.ruler-seg.is-active {
  box-shadow: inset 0 0 0 2px #FFFFFF;
}

.ruler-pointer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #1C1917;
  box-shadow: 0 0 0 1px #FFFFFF;
  pointer-events: none;
}

input[type="range"].loban-slider {
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--primary);
  min-height: 44px;
}

/* Văn Khấn Reader */
.prayer-item {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 120ms var(--ease-out), border-color 140ms ease;
}
.prayer-item:active { transform: scale(0.985); }

.prayer-reader-text {
  white-space: pre-wrap;
  font-family: 'Lora', Georgia, serif;
  line-height: 1.75;
  color: var(--text);
  margin: 0;
}

/* Bottom Navigation Bar (Mobile) */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
}

.bottom-tab {
  min-height: 54px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 10px;
  transition: transform 140ms var(--ease-out), color 140ms ease;
}

.bottom-tab.active {
  color: var(--primary);
}

/* Modal / Sheet */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 18, 16, 0.56);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 220ms var(--ease-out);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 100;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  max-width: calc(100vw - 28px);
  text-align: center;
}

.pair-code-box {
  font-family: 'Be Vietnam Pro', monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--primary);
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* Mobile-only hiding */
.hide-sm {
  display: none;
}

@media (min-width: 560px) {
  .hide-sm { display: inline-flex; }
  .hours-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .countdown-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal-overlay { align-items: center; }
}

/* Desktop Sidebar Layout */
@media (min-width: 880px) {
  .bottom-nav { display: none; }
  .sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 248px;
    flex-shrink: 0;
    padding: 18px 12px 24px;
    border-right: 1px solid var(--border);
    position: sticky;
    top: var(--topbar-h);
    height: calc(100dvh - var(--topbar-h));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .nav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background-color 140ms ease, color 140ms ease;
  }
  .nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
  }
  .sidebar-meta {
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }
  .sidebar-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
  }
  .sidebar-note {
    font-size: 12px;
    color: var(--muted);
    margin: 8px 0 0;
  }
  .main-content {
    padding: 22px 26px 40px;
    max-width: 860px;
  }
  .toast {
    bottom: 24px;
  }
}

/* Hover strictly gated behind fine pointer + hover capability */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--primary-dark); }
  .btn-outline:hover, .tool-btn:hover, .chip-btn:hover:not(.active), .prayer-item:hover {
    border-color: var(--primary);
  }
  .nav-item:hover:not(.active) {
    background: var(--surface-2);
    color: var(--text);
  }
  .month-cell:hover:not(.is-selected) {
    border-color: var(--primary);
  }
}

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