* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    /* Keep content clear of the status bar / notch and home indicator.
       env() is 0 where there is no inset, so normal browsers are unchanged. */
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    transition: background 0.3s;
}

body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    transition: background 0.3s;
}

body.dark-mode .container {
    background: #1e1e1e;
}

header {
    background: #16232f;
    color: white;
    padding: 12px 20px 15px 20px;
    text-align: center;
    position: relative;
}

body.dark-mode header {
    background: #16232f;
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 2px;
}

.header-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.version-number {
    font-size: 0.7em;
    opacity: 0.6;
    font-weight: 400;
    transition: opacity 0.3s;
    cursor: pointer;
}

.version-number:hover {
    opacity: 1;
}

.admin-buttons {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 1000;
}

@media (max-width: 768px) {
    .admin-buttons {
        bottom: 10px;
        gap: 5px;
    }
}

.admin-btn {
    background: rgba(102, 126, 234, 0.9);
    border: 1px solid rgba(102, 126, 234, 1);
    color: white;
    padding: 0;
    border-radius: 8px;
    font-size: 0.7em;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    line-height: 1;
}

.admin-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    .admin-btn {
        font-size: 0.65em;
    }
}

.changelog-entry {
    padding: 15px;
    border-left: 3px solid #667eea;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

body.dark-mode .changelog-entry {
    background: #333;
    border-left-color: #8b9dff;
}

.changelog-version {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1em;
    margin-bottom: 5px;
}

body.dark-mode .changelog-version {
    color: #8b9dff;
}

.changelog-date {
    font-size: 0.85em;
    color: #6c757d;
    margin-bottom: 8px;
}

body.dark-mode .changelog-date {
    color: #aaa;
}

.changelog-description {
    color: #2c3e50;
    line-height: 1.5;
}

body.dark-mode .changelog-description {
    color: #e0e0e0;
}

.submission-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.submission-modal.active {
    display: flex;
}

.submission-form-container {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

body.dark-mode .submission-form-container {
    background: #2a2a2a;
}

.disclaimer-content {
    color: #2c3e50;
}

body.dark-mode .disclaimer-content {
    color: #e0e0e0 !important;
}

body.dark-mode .disclaimer-content strong {
    color: #ffffff;
}

.submission-form-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

body.dark-mode .submission-form-header {
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
}

.submission-form-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.submission-form-close {
    background: white;
    border: none;
    color: #2c3e50;
    width: 36px;
    min-width: 36px;
    aspect-ratio: 1;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.submission-form-close:hover {
    background: #dc3545;
    color: white;
    transform: scale(1.1);
}

.submission-form-body {
    padding: 30px;
}

@media (max-width: 768px) {
    .submission-form-body {
        padding: 20px;
    }
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
}

body.dark-mode .form-group label {
    color: #e0e0e0;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

body.dark-mode .form-group input,
body.dark-mode .form-group textarea {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 0.85em;
}

body.dark-mode .form-group small {
    color: #aaa;
}

.required {
    color: #dc3545;
}

.compounds-section {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

body.dark-mode .compounds-section {
    border-color: #444;
}

.compound-entry {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 10px;
    align-items: end;
}

@media (max-width: 768px) {
    .compound-entry {
        grid-template-columns: 1fr;
    }
}

.remove-compound-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s;
}

.remove-compound-btn:hover {
    background: #c82333;
}

.add-compound-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background 0.3s;
    width: 100%;
}

.add-compound-btn:hover {
    background: #218838;
}

.submit-btn {
    background: linear-gradient(145deg, #667eea, #5568d3);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.submit-btn:hover {
    background: linear-gradient(145deg, #7688f0, #667eea);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0,0,0,0.25);
}

.submit-btn:active {
    transform: translateY(0px);
}

.dark-mode-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 2.2em;
    height: 2.2em;
    padding: 0;
    border-radius: 50%;
    font-size: 1.3em;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-sizing: border-box;
    flex-shrink: 0;
}

.dark-mode-toggle::after,
.settings-toggle::after {
    display: none;
}

.dark-mode-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.dark-mode-toggle:hover::after {
    opacity: 1;
}

@media (max-width: 768px) {
    .dark-mode-toggle {
        font-size: 1.1em;
        top: 15px;
        right: 65px;
    }
    
    .dark-mode-toggle::after {
        display: none;
    }
}

.settings-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 2.2em;
    height: 2.2em;
    padding: 0;
    border-radius: 50%;
    font-size: 1.3em;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-sizing: border-box;
    flex-shrink: 0;
}



.settings-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.settings-toggle:hover::after {
    opacity: 1;
}

@media (max-width: 768px) {
    .settings-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
        top: 15px;
        right: 15px;
    }

    .settings-toggle::after {
        display: none;
    }
}

.offline-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 50px;
    min-width: 50px;
    aspect-ratio: 1;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.offline-toggle::after {
    content: 'Online';
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5em;
    white-space: nowrap;
    opacity: 0.8;
    font-weight: 600;
    pointer-events: none;
}

.offline-toggle.offline::after {
    content: 'Offline';
    color: #ffa500;
}

.offline-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.offline-toggle:hover::after {
    opacity: 1;
}

.offline-toggle.offline {
    background: rgba(255, 165, 0, 0.5);
    border-color: rgba(255, 165, 0, 0.7);
}

@media (max-width: 768px) {
    .offline-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
        top: 15px;
        left: 15px;
    }
    
    .offline-toggle::after {
        font-size: 0.45em;
        bottom: -20px;
    }
}

h1 {
    font-size: 2.2em;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 1em;
    opacity: 0.9;
    margin-bottom: 0;
}

.header-logo {
    max-width: 280px;
    height: auto;
    margin: 10px auto;
    display: block;
}

@media (max-width: 768px) {
    .header-logo {
        max-width: 280px;
        margin: 8px auto;
    }
}

@media (max-width: 768px) {
    body {
        padding: 5px;
        padding-top: max(5px, env(safe-area-inset-top));
        padding-bottom: max(5px, env(safe-area-inset-bottom));
    }

    .container {
        border-radius: 10px;
    }

    header {
        padding: 8px 12px 10px 12px;
    }

    .dark-mode-toggle,
    .settings-toggle {
        width: 34px;
        height: 34px;
        font-size: 1.1em;
    }

    .dark-mode-toggle::after,
    .settings-toggle::after {
        display: none;
    }

    .version-number {
        position: static;
        font-size: 0.7em;
        opacity: 0.7;
    }

    .header-top-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 10px;
    }

    .header-buttons {
        display: flex;
        gap: 8px;
    }

    h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.9em;
        margin-bottom: 0;
    }

    .filters {
        padding: 12px 10px 8px 10px;
    }

    .filter-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .filter-group label {
        font-size: 1em;
    }
    .filter-group {
        margin-bottom: 10px;
    }

    .reset-button {
        width: 100%;
        padding: 16px;
        font-size: 1.1em;
        min-height: 52px;
    }

    .results {
        padding: 10px 15px 15px 15px;
    }
    .results-header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }
    .surface-checkboxes::after {
        display: none;
    }

    .results-count {
        font-size: 1em;
        width: 100%;
        text-align: center;
    }

    .tire-grid:has(.no-selection) {
        min-height: unset;
        align-items: flex-start;
    }

    .no-selection {
        width: 100%;
        text-align: center;
        padding: 20px 15px !important;
    }

    .tire-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tire-thumbnail {
        height: 100px;
    }

    .tire-item.expanded .tire-thumbnail {
        height: 250px;
    }

    .tire-name {
        font-size: 0.95em;
    }

    .tire-item.expanded .tire-name {
        font-size: 1.3em;
    }

    .tire-detail {
        padding: 10px 0;
    }

    .compounds-detailed {
        gap: 8px;
    }

    .compound-badge {
        font-size: 0.8em;
        padding: 4px 10px;
    }

    .no-selection,
    .no-selection {
        padding: 15px;
    }
    .no-selection-icon,
    .no-selection p {
        display: none;
    }

    .no-selection-icon {
        font-size: 3em;
    }

    .no-selection-text {
        font-size: 1.1em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .tire-brand {
        font-size: 0.75em;
    }

    .tire-name {
        font-size: 1em;
    }

    .tire-surface-preview {
        font-size: 0.8em;
    }

    .tire-detail-label {
        font-size: 0.75em;
    }

    .tire-detail-value {
        font-size: 0.85em;
    }

    .temp-range {
        font-size: 0.85em;
        padding: 6px 10px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .tire-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1025px) and (max-width: 1400px) {
    .tire-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (min-width: 1401px) {
    .tire-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

.filters {
    padding: 12px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    transition: background 0.3s, border-color 0.3s;
}

body.dark-mode .filters {
    background: #2a2a2a;
    border-bottom: 2px solid #444;
}

@media (max-width: 768px) {
    .button-container {
        flex-direction: row !important;
        flex-wrap: nowrap;
        gap: 5px !important;
        justify-content: center;
    }
    
    .button-container .reset-button,
    .button-container .compound-guide-button {
        /* Content-sized (each button only as wide as its text), all on
           one line, no wrap. !important overrides the generic per-button
           mobile rules below (larger 1.3em font + different sizing). */
        flex: 0 0 auto !important;
        font-size: 0.8em !important;
        min-width: 0 !important;
        min-height: 0 !important;
        padding: 7px 12px !important;
        white-space: nowrap !important;
        margin-top: 0 !important;
    }
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1.1em;
    transition: color 0.3s;
}

body.dark-mode .filter-group label {
    color: #e0e0e0;
}

.surface-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    align-items: center;
    transition: background 0.3s, border-color 0.3s;
    position: relative;
}

body.dark-mode .surface-checkboxes {
    background: #3a3a3a;
    border-color: #555;
}

@media (max-width: 768px) {
    .surface-checkboxes {
        max-height: none;
        gap: 6px;
    }
}

.surface-checkboxes::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to bottom, transparent, white);
    pointer-events: none;
    border-radius: 0 0 6px 6px;
}

