html {
    height: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Noto Sans TC", "Segoe UI", "Arial", sans-serif;
    background: #181d27;
    color: #e2e2e2;
    min-height: 100vh; /* 關鍵：確保 body 至少跟螢幕一樣高 */
    display: flex;
    flex-direction: column;
}

img,
iframe,
table,
ins.adsbygoogle {
    max-width: 100%;
}

img {
    height: auto;
}

main {
    flex: 1;
    z-index: 1;
    position: relative;
}

header {
    background: #232736;
    padding: 0.8em 0.5em 0.1em 0.5em;
    text-align: center;
    box-shadow: 0 2px 10px #13151d90;
    z-index: 1001 !important;
    position: relative;
    overflow: visible !important;
}

.logo-row {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 920px;
    margin: 0 auto;
    position: relative;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 1.2em;
    margin-bottom: 0;
}

.site-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 10px;
    background: none;
    box-shadow: none;
    border: none;
    padding: 0;
}

header h1 {
    margin: 0;
    font-size: 2.1em;
    letter-spacing: 0.05em;
    color: #e6b167;
}

header .en {
    font-size: 0.8em;
    color: #e0e0e0b2;
    margin-left: 0.5em;
}

nav {
    margin-top: 0.2em;
    display: flex;
    justify-content: center;
    gap: 1.3em;
    flex-wrap: wrap;
    width: 100%;
    position: relative;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 1.3em;
    flex-wrap: wrap;
}

.nav-list>li {
    position: relative;
}

.nav-list>li>a {
    color: #e6b167;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1em;
    padding: 0.2em 0.7em 0.2em 0.4em;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.5em;
    transition: color 0.2s, border-bottom 0.2s;
}

.nav-list>li>a:hover,
.nav-list>li>a:focus {
    color: #ffebc1;
    border-bottom: 2px solid #e6b167;
}

.nav-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 5px;
    vertical-align: middle;
    background: none;
    box-shadow: none;
    border: none;
    padding: 0;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 150px;
    background: #232736;
    border-radius: 0.7em;
    box-shadow: 0 8px 16px #00000033;
    padding: 0.5em 0;
    z-index: 999;
}

.nav-list>.dropdown:hover>.dropdown-menu {
    display: block;
}

.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    top: 0;
    left: 100%;
    margin-left: 0.35em;
}

.dropdown-submenu:hover>.dropdown-menu {
    display: block;
}

.dropdown-menu li {
    display: block;
}

.dropdown-menu a {
    display: block;
    color: #e6b167;
    padding: 0.6em 1.2em;
    font-size: 1em;
    font-weight: 400;
    text-decoration: none;
    background: none;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
    border: none;
}

.dropdown-menu a:hover {
    background: #363d52;
    color: #ffd994;
}

.dropdown-empty {
    display: block;
    padding: 0.6em 1.2em;
    color: #b9bdca;
    white-space: nowrap;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    position: absolute;
    top: 2.1em;
    right: 1.5em;
    width: 2.4em;
    height: 2.4em;
    z-index: 1003;
}

.nav-toggle span {
    display: block;
    width: 2em;
    height: 0.28em;
    margin: 0.38em 0;
    background: #ffd994;
    border-radius: 0.21em;
    transition: 0.2s;
}

@media (max-width: 700px) {
    .logo-row {
        padding: 0 0.7em;
    }

    .logo-title {
        gap: 0.7em;
        font-size: 1em;
    }

    .nav-toggle {
        display: block;
        position: static;
        margin-left: auto;
        margin-right: 0;
        margin-top: 0;
        align-self: center;
        z-index: 1102;
    }

    .site-logo {
        width: 32px;
        height: 32px;
        border-radius: 7px;
    }

    nav {
        margin-top: 0;
    }

    .nav-list,
    .nav-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        width: 100%;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 4.4em;
        left: 0;
        width: 100vw;
        background: #232736ee;
        box-shadow: 0 2px 24px #13151d88;
        padding: 1.5em 0 1em 0;
        z-index: 1002;
        animation: fadeInNav 0.23s;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-list>li {
        width: 100%;
        text-align: center;
    }

    .dropdown-menu {
        position: static;
        min-width: unset;
        box-shadow: none;
        border-radius: 0;
    }

    .dropdown-menu a {
        padding: 0.6em 2em;
    }

    header h1 {
        font-size: 1.3em;
    }
}

