body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    background-color: var(--color-body-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Site-wide navigation bar (matches /budget/ header) ── */
.site-nav {
    background: var(--color-primary-dark);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-nav__brand {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
    text-decoration: none;
}

.site-nav__links {
    display: flex;
    gap: 16px;
}

.site-nav__link {
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    transition: color 0.15s;
}

.site-nav__link:hover {
    color: #fff;
}

.site-nav__link--active {
    color: #fff;
}

/* Main content area below nav */
.page-content {
    padding: var(--space-md);
}

@media (min-width: 768px) {
    .page-content { padding: var(--space-2xl); }
}

/* Welcome Banner Overlay */
#welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

#welcome-overlay.hidden {
    display: none;
}

#welcome-banner {
    background: var(--color-surface);
    border-radius: 12px;
    padding: 20px 25px;
    max-width: min(90%, 550px);
    box-shadow: var(--shadow-xl);
    text-align: center;
    position: relative;
}

#welcome-skip {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.2s;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}

#welcome-skip:hover {
    color: var(--color-text-dark);
}

#welcome-banner h2 {
    color: var(--color-heading);
    margin: 0 0 20px 0;
    font-size: 1.8em;
}

#welcome-content {
    min-height: 180px;
    text-align: left;
}

.welcome-step {
    display: none;
}

.welcome-step.active {
    display: block;
}

.welcome-step p {
    color: var(--color-text-body);
    line-height: 1.6;
    margin: 15px 0;
}

.welcome-step ul {
    color: var(--color-text-body);
    line-height: 1.8;
    padding-left: 25px;
}

.welcome-step li {
    margin: 8px 0;
}

.welcome-action {
    color: var(--color-primary) !important;
    font-weight: 500;
}

.welcome-note {
    font-size: 0.9em;
    color: var(--color-text-muted) !important;
    font-style: italic;
    margin-top: 20px !important;
}

#welcome-nav {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#welcome-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border);
    cursor: pointer;
    transition: background 0.2s;
    padding: 12px;
    background-clip: content-box;
}

.dot.active {
    background: var(--color-primary);
}

.dot:hover {
    background: var(--color-dot-hover);
}

#welcome-buttons {
    display: flex;
    gap: 12px;
}

#welcome-buttons button {
    padding: 10px 24px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

#welcome-prev {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

#welcome-prev:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

#welcome-prev:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#welcome-next, #welcome-close {
    background: var(--color-primary);
    border: none;
    color: white;
}

#welcome-next:hover, #welcome-close:hover {
    background: var(--color-primary-hover);
}

#header {
    text-align: center;
    margin-bottom: 12px;
    max-width: var(--content-max-width);
    margin-left: auto;
    margin-right: auto;
}

#header h1 {
    color: var(--color-heading);
    margin: 0;
    font-size: 1.6em;
    font-weight: 800;
    letter-spacing: -0.5px;
}

#header h2 {
    color: var(--color-text-muted);
    margin: 2px 0 10px 0;
    font-weight: 400;
    font-size: 1em;
}

#controls {
    margin: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#controls label {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-heading);
}

#controls select {
    font-size: var(--font-size-lg); /* 16px prevents iOS zoom */
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color 0.15s;
}

#controls select:hover {
    border-color: var(--color-primary);
}

.scale-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    font-size: 13px;
    min-height: var(--touch-min);
    padding: 2px 0;
}

.scale-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#map-container {
    max-width: var(--content-max-width);
    position: relative;
    display: flex;
    justify-content: center;
    margin: 12px auto;
}

#map {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.county {
    stroke: var(--color-surface);
    stroke-width: 0.5px;
    cursor: pointer;
}

.county:hover {
    stroke: var(--color-text-dark);
    stroke-width: 2px;
}

.state-border {
    fill: none;
    stroke: var(--color-text-muted);
    stroke-width: 1px;
    stroke-linejoin: round;
    stroke-linecap: round;
    pointer-events: none;
}

