:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--secondary-bg);
}

.tab-btn {
  flex: 1 0 auto;
  white-space: nowrap;
  padding: 12px 10px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--hint);
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--link);
  border-bottom-color: var(--link);
}

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

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#search, #boardSearch {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--secondary-bg);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 15px;
}

#ownedFilter {
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--secondary-bg);
  background: var(--secondary-bg);
  color: var(--text);
}

.meta { color: var(--hint); font-size: 13px; margin-bottom: 8px; }

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

.card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--secondary-bg);
}

.card input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--button);
}

.card-body { flex: 1; min-width: 0; }
.card-name { font-weight: 600; line-height: 1.3; }
.card-sub { color: var(--hint); font-size: 13px; margin-top: 2px; }

.card-name.owned { text-decoration: line-through; opacity: 0.6; }

.load-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--button);
  color: var(--button-text);
  font-weight: 600;
  font-size: 15px;
}

.settings-block {
  padding: 12px;
  border-radius: 12px;
  background: var(--secondary-bg);
  margin-bottom: 16px;
}

.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row-title { font-weight: 600; }
.row-hint { color: var(--hint); font-size: 13px; margin-top: 2px; }

.section-title { font-weight: 700; margin: 4px 0 8px; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--hint); border-radius: 26px; transition: 0.2s;
}
.slider::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--button); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.unmute-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: var(--button);
  color: var(--button-text);
  font-size: 13px;
  flex-shrink: 0;
}

.empty { color: var(--hint); padding: 20px 0; text-align: center; }

.total-banner {
  text-align: center;
  padding: 18px 12px;
  border-radius: 14px;
  background: var(--secondary-bg);
  margin-bottom: 14px;
}
.total-label { color: var(--hint); font-size: 13px; }
.total-sum { font-size: 28px; font-weight: 700; margin-top: 2px; }
.total-count { color: var(--hint); font-size: 13px; margin-top: 2px; }

.collection-card { align-items: center; }
.price-input {
  width: 72px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--bg);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  flex-shrink: 0;
}
.remove-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--hint);
  font-size: 14px;
  flex-shrink: 0;
}

.notify-row:not(:last-child) { margin-bottom: 14px; }
.notify-row .row-title { font-size: 14px; padding-right: 8px; }

.full-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--bg);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0.95;
  z-index: 100;
}

.nudge {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  background: var(--bg-secondary, var(--bg));
  color: var(--text);
  border: 1px solid var(--hint, #8884);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: 0 6px 24px #0003;
  z-index: 99;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 3px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--secondary-bg);
}
.seg-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
}
.seg-btn.active { background: var(--bg); color: var(--text); }

.star-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  font-size: 16px;
  line-height: 1;
}

.chart-block { margin-bottom: 14px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.chart-value { font-weight: 700; }
.spark { display: block; width: 100%; height: 60px; }
.chart-range { display: flex; justify-content: space-between; color: var(--hint); font-size: 12px; margin-top: 2px; }

[hidden] { display: none !important; }

.export-btn { margin: 0 0 12px; }
.card-sub .live { color: var(--link); }
.muted-tag { margin-left: 6px; color: var(--hint); font-size: 12px; }
.card-name a { color: inherit; text-decoration: none; }
.low-tag { margin-left: 6px; padding: 1px 6px; border-radius: 8px; background: var(--bg); color: var(--link); font-size: 12px; white-space: nowrap; }
.price-chart { margin-top: 8px; }
.price-chart .spark { height: 48px; }
.bar-row + .bar-row { margin-top: 10px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 3px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--button); }
.plan-month { margin-bottom: 14px; scroll-margin-top: 56px; } /* keeps a scrolled-to month clear of the sticky tab bar */
.plan-month.current .section-title { color: var(--link); }
.badge { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 8px; background: var(--bg); font-size: 12px; }
.badge.released { color: var(--link); }
.badge.past, .badge.planned { color: var(--hint); }
details.plan-undated { margin-top: 8px; }
details.plan-undated > summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.plan-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.plan-form input, .plan-form select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--bg); background: var(--bg); color: var(--text); font-size: 15px; }
.plan-source-actions { display: flex; gap: 6px; flex-shrink: 0; }
.warn-text { color: #c0392b; font-size: 13px; margin-top: 2px; }
.hour-select { padding: 8px 6px; border-radius: 8px; border: 1px solid var(--bg); background: var(--bg); color: var(--text); font-size: 14px; }
.search-row .full-select { width: auto; flex: 1; min-width: 0; }
#planSearch { min-width: 0; }
.plan-card-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── thumbnails in lists ───────────────────────────────────────── */
.thumb { display: block; flex: 0 0 56px; width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--secondary-bg); }
.thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 24px; opacity: 0.5; }

