:root {
    --bg: #18201d;
    --surface: #26332e;
    --surface-strong: #31433a;
    --text: #f1efe6;
    --muted: #c2bcae;
    --accent: #d7b56d;
    --accent-strong: #f0ce80;
    --ink: #111614;
    --line: rgba(241, 239, 230, 0.18);
    --shadow: rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 180ms ease, color 180ms ease;
}

:root[data-theme="ink-wash"] {
    --bg: #17201c;
    --surface: #25332f;
    --surface-strong: #33473f;
    --text: #f3efe3;
    --muted: #c6bea9;
    --accent: #c9ad72;
    --accent-strong: #ead08c;
    --ink: #101511;
    --line: rgba(234, 208, 140, 0.3);
}

:root[data-theme="ukiyo-e"] {
    --bg: #1a2c35;
    --surface: #263f4a;
    --surface-strong: #8a3f32;
    --text: #f8e9c6;
    --muted: #e0bd88;
    --accent: #d24b35;
    --accent-strong: #f2b85b;
    --ink: #10222b;
    --line: rgba(242, 184, 91, 0.32);
}

:root[data-theme="bauhaus"] {
    --bg: #202124;
    --surface: #2f3034;
    --surface-strong: #473a2d;
    --text: #f0e7d2;
    --muted: #cfc1a8;
    --accent: #d6a22a;
    --accent-strong: #d94f3d;
    --ink: #121316;
    --line: rgba(214, 162, 42, 0.38);
}

:root[data-theme="art-deco"] {
    --bg: #121922;
    --surface: #1e2a38;
    --surface-strong: #26394d;
    --text: #f6e6bd;
    --muted: #c8b88b;
    --accent: #d7a94b;
    --accent-strong: #f0d486;
    --ink: #090f16;
    --line: rgba(215, 169, 75, 0.45);
}

:root[data-theme="cyberpunk"] {
    --bg: #171827;
    --surface: #25263d;
    --surface-strong: #31244a;
    --text: #f2f5ff;
    --muted: #b8b7d9;
    --accent: #00d7c5;
    --accent-strong: #ff4fd8;
    --ink: #0d0e18;
    --line: rgba(0, 215, 197, 0.36);
}

:root[data-theme="vaporwave"] {
    --bg: #231b36;
    --surface: #34254e;
    --surface-strong: #443060;
    --text: #fff0f8;
    --muted: #d6b8dc;
    --accent: #65d8ff;
    --accent-strong: #f58bd6;
    --ink: #161020;
    --line: rgba(245, 139, 214, 0.32);
}

:root[data-theme="brutalist"] {
    --bg: #24211c;
    --surface: #353027;
    --surface-strong: #4a4335;
    --text: #f6ead4;
    --muted: #d1c0a3;
    --accent: #e9c94c;
    --accent-strong: #ef6f43;
    --ink: #12100d;
    --line: rgba(233, 201, 76, 0.42);
}

:root[data-theme="memphis"] {
    --bg: #17242b;
    --surface: #263843;
    --surface-strong: #384654;
    --text: #f7f1d4;
    --muted: #cfcaaf;
    --accent: #f05b7d;
    --accent-strong: #38c6b4;
    --ink: #101820;
    --line: rgba(56, 198, 180, 0.36);
}

:root[data-theme="pixel"] {
    --bg: #151d28;
    --surface: #202c3d;
    --surface-strong: #2d4058;
    --text: #eef6d8;
    --muted: #b6c49a;
    --accent: #8bd450;
    --accent-strong: #ffcc4d;
    --ink: #0c121a;
    --line: rgba(139, 212, 80, 0.38);
}

:root[data-theme="noir"] {
    --bg: #111112;
    --surface: #222224;
    --surface-strong: #323236;
    --text: #eee7d6;
    --muted: #aaa296;
    --accent: #c9a35b;
    --accent-strong: #e1c37a;
    --ink: #080809;
    --line: rgba(238, 231, 214, 0.18);
}

:root[data-theme="nordic"] {
    --bg: #1b2c30;
    --surface: #2b3e43;
    --surface-strong: #3c555a;
    --text: #eef0e8;
    --muted: #bfcbc6;
    --accent: #d88463;
    --accent-strong: #92c5b6;
    --ink: #101b1d;
    --line: rgba(146, 197, 182, 0.34);
}

:root[data-theme="botanical"] {
    --bg: #172318;
    --surface: #263726;
    --surface-strong: #334a31;
    --text: #f1ead4;
    --muted: #c7bd99;
    --accent: #a9c76e;
    --accent-strong: #e1b45d;
    --ink: #0d150e;
    --line: rgba(169, 199, 110, 0.34);
}