#tooltip {
    position: fixed;
    background: var(--color-tooltip-bg);
    color: white;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    max-width: 250px;
    line-height: 1.5;
    z-index: 1000;
}

#tooltip strong {
    font-size: 14px;
}

#tooltip small {
    display: block;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border-tooltip);
}

#legend {
    text-align: center;
    max-width: 400px;
    margin: 12px auto;
    background: var(--color-surface);
    padding: 12px 20px 16px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    box-shadow: none;
}

#legend h3 {
    margin: 0 0 5px 0;
    color: var(--color-heading);
    font-size: 1.1em;
}

#legend-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: bold;
}

#legend-labels .loss {
    color: var(--color-loss);
}

#legend-labels .neutral {
    color: var(--color-text-muted);
}

#legend-labels .gain {
    color: var(--color-gain);
}

#legend-scale {
    display: inline-block;
    height: 50px;
    width: 250px;
}

#legend-scale svg {
    border-radius: 4px;
    overflow: visible;
}

#info {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
    margin-top: 20px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

#info p {
    margin: 10px 0;
}

#summary {
    background: var(--color-surface);
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid var(--color-border);
    text-align: left;
}

#summary p {
    margin: 8px 0;
}

#summary span {
    font-weight: bold;
}

/* About Section */
#about-section {
    max-width: var(--content-max-width);
    margin: 24px auto;
    background: var(--color-surface);
    border-radius: 10px;
    border: 1px solid var(--color-border);
    overflow: hidden;
}

#about-toggle {
    width: 100%;
    padding: 14px 20px;
    background: var(--color-primary-dark);
    color: white;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

#about-toggle:hover {
    opacity: 0.9;
}

.toggle-icon {
    font-size: 20px;
    font-weight: bold;
}

#about-content {
    padding: 25px 30px;
    text-align: left;
    color: var(--color-text-body);
    line-height: 1.7;
}

#about-content.collapsed {
    display: none;
}

#about-content h3 {
    color: var(--color-heading);
    margin: 0 0 15px 0;
    font-size: 1.4em;
}

#about-content h4 {
    color: var(--color-heading-alt);
    margin: 25px 0 10px 0;
    font-size: 1.1em;
}

#about-content p {
    margin: 10px 0;
}

#about-content ol, #about-content ul {
    margin: 10px 0;
    padding-left: 25px;
}

#about-content li {
    margin: 8px 0;
}

#about-content a {
    color: var(--color-primary);
    text-decoration: none;
}

#about-content a:hover {
    text-decoration: underline;
}

.about-credit {
    margin-top: 25px !important;
    padding-top: 15px;
    border-top: 1px solid var(--color-border-light);
    font-style: italic;
    color: var(--color-text-muted);
}

/* Contributors Section */
#contributors-section {
    max-width: var(--content-max-width);
    margin: 12px auto 24px;
    background: var(--color-surface);
    border-radius: 10px;
    border: 1px solid var(--color-border);
    overflow: hidden;
}

#contributors-toggle {
    width: 100%;
    padding: 14px 20px;
    background: var(--color-primary-dark);
    color: white;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

#contributors-toggle:hover {
    opacity: 0.9;
}

#contributors-content {
    padding: 25px 30px;
    text-align: left;
    color: var(--color-text-body);
    line-height: 1.7;
}

#contributors-content.collapsed {
    display: none;
}

#contributors-content h3 {
    color: var(--color-heading);
    margin: 0 0 20px 0;
    font-size: 1.4em;
}

#contributors-content h4 {
    color: var(--color-heading-alt);
    margin: 0 0 5px 0;
    font-size: 1.1em;
}

#contributors-content p {
    margin: 5px 0;
}

#contributors-content a {
    color: var(--color-primary);
    text-decoration: none;
}

#contributors-content a:hover {
    text-decoration: underline;
}

.contributor {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border-light);
}