/* ── full coin card (bottom sheet) ─────────────────────────────── */
body.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; }
.sheet[hidden], .viewer[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); color: var(--text); border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
}
.sheet-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 0; border-radius: 18px; background: var(--secondary-bg); color: var(--text); font-size: 16px; cursor: pointer; }
.sheet-title { font-weight: 700; font-size: 17px; line-height: 1.3; padding-right: 40px; }
.sheet-photos { display: flex; gap: 10px; margin: 12px 0; }
.sheet-photo { flex: 1; min-width: 0; padding: 0; border: 0; border-radius: 12px; background: var(--secondary-bg); cursor: zoom-in; display: flex; flex-direction: column; align-items: center; }
.sheet-photo img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 12px; display: block; }
.sheet-photo > span:not(.zoom-badge) { font-size: 12px; color: var(--hint); padding: 2px 0 6px; }
.sheet-photo.small { flex: 0 0 31%; }
.sheet-extra { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet-line { margin: 6px 0; }
.sheet-line a, .sheet-desc a { color: var(--link); }
.sheet-actions { display: flex; gap: 8px; margin: 12px 0 4px; }
.sheet-actions .load-more { margin-top: 0; flex: 1; }
.sheet-specs { padding: 4px 12px; }
.sheet-spec { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--bg); font-size: 14px; }
.sheet-spec:last-child { border-bottom: 0; }
.sheet-spec span { color: var(--hint); }
.sheet-spec b { font-weight: 600; text-align: right; }
.sheet-desc p { margin: 0 0 10px; line-height: 1.45; }
.viewer { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, 0.94); display: flex; flex-direction: column; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; }
.viewer-stage { position: relative; flex: 1; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: zoom-in; }
.viewer.zoomed .viewer-stage { cursor: grab; }
.viewer-stage img { position: absolute; max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; will-change: transform; -webkit-user-drag: none; }
.viewer-thumb { filter: blur(6px); transform: scale(1); opacity: 0.9; }
.viewer-full { opacity: 0; }
.viewer-full.ready { opacity: 1; }
.viewer-spinner { position: absolute; width: 46px; height: 46px; border: 4px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; border-radius: 50%; animation: viewer-spin 0.8s linear infinite; display: none; pointer-events: none; }
.viewer.loading .viewer-spinner { display: block; }
@keyframes viewer-spin { to { transform: rotate(360deg); } }
.viewer-error { position: absolute; display: none; flex-direction: column; align-items: center; gap: 10px; color: #ddd; text-align: center; }
.viewer.failed .viewer-error { display: flex; }
.viewer-retry { border: 0; border-radius: 10px; padding: 8px 14px; background: var(--button); color: var(--button-text); font-size: 14px; cursor: pointer; }
.viewer-close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; z-index: 2; width: 40px; height: 40px; border: 0; border-radius: 20px; background: rgba(255, 255, 255, 0.18); color: #fff; font-size: 18px; cursor: pointer; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: #fff; }
.viewer-bar button { width: 40px; height: 40px; border: 0; border-radius: 20px; background: rgba(255, 255, 255, 0.18); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.viewer-bar button[hidden] { display: none; }
.viewer-label { min-width: 110px; text-align: center; font-size: 14px; }
.viewer-hint { color: #aaa; font-size: 12px; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); text-align: center; }

/* ── "you can tap this" cues ─────────────────────────────────────── */
.zoom-badge { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 13px; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 13px; display: flex !important; align-items: center; justify-content: center; padding: 0 !important; }
.sheet-photo { position: relative; }
.sheet-hint { color: var(--hint); font-size: 13px; text-align: center; margin: -4px 0 8px; }

/* ── rows that open the coin card ─────────────────────────────── */
.card-open { align-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: filter 0.1s; }
.card-open:active { filter: brightness(0.93); }
.card-open:focus-visible { outline: 2px solid var(--button); outline-offset: 1px; }
.row-chevron { flex: 0 0 auto; align-self: center; color: var(--hint); font-size: 24px; line-height: 1; padding: 0 2px; }
.check-hit { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: -6px 0 -6px -10px; }
.card-open .star-btn { width: 38px; height: 38px; }
.check-hit input { margin: 0; }

/* ── booklet (PDF.js) viewer ───────────────────────────────────── */
.pdf-viewer { position: fixed; inset: 0; z-index: 300; background: var(--secondary-bg); display: flex; flex-direction: column; }
.pdf-viewer[hidden] { display: none; }
.pdf-bar { display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; background: var(--bg); border-bottom: 1px solid var(--secondary-bg); }
.pdf-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-pageno { color: var(--hint); font-size: 13px; min-width: 52px; text-align: right; }
.pdf-bar button { width: 36px; height: 36px; border: 0; border-radius: 18px; background: var(--secondary-bg); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; flex: 0 0 auto; }
.pdf-scroll { position: relative; flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 8px; }
#pdfPages { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: min-content; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.pdf-page canvas { display: block; }
.pdf-page-spinner { width: 28px; height: 28px; border: 3px solid rgba(0, 0, 0, 0.12); border-top-color: var(--button); border-radius: 50%; animation: viewer-spin 0.8s linear infinite; }
.pdf-page.ready .pdf-page-spinner { display: none; }
.pdf-loading, .pdf-error { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--hint); text-align: center; padding: 24px; }
.pdf-viewer.loading .pdf-loading { display: flex; }
.pdf-viewer.failed .pdf-error { display: flex; color: var(--text); }
.pdf-error-external { border: 0; border-radius: 10px; padding: 10px 16px; background: var(--button); color: var(--button-text); font-size: 15px; cursor: pointer; }

/* ── sharing the wishlist ──────────────────────────────────────── */
.share-link { width: 100%; margin: 8px 0; padding: 10px; border: 1px solid var(--bg); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 13px; }
.share-off { background: transparent !important; color: var(--hint) !important; margin-top: 4px; }
#sharedSheet { z-index: 90; } /* below the coin card, so a coin opened from the shared list shows on top */

/* ── board ─────────────────────────────────────────────────────── */
.form-label { display: block; font-size: 13px; color: var(--hint); margin: 12px 0 4px; }
.form-error { color: #d33; font-size: 14px; margin-top: 8px; }
.listing-thumb { width: 160px; height: 160px; object-fit: contain; border-radius: 12px; background: var(--secondary-bg); margin: 0 auto; }
.listing-price { font-size: 26px; font-weight: 700; margin: 8px 0; }
.listing-price small { font-size: 14px; font-weight: 400; color: var(--hint); }
.rules { padding-left: 20px; line-height: 1.45; }
.rules li { margin-bottom: 8px; }
#boardSheet { z-index: 95; } /* above the shared list, below the coin card */
select.share-link { appearance: auto; }
.tabs::-webkit-scrollbar { display: none; }

/* ── onboarding ────────────────────────────────────────────────── */
#onboardSheet { z-index: 98; }
.onboard-choice { width: 100%; text-align: left; border: 0; align-items: center; cursor: pointer; font: inherit; color: inherit; }
.onboard-emoji { font-size: 26px; flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
