:root {
    --color-panel: #ffffff;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --color-bg: #0f141b;
    --color-surface: #171d25;
    --color-panel: #1c242e;
    --color-accent: #e48361;
    --color-accent-strong: #f29a78;
    --color-accent-soft: #3b2925;
    --color-text: #e6eaf0;
    --color-muted: #a6afba;
    --color-border: #343e4a;
    --color-ink: #f5f7fa;
    --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.34);
}

.account-menu__identity {
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
}

.account-menu__identity-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-panel);
    color: var(--color-accent-strong);
    cursor: pointer;
    padding: 0;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.theme-toggle--header {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
}

.theme-toggle:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
}

.theme-toggle:focus-visible {
    outline: 3px solid var(--color-accent-soft);
    outline-offset: 2px;
}

.theme-toggle__icon {
    width: 20px;
    height: 20px;
}

.theme-toggle__icon--moon,
html[data-theme="dark"] .theme-toggle__icon--sun {
    display: none;
}

html[data-theme="dark"] .theme-toggle__icon--moon {
    display: block;
}

html[data-theme="dark"] body {
    background: var(--color-bg);
    color: var(--color-text);
}

html[data-theme="dark"] .site-header {
    background: var(--color-bg);
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.38);
}

html[data-theme="dark"] .brand__mark {
    opacity: 0.94;
}

html[data-theme="dark"] .site-footer {
    background: #141a21;
}

html[data-theme="dark"] .account-menu__trigger,
html[data-theme="dark"] .account-menu__dropdown,
html[data-theme="dark"] .notification-item,
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .favorite-button,
html[data-theme="dark"] .listing-card__features span,
html[data-theme="dark"] .detail-feature,
html[data-theme="dark"] .listing-card__cta,
html[data-theme="dark"] .seller-link,
html[data-theme="dark"] .pagination__control,
html[data-theme="dark"] .login-code-timer,
html[data-theme="dark"] .debug-code,
html[data-theme="dark"] .attachment-file,
html[data-theme="dark"] .attachment-photo,
html[data-theme="dark"] .form-check__label,
html[data-theme="dark"] .revealed-contact,
html[data-theme="dark"] .deal-filter,
html[data-theme="dark"] .deal-row,
html[data-theme="dark"] .deal-summary > div,
html[data-theme="dark"] .deal-photo-grid figure,
html[data-theme="dark"] .support-steps li > span,
html[data-theme="dark"] .support-topic-card,
html[data-theme="dark"] .chat-thread,
html[data-theme="dark"] .chat-compose textarea,
html[data-theme="dark"] .chat-message__attachments a {
    background: var(--color-panel);
}

html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    border-color: var(--color-border);
    background: var(--color-panel);
    color: var(--color-text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #7f8995;
}

html[data-theme="dark"] [data-read-receipt] {
    color: var(--color-muted);
}

html[data-theme="dark"] .notification-badge {
    border-color: var(--color-bg);
}

html[data-theme="dark"] .notification-item--unread,
html[data-theme="dark"] .push-prompt,
html[data-theme="dark"] .chat-message--admin,
html[data-theme="dark"] .sbp-notice {
    background: #2c2321;
}

html[data-theme="dark"] .account-menu__count {
    background: #442825;
    color: #ffb0a2;
}

html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .form-error,
html[data-theme="dark"] .chat-status,
html[data-theme="dark"] .chat-compose__locked,
html[data-theme="dark"] .push-prompt__copy p,
html[data-theme="dark"] .support-security-warning strong {
    color: #ffaca1;
}

html[data-theme="dark"] .btn-danger:hover,
html[data-theme="dark"] .support-security-warning,
html[data-theme="dark"] .chat-security-warning {
    border-color: #7b4943;
    background: #352022;
}

html[data-theme="dark"] .flash-message--error {
    border-color: #7b4943;
    background: #352022;
    color: #ffb2a8;
}

html[data-theme="dark"] .flash-message--success,
html[data-theme="dark"] .request-panel__submitted,
html[data-theme="dark"] .phone-share-notice--shared,
html[data-theme="dark"] .chat-message--system-restored {
    border-color: #436d51;
    background: #192c21;
    color: #a7e2b9;
}

html[data-theme="dark"] .listing-card__availability,
html[data-theme="dark"] .request-panel__submitted strong,
html[data-theme="dark"] .phone-share-notice--shared strong,
html[data-theme="dark"] .deposit-returned {
    color: #91d6a7;
}

html[data-theme="dark"] .favorite-button.is-favorite {
    border-color: #8b5949;
    background: #35241f;
}