.contributor:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.contributor-note {
    font-style: italic;
    color: var(--color-text-muted);
}

.contributor-note p {
    color: var(--color-text-muted);
}

/* Tour Button in Header */
#tour-button-container {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

#take-tour-btn {
    background: var(--color-primary-dark);
    color: white;
    border: none;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

#take-tour-btn:hover {
    background: var(--color-heading);
    opacity: 0.9;
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

.secondary-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Budget explorer link is also in the nav bar, but kept here
   for backward compatibility and direct discoverability */
#budget-explorer-link {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

#budget-explorer-link:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Guided Tour Modal System */
#tour-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 3000;
}

#tour-overlay.hidden {
    display: none;
}

/* Allow map interaction during step 6 (tooltip demo) */
#tour-overlay.interactive-step {
    pointer-events: none;
}

#tour-overlay.interactive-step #tour-modal,
#tour-overlay.interactive-step #tour-arrow {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    pointer-events: auto;
}

#tour-modal {
    position: fixed;
    background: var(--color-surface);
    border-radius: 12px;
    padding: 25px 30px;
    max-width: 90%;
    max-height: 90vh;
    min-width: auto;
    box-shadow: var(--shadow-xl);
    z-index: 3001;
    overflow: hidden;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    /* Default position - will be overridden by JS */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#tour-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.2s;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}

#tour-close:hover {
    color: var(--color-text-dark);
}

#tour-content {
    text-align: left;
    color: var(--color-text-body);
    line-height: 1.6;
    margin-bottom: 20px;
    max-height: calc(80vh - 150px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex-shrink: 1;
}

#tour-content p {
    margin: 10px 0;
}

#tour-content strong {
    color: var(--color-heading);
}

#tour-content .highlight-text {
    background: var(--color-tour-highlight-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

#tour-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--color-border-light);
    padding-top: 15px;
}

#tour-progress {
    font-size: 12px;
    color: var(--color-text-faint);
}

#tour-buttons {
    display: flex;
    gap: 10px;
}

#tour-buttons button {
    padding: 8px 20px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

#tour-prev {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

#tour-prev:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

#tour-prev:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#tour-next, #tour-finish {
    background: var(--color-primary);
    border: none;
    color: white;
}

#tour-next:hover, #tour-finish:hover {
    background: var(--color-primary-hover);
}

/* Tour Arrow */
#tour-arrow {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    position: fixed;
    width: 0;
    height: 0;
    z-index: 3002;
    pointer-events: none;
}

#tour-arrow.hidden {
    display: none;
}

#tour-arrow.arrow-down {
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 20px solid var(--color-tour-arrow);
}

#tour-arrow.arrow-up {
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 20px solid var(--color-tour-arrow);
}

#tour-arrow.arrow-left {
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-right: 20px solid var(--color-tour-arrow);
}

#tour-arrow.arrow-right {
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-left: 20px solid var(--color-tour-arrow);
}

/* Tour Highlight - spotlight effect using box-shadow to dim surrounding areas
   while keeping the highlighted element at normal brightness */
#tour-highlight {
    position: fixed;
    border: 3px solid var(--color-primary);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    z-index: 2999;
    pointer-events: none;
    transition: all 0.3s ease;
    /* Transparent background so the highlighted element is visible at full brightness */
    background: transparent;
}

#tour-highlight.hidden {
    display: none;
}

/* When multiple targets are highlighted, disable the dimming overlay */
#tour-highlight.multi-highlight {
    box-shadow: none;
}

/* Secondary highlight for multi-target tour steps */
#tour-highlight-2 {
    position: fixed;
    border: 3px solid var(--color-primary);
    border-radius: 8px;
    z-index: 2999;
    pointer-events: none;
    transition: all 0.3s ease;
    background: transparent;
}

#tour-highlight-2.hidden {
    display: none;
}