:root[data-theme="ice-age"] {
    --bg: #0a1017;
    --surface: #111a24;
    --surface-strong: #1a2736;
    --text: #e6f0fa;
    --muted: #6b8299;
    --accent: #00dcf0;
    --accent-strong: #00b8c8;
    --ink: #05080c;
    --line: rgba(0, 220, 240, 0.25);
    --shadow: rgba(0, 220, 240, 0.1); /* 新增這行：微透青色科技感陰影 */
}

/* ── Bootstrap Variable Overrides ────────────────────────────────────
   Map all --bs-* tokens to our design system so every Bootstrap
   component (card, modal, btn, form…) follows the active theme.
   These rules run AFTER bootstrap.min.css in the <head>.
──────────────────────────────────────────────────────────────────── */
:root {
    /* body / global */
    --bs-body-bg:               var(--bg);
    --bs-body-color:            var(--text);
    --bs-body-font-family:      "Segoe UI", "Noto Sans TC", Arial, sans-serif;
    --bs-secondary-color:       var(--muted);
    --bs-emphasis-color:        var(--text);
    --bs-border-color:          var(--line);
    --bs-border-color-translucent: var(--line);
    --bs-tertiary-bg:           var(--ink);
    --bs-secondary-bg:          var(--surface-strong);
    --bs-link-color:            var(--accent);
    --bs-link-hover-color:      var(--accent-strong);

    /* card */
    --bs-card-bg:               var(--surface);
    --bs-card-border-color:     var(--line);
    --bs-card-color:            var(--text);
    --bs-card-border-radius:    8px;
    --bs-card-box-shadow:       0 18px 44px var(--shadow);
    --bs-card-cap-bg:           var(--surface-strong);

    /* modal */
    --bs-modal-bg:              var(--surface);
    --bs-modal-color:           var(--text);
    --bs-modal-border-color:    var(--line);
    --bs-modal-header-border-color: var(--line);
    --bs-modal-footer-border-color: var(--line);

    /* form controls */
    --bs-form-control-bg:       var(--ink);
    --bs-form-control-color:    var(--text);
    --bs-form-control-border-color: var(--line);
}

/* Override .btn-primary colours to use accent palette */
.btn-primary {
    --bs-btn-color:             var(--ink);
    --bs-btn-bg:                var(--accent);
    --bs-btn-border-color:      transparent;
    --bs-btn-hover-color:       var(--ink);
    --bs-btn-hover-bg:          var(--accent-strong);
    --bs-btn-hover-border-color: var(--text);
    --bs-btn-active-bg:         var(--accent-strong);
    --bs-btn-active-color:      var(--ink);
    --bs-btn-disabled-bg:       #6b6f6d;
    --bs-btn-disabled-color:    #d4d8d6;
    --bs-btn-disabled-border-color: #6b6f6d;
    font-weight: 900;
    min-height: 44px;
}

/* Form inputs — use ink background & theme border */
.form-control,
.form-select {
    background-color: var(--ink);
    color: var(--text);
    border-color: var(--line);
}
.form-control:focus,
.form-select:focus {
    background-color: var(--ink);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.15);
}
.form-control::placeholder { color: var(--muted); }
.form-control:disabled,
.form-select:disabled {
    background-color: var(--surface);
    opacity: 0.55;
}
.form-label { color: var(--muted); font-weight: 700; }

/* ────────────────────────────────────────────────────────────────── */

header {
    padding: 12px clamp(18px, 4vw, 48px);
    background: var(--ink);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 10px 28px var(--shadow);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1080px;
    margin: 0 auto;
}

.topbar > div:first-child {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.topbar.page-titlebar {
    justify-content: flex-start;
    max-width: none;
    margin: 0;
    padding: 18px clamp(18px, 4vw, 48px) 0;
}

.topbar.page-titlebar .eyebrow {
    display: none;
}

header .topbar {
    margin-bottom: 10px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 4.2rem);
    letter-spacing: 0;
}

header h1 {
    font-size: clamp(1.45rem, 3.4vw, 2.35rem);
    line-height: 1.05;
}

h2 {
    margin-bottom: 12px;
    font-size: clamp(1.45rem, 3vw, 2.4rem);
    line-height: 1.18;
}