body.dark-mode .surface-checkboxes::after {
    background: linear-gradient(to bottom, transparent, #3a3a3a);
}

.surface-tag {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-size: 0.9em;
    background: #f0f0f0;
    color: #2c3e50;
    border: 2px solid transparent;
    user-select: none;
}

body.dark-mode .surface-tag {
    background: #444;
    color: #e0e0e0;
}

.surface-tag:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

body.dark-mode .surface-tag:hover {
    background: #555;
}

.surface-tag.selected {
    background: #667eea;
    color: white;
    border-color: #5568d3;
    font-weight: 600;
}

body.dark-mode .surface-tag.selected {
    background: #8b9dff;
    color: #1e1e1e;
    border-color: #7688f0;
}

@media (max-width: 768px) {
    .surface-tag {
        padding: 6px 12px;
        font-size: 0.85em;
    }
}

.temp-toggle {
    display: flex;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.temp-unit {
    background: white;
    border: none;
    padding: 6px 12px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: #6c757d;
}

body.dark-mode .temp-unit {
    background: #3a3a3a;
    color: #e0e0e0;
}

.temp-unit:hover {
    background: #f8f9fa;
}

.temp-unit.active {
    background: #667eea;
    color: white;
}

body.dark-mode .temp-unit.active {
    background: #8b9dff;
    color: #1e1e1e;
}

.temp-unit:first-child {
    border-right: 1px solid #ddd;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s, background 0.3s, color 0.3s;
}

body.dark-mode .filter-group select,
body.dark-mode .filter-group input {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}

@media (max-width: 768px) {
    .filter-group select,
    .filter-group input {
        padding: 10px;
        font-size: 0.95em;
    }
}

@media (max-width: 768px) {
    /* Track Temp: the placeholder was clipped ("Track Ten") on a 390px phone.
       !important is needed because the input carries inline padding/font-size. */
    #temp {
        padding: 8px 6px !important;
        font-size: 0.85em !important;
        text-overflow: clip;
        white-space: nowrap;
    }
    .temp-unit {
        padding: 6px 8px;
    }

    /* Breathing room around the Track Surface heading and Show Racer Data toggle.
       The groups carry inline margin-bottom: 0, hence !important. */
    .filter-group:has(> .surface-checkboxes),
    .filter-group:has(> label > #racerDataToggle) {
        margin-top: 14px !important;
        margin-bottom: 14px !important;
    }
    .filter-group:has(> label > #racerDataToggle) > label {
        margin-bottom: 0;
        padding: 6px 0;
    }
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #667eea;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.filter-row.three-col {
    grid-template-columns: 1fr 1fr;
}

@media (min-width: 1025px) {
    .filter-row.three-col {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .surface-tag {
        padding: 10px 18px;
        font-size: 1em;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    .filter-group select,
    .filter-group input {
        padding: 14px;
        font-size: 1em;
        min-height: 48px;
    }
    
    .reset-button,
    .compound-guide-button {
        min-height: 48px;
        padding: 12px 24px;
    }
}

/* Top-bar action buttons (Reset, Compounds, My Bag, Track Log).
   One source of truth for sizing; overrides the legacy per-button and
   breakpoint rules so they stay content-sized on one row. */
.topbar-btn {
    width: auto !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 7px 14px !important;
    margin: 0 !important;
    font-size: 0.82em !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

.reset-button {
    background: linear-gradient(145deg, #5a6c7d, #4a5c6d);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 15px;
    min-height: 44px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
}

@media (max-width: 768px) {
    .reset-button {
        padding: 4px 8px;
        font-size: 1.3em;
        min-height: 52px;
    }
}

.reset-button:hover {
    background: linear-gradient(145deg, #6a7c8d, #5a6c7d);
    box-shadow: 0 6px 8px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.reset-button:active {
    transform: translateY(0px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 2px 4px rgba(0,0,0,0.2);
}

.compound-guide-button {
    background: linear-gradient(145deg, #667eea, #5568d3);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 15px;
    min-height: 44px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
}

@media (max-width: 768px) {
    .compound-guide-button {
        padding: 4px 8px;
        font-size: 1.3em;
        min-height: 52px;
    }
}

.compound-guide-button:hover {
    background: linear-gradient(145deg, #7688f0, #667eea);
    box-shadow: 0 6px 8px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.compound-guide-button:active {
    transform: translateY(0px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 2px 4px rgba(0,0,0,0.2);
}

.compound-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.compound-modal.active {
    display: flex;
}

/* Scrolling to the end of a pop-up must not pass the scroll on to the page behind it */
.compound-modal,
.compound-modal-body,
.submission-modal,
.submission-form-body,
.tpick-overlay,
.tpick-list {
    overscroll-behavior: contain;
}

.compound-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh; /* fallback for older browsers */
    max-height: 90dvh; /* dynamic viewport: tracks mobile browser chrome */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transition: background 0.3s;
}

body.dark-mode .compound-modal-content {
    background: #2a2a2a;
}

@media (max-width: 768px) {
    .compound-modal {
        padding: 0;
        align-items: stretch;
    }
    .compound-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh; /* fallback */
        height: 100dvh; /* fills the actual visible viewport on mobile */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        /* Full-screen pop-ups reach under the status bar with viewport-fit=cover;
           keep the header (and its close X) and the bottom edge inside the safe area. */
        padding-bottom: env(safe-area-inset-bottom);
    }
}

.compound-modal-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .compound-modal-header {
        padding: 15px 20px;
        padding-top: calc(15px + env(safe-area-inset-top));
    }
}

.compound-modal-header h2 {
    margin: 0;
    font-size: 1.8em;
}

@media (max-width: 768px) {
    .compound-modal-header h2 {
        font-size: 1.3em;
    }
}

.compound-modal-close {
    background: white;
    border: none;
    color: #2c3e50;
    width: 36px;
    min-width: 36px;
    aspect-ratio: 1;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.compound-modal-close:hover {
    background: #dc3545;
    color: white;
    transform: scale(1.1);
}

/* ── Settings Modal ── */
.settings-hint {
    color: #6c757d;
    font-size: 0.95em;
    margin-bottom: 25px;
}
body.dark-mode .settings-hint { color: #aaa; }

.settings-section {
    margin-bottom: 25px;
}

.settings-label {
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
}
body.dark-mode .settings-label { color: #e0e0e0; }

.settings-input {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.9em;
    background: #f8f9fa;
    color: #2c3e50;
    width: 100%;
}
body.dark-mode .settings-input {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}

.settings-small {
    color: #6c757d;
    margin-top: 5px;
    display: block;
    font-size: 0.85em;
}
body.dark-mode .settings-small { color: #aaa; }

.settings-btn-primary {
    padding: 10px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
.settings-btn-primary:hover { background: #5568d3; }

.settings-btn-success {
    padding: 10px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
.settings-btn-success:hover { background: #218838; }

.settings-footer {
    font-size: 0.8em;
    color: #aaa;
    text-align: center;
    margin-top: 10px;
}
body.dark-mode .settings-footer { color: #666; }

/* ── Settings as a full page, layout C (same element and IDs as the old pop-up) ── */
#settingsModal.settings-page {
    --s-bg: #f2f4f8;
    --s-card: #ffffff;
    --s-line: #e3e7ee;
    --s-text: #2c3e50;
    --s-muted: #6c757d;
    --s-chip: #e3e7ee;
    --s-accent: #667eea;
    --s-switch-off: #adb5bd;
    padding: 0;
    align-items: stretch;
    background: var(--s-bg);
    font-family: -apple-system, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body.dark-mode #settingsModal.settings-page {
    --s-bg: #16232F;
    --s-card: #1d3042;
    --s-line: #26384a;
    --s-text: #e8edf2;
    --s-muted: #8fa2b4;
    --s-chip: #26384a;
    --s-switch-off: #3a4c5e;
}
#settingsModal.settings-page .compound-modal-content {
    width: 100%;
    max-width: none;
    height: 100vh; /* fallback */
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    background: var(--s-bg);
    color: var(--s-text);
}
/* Header: title on the left, round Back button where the close X used to be */
#settingsModal.settings-page .compound-modal-header {
    background: #16232F;
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    justify-content: space-between;
}
#settingsModal.settings-page .compound-modal-header h2 { font-size: 1.35em; font-weight: 700; }
#settingsModal.settings-page .settings-back {
    width: 44px;
    height: 44px;
    min-width: 44px;
}
#settingsModal.settings-page .settings-back:hover {
    background: #e9ecef;
    color: #2c3e50;
    transform: none;
}
/* Scroll area: min-height 0 lets it scroll inside the flex column; the big
   bottom padding keeps the last rows clear of the Safari toolbar / home bar. */
#settingsModal.settings-page .compound-modal-body {
    min-height: 0;
    padding: 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
#settingsModal.settings-page .compound-modal-body > *:not(#qrScannerOverlay) {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

/* Cards */
.settings-page .set-card {
    background: var(--s-card);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}
.settings-page .set-pad { padding: 14px 16px; }
.settings-page .set-label {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--s-muted);
    margin: 18px 4px 6px;
}
.settings-page .settings-small,
.settings-page .settings-footer { color: var(--s-muted); }
.settings-page .settings-footer { margin: 16px 8px 0; text-align: center; }

/* Account card + gradient button */
.settings-page .set-account {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.settings-page .set-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, #9020CD, #30A6DB);
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-page .set-account-text { min-width: 0; }
.settings-page .set-account-title { font-weight: 700; font-size: 16px; color: var(--s-text); overflow-wrap: anywhere; }
.settings-page .set-account-sub { font-size: 12px; color: var(--s-muted); margin-top: 2px; }
.settings-page .set-gradient-btn {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 12px;
    margin-bottom: 12px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, #9020CD, #30A6DB);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

/* Brands card */
.settings-page .set-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.settings-page .set-card-title { font-size: 15px; font-weight: 600; color: var(--s-text); }
.settings-page .set-links { display: flex; gap: 14px; }
.settings-page .set-link {
    background: none;
    border: none;
    padding: 8px 2px;
    min-height: 36px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--s-accent);
    cursor: pointer;
}
.settings-page .set-link-muted { color: var(--s-muted); }
#settingsModal.settings-page #brandFilterList {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    max-height: none;
    overflow: visible;
    margin-bottom: 6px;
}
#settingsModal.settings-page .brand-filter-chip {
    background: var(--s-accent);
    color: #fff;
    border: 0;
    border-radius: 14px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}
#settingsModal.settings-page .brand-filter-chip.hidden {
    background: var(--s-chip);
    color: var(--s-muted);
    text-decoration: line-through;
}

/* Grouped rows */
.settings-page .set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 12px 16px;
    background: none;
    border: 0;
    border-top: 1px solid var(--s-line);
    font-family: inherit;
    font-size: 15px;
    color: var(--s-text);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.settings-page .set-card > .set-row:first-child,
.settings-page .set-group > .set-row,
.settings-page .set-card > .set-group:first-child { border-top: 0; }
.settings-page .set-group { border-top: 1px solid var(--s-line); }
.settings-page .set-row-static { cursor: default; border-top: 0; }
.settings-page .set-row-main { flex: 1; min-width: 0; }
.settings-page .set-row-title { font-size: 15px; color: var(--s-text); }
.settings-page .set-row-sub { display: block; font-size: 12px; color: var(--s-muted); margin-top: 2px; }
.settings-page .set-row-note { display: block; padding: 0 16px 12px; font-size: 12px; color: var(--s-muted); }
/* Plain chevron: points right when closed; the app's JS rotates it 90deg when open */
.settings-page .set-chev {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--s-accent);
    transition: transform 0.2s;
}

/* Expanded areas (Device Sync, Account) */
.settings-page .set-sub { padding: 4px 16px 16px; }
.settings-page .set-field-label { display: block; font-size: 13px; font-weight: 600; color: var(--s-muted); margin-bottom: 6px; }
.settings-page .set-inline { display: flex; gap: 8px; align-items: center; }
.settings-page .set-gap { margin-bottom: 10px; }
.settings-page .set-full { width: 100%; }
.settings-page .settings-input {
    background: var(--s-bg);
    border: 1px solid var(--s-line);
    color: var(--s-text);
    font-size: 16px; /* 16px stops iOS zooming into the field */
}
.settings-page .set-req {
    background: rgba(127, 127, 127, 0.12);
    color: var(--s-muted);
    padding: 10px;
    border-radius: 8px;
    font-size: 0.8em;
    line-height: 1.5;
    margin-bottom: 12px;
}
.settings-page .set-ok {
    background: rgba(40, 167, 69, 0.18);
    color: var(--s-text);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.settings-page .set-why {
    margin-top: 14px;
    padding: 12px;
    background: rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    font-size: 0.85em;
    line-height: 1.6;
    color: var(--s-text);
}
.settings-page .set-divider { border-top: 1px solid var(--s-line); }
.settings-page .set-link-a { font-size: 0.9em; color: var(--s-accent); }

/* Real on/off switch (Offline Mode). Width/height are also set inline in the HTML
   so the switch can never collapse to a thin line. */
.gg-switch {
    position: relative;
    display: block;
    width: 52px;
    height: 30px;
    min-width: 52px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 15px;
    background: #adb5bd;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-appearance: none;
    appearance: none;
}
.gg-switch.on { background: #667eea; }
#settingsModal.settings-page .gg-switch { background: var(--s-switch-off); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
#settingsModal.settings-page .gg-switch.on { background: var(--s-accent); }
.gg-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}
.gg-switch.on .gg-switch-knob { transform: translateX(22px); }

/* ── Brand Filter ── */
.brand-filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    border: 2px solid transparent;
    background: #667eea;
    color: white;
}
.brand-filter-chip.hidden {
    background: #e9ecef;
    color: #999;
    border-color: #ddd;
    text-decoration: line-through;
}
.brand-filter-chip:hover { transform: translateY(-1px); }
body.dark-mode .brand-filter-chip { background: #8b9dff; color: #1e1e1e; }
body.dark-mode .brand-filter-chip.hidden { background: #444; color: #777; border-color: #555; }
body.dark-mode #brandFilterList { background: #3a3a3a; border-color: #555; }

/* ── Track Log ── */
.tracklog-tabs {
    display: flex;
    border-bottom: 3px solid #667eea;
    margin-bottom: 15px;
}
.tracklog-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    background: #e9ecef;
    border: none;
    border-radius: 8px 8px 0 0;
    color: #6c757d;
    transition: all 0.2s;
}
.tracklog-tab.active {
    background: #667eea;
    color: white;
}
body.dark-mode .tracklog-tab { background: #444; color: #aaa; }
body.dark-mode .tracklog-tab.active { background: #8b9dff; color: #1e1e1e; }

.tracklog-panel { display: none; }
.tracklog-panel.active { display: block; }

.tracklog-entry {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 4px solid #667eea;
}
body.dark-mode .tracklog-entry { background: #333; border-left-color: #8b9dff; }

.tracklog-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.tracklog-entry-track {
    font-weight: 700;
    color: #2c3e50;
    font-size: 1em;
}
body.dark-mode .tracklog-entry-track { color: #e0e0e0; }
.tracklog-entry-date {
    font-size: 0.8em;
    color: #6c757d;
}
body.dark-mode .tracklog-entry-date { color: #aaa; }
.tracklog-entry-detail {
    font-size: 0.85em;
    color: #555;
    line-height: 1.6;
}
body.dark-mode .tracklog-entry-detail { color: #ccc; }
.tracklog-entry-rating {
    font-size: 1.1em;
    letter-spacing: 2px;
}
.tracklog-entry-notes {
    font-style: italic;
    color: #888;
    margin-top: 4px;
    font-size: 0.85em;
}
body.dark-mode .tracklog-entry-notes { color: #999; }
.tracklog-entry-delete {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 1em;
    padding: 4px;
}

.tracklog-form-group {
    margin-bottom: 14px;
}
.tracklog-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #2c3e50;
    font-size: 0.9em;
}
body.dark-mode .tracklog-form-group label { color: #e0e0e0; }
.tracklog-form-group select,
.tracklog-form-group input,
.tracklog-form-group textarea {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    background: white;
    color: #2c3e50;
}
/* Native date input ignores width shrinking and can overflow its grid
   cell; force it to fit so it stops overlapping the Track Temp field. */
.tracklog-form-group input[type="date"] {
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}
.tracklog-form-row { min-width: 0; }
.tracklog-form-row > .tracklog-form-group { min-width: 0; }
body.dark-mode .tracklog-form-group select,
body.dark-mode .tracklog-form-group input,
body.dark-mode .tracklog-form-group textarea {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}
.tracklog-form-group textarea {
    resize: vertical;
    min-height: 60px;
}
.tracklog-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.tracklog-stars {
    display: flex;
    gap: 6px;
    font-size: 2.2em;
    cursor: pointer;
}
.tracklog-stars span {
    transition: transform 0.1s, color 0.1s;
    color: #999;
    text-shadow: 0 0 2px rgba(0,0,0,0.3);
}
.tracklog-stars span.filled {
    color: #ffcc00;
    text-shadow: 0 0 6px rgba(255,204,0,0.5);
}
body.dark-mode .tracklog-stars span {
    color: #777;
}
body.dark-mode .tracklog-stars span.filled {
    color: #ffcc00;
    text-shadow: 0 0 8px rgba(255,204,0,0.6);
}
.tracklog-stars span:hover {
    transform: scale(1.2);
    color: #ffcc00;
}
.tracklog-submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(145deg, #667eea, #5568d3);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    margin-top: 5px;
}
.tracklog-submit-btn:hover { background: linear-gradient(145deg, #7688f0, #667eea); }

/* Stepped wizard (New Entry) */
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-step-title {
    font-weight: 700;
    font-size: 1.05em;
    color: #2c3e50;
    margin: 0 0 12px;
}
body.dark-mode .wizard-step-title { color: #e0e0e0; }
.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}
.wizard-progress-text {
    font-size: 0.85em;
    font-weight: 600;
    color: #6c757d;
}
body.dark-mode .wizard-progress-text { color: #aaa; }
.wizard-dots {
    display: flex;
    gap: 7px;
}
.wizard-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ccc;
    transition: background 0.2s, transform 0.2s;
}
body.dark-mode .wizard-dot { background: #555; }
.wizard-dot.active {
    background: #667eea;
    transform: scale(1.25);
}
body.dark-mode .wizard-dot.active { background: #8b9dff; }
.wizard-dot.done { background: #667eea; opacity: 0.55; }
body.dark-mode .wizard-dot.done { background: #8b9dff; opacity: 0.55; }
.wizard-nav {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}
.wizard-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
}
.wizard-btn-next {
    background: linear-gradient(145deg, #667eea, #5568d3);
    color: white;
}
.wizard-btn-next:hover { background: linear-gradient(145deg, #7688f0, #667eea); }
.wizard-btn-back {
    background: #e9ecef;
    color: #6c757d;
}
body.dark-mode .wizard-btn-back { background: #444; color: #ccc; }
.wizard-btn-back:hover { background: #dde1e6; }
body.dark-mode .wizard-btn-back:hover { background: #505050; }
.wizard-review-item {
    font-size: 0.88em;
    color: #555;
    line-height: 1.7;
}
body.dark-mode .wizard-review-item { color: #ccc; }
.wizard-review-item strong { color: #2c3e50; }
body.dark-mode .wizard-review-item strong { color: #e0e0e0; }
/* Custom tire picker (replaces native <select> dropdowns; matches track picker) */
.tpick-display {
    font-size: 16px;
    padding: 10px 12px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: #999;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tpick-display.has-value { color: #2c3e50; }
.tpick-display .tpick-caret { color: #667eea; flex: none; margin-left: 8px; }
.tpick-display.disabled { opacity: 0.5; cursor: not-allowed; }
body.dark-mode .tpick-display { border-color: #444; background: #1a1a2e; color: #888; }
body.dark-mode .tpick-display.has-value { color: #e0e0e0; }
.tpick-wrap { position: relative; }
/* Picker opens as a fixed overlay above everything: full-screen on
   mobile, centered card on desktop. Never clipped by the modal, never
   resizes the page. */
.tpick-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.55);
    align-items: stretch;
    justify-content: center;
}
.tpick-overlay.open { display: flex; }
.tpick-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #fff;
    overflow: hidden;
}
body.dark-mode .tpick-panel { background: #16232f; }
.tpick-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid #ddd;
    flex: none;
}
body.dark-mode .tpick-head { border-bottom-color: #333; }
.tpick-title { font-weight: 700; color: #2c3e50; font-size: 1em; flex: 1; }
body.dark-mode .tpick-title { color: #e0e0e0; }
.tpick-close {
    background: #e9ecef; border: none; color: #333;
    width: 34px; height: 34px; border-radius: 50%;
    font-size: 1.1em; cursor: pointer; flex: none;
}
body.dark-mode .tpick-close { background: #333; color: #e0e0e0; }
.tpick-search {
    font-size: 16px;
    width: 100%;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: #f8f9fa;
    color: #2c3e50;
    padding: 10px 12px;
    box-sizing: border-box;
    margin: 12px;
    width: calc(100% - 24px);
    flex: none;
}
body.dark-mode .tpick-search { background: #2a2a3e; color: #e0e0e0; }
.tpick-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }
@media (min-width: 640px) {
    .tpick-overlay { align-items: center; }
    .tpick-panel {
        max-width: 440px;
        max-height: 70vh;
        border-radius: 14px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    }
}
.tpick-row {
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    color: #2c3e50;
    font-weight: 600;
    font-size: 1.02em;
}
.tpick-row:hover { background: #f0f3ff; }
.tpick-row.selected { background: #667eea; color: #fff; }
body.dark-mode .tpick-row { border-bottom-color: #2a2a3e; color: #e0e0e0; }
body.dark-mode .tpick-row:hover { background: #22304a; }
body.dark-mode .tpick-row.selected { background: #667eea; color: #fff; }
.tpick-empty { padding: 16px; color: #888; text-align: center; font-size: 0.95em; }
/* Inline validation banner (replaces native alert in the wizard) */
.wizard-error {
    display: none;
    align-items: center;
    gap: 10px;
    background: #fdecea;
    border: 1px solid #f5c2c0;
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    padding: 11px 13px;
    margin-bottom: 14px;
    color: #a12622;
    font-size: 0.9em;
    font-weight: 600;
}
.wizard-error.show { display: flex; }
.wizard-error .wizard-error-icon { font-size: 1.1em; flex: none; }
body.dark-mode .wizard-error {
    background: #3a1a1f;
    border-color: #a33;
    border-left-color: #e05260;
    color: #ffd7db;
}

.tracklog-track-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}
.tracklog-track-item:hover { background: #e9ecef; }
body.dark-mode .tracklog-track-item { background: #333; }
body.dark-mode .tracklog-track-item:hover { background: #444; }
.tracklog-track-name {
    font-weight: 600;
    color: #2c3e50;
}
body.dark-mode .tracklog-track-name { color: #e0e0e0; }
.tracklog-track-loc {
    font-size: 0.8em;
    color: #6c757d;
}
body.dark-mode .tracklog-track-loc { color: #aaa; }
.tracklog-search {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 10px;
}
body.dark-mode .tracklog-search { background: #3a3a3a; border-color: #555; color: #e0e0e0; }

.tracklog-add-track-btn {
    width: 100%;
    padding: 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
}
.tracklog-add-track-btn:hover { background: #218838; }

.compound-modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* Desktop: table view */
.compound-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.compound-table th, .compound-table td {
    padding: 12px; text-align: left;
    border: 1px solid #e9ecef;
    transition: border-color 0.3s, background 0.3s, color 0.3s;
}
body.dark-mode .compound-table th,
body.dark-mode .compound-table td { border-color: #444; color: #e0e0e0; }
.compound-table th {
    background: #667eea; color: white; font-weight: 600;
    position: sticky; top: 0; z-index: 10;
    white-space: nowrap;
}
.compound-table tbody tr:nth-child(even) { background: #f8f9fa; }
body.dark-mode .compound-table tbody tr:nth-child(even) { background: #333; }

/* Mobile: card view (hides table, shows cards) */
.compound-cards { display: none; padding: 12px; }

@media (max-width: 768px) {
    .compound-table-wrap { display: none; }
    .compound-cards { display: block; }

    .compound-card {
        border: 2px solid #667eea;
        border-radius: 10px;
        margin-bottom: 10px;
        overflow: hidden;
    }
    .compound-card-header {
        background: #667eea;
        color: white;
        font-weight: 700;
        font-size: 1em;
        padding: 12px 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        user-select: none;
    }
    .compound-card-header::after {
        content: '▼';
        font-size: 0.75em;
        transition: transform 0.2s;
    }
    .compound-card.open .compound-card-header::after {
        transform: rotate(180deg);
    }
    .compound-card-body {
        display: none;
    }
    .compound-card.open .compound-card-body {
        display: block;
    }
    .compound-card-compound {
        padding: 8px 12px;
        border-bottom: 1px solid #e9ecef;
        font-size: 0.85em;
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 4px 10px;
        align-items: baseline;
    }
    .compound-card-compound:last-child { border-bottom: none; }
    body.dark-mode .compound-card-compound { border-color: #444; color: #e0e0e0; }
    .compound-card-code {
        font-weight: 700;
        color: #667eea;
        font-size: 0.95em;
    }
    body.dark-mode .compound-card-code { color: #8b9dff; }
    .compound-card-name {
        font-weight: 500;
        color: #2c3e50;
    }
    body.dark-mode .compound-card-name { color: #e0e0e0; }
    .compound-card-detail {
        grid-column: 1 / -1;
        font-size: 0.82em;
        color: #6c757d;
        line-height: 1.4;
    }
    body.dark-mode .compound-card-detail { color: #aaa; }
    .compound-card-temp {
        display: inline-block;
        background: #e7f3ff;
        color: #0066cc;
        padding: 2px 8px;
        border-radius: 4px;
        font-weight: 600;
        font-size: 0.9em;
        margin-right: 6px;
    }
    body.dark-mode .compound-card-temp { background: #1a3a5c; color: #6db3f2; }
    .compound-card-surface {
        font-style: italic;
        color: #888;
    }
    body.dark-mode .compound-card-surface { color: #999; }
    .compound-card-grip {
        display: inline-block;
        background: #fff3e0;
        color: #8a5a00;
        padding: 2px 8px;
        border-radius: 4px;
        font-size: 0.9em;
        margin-right: 6px;
    }
    body.dark-mode .compound-card-grip { background: #3a2e1a; color: #e0a94a; }
    body.dark-mode .compound-card { border-color: #8b9dff; }
    body.dark-mode .compound-card-header { background: #8b9dff; color: #1e1e1e; }
}

body.dark-mode .compound-table tbody tr:nth-child(even) {
    background: #333;
}

.compound-table tbody tr:hover {
    background: #e7f3ff;
}

body.dark-mode .compound-table tbody tr:hover {
    background: #3a3a3a;
}

.compound-category {
    font-weight: 600;
    color: #2c3e50;
    transition: color 0.3s;
}

body.dark-mode .compound-category {
    color: #8b9dff;
}

.results {
    padding: 30px;
    transition: background 0.3s;
}

body.dark-mode .results {
    background: #1e1e1e;
}

.results-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
    text-align: center;
}

.results-count {
    font-size: 1.2em;
    color: #667eea;
    font-weight: 600;
    transition: color 0.3s;
}

body.dark-mode .results-count {
    color: #8b9dff;
}

.tire-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.tire-grid:has(.no-selection) {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

@media (max-width: 768px) {
    .tire-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
}

/* Skeleton Loading Styles */
.skeleton-card {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    cursor: default;
    transition: all 0.3s;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

body.dark-mode .skeleton-card {
    background: #2a2a2a;
    border-color: #444;
}

.skeleton-image {
    width: 100%;
    height: 150px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    margin-bottom: 15px;
}

body.dark-mode .skeleton-image {
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

body.dark-mode .skeleton-text {
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Pull to Refresh Styles */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(102, 126, 234, 0.95);
    color: white;
    padding: 15px 30px;
    border-radius: 0 0 20px 20px;
    font-weight: 600;
    font-size: 0.9em;
    z-index: 3000;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

body.dark-mode .pull-to-refresh {
    background: rgba(139, 157, 255, 0.95);
}

.pull-to-refresh.visible {
    transform: translateX(-50%) translateY(0);
}

.pull-to-refresh.refreshing {
    background: rgba(40, 167, 69, 0.95);
}

.refresh-icon {
    font-size: 1.2em;
    animation: rotate 1s linear infinite;
}

.pull-to-refresh:not(.refreshing) .refresh-icon {
    animation: none;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.tire-item {
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s;
    background: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    aspect-ratio: 1;
    min-height: 200px;
}

.tire-item:not(.expanded) {
    position: relative;
}

body.dark-mode .tire-item {
    background: #2a2a2a;
    border-color: #444;
}

@media (max-width: 768px) {
    .tire-item {
        min-height: 180px;
    }
}

.tire-item:hover {
    border-color: #667eea;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    transform: translateY(-4px);
}

.tire-item.expanded {
    position: fixed;
    z-index: 1000;
    margin: 0;
    aspect-ratio: auto;
    overflow-y: auto;
    animation: expandCard 0.3s ease-out;
    background: white;
}

/* Desktop: 2x size, centered */
@media (min-width: 769px) {
    .tire-item.expanded {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 600px;
        max-height: 90vh;
        border-radius: 12px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
}

/* Mobile: fullscreen */
@media (max-width: 768px) {
    .tire-item.expanded {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        width: 100%;
        height: 100%;
    }
    
    /* Mobile carousel container */
    .mobile-carousel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        display: none;
        overflow: hidden;
    }
    
    .mobile-carousel.active {
        display: block;
    }
    
    .mobile-carousel-track {
        display: flex;
        height: 100%;
        transition: transform 0.3s ease-out;
        will-change: transform;
    }
    
    .mobile-carousel-slide {
        min-width: 100%;
        height: 100%;
        overflow-y: auto;
        background: white;
    }
    
    body.dark-mode .mobile-carousel-slide {
        background: #2a2a2a;
    }
}

@keyframes expandCard {
    from {
        transform: scale(0.9);
        opacity: 0.8;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@media (min-width: 769px) {
    @keyframes expandCard {
        from {
            transform: translate(-50%, -50%) scale(0.9);
            opacity: 0.8;
        }
        to {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.tire-item.fading-out {
    animation: fadeOut 0.2s ease-out forwards;
}

.tire-item.expanded .tire-header {
    display: none;
}

.tire-item.expanded .tire-details {
    display: block;
    padding: 0;
}

.tire-item.expanded .tire-details-grid {
    padding: 20px;
}

.tire-item.expanded .tire-image-large {
    max-height: none;
    border-radius: 0;
    border: none;
    border-bottom: 2px solid #e9ecef;
}

@media (min-width: 769px) {
    .tire-item.expanded .tire-image-large {
        border-radius: 12px 12px 0 0;
    }
}

.close-button {
    position: fixed;
    z-index: 1001;
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    width: 40px;
    min-width: 40px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

/* Desktop: position relative to modal */
@media (min-width: 769px) {
    .close-button {
        top: 50%;
        left: 50%;
        transform: translate(280px, calc(-50vh + 20px));
    }
}

/* Mobile: top right corner */
@media (max-width: 768px) {
    .close-button {
        top: calc(20px + env(safe-area-inset-top));
        right: 20px;
    }
}

.close-button:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

@media (min-width: 769px) {
    .close-button:hover {
        transform: translate(280px, calc(-50vh + 20px)) scale(1.1);
    }
}

.close-button.active {
    display: flex;
}

.nav-arrow {
    position: fixed;
    z-index: 1001;
    background: transparent;
    border: none;
    width: 50px;
    min-width: 50px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
    padding: 0;
}

.nav-arrow img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.nav-arrow:hover {
    transform: scale(1.1);
    opacity: 0.325 !important;
}

.nav-arrow.active {
    display: flex;
}

.nav-arrow.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-arrow.disabled:hover {
    transform: scale(1);
    opacity: 0.3 !important;
}

/* Desktop positioning */
@media (min-width: 769px) {
    .nav-arrow-left {
        top: 50%;
        left: 50%;
        transform: translate(-380px, -50%);
    }
    
    .nav-arrow-left:hover:not(.disabled) {
        transform: translate(-380px, -50%) scale(1.1);
    }
    
    .nav-arrow-right {
        top: 50%;
        left: 50%;
        transform: translate(330px, -50%);
    }
    
    .nav-arrow-right:hover:not(.disabled) {
        transform: translate(330px, -50%) scale(1.1);
    }
}

/* Mobile positioning */
@media (max-width: 768px) {
    .nav-arrow-left {
        top: 50%;
        left: 20px;
        transform: translateY(-50%);
        opacity: 0.65;
    }
    
    .nav-arrow-left:hover:not(.disabled) {
        transform: translateY(-50%) scale(1.1);
    }
    
    .nav-arrow-right {
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        opacity: 0.65;
    }
    
    .nav-arrow-right:hover:not(.disabled) {
        transform: translateY(-50%) scale(1.1);
    }
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.overlay.active {
    display: block;
}

.tire-header {
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: #f8f9fa;
    flex: 1;
    position: relative;
    transition: background 0.3s;
}

body.dark-mode .tire-header {
    background: #333;
}

.tire-header-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tire-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    background: white;
}

@media (max-width: 768px) {
    .tire-thumbnail {
        height: 100px;
    }
}

.tire-image-container {
    position: relative;
    width: 100%;
}

.retired-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-25deg);
    font-size: 2em;
    font-weight: 900;
    color: rgba(220, 53, 69, 0.7);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 10;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: 4px solid rgba(220, 53, 69, 0.7);
    padding: 10px 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .retired-watermark {
        font-size: 1.5em;
        padding: 8px 20px;
        border-width: 3px;
    }
}

.tire-item.expanded .retired-watermark {
    font-size: 3em;
    padding: 15px 40px;
}

@media (max-width: 768px) {
    .tire-item.expanded .retired-watermark {
        font-size: 2.5em;
        padding: 12px 30px;
    }
}

.tire-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tire-brand {
    font-size: 0.85em;
    color: #667eea;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

@media (max-width: 768px) {
    .tire-brand {
        font-size: 0.75em;
    }
}

.tire-name {
    font-size: 1.2em;
    font-weight: 700;
    color: #2c3e50;
    margin: 4px 0;
    text-align: center;
    transition: color 0.3s;
}

body.dark-mode .tire-name {
    color: #e0e0e0;
}

@media (max-width: 768px) {
    .tire-name {
        font-size: 0.95em;
        line-height: 1.2;
    }
}

.tire-surface-preview {
    font-size: 0.85em;
    color: #6c757d;
    text-align: center;
    line-height: 1.3;
    transition: color 0.3s;
}

body.dark-mode .tire-surface-preview {
    color: #aaa;
}

/* Driving Style Picker */
.driving-style-picker {
    display: flex;
    gap: 8px;
}
.skill-hint {
    font-size: 0.75em;
    color: #6c757d;
    margin-top: 6px;
    line-height: 1.4;
}
body.dark-mode .skill-hint {
    color: #999;
}
.driving-style-btn {
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: #555;
    transition: all 0.2s;
}
.driving-style-btn:hover {
    border-color: #aaa;
    background: #f8f8f8;
}
.driving-style-btn[data-value="novice"]:hover {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.08);
}
.driving-style-btn[data-value="sportsman"]:hover {
    border-color: #f39c12;
    background: rgba(243, 156, 18, 0.08);
}
.driving-style-btn[data-value="expert"]:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}
.driving-style-btn.active[data-value="novice"] {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.12);
    color: #28a745;
}
.driving-style-btn.active[data-value="sportsman"] {
    border-color: #f39c12;
    background: rgba(243, 156, 18, 0.12);
    color: #f39c12;
}
.driving-style-btn.active[data-value="expert"] {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.12);
    color: #667eea;
}
.driving-style-icon {
    width: 20px;
    height: 20px;
    flex: none;
}
body.dark-mode .driving-style-btn {
    background: #3a3a3a;
    border-color: #555;
    color: #ccc;
}
/* On phones: three equal-width buttons that FILL the row (not shrunk to
   content), sized so "Sportsman" fits cleanly on one line. Desktop
   unaffected. */
@media (max-width: 768px) {
    .driving-style-picker { gap: 6px; }
    .driving-style-btn {
        flex: 1 1 0;
        gap: 4px;
        padding: 10px 2px;
        font-size: 0.8em;
        white-space: nowrap;
    }
    .driving-style-btn span { white-space: nowrap; }
    .driving-style-icon {
        width: 15px;
        height: 15px;
    }
}
body.dark-mode .driving-style-btn:hover {
    border-color: #777;
    background: #333;
}
body.dark-mode .driving-style-btn[data-value="novice"]:hover {
    border-color: #5cd87a;
    background: rgba(40, 167, 69, 0.1);
}
body.dark-mode .driving-style-btn[data-value="sportsman"]:hover {
    border-color: #ffc048;
    background: rgba(243, 156, 18, 0.1);
}
body.dark-mode .driving-style-btn[data-value="expert"]:hover {
    border-color: #8ea4f2;
    background: rgba(102, 126, 234, 0.1);
}
body.dark-mode .driving-style-btn.active[data-value="novice"] {
    border-color: #5cd87a;
    background: rgba(40, 167, 69, 0.2);
    color: #5cd87a;
}
body.dark-mode .driving-style-btn.active[data-value="sportsman"] {
    border-color: #ffc048;
    background: rgba(243, 156, 18, 0.2);
    color: #ffc048;
}
body.dark-mode .driving-style-btn.active[data-value="expert"] {
    border-color: #8ea4f2;
    background: rgba(102, 126, 234, 0.2);
    color: #8ea4f2;
}

/* Tire tread character badges */
.tread-icon {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    cursor: default;
}
.tread-img {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}
.tread-img-inline {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 4px;
}
.tread-badge-large {
    font-size: 0.85em;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    line-height: 1.4;
    display: flex;
    align-items: center;
}
.tread-badge-large.tread-precise {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.25);
}
.tread-badge-large.tread-balanced {
    background: rgba(243, 156, 18, 0.1);
    color: #f39c12;
    border: 1px solid rgba(243, 156, 18, 0.25);
}
.tread-badge-large.tread-forgiving {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.25);
}
body.dark-mode .tread-badge-large.tread-precise { color: #8ea4f2; }
body.dark-mode .tread-badge-large.tread-balanced { color: #ffc048; }
body.dark-mode .tread-badge-large.tread-forgiving { color: #5cd87a; }



@media (max-width: 768px) {
    .tire-surface-preview {
        font-size: 0.75em;
        display: none;
    }
}

.expand-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.2em;
    color: #667eea;
    transition: transform 0.3s;
    background: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.tire-item.expanded .expand-icon {
    transform: rotate(180deg);
}

.tire-details {
    display: none;
    padding: 20px;
    border-top: 2px solid #e9ecef;
    background: white;
    transition: background 0.3s, border-color 0.3s;
}

body.dark-mode .tire-details {
    background: #2a2a2a;
    border-top-color: #444;
}

.tire-item.expanded .tire-details {
    display: block;
}

.tire-details-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tire-image-large {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.tire-detail {
    margin: 10px 0;
    padding: 6px 0;
    border-top: 1px solid #e9ecef;
    transition: border-color 0.3s;
}

body.dark-mode .tire-detail {
    border-top-color: #444;
}

.tire-detail:first-of-type {
    margin-top: 5px;
}

.tire-detail-label {
    font-size: 0.85em;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    transition: color 0.3s;
}

body.dark-mode .tire-detail-label {
    color: #aaa;
}

.tire-detail-value {
    font-size: 0.95em;
    color: #2c3e50;
    font-weight: 500;
    transition: color 0.3s;
}

body.dark-mode .tire-detail-value {
    color: #e0e0e0;
}

.compounds {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.compound-badge {
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.compounds-detailed {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.compound-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.compound-temp {
    font-size: 0.75em;
    color: #6c757d;
    font-weight: 500;
}

.compound-grip {
    font-size: 0.75em;
    color: #5a6b7a;
    font-weight: 500;
    text-align: center;
}
.compound-grip-label {
    font-weight: 700;
    color: #8a5a00;
}
body.dark-mode .compound-grip { color: #aab7c4; }
body.dark-mode .compound-grip-label { color: #e0a94a; }

.temp-range {
    background: #e7f3ff;
    color: #0066cc;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-block;
}

.no-selection {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.no-selection-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.no-selection-text {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: #2c3e50;
    transition: color 0.3s;
}

body.dark-mode .no-selection-text {
    color: #e0e0e0;
}

body.dark-mode .no-selection p {
    color: #aaa;
}

.tire-header {
    position: relative;
}

/* Footer Copyright Styles */
.copyright-footer {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
    border-top: 3px solid #667eea;
    margin-top: 0;
}

body.dark-mode .copyright-footer {
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
    border-top-color: #8b9dff;
}

.copyright-footer .copyright-main {
    font-size: 0.95em;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.copyright-footer .copyright-details {
    font-size: 0.8em;
    opacity: 0.85;
    line-height: 1.6;
}

.copyright-footer .copyright-org {
    font-weight: 600;
    color: #667eea;
}

body.dark-mode .copyright-footer .copyright-org {
    color: #8b9dff;
}

.copyright-footer .copyright-team {
    font-size: 0.75em;
    margin-top: 8px;
    opacity: 0.7;
    font-style: italic;
}

@media (max-width: 768px) {
    .copyright-footer {
        padding: 15px 20px;
    }

    .copyright-footer .copyright-main {
        font-size: 0.85em;
    }

    .copyright-footer .copyright-details {
        font-size: 0.75em;
    }

    .copyright-footer .copyright-team {
        font-size: 0.7em;
    }
}
/* ── Search box ── */
.search-box-wrapper {
    position: relative;
    margin-bottom: 20px;
}
.search-box-wrapper input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s, background 0.3s, color 0.3s;
}
body.dark-mode .search-box-wrapper input {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}
.search-box-wrapper input:focus { outline: none; border-color: #667eea; }
.search-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    color: #999;
    display: none;
    line-height: 1;
}
.search-clear-btn:hover { color: #dc3545; }

/* ── Favorites ── */
.fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1.3em;
    cursor: pointer;
    z-index: 5;
    line-height: 1;
    transition: transform 0.15s;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
.fav-btn:hover { transform: scale(1.2); }

.fav-filter-btn {
    background: none;
    border: 2px solid #ddd;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.9em;
    cursor: pointer;
    color: #2c3e50;
    transition: all 0.2s;
    white-space: nowrap;
}
body.dark-mode .fav-filter-btn { border-color: #555; color: #e0e0e0; }
.fav-filter-btn.active {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
    font-weight: 600;
}
body.dark-mode #sort {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}
/* ── Partial match badge ── */
.match-badge {
    display: inline-block;
    background: #f39c12;
    color: white;
    font-size: 0.72em;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
    white-space: nowrap;
}
.match-badge.high { background: #27ae60; }
.partial-matches-header {
    grid-column: 1 / -1;
    padding: 12px 4px 8px 4px;
    color: #e67e22;
    font-weight: 600;
    font-size: 0.95em;
    border-bottom: 2px solid #e67e22;
    margin-bottom: 4px;
}
body.dark-mode .partial-matches-header { color: #f39c12; border-color: #f39c12; }

/* Partial match cards: list-style layout so badge + missing text are always visible */
.tire-item.partial-match {
    aspect-ratio: unset !important;
    min-height: unset;
    grid-column: 1 / -1;
}
.tire-item.partial-match .tire-header {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}
.tire-item.partial-match .tire-header-left {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}
.tire-item.partial-match .tire-image-container {
    width: 80px;
    flex-shrink: 0;
}
.tire-item.partial-match .tire-thumbnail {
    height: 80px;
    width: 80px;
    object-fit: cover;
}
.tire-item.partial-match .tire-header-info {
    text-align: left;
}
.tire-item.partial-match .tire-brand,
.tire-item.partial-match .tire-name {
    text-align: left;
}
@media (max-width: 768px) {
    .tire-item.partial-match .tire-image-container {
        width: 70px;
    }
    .tire-item.partial-match .tire-thumbnail {
        height: 70px;
        width: 70px;
    }
}