/* Debt Info Panel */
#debt-info {
    background: var(--color-tour-highlight-bg);
    border: 1px solid var(--color-alert-border);
    border-radius: 8px;
    padding: 15px 20px;
    margin-top: 15px;
    text-align: left;
}

#debt-info.hidden {
    display: none;
}

#debt-info p {
    margin: 8px 0;
}

#learn-debt-btn {
    background: var(--color-heading);
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

#learn-debt-btn:hover {
    background: var(--color-heading-alt);
}

/* Data Source Collapsibles */
.data-source-item {
    margin: 10px 0;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    overflow: hidden;
}

.data-source-toggle {
    width: 100%;
    padding: 12px 15px;
    background: var(--color-body-bg);
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.data-source-toggle:hover {
    background: var(--color-surface-hover);
}

.data-source-content {
    padding: 15px;
    background: var(--color-surface);
}

.data-source-content.collapsed {
    display: none;
}

.data-source-content p {
    margin: 8px 0;
}

.data-source-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

/* Grey Scale Map Mode */
.greyscale-mode .county {
    filter: none; /* Override any filters */
}

/* Welcome Banner Modified Buttons */
#welcome-tour, #welcome-skip-tour {
    padding: 10px 24px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

#welcome-tour {
    background: var(--color-primary);
    border: none;
    color: white;
}

#welcome-tour:hover {
    background: var(--color-primary-hover);
}

#welcome-skip-tour {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

#welcome-skip-tour:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Debt Popup Modal */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 4000;
}

.popup-overlay.hidden {
    display: none;
}

.popup-content {
    max-width: 90%;
    padding: 20px 25px;
    background: var(--color-surface);
    border-radius: 12px;
    padding: 30px 40px;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    text-align: center;
}

.popup-content h3 {
    color: var(--color-heading);
    margin: 0 0 15px 0;
    font-size: 1.4em;
}

.popup-content p {
    color: var(--color-text-body);
    line-height: 1.7;
    margin: 15px 0 25px 0;
    text-align: left;
}

.popup-close-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 10px 30px;
    font-size: 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.popup-close-btn:hover {
    background: var(--color-primary-hover);
}

/* Debt Mode Active Indicator */
#debt-toggle:checked + span {
    color: var(--color-loss);
    font-weight: bold;
}

/* Greyscale Mode Active Indicator */
#greyscale-toggle:checked + span {
    font-weight: bold;
}

/* County Search Box */
#county-search-container {
    max-width: var(--content-max-width);
    margin: 0 auto 10px;
    position: relative;
}

#county-search {
    width: 100%;
    padding: 8px 14px;
    font-size: 15px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}

#county-search:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

#county-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 500;
    box-shadow: var(--shadow-sm);
}

#county-search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-surface-hover);
    font-size: 14px;
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--color-surface-active);
}

.search-result-item .county-name {
    font-weight: bold;
    color: var(--color-heading);
}

.search-result-item .state-name {
    color: var(--color-text-muted);
    margin-left: 5px;
}

.search-result-item .net-effect {
    float: right;
    font-weight: bold;
}

/* County Info Card */
#info-card {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: var(--color-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 800;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#info-card.hidden {
    display: none;
}

#info-card-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--color-text-faint);
    padding: 4px 8px;
    line-height: 1;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}

#info-card-close:hover {
    color: var(--color-text-dark);
}

#info-card-title {
    padding: 15px 40px 10px 15px;
    margin: 0;
    font-size: 16px;
    color: var(--color-heading);
    border-bottom: 1px solid var(--color-border-light);
}

#info-card-body {
    padding: 10px 15px 15px;
}

#info-card-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#info-card-table td {
    padding: 6px 0;
}

#info-card-table td:first-child {
    color: var(--color-text-muted);
}

.ic-value {
    text-align: right;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.ic-value.positive {
    color: var(--color-gain);
}

.ic-value.negative {
    color: var(--color-loss);
}

.ic-net-row td {
    border-top: 2px solid var(--color-text-muted);
    padding-top: 8px;
}

#info-card-income-tabs {
    display: flex;
    gap: 4px;
    margin: 12px 0 8px;
}

