* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: clip; touch-action: manipulation; }
a { color: var(--link); }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
header {
  padding: calc(12px + env(safe-area-inset-top)) 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.version {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  opacity: 0.5;
  letter-spacing: 0.02em;
  background: none;
  border: none;
  padding: 4px;
  margin: -4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.title-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.title-sub {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
  line-height: 1;
}
#title-btn {
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 8px;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

/* Narrow screens: keep the whole header on one row (no Tavo/Trip stacking,
   no sync-button text wrap) by tightening paddings and font sizes. */
@media (max-width: 480px) {
  header { padding-left: 12px; padding-right: 12px; gap: 8px; }
  #title-btn { font-size: 16px; }
  #sync-btn { font-size: 12px; padding: 5px 9px; }
  #sync-btn .sync-label { white-space: nowrap; }
}

#title-btn .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.section-dots {
  display: grid;
  grid-template-rows: repeat(3, 7px);
  grid-auto-flow: column;
  gap: 3px;
  margin-top: 6px;
}
.sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  background: transparent;
  transition: background .25s ease, border-color .25s ease;
}
.sdot.active {
  background: var(--accent);
  border-color: var(--accent);
}
.nav-bubble {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  left: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow), 0 8px 32px rgba(0,0,0,.18);
  padding: 6px;
  z-index: 20;
  min-width: 210px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95) translateY(-4px);
  transform-origin: top left;
  transition: opacity .15s ease, transform .15s ease;
}
.nav-bubble.open {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}
.nav-bubble button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.nav-bubble button:active {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.nav-bubble button .nav-icon { font-size: 16px; margin-right: 10px; }
.nav-bubble button .nav-arrow { color: var(--muted); font-size: 12px; }
.tabs {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px;
  gap: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 6px 10px 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
.tab .tab-num {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.tab .tab-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.tab[aria-current="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab[aria-current="true"] .tab-num,
.tab[aria-current="true"] .tab-name {
  color: var(--accent);
}
.tab.tab-hidden { display: none; }
.tab-sec.days-collapsed { opacity: 0.45; }
.tab-sec .tab-icon { font-size: 16px; line-height: 1.3; }
.tab-sec .tab-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}
.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 14px;
}
.section {
  margin-bottom: 28px;
  scroll-margin-top: calc(120px + env(safe-area-inset-top));
}
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 1.45;
  scroll-margin-top: calc(120px + env(safe-area-inset-top));
}
.info-card .icon {
  font-size: 18px;
  line-height: 1.3;
  flex-shrink: 0;
}
.info-card > div { flex: 1; min-width: 0; }
.info-card strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.info-card ul {
  margin: 4px 0 0;
  padding-left: 28px;
}
.info-card li { margin: 2px 0; }
.info-card li ul { margin: 2px 0 0; padding-left: 24px; }
.info-card li:has(> input[type="checkbox"]:not(:checked)),
.day-body li:has(> input[type="checkbox"]:not(:checked)) {
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  list-style: none;
  margin-left: -22px;
  padding-left: 10px;
}
/* Nested unchecked items keep the default `margin-left: -22px` from the rule
   above. That lets the highlight sit naturally further right than the outer
   one, visually conveying nesting depth. */
.info-card p {
  margin: 0;
  padding-left: 28px;
  color: var(--muted);
  -webkit-user-select: text;
  user-select: text;
}
.info-card[id^="location-"] strong {
  font-size: 18px;
}
.info-card[data-day-target] strong {
  cursor: pointer;
}
.info-card[data-day-target] strong {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  scroll-margin-top: calc(110px + env(safe-area-inset-top));
}
#theme-btn {
  font-size: 16px;
  line-height: 1;
  background: none;
  border: none;
  padding: 4px;
  margin: -4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 1;
  padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
#sync-btn:hover {
  background: color-mix(in srgb, var(--accent) 30%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
}
#sync-btn:active { transform: translateY(1px); }
#sync-btn .sync-emoji {
  font-size: 16px;
  display: inline-block;
}
#sync-btn .sync-emoji:empty { display: none; }
#sync-btn.spinning .sync-emoji {
  animation: sync-spin 1s linear infinite;
}
#sync-btn:disabled { opacity: 0.7; cursor: wait; }
@keyframes sync-spin {
  to { transform: rotate(360deg); }
}
.day-meta {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.day-meta .num { color: var(--accent); }
.city {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.city-note {
  margin-left: auto;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.city-btn {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
}
.city-btn[data-linked="true"] {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.section-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  -webkit-tap-highlight-color: transparent;
}
.section-title[data-day-target] {
  cursor: pointer;
}
.section-title[data-day-target] .section-name {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.day-body {
  color: var(--muted);
  font-size: 14px;
  -webkit-user-select: text;
  user-select: text;
}
.day-body p { margin: 6px 0; }
.day-sub {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 12px 0 2px;
}
.day-body ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.day-body li { margin: 2px 0; }
.day-body li ul {
  margin: 2px 0 0;
  padding-left: 16px;
}
.day-body a {
  color: var(--link);
  text-decoration: none;
}
.day-body a:hover { text-decoration: underline; }
.day-body code {
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 1px 5px;
  border-radius: 4px;
}
.error {
  color: var(--accent);
  text-align: center;
  padding: 20px;
}
.map-thumb {
  width: 100%;
  border-radius: 14px;
  display: block;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  cursor: zoom-out;
}
.lightbox.open {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: pinch-zoom;
}
.pdf-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  flex-direction: column;
  background: var(--bg);
}
.pdf-modal.open { display: flex; }
.pdf-modal-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.pdf-modal-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pdf-open {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.pdf-close {
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pdf-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #525659;
}
.bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.bingo-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 4px;
  font: inherit;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  word-break: break-word;
  hyphens: auto;
  box-shadow: var(--shadow);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  user-select: none;
}
.bingo-cell.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bingo-cell.has-target {
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  padding-bottom: 5px;
}
.bingo-text { flex: 1; display: flex; align-items: center; justify-content: center; }
.bingo-progress { width: 100%; }
.bingo-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2px;
}
.bingo-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .2s ease;
  width: 0%;
}
.bingo-count {
  display: block;
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
  text-align: center;
}
.bingo-cell.checked .bingo-fill { background: #fff; }
.bingo-cell.checked .bingo-count { color: rgba(255,255,255,.7); }
footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0 24px;
}
