/* Appearance preferences share the existing design-system roles and component
   geometry. Only the dark variant changes colors. Branded navy heroes and
   gold ticket materials retain their original foreground/background pairing. */
.appearance-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--cgb-neutral-200);
  color: var(--cgb-ink-900);
  font-weight: 650;
}
.appearance-setting select {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--cgb-ink-900);
  background: var(--cgb-white);
  border: 1px solid var(--cgb-neutral-300);
  border-radius: var(--radius-sm);
}

.appearance-dialog { max-width: min(360px, calc(100vw - 24px)); }
.appearance-dialog .appearance-help {
  margin: 0;
  color: var(--brand-text-muted);
  font-size: .85rem;
}
.my-cgb-profile-section > .appearance-setting { border-top: 0; }
@media (max-width: 899px) {
  .site-footer #appearance-button,
  .site-footer #appearance-button + span { display: none; }
}

:root[data-appearance="light"] { color-scheme: only light; }

:root[data-appearance="dark"] {
  color-scheme: dark;
  --theme-page: #0b1527;
  --theme-surface: #111d35;
  --theme-raised: #1c2b44;
  --theme-border: #35465e;
  --theme-text: #f1f4f8;
  --theme-muted: #b3c0d2;
  --theme-link: #b1cdf7;
  --theme-brand-navy: var(--brand-loading-background);
  --theme-fixed-primary: var(--brand-primary);
  --theme-fixed-primary-dark: var(--brand-primary-dark);
  --brand-primary-light: var(--theme-raised);
  --text-muted: var(--theme-muted);
  --brand-page-background: var(--theme-page);
  --brand-mobile-safe-surface: var(--theme-surface);
  --brand-surface: var(--theme-surface);
  --brand-text: var(--theme-text);
  --brand-text-muted: var(--theme-muted);
  --brand-watch-party-surface: #3b3220;
  --cgb-navy-950: var(--theme-text);
  --cgb-navy-900: var(--theme-link);
  --cgb-navy-800: var(--theme-link);
  --cgb-navy-700: #a3bad8;
  --cgb-navy-100: #263a53;
  --cgb-navy-50: var(--theme-raised);
  --cgb-ink-700: #d5deea;
  --cgb-ink-600: #c4cfde;
  --cgb-neutral-300: #52637a;
  --cgb-neutral-200: var(--theme-border);
  --cgb-neutral-100: var(--theme-raised);
  --cgb-neutral-50: var(--theme-page);
  --cal-blue: var(--theme-link);
  --cal-blue-dark: var(--theme-text);
  --cgb-gold-600: #f4c75c;
  --cgb-success: #76d5ac;
  --cgb-danger: #f6a29a;
  --shadow-sm: 0 3px 10px rgba(0,0,0,.24);
  --shadow-md: 0 10px 24px rgba(0,0,0,.32);
  --shadow-lg: 0 18px 40px rgba(0,0,0,.4);
  background: var(--theme-brand-navy);
}