.ic-tab {
    flex: 1;
    padding: 6px;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-surface);
    cursor: pointer;
    text-align: center;
}

.ic-tab:hover {
    background: var(--color-surface-hover);
}

.ic-tab.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

#info-card-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

#info-card-copy-link {
    flex: 1;
    padding: 8px;
    font-size: 13px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    cursor: pointer;
}

#info-card-copy-link:hover {
    background: var(--color-surface-hover);
}

#info-card-copy-link.copied {
    background: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

/* Selected county highlight */
.county.selected {
    stroke: var(--color-highlight) !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 4px var(--color-highlight-glow));
}

/* ── Mobile-First: Touch Targets & iOS Fixes ─────────────────── */
/* These are defaults (mobile), overridden for desktop above */

select, button, .ic-tab, #info-card-copy-link, #take-tour-btn,
#welcome-tour, #welcome-skip-tour, #tour-next, #tour-prev,
#tour-finish, #tour-close, #welcome-skip, #about-toggle,
#contributors-toggle, .data-source-toggle, #budget-explorer-link {
    min-height: var(--touch-min);
}

select {
    font-size: var(--font-size-lg); /* 16px prevents iOS zoom on focus */
}

#county-search {
    font-size: var(--font-size-lg);
}

/* Info card: bottom sheet on mobile (default) */
#info-card {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    max-height: 70vh;
    overflow-y: auto;
}

/* ── Desktop overrides ───────────────────────────────────────── */
/* ── Mobile tour fixes ──────────────────────────────────────── */
/* ── Mobile controls collapse (<768px) ────────────────────── */
.more-options-toggle {
    display: none; /* hidden on desktop */
}

@media (max-width: 767px) {
    .more-options-toggle {
        display: block;
        background: none;
        border: 1px solid var(--color-border);
        border-radius: 4px;
        padding: 8px 16px;
        font-size: 14px;
        color: var(--color-heading);
        cursor: pointer;
        width: 100%;
        text-align: center;
    }

    .more-options-toggle:hover {
        background: var(--color-surface-hover);
    }

    .advanced-controls {
        display: none;
    }

    .advanced-controls.expanded {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
}

@media (min-width: 768px) {
    .advanced-controls {
        display: contents; /* on desktop, acts as if the wrapper isn't there */
    }
}

@media (max-width: 480px) {
    #tour-modal {
        max-width: 95vw;
        padding: 20px 16px;
    }

    #tour-nav {
        flex-wrap: wrap;
        gap: 8px;
    }

    #tour-buttons {
        width: 100%;
    }

    #tour-buttons button {
        flex: 1;
        padding: 12px 16px;
        min-height: 44px;
    }

    #tour-content {
        max-height: calc(70vh - 130px);
    }
}

/* ── Tablet+ overrides (768px+) ────────────────────────────── */
@media (min-width: 768px) {
    #welcome-banner {
        padding: 30px 40px;
    }

    #header h1 {
        font-size: 2.2em;
    }

    #controls {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
        flex-wrap: wrap;
    }

    .control-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    #legend-scale {
        width: 350px;
    }

    #tour-modal {
        max-width: 550px;
        min-width: 350px;
    }

    select {
        font-size: var(--font-size-base);
    }

    .popup-content {
        max-width: 500px;
        padding: 30px 40px;
    }
    /* Info card: positioned panel on tablet+ */
    #info-card {
        position: fixed;
        bottom: 20px;
        right: 20px;
        left: auto;
        width: 320px;
        border-radius: var(--radius-xl);
        max-height: none;
        overflow-y: visible;
    }
}

/* ── Large desktop overrides (1024px+) ──────────────────────── */
@media (min-width: 1024px) {
    .control-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    #controls {
        gap: 24px;
    }

    #info-card {
        width: 360px;
    }
}