@media (max-width: 700px) {
    .dropdown-menu .dropdown>.dropdown-menu {
        position: static;
        display: block;
        width: 100%;
        margin-left: 0;
        padding-left: 1em;
        border-radius: 0;
        box-shadow: none;
        background: #1a1f2c;
    }
}

.intro {
    background: #232736;
    border-radius: 1.2em;
    padding: 2em 1.5em;
    box-shadow: 0 2px 14px #1c202d44;
    margin-bottom: 2em;
    text-align: center;
    color: #fff9ec;
}

.works ul {
    padding: 0;
    list-style: none;
}

.works li {
    background: #232736;
    border-radius: 1em;
    margin-bottom: 1.3em;
    padding: 1.2em 1em;
    box-shadow: 0 1px 8px #00000033;
    transition: box-shadow 0.2s, background 0.2s;
}

.works li:hover {
    box-shadow: 0 4px 20px #e6b16722;
    background: #292d3c;
}

.works h3 {
    margin-top: 0;
    color: #e6b167;
}

/* Footer樣式 */
footer {
    left: 0;
    bottom: 0;
    width: 100%;
    background: #232736e6;
    color: #e6b167;
    font-size: 1em;
    text-align: center;
    padding: 0.9em 0;
    letter-spacing: 0.02em;
    z-index: 100;
    box-shadow: 0 -2px 10px #00000030;
    backdrop-filter: blur(2px);
    flex-shrink: 0;
}

.include-error {
    color: #e6b167;
    text-align: center;
}

.footer-links {
    margin-bottom: 0.25em;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.2em;
    font-size: 1.06em;
    flex-wrap: wrap;
}

.footer-links a {
    color: #ffd994;
    text-decoration: none;
    font-weight: 500;
    margin: 0 0.18em;
    transition: color 0.18s, border-bottom 0.18s;
    padding: 0.05em 0.3em;
    border-radius: 0.5em;
    border-bottom: 2px solid transparent;
}

.footer-links a:hover,
.footer-links a:focus {
    color: #ffebc1;
    background: #282f3a;
    border-bottom: 2px solid #e6b167;
}

.footer-divider {
    color: #e6b167cc;
    margin: 0 0.13em;
    font-size: 1.06em;
    user-select: none;
}

.footer-copyright {
    font-size: 0.98em;
    color: #e6b167;
    margin-top: 0.15em;
    letter-spacing: 0.02em;
}

@media (max-width: 600px) {
    main {
        padding: 0 0.3em;
    }

    .footer-links {
        font-size: 0.97em;
        gap: 0.09em;
    }

    .footer-copyright {
        font-size: 0.92em;
    }
}

@keyframes fadeInNav {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 700px) {
    .logo-title {
        flex-direction: column;
        align-items: center;
        gap: 0.3em;
    }

    header h1 {
        font-size: 1.1em;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 0.2em;
        margin-bottom: 0;
    }

    header .en {
        display: block;
        margin: 0.1em 0 0 0;
        font-size: 0.98em;
        white-space: normal;
        word-break: keep-all;
    }
}

.logo-row {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 920px;
    margin: 0 auto;
    position: relative;
    padding: 0 0.7em;
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 0.7em;
}

.site-logo {
    width: 45px;
    height: 45px;
    border-radius: 8px;
}

.logo-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.08;
}

.title-zh {
    font-size: 2.1em;
    font-weight: bold;
    color: #e6b167;
    margin-bottom: 0.10em;
    letter-spacing: 0.05em;
}

.title-en {
    font-size: 1em;
    color: #b5bbc9;
    font-weight: 400;
    margin-left: 0.04em;
    letter-spacing: 0.03em;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    margin-left: auto;
    z-index: 1102;
}

