html {
    scroll-behavior: smooth;
}

body {
    background-color: #131313;
    color: #e2e2e2;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 64px 64px;
    background-position: center top;
}

html.dark {
    color-scheme: dark;
}

html.light {
    color-scheme: light;
}

.glass-panel {
    background: rgba(19, 19, 19, 0.4);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.border-line {
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.glow-hover:hover {
    box-shadow: inset 0 0 20px rgba(179, 198, 243, 0.1);
    border-color: rgba(179, 198, 243, 0.5);
}

/* Minimalist Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #131313;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: #444748;
}

::-webkit-scrollbar-thumb:hover {
    background: #8e9192;
}

.lang-switch {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(19, 19, 19, 0.75);
    backdrop-filter: blur(8px);
}

.lang-select-shell {
    position: relative;
    min-width: 90px;
}

.lang-select-shell::after {
    content: '';
    position: absolute;
    right: 11px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 1px solid rgba(226, 226, 226, 0.8);
    border-bottom: 1px solid rgba(226, 226, 226, 0.8);
    transform: translateY(-60%) rotate(45deg);
    pointer-events: none;
}

.lang-select-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-width: 90px;
    border: 0;
    border-radius: 0;
    background-color: rgba(19, 19, 19, 0.95);
    color: #e2e2e2;
    font-family: 'Geist', monospace;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: none;
    line-height: 1;
    padding: 0.68rem 2rem 0.68rem 0.8rem;
    transition: none;
    cursor: pointer;
}

.lang-switch:hover {
    border-color: rgba(179, 198, 243, 0.55);
}

.lang-select-trigger:hover,
.lang-select-trigger:focus {
    outline: none;
    background-color: rgba(179, 198, 243, 0.12);
    color: #e2e2e2;
}

.lang-select-trigger:focus-visible {
    outline: 1px solid rgba(179, 198, 243, 0.7);
    outline-offset: -1px;
}

.custom-lang-dropdown.is-open .lang-select-shell::after {
    transform: translateY(-35%) rotate(225deg);
}

.lang-menu {
    position: absolute;
    left: -1px;
    right: -1px;
    top: calc(100% + 1px);
    z-index: 60;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background-color: rgba(13, 13, 13, 0.98);
    backdrop-filter: blur(10px);
}

.lang-menu.hidden {
    display: none;
}

.lang-option {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: #131313;
    color: #e2e2e2;
    font-family: 'Geist', monospace;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: none;
    white-space: nowrap;
    text-align: left;
    padding: 0.62rem 0.8rem;
    cursor: pointer;
    transition: none;
}

.lang-option:first-child {
    border-top: 0;
}

.lang-option:hover,
.lang-option:focus-visible {
    outline: none;
    background-color: rgba(179, 198, 243, 0.2);
    color: #e2e2e2;
}

.lang-option[aria-selected='true'] {
    background-color: rgba(179, 198, 243, 0.16);
    color: #b3c6f3;
}

.lang-current[lang='zh-TW'],
.lang-option[lang='zh-TW'] {
    font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', 'Heiti TC', sans-serif;
}

.lang-current[lang='zh-CN'],
.lang-option[lang='zh-CN'] {
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Heiti SC', sans-serif;
}

.lang-current[lang='ja'],
.lang-option[lang='ja'] {
    font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
}

.lang-current[lang='en'],
.lang-option[lang='en'] {
    font-family: 'Geist', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

.lang-switch-mobile {
    display: flex;
    width: 100%;
}

.lang-switch-icon {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 0;
    backdrop-filter: none;
}

.lang-switch-icon .lang-select-shell {
    min-width: auto;
}

.lang-switch-icon .lang-select-shell::after {
    display: none;
}

.lang-select-trigger--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: auto;
    padding: 0;
    border: 0;
    background: transparent !important;
}

.lang-icon {
    font-size: 20px;
    line-height: 1;
}

.lang-select-trigger--icon:hover,
.lang-select-trigger--icon:focus {
    background: transparent !important;
    color: #b3c6f3;
}

.lang-current-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.lang-switch-icon .lang-menu {
    right: -18px;
    left: auto;
    min-width: 120px;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: #e2e2e2;
    font-family: 'Geist', monospace;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0;
    transition: none;
}

.theme-toggle-btn .material-symbols-outlined {
    font-size: 20px;
    line-height: 1;
}

.theme-toggle-btn:hover,
.theme-toggle-btn:focus-visible {
    outline: none;
    background: transparent;
    color: #b3c6f3;
}

.theme-toggle-btn-mobile {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0 0.8rem;
    margin-top: 0.6rem;
    min-height: 42px;
}

.hire-me-anchor {
    scroll-margin-top: 90px;
}

.hire-me-section {
    margin-top: 0.75rem;
    margin-bottom: 1.5rem;
}

.footer-with-gap {
    margin-top: 0.75rem;
}

@media (min-width: 768px) {
    .hire-me-section {
        margin-top: 1rem;
        margin-bottom: 2rem;
    }

    .footer-with-gap {
        margin-top: 1rem;
    }
}

/* Harmonize interactive states with dark theme by overriding white inversion utilities */
.dark .hover\:bg-primary:hover,
.dark .hover\:bg-primary:focus-visible {
    background-color: rgba(179, 198, 243, 0.18) !important;
    color: #e2e2e2 !important;
    border-color: rgba(179, 198, 243, 0.55) !important;
}

.dark .hover\:text-background:hover,
.dark .hover\:text-background:focus-visible {
    color: #e2e2e2 !important;
}

.light .hover\:bg-primary:hover,
.light .hover\:bg-primary:focus-visible {
    background-color: #101828 !important;
    color: #f8fafc !important;
    border-color: #101828 !important;
}

.light .hover\:text-background:hover,
.light .hover\:text-background:focus-visible {
    color: #f8fafc !important;
}

a:focus-visible,
button:focus-visible {
    outline: 1px solid rgba(179, 198, 243, 0.7);
    outline-offset: 1px;
}

#three-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    cursor: grab;
}

#three-canvas:active {
    cursor: grabbing;
}