/* Retain the original brand colors for surfaces designed as navy or gold. */
[data-appearance="dark"] :is(.site-header, .add-context,
  .activity-card, .detail-game-context, .primary-button, .search-submit,
  .marker-star, .map-legend__marker--watch-party, .badge--cal) {
  --cgb-navy-950: var(--brand-primary-dark);
  --cgb-navy-900: var(--brand-primary);
  --cgb-navy-800: #052b67;
  --cgb-navy-700: #153f78;
  --cgb-white: var(--brand-text-on-primary);
  --cgb-ink-900: var(--brand-text-on-primary);
  --cgb-ink-500: #c8d5e7;
  --cal-blue: var(--brand-primary);
  --cal-blue-dark: var(--brand-primary-dark);
}
[data-appearance="dark"] .site-header {
  --cgb-mobile-safe-surface: var(--theme-brand-navy);
  --cgb-header-safe-area-blend: linear-gradient(transparent,transparent);
}
[data-appearance="dark"] .site-header .opening-stat {
  --cgb-white: var(--theme-surface);
  --cgb-navy-950: var(--theme-text);
  --cgb-navy-900: var(--theme-link);
  --cgb-ink-900: var(--theme-text);
  --cgb-ink-700: var(--theme-muted);
  --cgb-ink-500: var(--theme-muted);
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
[data-appearance="dark"] :is(.map-view, #map, .detail-local-map) {
  background-color: #202d3b;
}
[data-appearance="dark"] :is(.maplibregl-ctrl-group, .maptilersdk-ctrl-group) {
  background: var(--theme-surface) !important;
  border-color: var(--theme-border) !important;
}
[data-appearance="dark"] :is(.maplibregl-ctrl-group, .maptilersdk-ctrl-group) button .maplibregl-ctrl-icon {
  filter: invert(1);
}
[data-appearance="dark"] .map-actions #near-me-button {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
[data-appearance="dark"] .opening-stat {
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
[data-appearance="dark"] :is(.cgb-marker.marker--cal-bar .marker-pin, .map-legend__marker--cal-bar) {
  background: var(--cgb-gold-400);
  border-color: var(--cgb-gold-400);
}
[data-appearance="dark"] :is(.cgb-marker.marker--cal-bar .marker-pin, .map-legend__marker--cal-bar)::after {
  background: var(--brand-primary-dark);
}
[data-appearance="dark"] .cgb-marker.marker--fan-added .marker-pin {
  background: #202d3b;
  border-color: #b1cdf7;
}
[data-appearance="dark"] .cgb-marker.marker--fan-added .marker-pin::after {
  background: #b1cdf7;
}
[data-appearance="dark"] .map-legend__marker--fan-added {
  background: #202d3b;
  border-color: #b1cdf7;
}
[data-appearance="dark"] .map-legend__marker--fan-added::after {
  background: #b1cdf7;
}
[data-appearance="dark"] .marker-count {
  background: var(--theme-surface);
  color: var(--theme-text);
  border-color: var(--theme-border);
}

[data-appearance="dark"] :is(.search-field, .search-suggestions, .search-suggestions button,
  .venue-tray, .tray-list__header, .secondary-button, .icon-button,
  .site-footer, .add-action, .command-surface__back, .game-dialog, .about-dialog,
  .external-venue-dialog, .external-place-result) {
  background: var(--theme-surface);
  color: var(--theme-text);
  border-color: var(--theme-border);
}
[data-appearance="dark"] :is(.search-suggestions button, .secondary-button, .icon-button,
  .add-action, .external-place-result):hover:not(:disabled) {
  background: var(--theme-raised);
}
[data-appearance="dark"] :is(.search-suggestions button, .secondary-button, .icon-button,
  .add-action, .external-place-result):focus-visible {
  background: var(--theme-raised);
}
[data-appearance="dark"] :is(.search-field input, .command-surface input, .command-surface select,
  .command-surface textarea, dialog input, dialog select, dialog textarea,
  .accounts-shell input, .accounts-shell select, .accounts-shell textarea) {
  color: var(--theme-text);
  background-color: var(--theme-raised);
  border-color: var(--theme-border);
}
[data-appearance="dark"] .mobile-command-bar {
  color: var(--theme-muted);
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
[data-appearance="dark"] .mobile-command[aria-current="page"] {
  color: var(--theme-text);
}
[data-appearance="dark"] .mobile-command[aria-current="page"] .ui-icon {
  color: var(--cgb-gold-400);
}
[data-appearance="dark"] .cgb-safe-area-fill--top {
  background: var(--theme-brand-navy);
}
[data-appearance="dark"] .cgb-safe-area-fill--bottom {
  background: var(--theme-surface);
}

/* Gold tickets have dark ink in both themes. Preserve the cutout against
   the surrounding profile surface instead of turning the paper dark. */
[data-appearance="dark"] .party-module {
  --cgb-navy-950: var(--brand-primary-dark);
  --cgb-navy-900: var(--brand-primary);
  --cgb-ink-900: #101626;
  --cgb-ink-700: #354052;
  --cgb-ink-500: #586373;
  --cgb-white: #ffffff;
  --brand-text: #101626;
  --brand-text-muted: #586373;
  --brand-primary-light: #dce6f1;
  --cgb-gold-50: #fff8e6;
  color: var(--cgb-navy-950);
  color-scheme: light;
}
[data-appearance="dark"] .party-module__summary::before,
[data-appearance="dark"] .party-module__summary::after {
  background: var(--theme-surface);
}
[data-appearance="dark"] :is(.intent-feedback, .external-venue-error) {
  background: #391f27;
  color: #f6a29a;
  border-color: #8a4950;
}
[data-appearance="dark"] :is(.detail-local-map__photo-action, .detail-primary-actions) {
  background: var(--theme-surface) !important;
}
[data-appearance="dark"] .detail-local-map__photo-action {
  color: var(--theme-link) !important;
}
[data-appearance="dark"] .map-fallback {
  background-color: var(--theme-brand-navy);
}

@media (max-width: 899px) {
  [data-appearance="dark"] .tray-summary {
    color: var(--theme-text);
  }
  [data-appearance="dark"] .tray--selected .selected-card__header {
    --cgb-navy-950: var(--brand-primary-dark);
    --cgb-navy-900: var(--brand-primary);
    --cgb-navy-700: #153f78;
    --cgb-white: var(--brand-text-on-primary);
    --cgb-ink-900: var(--brand-text-on-primary);
    --cgb-ink-500: #c8d5e7;
  }
  [data-appearance="dark"] .venue-tray .tray-list__header {
    --cgb-navy-950: var(--brand-primary-dark);
    --cgb-white: var(--brand-text-on-primary);
  }
}
@media (min-width: 900px) {
  [data-appearance="dark"] .my-cgb-surface .accounts-header {
    --cgb-navy-950: var(--brand-primary-dark);
    --cgb-white: var(--brand-text-on-primary);
  }
}

/* The account styles are lazy-loaded. Their legacy primary text role is
   scoped here, while the account header, avatar and primary action keep the
   fixed brand colors. */
[data-appearance="dark"] :is(.accounts-shell, .my-cgb-promo-shell, .public-bear-dialog) {
  --brand-primary: var(--theme-link);
  --brand-primary-dark: var(--theme-text);
  --text-muted: var(--theme-muted);
}
[data-appearance="dark"] :is(.accounts-header, .accounts-auth-header,
  .accounts-avatar-fallback, .public-community-sample-avatar,
  .account-launcher__avatar, .accounts-shell .primary-button,
  .accounts-shell .search-submit) {
  --brand-primary: var(--theme-fixed-primary);
  --brand-primary-dark: var(--theme-fixed-primary-dark);
}
[data-appearance="dark"] .public-bear-dialog,
[data-appearance="dark"] .public-bear-dialog .public-bear-shell,
[data-appearance="dark"] .watch-party-attendance-handoff__panel,
[data-appearance="dark"] .external-venue-disclosure,
[data-appearance="dark"] .venue-detail {
  background: var(--theme-surface);
  color: var(--theme-text);
}
[data-appearance="dark"] .accounts-shell .accounts-status[data-state="error"] {
  background: #391f27;
  color: #f6a29a;
}
[data-appearance="dark"] .external-venue-manual input {
  color: var(--theme-text);
  background: var(--theme-raised);
  border-color: var(--theme-border);
}
[data-appearance="dark"] .map-toolbar .search-add-location-action:not([hidden]) {
  background: var(--theme-surface);
  color: var(--theme-link);
  border-color: var(--theme-border);
}
[data-appearance="dark"] .primary-button:hover:not(:disabled) {
  color: var(--theme-fixed-primary-dark);
}
[data-appearance="dark"] .primary-button.intent-button[aria-pressed="true"]:hover:not(:disabled) {
  color: var(--brand-text-on-primary);
}