p {
    line-height: 1.75;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar .eyebrow {
    margin-bottom: 0;
    line-height: 1;
}

.theme-picker {
    display: grid;
    gap: 8px;
    min-width: 180px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.theme-picker select {
    width: 100%;
    padding: 10px 38px 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: min(1080px, 100%);
    max-width: 1080px;
    margin: 0 auto;
}

nav a,
.theme-cycle,
.theme-menu-toggle,
.nav-login-icon {
    color: var(--text);
    position: relative;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    text-decoration: none;
    font-weight: 800;
    font-size: 0.92rem;
    line-height: 1;
}

.theme-cycle,
.theme-menu-toggle,
.nav-login-icon {
    display: inline-flex;
    align-items: end;
    justify-content: center;
    height: 34px;
    padding: 0;
    color: var(--accent-strong);
    cursor: pointer;
}

.theme-cycle {
    width: 12px;
}

.theme-menu-toggle {
    width: 24px;
    color: var(--muted);
}

.nav-login-icon {
    width: 28px;
    margin-left: 8px;
    color: var(--text);
}

.theme-cycle span,
.theme-menu-toggle span,
.nav-login-icon svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2em;
    font-size: 1rem;
}

.nav-login-icon svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle-chevron {
    color: var(--muted);
    font-size: 0.5rem !important;
}

.theme-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    display: none;
    min-width: 180px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 18px 44px var(--shadow);
}

.theme-menu.open .theme-dropdown {
    display: grid;
    gap: 4px;
}

.theme-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
}

.theme-menu-item.active {
    background: var(--accent);
    color: var(--ink);
    outline: 0;
}

nav a.active {
    color: var(--accent-strong);
}

nav a.active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 1px;
    height: 2px;
    border-radius: 999px;
    background: var(--accent-strong);
}

.nav-login-icon.logged-in {
    color: var(--accent-strong);
}

.nav-login-icon img,
.nav-login-initial {
    width: 24px;
    height: 24px;
    border-radius: 999px;
}

.nav-login-icon img {
    object-fit: cover;
}

.nav-login-initial {
    display: inline-grid;
    place-items: center;
    background: var(--accent);
    color: var(--ink);
    font-size: 0.76rem;
    font-weight: 900;
}

.login-drawer-root {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

.login-drawer-root.open {
    pointer-events: auto;
}

.login-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    opacity: 0;
    transition: opacity 0.22s ease, background 0.22s ease;
}

.login-drawer-root.open .login-backdrop {
    background: rgba(0, 0, 0, 0.58);
    opacity: 1;
}

.login-drawer {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    align-content: start;
    gap: 22px;
    width: min(420px, 92vw);
    height: 100%;
    padding: 28px;
    border-left: 1px solid var(--line);
    background: var(--surface);
    box-shadow: -24px 0 70px var(--shadow);
    transform: translateX(100%);
    transition: transform 0.26s ease;
    overflow-y: auto;
}

.login-drawer-root.open .login-drawer {
    transform: translateX(0);
}

.login-drawer-open {
    overflow: hidden;
}

.login-close {
    justify-self: end;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
}

.login-panel-head {
    display: grid;
    gap: 8px;
}

.login-panel-head h2,
.login-user-panel h2 {
    margin: 0;
}

.login-panel-copy {
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
}

.login-form input,
.login-form select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--ink);
    color: var(--text);
    font: inherit;
}

.login-message {
    min-height: 1.4em;
    color: var(--accent-strong);
    font-weight: 800;
}

.login-message.error {
    color: #ff8a8a;
}

.login-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.login-submit,
.signup-submit,
.signup-confirm,
.login-logout {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.login-submit {
    background: var(--accent);
    color: var(--ink);
}

.signup-confirm {
    width: 100%;
    background: var(--accent);
    color: var(--ink);
}

.signup-submit,
.login-logout {
    background: transparent;
    color: var(--text);
}

.login-submit:disabled,
.signup-submit:disabled,
.signup-confirm:disabled,
.login-switch-link:disabled {
    cursor: wait;
    opacity: 0.65;
}

.signup-actions {
    grid-template-columns: 1fr;
}

.login-switch-link {
    justify-self: start;
    margin-top: -2px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
}

.login-switch-link:hover,
.login-switch-link:focus-visible {
    color: var(--accent-strong);
}

.login-user-panel {
    display: grid;
    gap: 16px;
}

.login-user-avatar {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--accent);
    color: var(--ink);
    font-size: 1.5rem;
    font-weight: 900;
}

.login-user-avatar img,
.login-user-avatar .nav-login-initial {
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}


main {
    flex: 1;
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 36px;
}

.hero {
    margin-bottom: 18px;
}

