.more-sheet-head,
.more-sheet-section-label,
.more-sheet-row-meta {
    display: none;
}
.more-sheet-section,
.more-sheet-card,
.more-sheet-row-main {
    display: contents;
}
.header-tools {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.75rem;
    flex-shrink: 0;
}
.nav-tab-extra {
    display: none;
}
.nav-tab-signin {
    display: none;
}
.header-quick-nav {
    display: none;
}
.header-account-menu,
.header-tools-menu {
    background: var(--ch-bar-solid, #ffffff);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
}
[data-theme="dark"] .header-account-menu,
[data-theme="dark"] .header-tools-menu {
    background: var(--ch-surface, #1c1a17);
}
.header-account {
    position: relative;
}
.header-signin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--ch-line, rgba(0, 0, 0, 0.12));
    background: var(--ch-text, #1f1f1f);
    color: var(--ch-surface, #ffffff);
    text-decoration: none;
    flex-shrink: 0;
}
.header-signin .icon-svg {
    width: 1.15rem;
    height: 1.15rem;
}
[data-theme="dark"] .header-signin {
    background: var(--ch-text, #e8e4dc);
    color: var(--ch-bg, #161512);
    border-color: transparent;
}
.header-avatar-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    border: 1px solid var(--ch-line, rgba(0, 0, 0, 0.12));
    background: var(--ch-orange, #ec6a35);
    color: var(--ch-on-accent, #ffffff);
    font-weight: 700;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.header-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.header-account-menu {
    display: none;
    position: absolute;
    top: 120%;
    right: 0;
    min-width: 200px;
    padding: 0.5rem;
    border-radius: var(--radius-lg, 14px);
    border: 1px solid var(--ch-line, rgba(28, 25, 23, 0.085));
    background: var(--ch-surface, #ffffff);
    color: var(--ch-text, #171513);
    box-shadow: var(--shadow-lg, 0 18px 44px -12px rgba(28, 25, 23, 0.2));
    z-index: 40;
    flex-direction: column;
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
}
.header-account-menu.open {
    display: flex;
}
.header-account-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.45rem 0.6rem 0.55rem;
    border-bottom: 1px solid var(--ch-line, rgba(0, 0, 0, 0.08));
    margin-bottom: 0.25rem;
}
.header-account-meta span {
    font-size: 0.75rem;
    color: var(--ch-muted, #5e5e5e);
}
.header-account-menu a {
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm, 6px);
    text-decoration: none;
    color: inherit;
    font-size: 0.86rem;
}
.header-account-menu a:hover {
    background: var(--ch-orange-soft, rgba(236, 106, 53, 0.14));
}
[data-theme="dark"] .header-account-menu {
    background: var(--ch-surface, #262421);
    color: var(--ch-text, #e8e4dc);
    border-color: var(--ch-line, rgba(255, 255, 255, 0.08));
}
[data-theme="dark"] .header-account-meta strong,
[data-theme="dark"] .header-account-menu a {
    color: var(--ch-text, #e8e4dc);
}
[data-theme="dark"] .header-account-meta span {
    color: var(--ch-muted, #a8a29a);
}
[data-theme="dark"] .header-account-menu a:hover {
    background: var(--ch-surface-3, #312e2b);
    color: var(--ch-text, #e8e4dc);
}
.header-dark-sun {
    display: none;
}
.header-dark-moon {
    display: block;
}
[data-theme="dark"] .header-dark-sun {
    display: block;
}
[data-theme="dark"] .header-dark-moon {
    display: none;
}
.dark-mode-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: rgba(15, 23, 42, 0.02);
    color: #0f172a;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.dark-mode-toggle:hover {
    background: rgba(15, 23, 42, 0.04);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
.dark-mode-toggle .icon-svg {
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.dark-mode-toggle[aria-expanded="true"] .icon-svg {
    transform: rotate(42deg);
}
[data-theme="dark"] .dark-mode-toggle {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(148, 163, 184, 0.4);
    color: #e5e7eb;
}
.header-tools-menu {
    position: fixed;
    top: 3.7rem;
    right: max(1rem, calc((100vw - 1100px) / 2 + 1rem));
    width: min(320px, calc(100vw - 1.5rem));
    min-width: 0;
    padding: 0.7rem;
    border-radius: 16px;
    border: 1px solid rgba(28, 25, 22, 0.1);
    background: #fffdf9;
    box-shadow:
        0 4px 6px rgba(28, 25, 22, 0.04),
        0 18px 40px rgba(28, 25, 22, 0.14);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate3d(0, -8px, 0) scale(0.98);
    transform-origin: top right;
    transition:
        opacity 0.16s ease,
        transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.16s;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.header-tools-menu.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate3d(0, 0, 0) scale(1);
}

/* Mobile-only More sheet chrome — hidden in the desktop gear popup */
.more-sheet-head,
.more-sheet-kicker,
.more-sheet-title,
.more-sheet-section-label,
.tools-menu-divider,
.more-mode-row {
    display: none;
}

.tools-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    font-size: 0.86rem;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
.tools-menu-item button,
.tools-menu-item select {
    font: inherit;
}

#toolsDarkToggle {
    width: 100%;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(28, 25, 22, 0.08);
    border-radius: 12px;
    background: rgba(28, 25, 22, 0.03);
    color: #1c1916;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
#toolsDarkToggle:hover {
    background: rgba(181, 136, 99, 0.1);
    border-color: rgba(181, 136, 99, 0.35);
}
#toolsDarkToggle:active {
    transform: scale(0.99);
}
#toolsDarkToggle .more-sheet-row-main {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}
#toolsDarkToggle .more-sheet-row-meta {
    font-size: 0.75rem;
    font-weight: 650;
    color: #8a8176;
    letter-spacing: 0.02em;
}

.piece-theme-item,
.board-theme-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.55rem 0.7rem 0.65rem;
    border: 1px solid rgba(28, 25, 22, 0.08);
    border-radius: 12px;
    background: rgba(28, 25, 22, 0.03);
}
.piece-theme-item .theme-picker-label,
.board-theme-item .theme-picker-label {
    margin: 0;
    font-weight: 650;
    font-size: 0.82rem;
    color: #4b5563;
}
.piece-set-picker,
.board-theme-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.piece-set-option,
.board-theme-swatch {
    width: 2.25rem;
    height: 2.25rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0;
    border-radius: 8px;
    border: 1.5px solid rgba(28, 25, 22, 0.12);
    box-sizing: border-box;
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.piece-set-option img {
    width: 1.45rem;
    height: 1.45rem;
    display: block;
    pointer-events: none;
}
.piece-set-option:hover,
.board-theme-swatch:hover {
    transform: translateY(-1px);
    border-color: rgba(181, 136, 99, 0.55);
}
.piece-set-option:focus-visible,
.board-theme-swatch:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(181, 136, 99, 0.22);
}
.piece-set-option.is-active,
.board-theme-swatch.is-active {
    border-color: var(--color-success, #22a55a);
    box-shadow: 0 0 0 2px rgba(34, 165, 90, 0.28);
}
.board-theme-swatch.default {
    background: linear-gradient(135deg, #ebecd0 50%, #b68860 50%);
}
.board-theme-swatch.grayscale {
    background: linear-gradient(135deg, #dddddd 50%, #8f8f8f 50%);
}
.board-theme-swatch.green {
    background: linear-gradient(135deg, #d9e9d1 50%, #6f9262 50%);
}
.board-theme-swatch.blue {
    background: linear-gradient(135deg, #d1e0e9 50%, #5a7a8f 50%);
}

.tools-dark-icons {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 9px;
    background: rgba(28, 25, 22, 0.05);
}
.tools-dark-icons .icon-svg {
    width: 15px;
    height: 15px;
}
.tools-dark-sun { color: #d4a017; }
.tools-dark-moon { color: #6b6358; opacity: 0.45; }
[data-theme="dark"] .tools-dark-sun { opacity: 0.35; }
[data-theme="dark"] .tools-dark-moon {
    color: #e5e7eb;
    opacity: 1;
}
.tools-dark-label {
    font-weight: 650;
}

[data-theme="dark"] .header-tools-menu {
    background: var(--ch-surface, #262421);
    border-color: var(--ch-line, rgba(255, 255, 255, 0.08));
    box-shadow: var(--shadow-lg, 0 14px 36px rgba(0, 0, 0, 0.5));
}
[data-theme="dark"] #toolsDarkToggle,
[data-theme="dark"] .piece-theme-item,
[data-theme="dark"] .board-theme-item {
    background: var(--ch-surface-2, #1e1c1a);
    border-color: var(--ch-line, rgba(255, 255, 255, 0.08));
    color: var(--ch-text, #e8e4dc);
}
[data-theme="dark"] #toolsDarkToggle:hover {
    background: var(--ch-surface-3, #312e2b);
    border-color: var(--ch-orange, #ec6a35);
}
[data-theme="dark"] #toolsDarkToggle .more-sheet-row-meta,
[data-theme="dark"] .piece-theme-item .theme-picker-label,
[data-theme="dark"] .board-theme-item .theme-picker-label {
    color: var(--ch-muted, #a8a29a);
}
[data-theme="dark"] .piece-set-option {
    background: var(--ch-bg, #161512);
    border-color: var(--ch-line, rgba(255, 255, 255, 0.1));
}
[data-theme="dark"] .tools-dark-icons {
    background: var(--ch-surface-3, #312e2b);
}
[data-theme="dark"] .board-theme-swatch {
    border-color: var(--ch-line, rgba(255, 255, 255, 0.14));
}
[data-theme="dark"] .piece-set-option.is-active,
[data-theme="dark"] .board-theme-swatch.is-active {
    border-color: var(--ch-orange, #ec6a35);
    box-shadow: 0 0 0 2px var(--ch-orange-soft, rgba(236, 106, 53, 0.25));
}

@media (max-width: 1024px) {
    .header-tools {
        margin-left: 0.5rem;
    }
}

.contact-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 2000;
}
.contact-modal-overlay.open {
    display: flex;
}
.contact-modal {
    width: min(560px, 100%);
    background: var(--ch-surface, #ffffff);
    border-radius: var(--radius-lg, 10px);
    box-shadow: var(--shadow-lg, 0 14px 36px rgba(0, 0, 0, 0.35));
    border: 1px solid var(--ch-line, rgba(0, 0, 0, 0.08));
    overflow: hidden;
}
.contact-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--ch-line, rgba(0, 0, 0, 0.08));
}
.contact-modal-head h3,
.contact-modal-head p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ch-text, #1f1f1f);
}
.contact-modal-close {
    background: transparent;
    border: 0;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--ch-muted, #5e5e5e);
    cursor: pointer;
}
.contact-modal-body {
    padding: 1rem 1.15rem 1.15rem;
}
.contact-copy {
    margin: 0 0 0.75rem;
    color: var(--ch-muted, #5e5e5e);
    line-height: 1.55;
    font-size: 0.95rem;
}
.contact-email-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.3rem;
    border: 0;
    border-radius: var(--radius-md, 8px);
    padding: 0.62rem 1rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--ch-on-accent, #ffffff);
    background: var(--ch-orange, #ec6a35);
    cursor: pointer;
    transition: background 0.15s ease;
}
.contact-email-btn:hover {
    background: var(--ch-orange-hi, #f27d4b);
}
[data-theme="dark"] .contact-modal {
    background: var(--ch-surface, #262421);
    border-color: var(--ch-line, rgba(255, 255, 255, 0.08));
}
[data-theme="dark"] .contact-modal-head {
    border-bottom-color: var(--ch-line, rgba(255, 255, 255, 0.08));
}
[data-theme="dark"] .contact-modal-head h3,
[data-theme="dark"] .contact-modal-head p,
[data-theme="dark"] .contact-modal-close {
    color: var(--ch-text, #e8e4dc);
}
[data-theme="dark"] .contact-copy {
    color: var(--ch-muted, #a8a29a);
}
[data-theme="dark"] .contact-email-btn {
    background: var(--ch-orange, #ec6a35);
}
[data-theme="dark"] .contact-email-btn:hover {
    background: var(--ch-orange-hi, #f27d4b);
}
@media (max-width: 1024px) {
    .header {
        padding: 0.12rem 0.4rem;
    }
    .header-container {
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
        gap: 0.2rem;
        min-height: 34px;
    }
    .logo {
        gap: 0;
        min-width: 0;
        order: 1;
        flex: 0 0 auto;
        margin-right: 0.1rem;
    }
    .logo a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        text-decoration: none;
    }
    .logo-icon {
        font-size: 1.2rem;
        line-height: 1;
    }
    /* Icon-only brand on mobile — frees space for chat + quick tools */
    .logo .logo-text {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    .header-quick-nav {
        display: flex;
        order: 2;
        align-items: center;
        gap: 0.12rem;
        flex: 1 1 auto;
        min-width: 0;
        margin: 0 0.15rem;
    }
    .header-quick-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        color: var(--color-text, #1c1916);
        text-decoration: none;
        border: 1px solid transparent;
        background: transparent;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }
    .header-quick-link .icon-svg {
        width: 1.15rem;
        height: 1.15rem;
    }
    .header-quick-link:hover,
    .header-quick-link:focus-visible {
        background: rgba(181, 136, 99, 0.12);
        border-color: rgba(181, 136, 99, 0.35);
        outline: none;
    }
    .header-quick-link.active {
        background: rgba(181, 136, 99, 0.18);
        border-color: rgba(181, 136, 99, 0.55);
        color: #8d6240;
    }
    [data-theme="dark"] .header-quick-link {
        color: #e2e8f0;
    }
    [data-theme="dark"] .header-quick-link:hover,
    [data-theme="dark"] .header-quick-link:focus-visible {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(148, 163, 184, 0.35);
    }
    [data-theme="dark"] .header-quick-link.active {
        background: rgba(181, 136, 99, 0.22);
        border-color: rgba(181, 136, 99, 0.55);
        color: #e8d5c0;
    }
    .header-tools {
        order: 3;
        gap: 0.15rem;
        margin-left: auto;
        flex-shrink: 0;
    }
    .mobile-menu-toggle {
        display: flex;
        order: 4;
        width: 30px;
        height: 30px;
        border-width: 1px;
        gap: 3px;
    }
    .mobile-menu-toggle span {
        width: 13px;
    }
    .header-trophy {
        display: none;
    }
    .nav-tab-extra,
    .nav-tab-signin {
        display: flex;
    }
    /* Sign in lives in the hamburger drawer on mobile */
    .header-signin {
        display: none !important;
    }
    .dark-mode-toggle,
    .header-avatar-btn,
    .mobile-menu-toggle {
        width: 30px;
        height: 30px;
    }
}