html[data-theme="dark"] .detail-feature--yes {
    border-color: #41684e;
    background: #17261d;
}

html[data-theme="dark"] .detail-feature--yes .detail-feature__status {
    border-color: #4f7c5d;
    background: #24412e;
    color: #a6dfb7;
}

html[data-theme="dark"] .detail-feature--no {
    border-color: #714842;
    background: #2b1e20;
}

html[data-theme="dark"] .detail-feature--no .detail-feature__status {
    border-color: #7e4f49;
    background: #442729;
    color: #ffafa5;
}

html[data-theme="dark"] .detail-feature--neutral .detail-feature__status {
    border-color: var(--color-border);
    background: #242d37;
    color: var(--color-muted);
}

html[data-theme="dark"] .profile-badge,
html[data-theme="dark"] .status--active,
html[data-theme="dark"] .status--confirmed,
html[data-theme="dark"] .status--deal_done {
    border-color: #41684e;
    background: #1e3527;
    color: #9eddb1;
}

html[data-theme="dark"] .status,
html[data-theme="dark"] .status--draft {
    background: #29313b;
    color: #bdc4cd;
}

html[data-theme="dark"] .status--moderation,
html[data-theme="dark"] .status--new {
    background: #3a3020;
    color: #f1c778;
}

html[data-theme="dark"] .status--hidden,
html[data-theme="dark"] .status--rejected {
    background: #3b2526;
    color: #f0a29a;
}

html[data-theme="dark"] .support-steps {
    background: #141a21;
}

html[data-theme="dark"] .support-topic-option > input:checked + .support-topic-card,
html[data-theme="dark"] .support-selected-topic {
    background: var(--color-accent-soft);
}

html[data-theme="dark"] .support-file-field input[type="file"] {
    border-color: var(--color-border);
    background: #141a21;
}

html[data-theme="dark"] .phone-share-notice {
    border-color: #684b3f;
    background: #2c2320;
}

html[data-theme="dark"] .chat-security-warning,
html[data-theme="dark"] .chat-security-warning strong,
html[data-theme="dark"] .chat-security-warning a {
    color: #ffb0a6;
}

html[data-theme="dark"] .chat-message--mine {
    border-color: #805442;
    background: var(--color-accent-soft);
}

html[data-theme="dark"] .chat-message--system {
    border-color: #79473f;
    background: #352022;
    color: #ffc0b7;
}

html[data-theme="dark"] .chat-compose--locked {
    background: #161c23;
}

html[data-theme="dark"] .chat-compose--locked textarea {
    background: #202731;
    color: #8e98a4;
}

html[data-theme="dark"] .chat-message--deal-event {
    border-color: #41566a;
    background: #182430;
    box-shadow: inset 4px 0 0 #6e9bc1;
    color: #c7dff3;
}

html[data-theme="dark"] .deal-event-row code {
    background: #222c36;
    color: #c6d4e0;
}

html[data-theme="dark"] .pagination__page--current,
html[data-theme="dark"] .deal-filter a.is-active {
    background: #f0f3f7;
    color: #141a21;
}

/* Keep semantic and interactive states stronger than the generic dark surfaces. */
html[data-theme="dark"] .account-menu__trigger:hover,
html[data-theme="dark"] .account-menu__trigger[aria-expanded="true"],
html[data-theme="dark"] .account-menu__trigger--active {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: #fff;
}

html[data-theme="dark"] .status--active,
html[data-theme="dark"] .status--confirmed,
html[data-theme="dark"] .status--deal_done {
    border-color: #41684e;
    background: #1e3527;
    color: #9eddb1;
}

html[data-theme="dark"] .phone-share-notice--shared,
html[data-theme="dark"] .chat-message--system-restored {
    border-color: #436d51;
    background: #192c21;
    color: #a7e2b9;
}

html[data-theme="dark"] .phone-share-notice--shared strong {
    color: #91d6a7;
}

html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip {
    background: var(--color-panel);
    color: var(--color-text);
}

html[data-theme="dark"] .leaflet-control-zoom a,
html[data-theme="dark"] .leaflet-control-attribution {
    border-color: var(--color-border);
    background: var(--color-panel);
    color: var(--color-text);
}

html[data-theme="dark"] .leaflet-control-attribution a {
    color: var(--color-accent-strong);
}

@media (prefers-reduced-motion: no-preference) {
    body,
    .site-header,
    .site-footer,
    .account-menu__dropdown {
        transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
    }
}

@media (max-width: 520px) {
    .theme-toggle--header {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .theme-toggle__icon {
        width: 18px;
        height: 18px;
    }
}