/* Ensure overlay allows pointer events through to canvas */
.pointer-events-none-except-buttons {
    pointer-events: none;
}

.pointer-events-none-except-buttons a,
.pointer-events-none-except-buttons button {
    pointer-events: auto;
}

html.light body {
    background-color: #f7f9fc;
    color: #1f2937;
    background-image:
        linear-gradient(to right, rgba(16, 24, 40, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(16, 24, 40, 0.06) 1px, transparent 1px);
}

html.light .glass-panel {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(16, 24, 40, 0.16);
}

html.light .border-line {
    border-color: rgba(16, 24, 40, 0.2);
}

html.light .glow-hover:hover {
    box-shadow: inset 0 0 20px rgba(47, 99, 216, 0.09);
    border-color: rgba(47, 99, 216, 0.45);
}

html.light ::-webkit-scrollbar-track {
    background: #f3f6fb;
    border-left: 1px solid rgba(16, 24, 40, 0.12);
}

html.light ::-webkit-scrollbar-thumb {
    background: #b2bdd1;
}

html.light ::-webkit-scrollbar-thumb:hover {
    background: #6b7a96;
}

html.light .theme-toggle-btn {
    border: 0;
    background: transparent;
    color: #1f2937;
}

html.light .theme-toggle-btn:hover,
html.light .theme-toggle-btn:focus-visible {
    background: transparent;
    color: #2f63d8;
}

html.light .lang-switch {
    border-color: rgba(16, 24, 40, 0.2);
    background: rgba(255, 255, 255, 0.88);
}

html.light .lang-select-trigger {
    background-color: rgba(255, 255, 255, 0.92);
    color: #1f2937;
}

html.light .lang-select-shell::after {
    border-right-color: rgba(16, 24, 40, 0.75);
    border-bottom-color: rgba(16, 24, 40, 0.75);
}

html.light .lang-select-trigger:hover,
html.light .lang-select-trigger:focus {
    background-color: rgba(47, 99, 216, 0.12);
    color: #1f2937;
}

html.light .lang-select-trigger--icon:hover,
html.light .lang-select-trigger--icon:focus {
    color: #2f63d8;
}

html.light .lang-menu {
    border-color: rgba(16, 24, 40, 0.2);
    background-color: rgba(255, 255, 255, 0.96);
}

html.light .lang-option {
    border-top-color: rgba(16, 24, 40, 0.1);
    background-color: #ffffff;
    color: #1f2937;
}

html.light .lang-option:hover,
html.light .lang-option:focus-visible {
    background-color: rgba(47, 99, 216, 0.12);
}

html.light .lang-option[aria-selected='true'] {
    background-color: rgba(47, 99, 216, 0.15);
    color: #1e4aa8;
}

html.light .text-primary {
    color: #101828 !important;
}

html.light .text-on-surface {
    color: #1f2937 !important;
}

html.light .text-on-surface-variant {
    color: #475467 !important;
}

html.light .text-secondary {
    color: #2f63d8 !important;
}

html.light .text-outline {
    color: #667085 !important;
}

html.light .bg-background {
    background-color: #f7f9fc !important;
}

html.light .bg-background\/95 {
    background-color: rgba(247, 249, 252, 0.95) !important;
}

html.light .bg-background\/90 {
    background-color: rgba(247, 249, 252, 0.9) !important;
}

html.light .bg-background\/80 {
    background-color: rgba(247, 249, 252, 0.82) !important;
}

html.light .bg-background\/50 {
    background-color: rgba(247, 249, 252, 0.62) !important;
}

html.light .bg-background\/30 {
    background-color: rgba(247, 249, 252, 0.5) !important;
}

html.light .bg-surface\/50 {
    background-color: rgba(255, 255, 255, 0.72) !important;
}

html.light .bg-surface-container-lowest {
    background-color: #eef2f8 !important;
}

html.light .border-white\/15 {
    border-color: rgba(16, 24, 40, 0.18) !important;
}

html.light .border-white\/10 {
    border-color: rgba(16, 24, 40, 0.12) !important;
}

html.light .border-white\/5 {
    border-color: rgba(16, 24, 40, 0.08) !important;
}

html.light .border-white\/30 {
    border-color: rgba(16, 24, 40, 0.26) !important;
}

html.light .hover\:bg-white\/5:hover,
html.light .hover\:bg-white\/5:focus-visible {
    background-color: rgba(16, 24, 40, 0.05) !important;
}

html.light a:focus-visible,
html.light button:focus-visible {
    outline: 1px solid rgba(47, 99, 216, 0.6);
}