.hero-copy {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 44px var(--shadow);
    padding: clamp(24px, 5vw, 52px);
}

.hero-copy p:last-child { margin-bottom: 0; }

/* Card tweaks on top of Bootstrap .card */
.card {
    margin-bottom: 18px;
    box-shadow: 0 18px 44px var(--shadow);
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--line);
}

a.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    margin-left: 0 !important;
    transition: border-color 150ms, box-shadow 150ms, transform 150ms;
}

a.card-link:hover {
    border-color: var(--accent);
    box-shadow: 0 22px 52px var(--shadow);
    transform: translateY(-2px);
}

a.card-link article {
    pointer-events: none;
}

.intro-card {
    --bs-card-bg: var(--surface-strong);
    background-color: var(--surface-strong);
}

.project-entry-section {
    margin-bottom: 18px;
}

.section-heading {
    margin-bottom: 12px;
}

.section-heading h2 {
    margin-bottom: 0;
}

.case-list {
    display: grid;
    gap: 10px;
}

.case-row {
    display: grid;
    grid-template-columns: minmax(240px, 0.85fr) minmax(320px, 1.15fr) 36px;
    gap: clamp(14px, 3vw, 26px);
    align-items: center;
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(90deg, var(--surface-strong), var(--surface));
    box-shadow: 0 18px 44px var(--shadow);
    color: inherit;
    text-decoration: none;
    transition: border-color 150ms, box-shadow 150ms, transform 150ms, background 150ms;
}

.case-row:hover,
.case-row:focus-visible {
    border-color: var(--accent);
    background: var(--surface-strong);
    box-shadow: 0 22px 52px var(--shadow);
    color: inherit;
    transform: translateX(4px);
}

.case-title h3 {
    margin: 0;
    color: var(--text);
    font-size: clamp(1.55rem, 3vw, 2.35rem);
    font-weight: 850;
    line-height: 1.16;
}

.case-summary p {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 0.98rem;
}

.case-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--accent-strong);
    font-size: 1.1rem;
    font-weight: 900;
    transition: background 150ms, color 150ms, transform 150ms;
}

.case-row:hover .case-arrow,
.case-row:focus-visible .case-arrow {
    background: var(--accent);
    color: var(--ink);
    transform: translate(2px, -2px);
}

.tech-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

.tech-tags span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--ink);
    color: var(--accent-strong);
    font-size: 0.88rem;
    font-weight: 800;
}

.result-box {
    min-height: 140px;
    margin: 0;
    padding: 14px;
    overflow: auto;
    white-space: pre-wrap;
    background: var(--ink);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
}

small {
    color: var(--muted);
    font-weight: 700;
}

footer {
    text-align: center;
    padding: 22px;
    color: var(--muted);
}

@media (max-width: 720px) {
    .topbar {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
        align-items: start;
    }

    .topbar.page-titlebar {
        display: flex;
        align-items: baseline;
        padding-top: 14px;
    }

    .topbar.page-titlebar > div:first-child {
        gap: 8px;
    }

    .theme-dropdown {
        right: 0;
        max-width: calc(100vw - 36px);
    }

    .case-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .case-title,
    .case-summary {
        grid-column: 1;
    }

    .case-title h3 {
        font-size: 1.55rem;
    }

    .case-arrow {
        grid-column: 1;
        justify-self: start;
        margin-top: 4px;
    }
}

/* 自訂滾動條樣式 (適用於 Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 8px;  /* 垂直滾軸的寬度 */
    height: 8px; /* 水平滾軸的高度 */
}

/* 滾軸的軌道 (背景) */
::-webkit-scrollbar-track {
    background: var(--ink); /* 使用最深的背景色作為軌道 */
    border-radius: 4px;
}

/* 滾軸的滑塊 (本體) */
::-webkit-scrollbar-thumb {
    background: var(--surface-strong); /* 使用比背景稍亮的顏色 */
    border-radius: 4px;
}

/* 滑鼠懸停在滑塊上時的顏色 */
::-webkit-scrollbar-thumb:hover {
    background: var(--muted); /* 懸停時變亮一點 */
}

/* 滑鼠點擊拖曳時的顏色 */
::-webkit-scrollbar-thumb:active {
    background: var(--accent); /* 拖曳時使用主題強調色 */
}

/* 針對 Firefox 瀏覽器的支援 (Firefox 語法不同) */
* {
    scrollbar-width: thin; /* 設定為細滾軸 */
    scrollbar-color: var(--surface-strong) var(--ink); /* 滑塊顏色 軌道顏色 */
}
