/* Light / dark appearance controls. */
.top-user-card.header-user-widget { grid-template-rows: auto minmax(0, 1fr); }
.top-user-card.header-user-widget .user-stats { grid-row: 2; grid-template-rows: repeat(3, minmax(0, 1fr)); }
.top-user-card.header-user-widget .attendance-stat,
.top-user-card.header-user-widget .theme-mode-stat {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-column: 1 / -1;
  align-items: center;
  padding: 2px 4px;
}
.top-user-card.header-user-widget .attendance-stat dt,
.top-user-card.header-user-widget .theme-mode-stat dt { justify-self: start; margin: 0; }
.top-user-card.header-user-widget .attendance-stat dd,
.top-user-card.header-user-widget .theme-mode-stat dd { min-width: 0; justify-self: end; margin: 0; }
.top-user-card.header-user-widget .theme-mode-stat .theme-mode-toggle { max-width: 125px; }
.top-user-card.header-user-widget .theme-mode-stat .theme-mode-toggle button { min-height: 20px; padding: 0 5px; font-size: 8px; }
.theme-mode-toggle { display: inline-flex; align-items: center; gap: 3px; border: 1px solid #dfd3cb; border-radius: 999px; padding: 2px; background: #f4ece6; }
.theme-mode-toggle button { display: inline-flex; min-height: 23px; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 999px; padding: 0 7px; background: transparent; color: #7b6e67; font-size: 9px; font-weight: 900; cursor: pointer; white-space: nowrap; }
.theme-mode-toggle button.is-active { background: #fffdf9; color: #5c1a2b; box-shadow: 0 2px 7px rgba(43,27,46,.12); }
.theme-mode-toggle button span { font-size: 11px; }
.mobile-theme-mode { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid #dfe9e7; border-radius: 12px; padding: 7px 9px 7px 14px; background: #f8fbfa; }
.mobile-theme-mode > span { color: var(--brand-navy); font-size: 14px; font-weight: 900; }
.mobile-theme-mode .theme-mode-toggle button { min-height: 32px; padding: 0 10px; font-size: 11px; }

html[data-theme="dark"] {
  --bg: #151316;
  --surface: #211e22;
  --ink: #f3ece8;
  --muted: #b9ada7;
  --line: #443a40;
  --soft-blue: #33252c;
  --soft-green: #292226;
  --soft-red: #3b252d;
  --brand-ivory: #151316;
  background: #151316;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 12% 9%, rgba(201,162,91,.08), transparent 25%),
    radial-gradient(circle at 90% 18%, rgba(201,123,147,.08), transparent 24%),
    #151316;
  color: var(--ink);
}

html[data-theme="dark"] .site-header,
html[data-theme="dark"] .category-nav,
html[data-theme="dark"] .result-panel,
html[data-theme="dark"] .side-panel,
html[data-theme="dark"] .map-panel,
html[data-theme="dark"] .info-widget,
html[data-theme="dark"] .top-user-card,
html[data-theme="dark"] .mobile-account-sheet,
html[data-theme="dark"] .write-dialog,
html[data-theme="dark"] .auth-dialog,
html[data-theme="dark"] .chat-dialog,
html[data-theme="dark"] .podoko-about-dialog,
html[data-theme="dark"] .detail-card,
html[data-theme="dark"] .listing-card,
html[data-theme="dark"] .marketplace-card,
html[data-theme="dark"] .mobile-food-post-card,
html[data-theme="dark"] .massage-map-listing-card,
html[data-theme="dark"] .map-side-detail,
html[data-theme="dark"] .home-trend-box,
html[data-theme="dark"] .home-info-box,
html[data-theme="dark"] .daily-info-card {
  border-color: #443a40 !important;
  background-color: #211e22 !important;
  color: #f3ece8;
}

html[data-theme="dark"] .map-side-detail-body {
  background: #211e22;
}

html[data-theme="dark"] .site-header { background: rgba(28,25,29,.97); box-shadow: 0 10px 30px rgba(0,0,0,.28); }
html[data-theme="dark"] .category-nav { background: #1d1a1e; }
html[data-theme="dark"] .category-nav a,
html[data-theme="dark"] .category-more-panel section,
html[data-theme="dark"] .business-tabs button,
html[data-theme="dark"] .food-subcategory-filter button,
html[data-theme="dark"] .main-search,
html[data-theme="dark"] .main-search input,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  border-color: #4b4046 !important;
  background: #29252a !important;
  color: #f3ece8 !important;
}

html[data-theme="dark"] :where(h1,h2,h3,h4,strong,b,dt,dd,label),
html[data-theme="dark"] .mobile-account-sheet-head h2,
html[data-theme="dark"] .mobile-theme-mode > span,
html[data-theme="dark"] .mobile-food-post-copy h3,
html[data-theme="dark"] .mobile-food-section-head strong { color: #f3ece8; }
html[data-theme="dark"] :where(p,small,.meta,.desc),
html[data-theme="dark"] .utility,
html[data-theme="dark"] .utility a { color: #b9ada7; }
html[data-theme="dark"] .podoko-promo-slot { border-color: #634955; background: linear-gradient(135deg,#38262e,#2b2527); color: #e4b7c3; }
html[data-theme="dark"] .dashboard.detail-mode .detail-side-promos { border-color: #593e49; background: #32242a !important; }
html[data-theme="dark"] .dashboard.detail-mode .detail-side-promos .detail-side-card { background: #32242a; }
html[data-theme="dark"] .business-map { background-color: #242126; }
html[data-theme="dark"] .theme-mode-toggle { border-color: #55464d; background: #171519; }
html[data-theme="dark"] .theme-mode-toggle button { color: #b9ada7; }
html[data-theme="dark"] .theme-mode-toggle button.is-active { background: #5c1a2b; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
html[data-theme="dark"] .mobile-theme-mode,
html[data-theme="dark"] .mobile-account-sheet > button { border-color: #443a40; background: #29252a; color: #f3ece8; }
html[data-theme="dark"] .mobile-account-logout { border-color: #67404a; background: #35252b; color: #f3a9b8; }
html[data-theme="dark"] .mobile-food-nearby-card { color: #f3ece8; }
html[data-theme="dark"] .mobile-food-nearby-card > span,
html[data-theme="dark"] .mobile-food-post-image { background: #342b30; }
html[data-theme="dark"] .mobile-food-empty,
html[data-theme="dark"] .marketplace-empty { border-color: #4b4046; background: #29252a; color: #b9ada7; }
html[data-theme="dark"] .modal-backdrop,
html[data-theme="dark"] .write-backdrop,
html[data-theme="dark"] .auth-backdrop,
html[data-theme="dark"] .mobile-account-backdrop { background: rgba(0,0,0,.7); }

@media (max-width: 720px) {
  html[data-theme="dark"] body { background: #151316; }
  html[data-theme="dark"] .mobile-home-shortcuts,
  html[data-theme="dark"] .mobile-bottom-nav { border-color: #443a40; background: #1d1a1e; }
  html[data-theme="dark"] .mobile-home-shortcuts a:nth-child(n) { border-color: #443a40; background: #29252a; }
}

/* Codex-like high-contrast dark palette. Keep this block last. */
html[data-theme="dark"] {
  --bg: #0f0f12;
  --surface: #18181d;
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --line: #303038;
  --brand-ivory: #0f0f12;
  background: #0f0f12;
}

html[data-theme="dark"] body {
  background: #0f0f12 !important;
  color: #f4f4f5 !important;
}

html[data-theme="dark"] body :where(
  .site-header,.utility,.category-nav,.category-more-panel,
  .result-panel,.side-panel,.map-panel,.business-map-wrap,.business-map,
  .info-widget,.top-user-card,.home-trend-box,.home-info-box,.daily-info-card,
  .result-card,.detail-card,.listing-feature,.marketplace-board-shell,.marketplace-card,
  .mobile-food-board,.mobile-food-post-card,.mobile-food-nearby-card,
  .massage-ad-board,.massage-ad-card,.massage-map-results,.massage-map-listing-card,.map-side-detail,
  .write-dialog,.auth-dialog,.chat-dialog,.podoko-about-dialog,.mobile-account-sheet,
  .mobile-theme-mode,.mobile-home-shortcuts,.mobile-bottom-nav,.mobile-market-section,
  .board-search-form,.food-subcategory-filter,.marketplace-filter-panel,.massage-filter-panel
) {
  border-color: #303038 !important;
  background-color: #18181d !important;
  background-image: none !important;
  color: #f4f4f5 !important;
  box-shadow: none;
}

html[data-theme="dark"] body :where(
  h1,h2,h3,h4,h5,h6,p,span,small,strong,b,em,dt,dd,li,label,a,
  .meta,.desc,.result-title-row,.listing-feature-copy,.mobile-food-post-copy,
  .mobile-food-section-head,.marketplace-card-copy,.massage-card-content
) { color: inherit !important; }

html[data-theme="dark"] body :where(input,textarea,select) {
  border-color: #3a3a43 !important;
  background: #202026 !important;
  color: #f4f4f5 !important;
  caret-color: #f4f4f5;
}
html[data-theme="dark"] body :where(input,textarea)::placeholder { color: #777782 !important; opacity: 1; }

html[data-theme="dark"] body :where(
  .category-nav a,.category-more-panel a,.business-tabs button,.food-subcategory-filter button,
  .mobile-account-sheet > button,.mobile-account-logout,.board-search-form button,
  .marketplace-complete-button,.detail-action-button
) {
  border-color: #3a3a43 !important;
  background: #202026 !important;
  color: #e4e4e7 !important;
}

html[data-theme="dark"] body :where(
  .category-nav a.active,.business-tabs button.active,.food-subcategory-filter button.is-active,
  .theme-mode-toggle button.is-active
) {
  border-color: #7a2740 !important;
  background: #6f1731 !important;
  color: #fff !important;
}

html[data-theme="dark"] .theme-mode-toggle { border-color: #3a3a43; background: #0f0f12; }
html[data-theme="dark"] .theme-mode-toggle button { color: #a1a1aa; }
html[data-theme="dark"] .podoko-promo-slot { border-color: #4b3a43; background: #202026 !important; color: #e8c6cf !important; }
html[data-theme="dark"] .dashboard.detail-mode .detail-side-promos,
html[data-theme="dark"] .dashboard.detail-mode .detail-side-promos .detail-side-card { border-color: #3a3a43; background: #18181d !important; }
html[data-theme="dark"] .badge { background: #32242a !important; color: #f0c9d4 !important; }
html[data-theme="dark"] .site-footer { background: #09090b; }

@media (max-width: 720px) {
  html[data-theme="dark"] .site-header { background: #141418 !important; }
  html[data-theme="dark"] .mobile-account-backdrop { background: rgba(0,0,0,.76); }
}