.nav-toggle span {
    display: block;
    width: 2em;
    height: 0.28em;
    margin: 0.38em 0;
    background: #ffeab7;
    border-radius: 0.21em;
    transition: 0.2s;
}

@media (max-width: 700px) {
    .logo-row {
        justify-content: space-between;
        padding: 0 0.6em;
    }

    .site-logo {
        width: 38px;
        height: 38px;
    }

    .logo-block {
        gap: 0.55em;
    }

    .logo-text {
        line-height: 1.08;
        min-width: 85px;
    }

    .title-zh {
        font-size: 1.11em;
        margin-bottom: 0.08em;
    }

    .title-en {
        font-size: 0.99em;
        white-space: nowrap;
    }

    .nav-toggle {
        display: block;
        position: static;
        margin-left: 0;
        margin-right: 0;
        align-self: center;
    }

    nav {
        margin-top: 0;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        position: fixed;
        top: calc(60px + 1em);
        left: 0;
        width: 100vw;
        background: #232736ee;
        box-shadow: 0 2px 24px #13151d88;
        padding: 0.6em 0 1em 0;
        z-index: 1002;
        animation: fadeInNav 0.23s;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-list>li {
        width: 100%;
        text-align: left;
        padding-left: 2em;
    }
}

@media (max-width: 460px) {
    .logo-text {
        min-width: 68px;
    }
}

/* 共用導覽列收斂：放在檔尾統一覆蓋舊版重複規則。 */
.logo-block {
    color: inherit;
    text-decoration: none;
}

.nav-list,
.dropdown-menu {
    list-style: none;
}

.nav-toggle {
    padding: 0;
}

.nav-toggle span {
    pointer-events: none;
}

.dropdown>a::after {
    content: "▾";
    font-size: 0.75em;
    opacity: 0.8;
}

@media (min-width: 701px) {
    .nav-menu {
        display: flex;
    }
}

@media (max-width: 700px) {
    header {
        padding: 0.65em 0;
    }

    .logo-row {
        max-width: 100%;
        justify-content: space-between;
        gap: 0.8em;
    }

    .logo-block {
        min-width: 0;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100vw;
        padding: 0.6em 0 1em;
        overflow-x: hidden;
    }

    .nav-list>li {
        padding-left: 0;
        text-align: left;
    }

    .nav-list>li>a,
    .dropdown-menu a {
        width: 100%;
        padding: 0.75em 1.4em;
    }

    .dropdown-menu {
        display: block;
        width: 100%;
        padding: 0 0 0.2em;
        background: #1f2431;
    }
}

/* 本機 file:// 預覽：說明 CSV / 雲端資料需透過 http 伺服器開啟 */
.kojiro-file-protocol-hint {
    position: relative;
    z-index: 10000;
    margin: 0;
    padding: 0.85em 3.2em 0.85em 1em;
    background: #3d2914;
    color: #ffe9c7;
    border-bottom: 2px solid #e6b167;
    font-size: 0.95rem;
    line-height: 1.55;
}

.kojiro-file-protocol-hint strong {
    color: #ffd994;
}

.kojiro-file-protocol-hint p {
    margin: 0.45em 0 0 0;
}

.kojiro-file-protocol-hint code {
    background: #1a1410;
    padding: 0.1em 0.35em;
    border-radius: 0.25em;
    font-size: 0.92em;
}

.kojiro-file-protocol-hint pre {
    margin: 0.5em 0 0 0;
    padding: 0.6em 0.75em;
    background: #1a1410;
    border-radius: 0.4em;
    overflow-x: auto;
    font-size: 0.88em;
}

.kojiro-file-protocol-hint-close {
    position: absolute;
    top: 0.55em;
    right: 0.55em;
    padding: 0.25em 0.65em;
    border-radius: 0.35em;
    border: 1px solid #e6b167;
    background: #2a2118;
    color: #ffe9c7;
    cursor: pointer;
    font-size: 0.88em;
}

.kojiro-file-protocol-hint-close:hover {
    background: #3d2914;
}