/* ==================== CSS 變數 ==================== */
:root {
    /* 固定淺色：Chrome/Samsung 的「網頁自動深色」看到 only light 就不會反轉配色，
       表單控制項也不會跟著系統深色模式變黑 */
    color-scheme: only light;
    --font-sans:  "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
    --font-serif: "Noto Serif TC", Georgia, serif;
    --color-primary:   #1a3260;
    --color-accent:    #1a3260; /* 不再使用亮藍，統一深藍 */
    --color-hover:     #0f1d3b; /* 滑鼠移上去：更深的藍，不跳亮藍 */
    --color-text:      #1a1a2e;
    --color-muted:     #64748b;
    --color-border:    #e2e8f0;
    --color-bg:        #f5f5f5;
    /* 首頁插圖色票：暖黃、米白、淺藍 */
    --hp-yellow: #f6c344;
    --hp-cream: #fdf8ec;
    --hp-sky: #e9f0f9;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* 全站內容寬度的唯一來源。各頁請勿自行宣告 max-width，
       一律沿用 .container／.page-content 等既有容器類別。 */
    --content-width: 1100px;
    /* 左右留白：手機 16px，較寬螢幕恢復 32px。
       390px 下固定 32px 兩側共吃掉 64px（畫面的 16%）。 */
    --content-gutter: clamp(1rem, 0.3rem + 3vw, 2rem);
    /* 固定導覽列高度 = logo 高 + 上下 0.3rem + 2px 邊框；手機版在下方縮小 */
    --nav-h: 92px;
}

/* ==================== ?��?�?? ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    line-height: 1.6;
    padding-top: var(--nav-h);
    overflow-x: hidden;
}

/* ==================== 導航?�樣�?==================== */

/* ?��?導航?��??��???*/
nav.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-bottom: 2px solid #e0e0e0;
}

/* 導航?��?�?*/
.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 1rem;
}

/* Logo?��??�左??*/
.logo {
    display: flex;
    align-items: center;
    max-width: 320px;
}

.logo a {
    display: block;
    line-height: 0;
}

.logo img {
    height: 80px;
    width: auto;
    max-width: 310px;
    object-fit: contain;
    display: block;
}

@media (max-width: 640px) {
    :root { --nav-h: 68px; }
    .logo img { height: 56px; }
}

/* ?��??�單?�塊�??�含上�??��?�?*/
.nav-menus {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-end;
}

/* 上層?�單 */
.nav-top-menu {
    list-style: none;
    display: flex;
    gap: 1rem;
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav-top-menu li a {
    color: #333333;
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-top-menu li a:hover {
    color: #333333;
    font-weight: 900;
}

/* 導航?�中?�表?�樣式�??�於?�出?��?�?*/
.nav-top-menu form {
    display: inline;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

/* ?�入?��??��?�?? */
/* 下層?�單 */
.nav-bottom-menu {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav-bottom-menu > li {
    position: relative;
}

.nav-bottom-menu > li > a {
    color: #333333;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.25rem 0;
    padding-bottom: 0.15rem;
    display: block;
    position: relative;
}

/* Hover?��?：�?�?+ 粗�?線直?�出??*/
.nav-bottom-menu > li > a:hover {
    color: #333333;
    font-weight: 900;
}

.nav-bottom-menu > li > a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background-color: var(--color-accent);
}

.nav-bottom-menu > li > a:hover::after {
    width: 100%;
}

/* 下�??�單�?? */
.has-dropdown {
    position: relative;
}

.dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 4px;
    padding: 0.5rem 0;
    list-style: none;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

.dropdown-caret {
    display: none;
}

.has-dropdown:hover .dropdown {
    opacity: 1;
    visibility: visible;
}

.dropdown li {
    padding: 0;
    margin: 0;
}

.dropdown li a {
    display: block;
    padding: 0.6rem 1.2rem;
    color: #555555;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: left;
    white-space: nowrap;
}

.dropdown li a:hover {
    background-color: #f0f0f0;
    color: #333333;
    font-weight: 700;
}

/* 漢堡?�單?��? */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: #333333;
    transition: all 0.3s;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ==================== 主�??�容?�??==================== */
.container {
    max-width: var(--content-width);
    margin: 1.4rem auto 2rem;
    padding: 0 var(--content-gutter);
}

/* 版面系統統一內容寬度：三者皆為 var(--content-width)，
   差異僅在左右留白與用途語意，不再各自訂寬度。 */
.page-content {
    max-width: var(--content-width);
    margin: 0 auto;
}

/* 寬版內容器：與 footer 對齊，左右各留 var(--content-gutter) */
.page-content--wide {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--content-gutter);
}

.page-content--sm {
    max-width: var(--content-width);
    margin: 0 auto;
}

.page-header {
    margin-bottom: 1.4rem;
    display: block;
    width: 100%;
}

.page-header h1 {
    /* 手機 1.75rem → 桌機 2.6rem，隨畫面寬度無級縮放 */
    font-size: clamp(1.75rem, 1.15rem + 2.6vw, 2.6rem);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: 0.03em;
    line-height: 1;
    margin-bottom: 0;
}

.page-header p {
    color: #666;
    font-size: 0.95rem;
    margin-top: 0.6rem;
    display: none;
}

.page-header .page-en-label {
    width: auto;
}

/* ?��??�面：英?��?字�??��??��??��?題�?下方?��?一?��? */
.page-header.page-header--top-gap {
    padding-top: 1.4rem;
}

.page-header.page-header--top-gap .page-en-label {
    margin-top: 0;
}

/* 標�??��?標�? + ?�側 CTA ?��?並�?�?*/
.page-header-row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
    margin-bottom: 1.4rem;
    gap: 1rem;
}

.page-header-row .page-header {
    margin-bottom: 0;
}

.page-header-row .create-btn {
    margin-left: auto;
}

/* 標�?上方?��?小�?（通用�?*/
.page-en-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--color-accent);
    margin-bottom: 0.5rem;
}

/* ==================== 訊息?�示�?? ==================== */
/* 通知條：首頁風格，淡色底＋圓角＋圓形圖示，不用左側粗色條 */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.85rem 1.1rem;
    margin-bottom: 0.6rem;
    border: 1.5px solid #c5d3e6;
    border-radius: 14px;
    background: var(--hp-sky);
    color: var(--color-primary);
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.6;
}

.alert::before {
    content: 'i';
    flex: none;
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--hp-yellow);
    font-size: 0.8rem;
    font-weight: 900;
}

.alert-success {
    border-color: var(--color-primary);
    background: #fff;
}
.alert-success::before { content: '\2713'; }

.alert-warning {
    border-color: var(--hp-yellow);
    background: #fff6dc;
}
.alert-warning::before { content: '!'; background: var(--hp-yellow); color: var(--color-primary); }

.alert-error {
    border-color: #f3c2bd;
    background: #fff1f0;
    color: #8f2318;
}
.alert-error::before { content: '!'; background: #c0392b; color: #fff; }

/* 右上角通知卡：像 macOS 通知，白卡＋圓形圖示＋標題，可按 × 關閉（base.html） */
.toast-stack {
    position: fixed;
    top: calc(var(--nav-h) + 1rem);
    right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(380px, calc(100vw - 2rem));
}

.toast {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: start;
    padding: 0.9rem 0.75rem 0.9rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 12px 36px rgba(26, 50, 96, 0.16);
    animation: alertFloatIn 0.2s ease-out;
}

.toast.is-hiding { animation: alertFloatOut 0.25s ease-in forwards; }

.toast__icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--hp-yellow);
    font-size: 0.95rem;
    font-weight: 900;
}

.toast--info .toast__icon::before { content: 'i'; }
.toast--success .toast__icon::before { content: '\2713'; }
.toast--warning .toast__icon { background: var(--hp-yellow); color: var(--color-primary); }
.toast--warning .toast__icon::before { content: '!'; }
.toast--error .toast__icon { background: #c0392b; color: #fff; }
.toast--error .toast__icon::before { content: '!'; }

.toast__title {
    display: block;
    color: var(--color-primary);
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 1.4;
}

.toast--error .toast__title { color: #a8281d; }

.toast__message {
    margin-top: 0.15rem;
    color: #3d4a63;
    font-size: 0.9rem;
    line-height: 1.6;
}

.toast__close {
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.2rem 0 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--color-muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.toast__close:hover { background: var(--hp-sky); color: var(--color-primary); }

@keyframes alertFloatIn {
    from {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes alertFloatOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
}

@media (max-width: 640px) {
    .toast-stack {
        top: calc(var(--nav-h) + 0.75rem);
        right: 0.75rem;
        left: 0.75rem;
        width: auto;
    }
}

/* ==================== ?��?�?? ==================== */
/* ==================== 全站按鈕（唯一一份） ====================
   所有按鈕都是膠囊形、粗體、同字級，只分三種外觀與兩種尺寸：
     主要  深藍底白字，移上去變亮藍           （送出、登入、申請、搜尋、確認）
     次要  深藍框深藍字，移上去填深藍         （編輯、查看、取消、收藏）
     危險  紅框紅字，移上去填紅               （刪除、退回、停用、拒絕）
     標準 44px／小 36px（卡片內、導覽列、表格列、輸入框內的搜尋鈕）
   各頁的舊 class 直接列進下面的群組，不要在頁面 CSS 再另寫顏色、圓角或高度。
   特例：首頁深藍區塊上的金色與白框按鈕（.hp-btn--gold／--ghost）、純文字連結、圖示鈕。 */
.hp-btn, .btn, .btn-login, .auth-submit, .search-btn, .invite-banner-btn,
.admin-btn, .admin-period-filter button,
.cl-btn-view, .cl-btn-apply, .cl-btn-edit, .cl-btn-close, .cl-search-btn, .team-search-btn,
.cd-btn-primary, .cd-btn-secondary, .cd-btn-fav, .cd-app-btn-accept, .cd-app-btn-reject,
.td-btn-primary, .td-btn-secondary, .download-btn,
.notif-pref-save-btn, .notif-mark-read-btn,
.form-confirm__submit, .form-confirm__cancel, .form-confirm__alt,
.team-graph-actions button, .team-graph-actions a, .team-network-empty a, .team-invite-picker__selection button, .team-network-detail {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0 1.35rem;
    border: 1.5px solid transparent;
    border-radius: 999px;
    background: transparent;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* 主要 */
.hp-btn--primary, .btn-primary, .btn-login, .auth-submit, .search-btn,
.admin-btn--primary, .admin-period-filter button,
.cl-btn-view, .cl-btn-apply, .cl-search-btn, .team-search-btn,
.cd-btn-primary, .cd-app-btn-accept, .td-btn-primary, .download-btn,
.notif-pref-save-btn, .form-confirm__submit,
.team-graph-actions a, .team-network-empty a, .team-network-detail {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff !important; /* 蓋過 a:visited 與導覽列連結顏色 */
}

.hp-btn--primary:hover, .btn-primary:hover, .btn-login:hover, .auth-submit:hover, .search-btn:hover,
.admin-btn--primary:hover, .admin-period-filter button:hover,
.cl-btn-view:hover, .cl-btn-apply:hover, .cl-search-btn:hover, .team-search-btn:hover,
.cd-btn-primary:hover, .cd-app-btn-accept:hover, .td-btn-primary:hover, .download-btn:hover,
.notif-pref-save-btn:hover, .form-confirm__submit:hover,
.team-graph-actions a:hover, .team-network-empty a:hover, .team-network-detail:hover {
    border-color: var(--color-hover);
    background: var(--color-hover);
    text-decoration: none;
}

/* 次要 */
.hp-btn--line, .invite-banner-btn, .admin-btn--ghost,
.cl-btn-edit, .cd-btn-secondary, .cd-btn-fav, .td-btn-secondary, .cd-app-btn-reject,
.notif-mark-read-btn, .form-confirm__cancel, .form-confirm__alt,
.team-graph-actions button, .team-invite-picker__selection button {
    border-color: var(--color-primary);
    background: #fff;
    color: var(--color-primary);
}

.hp-btn--line:hover, .invite-banner-btn:hover, .admin-btn--ghost:hover,
.cl-btn-edit:hover, .cd-btn-secondary:hover, .cd-btn-fav:hover, .td-btn-secondary:hover, .cd-app-btn-reject:hover,
.notif-mark-read-btn:hover, .form-confirm__cancel:hover, .form-confirm__alt:hover,
.team-graph-actions button:hover, .team-invite-picker__selection button:hover {
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
}

/* 危險 */
.admin-btn--danger, .cl-btn-close {
    border-color: #f3c2bd;
    background: #fff;
    color: #b42318;
}

.admin-btn--danger:hover, .cl-btn-close:hover {
    border-color: #c0392b;
    background: #c0392b;
    color: #fff;
}

/* 小尺寸 */
.admin-btn--sm, .btn-login,
.cl-btn-view, .cl-btn-apply, .cl-btn-edit, .cl-btn-close,
.cd-app-btn-accept, .cd-app-btn-reject,
.notif-mark-read-btn,
.team-invite-picker__selection button, .team-network-detail {
    min-height: 36px;
    padding: 0 1.05rem;
    font-size: 0.86rem;
}

/* 停用 */
.cl-btn-apply.is-disabled, .hp-btn:disabled, .admin-btn:disabled, .auth-submit:disabled {
    border-color: transparent;
    background: #eef1f5;
    color: var(--color-muted) !important;
    cursor: default;
}

/* 首頁深藍 CTA 區的特例 */
.hp-btn--gold { border-color: var(--hp-yellow); background: var(--hp-yellow); color: var(--color-primary); }
.hp-btn--gold:hover { border-color: #fff; background: #fff; }
.hp-btn--ghost { border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.hp-btn--ghost:hover { border-color: #fff; background: rgba(255, 255, 255, 0.1); }

/* 首頁主視覺的按鈕大一號 */
.hp-hero-cta .hp-btn { min-height: 52px; padding: 0 1.7rem; font-size: 0.98rem; }

/* 導覽列的登入鈕：蓋過 .nav-top-menu li a 的字級、對齊與手機版底線 */
.nav-top-menu li a.btn-login { font-size: 0.86rem; color: #fff; }
.nav-top-menu li a.btn-login::after { display: none; }

@media (max-width: 992px) {
    .nav-top-menu li a.btn-login {
        display: flex;
        border-radius: 999px;
        padding: 0 1.05rem;
        text-align: center;
    }

    .nav-top-menu li a.btn-login:hover { font-weight: 700; }
}

/* 登入／註冊表單的送出鈕佔滿一列 */
.auth-submit { width: 100%; min-height: 48px; margin-top: 0.5rem; }

/* ==================== ?��?�?? ==================== */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* ==================== 表單�?? ==================== */
/* Use .form-card on forms that should display as a white card.
   Default form element has no background so auth pages stay transparent. */
.form-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* .form-card ?��??��?表單?�輸?��?位樣�?
   不�? .form-card ?�表?��?auth?�search）�??�影??*/
.form-card label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #2c3e50;
}

.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"],
.form-card input[type="number"],
.form-card input[type="date"],
.form-card textarea,
.form-card select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-card textarea {
    min-height: 100px;
    resize: vertical;
}

.errorlist {
    color: #e74c3c;
    list-style: none;
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* ==================== ?�?��?�?==================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
}

.badge-pending {
    background-color: #fff3cd;
    color: #856404;
}

.badge-approved {
    background-color: #d4edda;
    color: #155724;
}

.badge-rejected {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-company {
    background-color: #d1ecf1;
    color: #0c5460;
}

.badge-teacher {
    background-color: #e2e3e5;
    color: #383d41;
}

/* ==================== Footer�?? ==================== */
footer {
    background-color: #ffffff;
    border-top: 2px solid #e0e0e0;
    margin-top: 3rem;
    padding: 2rem 0 0.5rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.footer-menu-section {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--content-gutter);
}

.footer-menu-grid {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-menu-col {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
}

.footer-menu-title {
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--color-accent);
    display: inline-block;
    width: fit-content;
}

.footer-menu-title a {
    color: var(--color-accent);
    text-decoration: none;
    transition: all 0.3s;
}

.footer-menu-title a:hover {
    color: var(--color-primary);
    font-weight: 900;
}

.footer-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.footer-menu-list li {
    margin-bottom: 0.4rem;
    width: 100%;
}

.footer-menu-list a {
    color: #333333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: inline-block;
    position: relative;
}

.footer-menu-list a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-accent);
    transition: width 0.3s ease;
}

.footer-menu-list a:hover {
    color: var(--color-hover);
    font-weight: 700;
}

.footer-menu-list a:hover::after {
    width: 100%;
}

.footer-separator {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 1.5rem 0;
}

.footer-info-section {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--content-gutter);
    display: grid;
    /* minmax 下限取 0：若給固定最小寬，欄位會撐出父元素
       （390px 手機上曾撐到 448px 而造成全站橫向溢位）。 */
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    /* flex 項目預設 min-width:auto 不會縮小，兩顆 logo 加
       130px 印章會把 grid 欄位撐到 416px；允許換行並可縮。 */
    flex-wrap: wrap;
    min-width: 0;
}

.footer-logo > a {
    display: block;
    line-height: 0;
}

.footer-logo img {
    height: 80px;
    width: auto;
    max-width: 100%;
    transition: transform 0.3s;
    display: block;
}

.footer-logo > a:hover img {
    transform: scale(1.05);
}

.footer-contact {
    color: #555555;
    font-size: 0.85rem;
    line-height: 1.8;
}

.footer-contact strong {
    color: var(--color-accent);
    font-size: 0.95rem;
}

/* TWCA 印章由第三方 script 注入，內部元素（#twcad1/2/3）全為
   position:absolute，容器本身會被撐成 0 高度而破壞版面；
   故在此明確給定實際尺寸。#twcad2 是憑證資訊浮層，
   載入時會顯示 1.5 秒再隱藏，以 twca_d2hide 關閉（見 base.html）。 */
.footer-twca-badge {
    display: block;
    flex-shrink: 0;
    width: 130px;
    height: 71px;
    /* 第三方樣式表為非同步載入，未套用前
       憑證資訊會以正常流排入而撐開 footer；
       此處強制裁切。 */
    overflow: hidden;
    position: relative;
}

/* 憑證詳細資訊浮層：不論第三方 CSS 是否到位，
   一律抽離正常流，避免撠寬 footer。 */
.footer-twca-badge #twcad2 {
    position: absolute !important;
    visibility: hidden;
    pointer-events: none;
}

.twca-seal-img {
    display: block;
}

.footer-copyright {
    text-align: center;
    color: #777777;
    font-size: 0.8rem;
    padding: 1rem 2rem;
    border-top: 1px solid #dee2e6;
    margin: 0;
}

.footer-copyright strong {
    color: var(--color-accent);
}

/* 手機版 footer：每個分類改成「標題｜連結橫排」一列，
   避免五欄直式清單在窄螢幕拉成一長串。桌機版不受影響。 */
@media (max-width: 640px) {
    /* 直排且 nowrap：column + wrap 時 Chrome 會用子項在
       min-content 寬度下的高度當 flex-basis，每列都被撐高。 */
    .footer-menu-grid {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .footer-menu-col {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .footer-menu-title {
        flex: 0 0 4.2em;
        margin: 0;
        padding: 0;
        border-bottom: none;
        white-space: nowrap;
    }

    /* 連結排成等寬欄位（390px 約兩欄），換行後仍上下對齊 */
    .footer-menu-list {
        flex: 1 1 auto;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
        gap: 0.2rem 0.6rem;
    }

    .footer-menu-list li {
        width: auto;
        margin: 0;
    }

    /* logo 與 TWCA 印章固定同一列：印章 130px 不能縮，
       logo 改依剩餘寬度等比縮小（360px 手機約 185px 寬） */
    .footer-logo {
        flex-wrap: nowrap;
        gap: 0.8rem;
    }

    .footer-logo > a {
        flex: 1 1 auto;
        min-width: 0;
    }

    .footer-logo img {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 56px;
    }

    .footer-twca-badge {
        flex: 0 0 auto;
    }
}

/* ==================== 首�?輪播�?? ==================== */
.carousel-container {
    width: 100vw;
    max-width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    margin-top: -2rem;
    padding: 0;
}

.carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.carousel-inner {
    position: relative;
    width: 100%;
    height: 500px;
}

.carousel-item {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    pointer-events: none;
}

.carousel-item.active {
    opacity: 1;
    pointer-events: auto;
}

.carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 輪播?�示?��??��?�?*/
.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    z-index: 15;
}

.carousel-indicators li {
    width: 12px;
    height: 12px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s;
}

.carousel-indicators li.active {
    background-color: #ffffff;
}

.carousel-indicators li a {
    display: block;
    width: 100%;
    height: 100%;
    text-indent: -9999px;
    overflow: hidden;
}

/* 左右箭頭 */
.carousel-control-prev,
.carousel-control-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background-color: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    opacity: 0.7;
}

.carousel-control-prev {
    left: 20px;
}

.carousel-control-next {
    right: 20px;
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
    width: 20px;
    height: 20px;
    display: inline-block;
}

.carousel-control-prev-icon:before {
    content: '‹';
    font-size: 40px;
    line-height: 1;
}

.carousel-control-next-icon:before {
    content: '›';
    font-size: 40px;
    line-height: 1;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* ==================== 案件?�表�?? ==================== */
.case-module-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* 全站膠囊頁籤共用這一組樣式（案件、研究團隊、公告、通知、常見問題），
   要改外觀只改這裡，不要在各頁另寫一份 */
.case-module-tab,
.announcement-tab,
.notif-page-tab,
.notif-filter-btn,
.tag-pill {
    display: inline-block;
    padding: 0.38rem 0.95rem;
    border: 1px solid #d0d5dd;
    border-radius: 999px;
    color: #666;
    background: #fff;
    text-decoration: none;
    font-size: 0.84rem;
    white-space: nowrap;
    transition: all 0.15s;
}

.case-module-tab:hover,
.announcement-tab:hover,
.notif-page-tab:hover,
.notif-filter-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    text-decoration: none;
}

.case-module-tab.active,
.announcement-tab.active,
.notif-page-tab.active,
.notif-filter-btn.active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}

.search-section {
    padding: 0;
    margin-bottom: 2rem;
    background: none;
    border: none;
}

.search-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    padding: 0.45rem 1rem;
    border: 1px solid #d0d7e2;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    outline: none;
    background: #fff;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 50, 96, 0.12);
}

.filter-select {
    appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23808a98' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
    border: 1px solid #d0d7e2;
    border-radius: 9px;
    padding: 0.38rem 1.9rem 0.38rem 0.72rem;
    font-size: 0.8rem;
    font-family: var(--font-sans);
    color: #4b5563;
    cursor: pointer;
    transition: border-color 0.15s;
}

.case-table-header {
    background-color: #e3f2fd;
    padding: 1rem 1.5rem;
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 0.8fr;
    gap: 1rem;
    font-weight: 600;
    color: #333;
    border-radius: 4px 4px 0 0;
    align-items: center;
}

.case-table-row {
    background-color: white;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 0.8fr;
    gap: 1rem;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
    transition: background-color 0.2s;
}

.case-table-row:hover {
    background-color: #f8f9fa;
}

.case-title {
    color: #333;
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.3rem;
}

.case-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s;
}

.case-title a:hover {
    color: var(--color-hover);
}

.case-meta {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.3rem;
}

.case-company {
    color: #555;
    font-size: 1rem;
}

.case-date {
    color: var(--color-accent);
    font-size: 0.95rem;
}

.view-btn {
    padding: 0.6rem 1.2rem;
    background-color: white;
    color: var(--color-accent);
    border: 2px solid var(--color-accent);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.view-btn:hover {
    background-color: var(--color-hover);
    color: white;
}

.badge-tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background-color: #ffebcc;
    color: #d97706;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 0.5rem;
}

.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-approved {
    background-color: #d4edda;
    color: #155724;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-rejected {
    background-color: #f8d7da;
    color: #721c24;
}

.match-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.match-matching {
    background-color: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
    font-weight: normal;
}

.match-matched {
    background-color: #d4edda;
    color: #155724;
}

.match-closed {
    background-color: #e2e3e5;
    color: #383d41;
}

.result-count {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.result-count strong {
    color: var(--color-accent);
}

.create-btn {
    padding: 0.8rem 1.5rem;
    background-color: var(--color-accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s;
}

.create-btn:hover {
    background-color: #004080;
    color: white;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    color: #666;
}

.empty-state img {
    width: 200px;
    opacity: 0.5;
    margin-bottom: 1rem;
}

/* ==================== ?��?式設�?==================== */

/* 小於992px：漢?�選??*/
@media (max-width: 992px) {
    /* 顯示漢堡?��? */
    .mobile-menu-toggle {
        display: flex;
    }

    /* ?�單?�設?��? */
    .nav-menus {
        position: fixed;
        top: var(--nav-h);
        left: -100%;
        width: min(280px, 65vw);
        height: calc(100vh - var(--nav-h));
        height: calc(100dvh - var(--nav-h));
        background-color: #ffffff;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
        overflow-y: auto;
        transition: left 0.3s ease;
        gap: 0;
    }

    .nav-menus.active {
        left: 0;
    }

    /* 上層?�單?�直?��? */
    .nav-top-menu {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 0;
        border-bottom: 1px solid #e0e0e0;
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .nav-top-menu li {
        width: 100%;
    }

    .nav-top-menu li a,
    .nav-top-menu li button {
        display: block;
        width: 100%;
        text-align: left;
        padding: 0.6rem 1rem;
        border-radius: 4px;
        position: relative;
    }

    .nav-top-menu li a:hover {
        font-weight: 900;
    }

    .nav-top-menu li a::after {
        content: '';
        position: absolute;
        bottom: 0.3rem;
        left: 1rem;
        width: 0;
        height: 4px;
        background-color: var(--color-accent);
    }

    .nav-top-menu li a:hover::after {
        width: calc(100% - 2rem);
    }

    /* 下層?�單?�直?��? */
    .nav-bottom-menu {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 0;
    }

    .nav-bottom-menu > li {
        width: 100%;
    }

    .nav-bottom-menu > li > a {
        display: block;
        width: 100%;
        padding: 0.6rem 1rem;
        border-radius: 4px;
        position: relative;
    }

    .nav-bottom-menu > li > a:hover {
        font-weight: 900;
    }

    .nav-bottom-menu > li > a::after {
        content: '';
        position: absolute;
        bottom: 0.3rem;
        left: 1rem;
        width: 0;
        height: 4px;
        background-color: var(--color-accent);
        display: block;
    }

    .nav-bottom-menu > li > a:hover::after {
        width: calc(100% - 2rem);
    }

    /* 子選單預設收合，點右側箭頭展開 */
    .has-dropdown {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .nav-bottom-menu > li.has-dropdown > a {
        flex: 1;
        width: auto;
    }

    .dropdown-caret {
        display: block;
        width: 44px;
        height: 44px;
        border: 0;
        background: none;
        cursor: pointer;
    }

    .dropdown-caret::before {
        content: '';
        display: block;
        width: 8px;
        height: 8px;
        margin: 0 auto;
        border-right: 2px solid var(--color-muted);
        border-bottom: 2px solid var(--color-muted);
        transform: rotate(45deg);
        transition: transform 0.18s;
    }

    .has-dropdown.active .dropdown-caret::before {
        transform: rotate(-135deg);
    }

    .has-dropdown .dropdown {
        display: none;
        flex-basis: 100%;
    }

    .has-dropdown.active .dropdown {
        display: block;
    }

    /* 子選?�樣式調??*/
    .dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        padding: 0.5rem 0;
        margin: 0;
        max-height: none;
        overflow: visible;
    }

    .dropdown li a {
        padding: 0.6rem 1rem 0.6rem 2rem !important;
        font-size: 0.85rem;
        color: #666666;
        position: relative;
    }

    .dropdown li a::after {
        content: '';
        position: absolute;
        bottom: 0.3rem;
        left: 2rem;
        width: 0;
        height: 4px;
        background-color: var(--color-accent);
    }

    .dropdown li a:hover {
        color: #333333;
        font-weight: 900;
    }

    .dropdown li a:hover::after {
        width: calc(100% - 3rem);
    }

    /* ?�入?��??��??�調??*/
    .btn-login {
        width: 100%;
        text-align: center;
        margin: 0;
    }

    /* 案件?�表?��?�?*/
    .case-table-header {
        display: none;
    }

    .case-table-row {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        padding: 1.2rem;
        border-left: 4px solid var(--color-accent);
    }

    .case-table-row > div {
        display: flex;
        flex-direction: column;
    }

    .case-table-row > div::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-accent);
        margin-bottom: 0.3rem;
        font-size: 0.9rem;
    }

    .case-title {
        font-size: 1.1rem;
    }

    .view-btn {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* 小於768px */
@media (max-width: 768px) {
    .carousel-inner {
        height: 300px;
    }

    .carousel-control-prev,
    .carousel-control-next {
        width: 40px;
        height: 40px;
    }

    /* 按鈕縮到 40px 時，內部 40px 的符號會滿出框外 */
    .carousel-control-prev-icon:before,
    .carousel-control-next-icon:before {
        font-size: 24px;
    }

    .carousel-control-prev {
        left: 10px;
    }

    .carousel-control-next {
        right: 10px;
    }

    .footer-info-section {
        grid-template-columns: 1fr;
    }
}

/* ?��?式顯�??��?類別 */
.d-none {
    display: none !important;
}

.d-sm-block {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-sm-none {
    display: block !important;
}

@media (min-width: 576px) {
    .d-none.d-sm-block {
        display: block !important;
    }
    .d-block.d-sm-none {
        display: none !important;
    }
}

/* ==================== 認�??��??�入 / 註�? / 密碼?�設�?=================== */

/* ?�面容器：無?�景，�??�灰�?*/
.auth-page {
    max-width: var(--content-width);
    margin: 0 auto;
    padding-bottom: 5rem;
}

.auth-page-wide {
    max-width: var(--content-width);
    margin: 0 auto;
    padding-bottom: 5rem;
}

/* ?��?：EN 標籤 + 大�?�?*/
.auth-header {
    margin-top: 2.8rem;
    margin-bottom: 2.5rem;
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    width: fit-content;
    max-width: 100%;
}

.auth-header .page-en-label {
    width: 100%;
}

.auth-header > p {
    display: none;
}

/* 大�?�????�代??auth template ?��?�?inline style */
.auth-page-title {
    font-size: clamp(1.75rem, 1.15rem + 2.6vw, 2.6rem);
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    line-height: 1;
}

/* 欄�? */
.auth-field {
    margin-bottom: 1.8rem;
}

.auth-field label {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #555;
    display: block;
    margin-bottom: 0.55rem;
}

/* 必填?��? */
.auth-req {
    color: var(--color-accent);
    font-weight: 900;
    margin-left: 0.1em;
}

/* ?�塊�?題�?企業資�??�帳?�設定�? */
.auth-section-title {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--color-accent);
    text-transform: uppercase;
    margin-bottom: 1.2rem;
}

/* 輸入框�??��?�?+ 下�?�?*/
.auth-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid #d0d0d0;
    border-radius: 0;
    padding: 0.55rem 0.4rem;
    font-size: 1rem;
    color: var(--color-text);
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.2s;
}

.auth-input:focus {
    border-bottom-color: var(--color-accent);
}

.auth-input::placeholder {
    color: #bbb;
    font-size: 0.9rem;
}

/* ?�誤訊息 */
.auth-error {
    color: #c0392b;
    font-size: 0.8rem;
    margin-top: 0.4rem;
    display: block;
}

/* 輔助?��? */
.auth-hint {
    color: #aaa;
    font-size: 0.78rem;
    margin-top: 0.35rem;
    display: block;
}

/* ?�交?��? */
/* ?��?�?*/
.auth-divider {
    border: none;
    border-top: 1px solid #e8e8e8;
    margin: 2rem 0;
}

/* 底部??? */
.auth-links {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: #999;
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.auth-links a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.auth-inline-form {
    margin: 0;
}

.auth-link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    font: inherit;
    cursor: pointer;
    transition: color 0.2s;
}

.auth-links a:hover {
    color: var(--color-text);
}

.auth-link-btn:hover {
    color: var(--color-text);
}

/* ?��?位錯誤�?帳�??�誤�?/
.auth-form-error {
    background: #fff0f0;
    border-left: 3px solid #c0392b;
    color: #c0392b;
    font-size: 0.88rem;
    padding: 0.7rem 1rem;
    border-radius: 0 4px 4px 0;
    margin-bottom: 1.5rem;
}

/* 表單?�出失�??��??�示 */
.auth-error-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--color-text);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
}

.auth-error-bar-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: #c0392b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 900;
    line-height: 1;
}

/* select ?��?�?*/
.auth-input-select {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid #d0d0d0;
    border-radius: 0;
    padding: 0.5rem 0;
    font-size: 1rem;
    color: var(--color-text);
    font-family: var(--font-sans);
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.auth-input-select:focus {
    border-bottom-color: var(--color-accent);
}

/* ==================== ?��?身份??==================== */
.register-select-page {
    max-width: var(--content-width);
    margin: 0 auto;
    padding-bottom: 5rem;
}

.register-choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.register-choice {
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    padding: 2rem 1.5rem 1.8rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.25s;
    text-decoration: none;
    display: block;
    color: inherit;
    background: transparent;
}

/* ==================== 統�?表單�??（�?齊註?��?�?==================== */
.form-unified .profile-form-section {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 1.6rem;
}

.form-unified .profile-form-section + .profile-form-section {
    border-top: 1px solid #e7ebf0;
    padding-top: 1.25rem;
}

.form-unified .profile-form-section-title {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--color-accent);
    text-transform: uppercase;
    margin: 0 0 1.1rem;
    border: none;
    padding: 0;
}

.form-unified .profile-field > label,
.form-unified .auth-field > label,
.form-unified .form-unified-label {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #555;
    display: block;
    margin-bottom: 0.55rem;
}

.form-unified input[type="text"],
.form-unified input[type="email"],
.form-unified input[type="password"],
.form-unified input[type="number"],
.form-unified input[type="date"],
.form-unified input[type="tel"],
.form-unified input[type="url"],
.form-unified textarea,
.form-unified select {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid #d0d0d0;
    border-radius: 0;
    padding: 0.55rem 0.4rem;
    font-size: 1rem;
    color: var(--color-text);
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.2s;
}

.form-unified input[type="text"]:focus,
.form-unified input[type="email"]:focus,
.form-unified input[type="password"]:focus,
.form-unified input[type="number"]:focus,
.form-unified input[type="date"]:focus,
.form-unified input[type="tel"]:focus,
.form-unified input[type="url"]:focus,
.form-unified textarea:focus,
.form-unified select:focus {
    border-bottom-color: var(--color-accent);
}

.form-unified textarea {
    min-height: 120px;
    resize: vertical;
}

.form-unified input::placeholder,
.form-unified textarea::placeholder {
    color: #bbb;
    font-size: 0.9rem;
}

.form-unified input[type="file"] {
    width: 100%;
    font-size: 0.9rem;
    color: #555;
    border: none;
    padding: 0.35rem 0;
}

.form-unified .media-upload {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-unified .media-upload-preview {
    width: 96px;
    height: 96px;
    border: 1px solid #d7dee7;
    border-radius: var(--radius-md);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.form-unified .media-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.form-unified .media-upload-preview--contain img {
    object-fit: contain;
    padding: 6px;
    background: #fff;
}

.form-unified .media-upload-empty {
    font-size: 0.75rem;
    color: #9aa4b2;
}

.form-unified .media-upload-body {
    flex: 1;
    min-width: 240px;
}

.form-unified .media-upload-input {
    width: auto;
    max-width: 100%;
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: 0.9rem;
    color: #404b57;
    background: transparent;
}

.form-unified .media-upload-input::file-selector-button {
    margin-right: 0.8rem;
    border: 1px solid #c9d3df;
    border-radius: var(--radius-sm);
    background: #eef3f9;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.84rem;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
}

.form-unified .media-upload-clear {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.55rem;
    font-size: 0.84rem;
    color: #5f6975;
}

.form-unified .media-upload-clear input[type="checkbox"] {
    width: 15px;
    height: 15px;
}

.form-unified .field-help,
.form-unified .auth-hint,
.form-unified .form-unified-help {
    color: #aaa;
    font-size: 0.78rem;
    margin-top: 0.35rem;
    display: block;
}

.form-unified .field-error,
.form-unified .auth-error,
.form-unified .errorlist {
    color: #c0392b;
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

.form-unified .errorlist {
    list-style: none;
    padding: 0;
}

.form-unified .profile-form-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

/* 統一表單的送出鈕：外觀同全站主要按鈕 */
.form-unified .form-unified-submit {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}

.form-unified .form-unified-submit:hover {
    border-color: var(--color-hover);
    background: var(--color-hover);
}

.form-unified .expertise-checkbox-label,
.form-unified label.expertise-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.87rem;
    color: #333;
    letter-spacing: 0;
    font-weight: 400;
}

.team-edit-meta,
.team-edit-intro {
    color: #7f8c8d;
}

.team-edit-meta {
    margin-bottom: 0.5rem;
}

.team-edit-intro {
    margin-bottom: 1.25rem;
}

.team-edit-markdown-help {
    background: #e8f4f8;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.team-edit-markdown-help strong {
    color: var(--color-accent);
}

.team-edit-markdown-help ul {
    margin: 0.5rem 0 0 1.5rem;
    color: #555;
}

.team-edit-locked-notice {
    background: #f8fafc;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    border: 1px solid #d9e2ef;
    border-left: 4px solid var(--color-primary);
    color: #334155;
    line-height: 1.7;
}

.team-edit-locked-notice strong {
    color: #1f2937;
}

.team-edit-field-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.team-edit-lock-badge {
    font-size: 0.75rem;
    background: #fef3c7;
    color: #92400e;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid #fcd34d;
}

.team-edit-unlock-btn {
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.team-edit-unlock-btn:hover {
    border-color: #9ca3af;
    color: #374151;
}

.team-edit-scraper-note {
    font-size: 0.75rem;
    color: #6b7280;
}

.team-edit-description-note {
    font-size: 0.85rem;
    color: #555;
    margin: 0 0 0.4rem;
}

.team-edit-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.register-choice:hover {
    border-color: var(--color-text);
    transform: translateY(-4px);
    color: inherit;
}

.register-choice-icon {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
}

.register-choice-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--color-accent);
    display: block;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

.register-choice-title {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--color-text);
    margin-bottom: 0.6rem;
    display: block;
}

.register-choice-desc {
    font-size: 0.85rem;
    color: #888;
    line-height: 1.6;
    display: block;
}

.register-choice-arrow {
    display: block;
    margin-top: 1.2rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #ccc;
    letter-spacing: 0.08em;
    transition: color 0.2s;
}

.register-choice:hover .register-choice-arrow {
    color: var(--color-text);
}

/* ?�請碼橫�? */
.invite-banner {
    margin-top: 2rem;
    padding: 1rem 1.5rem;
    border: 1.5px dashed #d0d0d0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.invite-banner-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.2rem;
}

.invite-banner-desc {
    font-size: 0.82rem;
    color: #999;
}

@media (max-width: 600px) {
    .register-choice-grid {
        grid-template-columns: 1fr;
    }

    .auth-page,
    .auth-page-wide,
    .register-select-page {
        padding: 0 1rem 4rem;
    }
}

/* ==================== ?�?��??��? ==================== */

/* 工具?��?tabs + ?��?�?*/
.announcement-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

/* ?��?篩選 tabs ??pill �?? */
.announcement-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    /* 作為 flex 子項需明確限寬，否則會以
       max-content 寬度撐出父元素而造成頁面橫向溢位。 */
    min-width: 0;
    max-width: 100%;
    flex: 1 1 100%;
}
.announcement-tabs::-webkit-scrollbar { display: none; }


/* ?��?�?*/
.announcement-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ?��?軸整�?*/
.announcement-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* 每個�?份群�?*/
.timeline-group,
.content-group--timeline {
    display: flex;
    gap: 2.5rem;
    padding: 1.5rem 0;
    border-bottom: 1px solid #e8e8e8;
}

.timeline-group:last-child,
.content-group--timeline:last-child {
    border-bottom: none;
}

/* 檔案下載的分組之間不畫線，只靠間距分開 */
.content-group--timeline {
    border-bottom: none;
}

/* 左側年�?標籤 */
.timeline-month-label {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 72px;
    padding-top: 0.1rem;
    flex-shrink: 0;
}

.timeline-year {
    font-size: 1.5rem;
    font-weight: 900;
    color: #c8c8c8;
    line-height: 1;
}

.timeline-month {
    font-size: 2.2rem;
    font-weight: 900;
    color: #c8c8c8;
    line-height: 1.1;
}

/* ?�側?��??�表 */
.timeline-items {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
}

/* ?��??��???*/
.timeline-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.9rem 0;
    border-bottom: 1px dashed #ebebeb;
}

.timeline-items .timeline-item:last-child {
    border-bottom: none;
}

/* ?��? + 類別?��?�?*/
.timeline-item-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ?��? */
.timeline-date {
    font-size: 0.82rem;
    color: #999;
    white-space: nowrap;
}

/* 類別徽�? */
.timeline-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-maintenance {
    background-color: #fff3cd;
    color: #856404;
}

.badge-important {
    background-color: #f8d7da;
    color: #842029;
}

.badge-news {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* ?��?標�? */
.timeline-title {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: color 0.2s;
}

.timeline-title:hover {
    color: var(--color-hover);
}

/* ?�公?��?�?*/
.announcement-empty {
    color: #999;
    text-align: center;
    padding: 3rem 0;
    font-size: 0.95rem;
}

/* ?��???*/
@media (max-width: 600px) {
    .timeline-group,
    .content-group--timeline {
        flex-direction: column;
        gap: 0.8rem;
    }

    .timeline-month-label {
        flex-direction: row;
        align-items: baseline;
        gap: 0.4rem;
        min-width: unset;
    }

    .timeline-year {
        font-size: 1.1rem;
    }

    .timeline-month {
        font-size: 1.5rem;
    }

    .announcement-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    /* 四顆短標籤改為換行，全部可見，
       比橫向捲動更容易點選。 */
    .announcement-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .search-input {
        width: 140px;
    }

    /* ?��??�容?��?機�? */
    .detail-title {
        font-size: 1.4rem;
    }

    .detail-top-bar {
        margin-top: 1.5rem;
    }

    .md-content {
        font-size: 0.93rem;
    }

    .detail-images {
        flex-direction: column;
    }
}

/* ==================== ?��??�容??==================== */

.announcement-detail-page {
    /* 沿用 .page-content 的 max-width，不再重複宣告 */
}

/* ?�部：�???+ ?��? */
.detail-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2.8rem;
    margin-bottom: 1.4rem;
}

/* 類別?��?標籤（無?�景，�??��?�?*/
.detail-category-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.cat-maintenance { color: #b07800; }
.cat-important   { color: #c0392b; }
.cat-news        { color: var(--color-accent); }

.detail-date {
    font-size: 0.82rem;
    color: #aaa;
    letter-spacing: 0.04em;
}

/* 大�?�?*/
.detail-title {
    font-size: 2rem;
    font-weight: 900;
    color: var(--color-text);
    line-height: 1.4;
    margin-bottom: 2.2rem;
}

/* ?��?（Markdown 輸出�?*/
.md-content {
    font-size: 0.97rem;
    color: #333;
    line-height: 1.9;
}

.md-content p      { margin-bottom: 1.2em; }
.md-content h2     { font-size: 1.25rem; font-weight: 700; color: var(--color-text); margin: 2em 0 0.6em; }
.md-content h3     { font-size: 1.05rem; font-weight: 700; color: var(--color-text); margin: 1.6em 0 0.5em; }
.md-content ul,
.md-content ol     { padding-left: 1.6em; margin-bottom: 1.2em; }
.md-content li     { margin-bottom: 0.4em; }
.md-content strong { font-weight: 700; color: var(--color-text); }
.md-content a      { color: var(--color-accent); text-decoration: underline; }
.md-content blockquote {
    border-left: 3px solid #ccc;
    margin: 1.2em 0;
    padding: 0.4em 1em;
    color: #666;
}
.md-content code {
    background: #f0f0f0;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}
.md-content pre code {
    display: block;
    padding: 1em;
    overflow-x: auto;
    background: var(--color-bg);
}
.md-content hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 2em 0;
}

/* ?��? */
.detail-images {
    margin-top: 2.5rem;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.detail-images img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* 返�???? */
.detail-back {
    margin-top: 3rem;
}

.detail-back a {
    color: #999;
    text-decoration: none;
    font-size: 0.88rem;
    transition: color 0.2s;
}

.detail-back a:hover {
    color: var(--color-hover);
}

/* ==================== 導航?��?�?& ?��? ==================== */

/* ?�示?��?（�??�、通知?�鐺�?*/
.nav-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #444;
    text-decoration: none;
    transition: background 0.18s, color 0.18s;
    flex-shrink: 0;
}

.nav-icon-btn:hover {
    background: #f0f3f8;
    color: var(--color-primary);
    text-decoration: none;
}

.nav-icon-btn svg {
    display: block;
    flex-shrink: 0;
}

.nav-notification-label {
    display: none;
}

/* ?�知?��??��?徽�? */
.nav-icon-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 9px;
    height: 9px;
    background: #e74c3c;
    border: 2px solid #fff;
    border-radius: 50%;
    pointer-events: none;
}

/* ?��??��? */
.nav-avatar-wrapper {
    position: relative;
}

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.18s, box-shadow 0.18s;
    flex-shrink: 0;
    font-family: var(--font-sans);
    background: transparent;
    padding: 0;
}

.nav-avatar-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    overflow: hidden;
    border-radius: 50%;
    color: #fff;
}

.nav-avatar-visual img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.nav-avatar--teacher .nav-avatar-visual { background: var(--color-primary); }
.nav-avatar--company .nav-avatar-visual { background: var(--color-accent); }
.nav-avatar--admin .nav-avatar-visual { background: #34495e; }

.nav-avatar-mobile-label,
.nav-avatar-chevron {
    display: none;
}

.nav-avatar:hover {
    opacity: 0.85;
    box-shadow: 0 0 0 3px rgba(26, 50, 96,0.18);
}

/* ?��?下�??�單 */
.avatar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid #e4e8f0;
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 20px rgba(0,0,0,0.10);
    min-width: 210px;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s, visibility 0.18s, transform 0.18s;
}

.nav-avatar-wrapper.open .avatar-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.avatar-dropdown-header {
    padding: 0.8rem 1rem 0.7rem;
}

.avatar-dropdown-role {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #aaa;
    margin-bottom: 0.2rem;
}

.avatar-dropdown-email {
    font-size: 0.82rem;
    color: #333;
    word-break: keep-all;
    white-space: nowrap;
    /* 信箱長度不可控，需截斷以免撐寬選單 */
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.avatar-dropdown-divider {
    height: 1px;
    background: #f0f0f0;
    margin: 0;
}

.avatar-dropdown-item {
    display: block;
    width: 100%;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    color: #333;
    text-decoration: none;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: background 0.12s;
    line-height: 1.4;
}

.avatar-dropdown-item:hover {
    background: #f5f7fb;
    color: var(--color-primary);
    text-decoration: none;
}

.avatar-dropdown-logout {
    color: #c0392b;
}

.avatar-dropdown-logout:hover {
    background: #fdecea;
    color: #c0392b;
}

@media (max-width: 992px) {
    .nav-top-menu .nav-icon-btn {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.65rem;
        width: 100%;
        height: auto;
        padding: 0.7rem 1rem;
        border-radius: var(--radius-md);
        color: var(--color-text);
    }

    .nav-icon-btn > svg { display: none; }

    .nav-notification-label {
        display: block;
        font-size: 0.95rem;
        font-weight: 700;
    }

    .nav-icon-badge {
        position: static;
        width: 8px;
        height: 8px;
        border: 0;
        flex: 0 0 8px;
    }

    .nav-avatar-wrapper {
        width: 100%;
        margin-top: 0.35rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--color-border);
    }

    .nav-top-menu .nav-avatar {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.75rem;
        width: 100%;
        height: auto;
        padding: 0.65rem 0.75rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        color: var(--color-text);
        background: #fff;
        box-shadow: 0 5px 16px rgba(26, 50, 96, 0.07);
        text-align: left;
    }

    .nav-avatar:hover {
        opacity: 1;
        box-shadow: 0 5px 16px rgba(26, 50, 96, 0.12);
    }

    .nav-avatar-visual {
        flex: 0 0 38px;
        width: 38px;
        height: 38px;
    }

    .nav-avatar-mobile-label {
        display: grid;
        min-width: 0;
        flex: 1;
        gap: 0.12rem;
    }

    .nav-avatar-mobile-label strong {
        color: var(--color-text);
        font-size: 0.9rem;
    }

    .nav-avatar-mobile-label small {
        overflow: hidden;
        color: var(--color-muted);
        font-size: 0.72rem;
        font-weight: 500;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-avatar-chevron {
        display: block;
        width: 18px;
        height: 18px;
        fill: none;
        stroke: var(--color-muted);
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
        transition: transform 0.18s;
    }

    .nav-avatar-wrapper.open .nav-avatar-chevron { transform: rotate(180deg); }

    .nav-avatar-wrapper .avatar-dropdown {
        position: static;
        display: none;
        min-width: 0;
        width: 100%;
        margin-top: 0.4rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .nav-avatar-wrapper.open .avatar-dropdown {
        display: block;
        transform: none;
    }

    .avatar-dropdown-header { display: none; }
    .avatar-dropdown-item { padding: 0.7rem 0.9rem; }
}

/* ==================== 強制?��?�?Modal ==================== */
.fpw-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.fpw-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem 2.25rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.fpw-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.5rem;
}

.fpw-desc {
    font-size: 0.88rem;
    color: var(--color-muted);
    line-height: 1.6;
    margin: 0 0 1.25rem;
}

.fpw-messages { margin-bottom: 1rem; }

.fpw-msg {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    border: 1px solid;
}

.fpw-msg--success { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.fpw-msg--error   { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }

.fpw-form { display: flex; flex-direction: column; gap: 1rem; }

.fpw-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.fpw-field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
}

.fpw-input {
    padding: 0.6rem 0.9rem;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fpw-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 50, 96,0.12);
}

.fpw-hint {
    font-size: 0.75rem;
    color: #94a3b8;
}

.fpw-btn {
    margin-top: 0.25rem;
    padding: 0.7rem 1rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.fpw-btn:hover { background: var(--color-primary); }

/* ==================== 英文小字標題（eyebrow / kicker） ==================== */
/* 實驗性關閉：隱藏全站標題上方的英文小字標籤。
   若要還原，直接刪除本段即可，樣板一律未動。
   注：部分頁面樣式表（如 faculty.css）在 main.css 之後載入，
   同權重下會覆寫本規則，故使用 !important 確保生效。 */
.page-en-label,
.hp-eyebrow,
.hp-eyebrow-s,
.hp-cta-eyebrow,
.ap-eyebrow,
.ap-hero-eyebrow,
.ap-cta-eyebrow,
.th-hero-eyebrow,
.th-section-label,
.teacher-section-kicker,
.team-graph-kicker,
.company-detail-kicker,
.admin-section-label {
    display: none !important;
}

/* ==================== 工具列統一尺度（全站） ==================== */
/* 團隊／案件／公告頁的搜尋列與篩選列各自複製，字級 0.76–0.95rem、
   高度 26–48px 不一，與 2.6rem 的頁標題落差過大。統一成：
     頁標題  最大 2.2rem
     控制項（輸入框、下拉、按鈕）40px / 0.9rem
     膠囊（分類頁籤）34px / 0.88rem，篩選標籤 30px / 0.82rem
   用屬性選擇器一次涵蓋 team-/cl-/無前綴三套，!important 壓過後載入的
   頁面 CSS。手機版由下方區塊再覆寫。 */
.page-header h1,
.auth-page-title {
    font-size: clamp(1.6rem, 1.1rem + 2vw, 2.2rem);
}

/* 表單控制項一律用網站字體；瀏覽器預設不繼承，部分按鈕會變成系統字型 */
button,
input,
select,
textarea {
    font-family: inherit;
}

[class*="search-input"] {
    min-height: 40px;
    padding-top: 0.45rem !important;
    padding-bottom: 0.45rem !important;
    font-size: 0.95rem !important;
}

[class*="search-btn"] {
    min-height: 40px;
    padding: 0 1rem !important;
    font-size: 0.9rem !important;
}

/* 搜尋列一律「輸入框＋框外按鈕」：案件、研究團隊、團隊成果（公告、師資、管理中心本來就是） */
.cl-search-wrap,
.team-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.cl-search-wrap > label,
.team-search-wrap > label {
    flex: 1 1 auto;
    min-width: 0;
}

/* 輸入框內的裝飾放大鏡與旁邊的「搜尋」鈕重複，全站拿掉（公告、師資本來就沒有） */
.cl-search-icon,
.team-search-icon { display: none; }

.cl-search-input,
.team-search-input { padding-left: 1rem !important; }

[class*="filter-select"] {
    min-height: 40px;
    font-size: 0.9rem !important;
}

[class*="filter-reset"] {
    min-height: 40px;
    padding: 0 0.8rem !important;
    font-size: 0.88rem !important;
}

.case-module-tab,
.announcement-tab,
.notif-page-tab,
.notif-filter-btn,
.tag-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 1rem;
    font-size: 0.88rem;
}

[class*="active-tag"] {
    min-height: 30px;
    font-size: 0.82rem !important;
}

[class*="result-bar"] {
    font-size: 0.88rem !important;
}

/* 公告頁：頁籤與搜尋列同一列，搜尋靠右（原本 flex-basis 100% 把搜尋擠到下一列） */
.announcement-tabs {
    flex: 1 1 auto;
}

.announcement-search {
    flex: 0 0 auto;
}

/* ==================== 手機版統一尺度 ==================== */
/* 團隊／案件／公告頁的搜尋列與篩選列是各自複製的一份樣式
   （team-、cl-、無前綴），字級 0.66–0.95rem、高度 28–44px 各不相同。
   這裡用屬性選擇器一次涵蓋三套，統一成兩階：
     控制項（輸入框、下拉、按鈕）40px / 1rem
     膠囊（分類頁籤、篩選標籤）  36px / 0.85rem
   以 !important 壓過後載入的頁面 CSS；輸入框與下拉固定 16px
   同時避免 iOS 聚焦時自動放大。桌機版不受影響。 */
@media (max-width: 640px) {
    /* --- 標題與導覽列的距離全站統一約 16px：
           英文小字標籤已全站隱藏，--top-gap 留的位置成了純空白 --- */
    .container {
        margin-top: 1rem;
    }

    .page-header {
        margin-bottom: 1rem;
    }

    .page-header.page-header--top-gap {
        padding-top: 0;
    }

    .auth-header {
        margin-top: 0;
        margin-bottom: 1.5rem;
    }

    .page-header h1,
    .auth-page-title {
        font-size: 1.5rem;
    }

    /* --- 控制項：40px / 1rem --- */
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
    select,
    textarea {
        font-family: inherit;
        font-size: 1rem !important;
        min-height: 40px;
    }

    /* 全站區塊用 class 選擇器設了 0.9/0.95rem !important，
       權重高於上面的元素選擇器，這裡同權重再壓回 16px */
    [class*="search-input"],
    [class*="filter-select"] {
        font-size: 1rem !important;
    }

    button {
        font-family: inherit;
    }

    /* --- 工具列各列間距一致 --- */
    [class*="search-wrap"],
    [class*="filter-row"],
    .announcement-toolbar {
        margin-bottom: 0.75rem;
    }

    /* 上下間距：膠囊列到下方搜尋列與其他頁的膠囊列一致（1.25rem） */
    .announcement-toolbar {
        gap: 1.25rem 0.75rem;
    }

    /* --- 搜尋列：輸入框撐滿，按鈕縮成放大鏡（文字以 font-size:0 留給螢幕閱讀器） --- */
    [class*="search-input"] {
        flex: 1 1 auto;
        min-width: 0;
    }

    .announcement-search {
        align-self: stretch;
        width: 100%;
    }

    .announcement-search label {
        flex: 1 1 auto;
        min-width: 0;
    }

    .announcement-search .search-input {
        width: 100%;
    }

    [class*="search-btn"] {
        font-size: 0 !important;
        width: 40px;
        height: 40px;
        padding: 0 !important;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: center !important;
    }

    /* 輸入框左側的裝飾放大鏡與右側按鈕重複，隱藏並收回內距 */
    [class*="search-icon"] {
        display: none !important; /* 頁面 CSS 後載入且同權重 */
    }

    [class*="-search-input"] {
        padding: 0.45rem 1rem !important; /* 頁面 CSS 的 0.82rem 上下內距會把高度撐到 52px */
    }

    /* --- 篩選列：下拉撐滿一列，清除鈕靠右、與下拉同高 --- */
    [class*="filter-row"] > label {
        flex: 1 1 auto;
        min-width: 0;
    }

    [class*="filter-select"] {
        width: 100%;
    }

    [class*="filter-reset"] {
        flex: 0 0 auto;
        min-height: 40px;
        font-size: 0.9rem !important;
        padding: 0 0.8rem !important;
    }

    /* --- 膠囊：36px / 0.85rem，排成一列，放不下時橫向捲動 --- */
    .case-module-tabs,
    .announcement-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .case-module-tabs::-webkit-scrollbar,
    .announcement-tabs::-webkit-scrollbar {
        display: none;
    }

    .case-module-tab,
    .announcement-tab,
    .notif-page-tab,
    .notif-filter-btn,
    .tag-pill,
    [class*="active-tag"] {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
        font-size: 0.85rem !important;
        padding: 0 0.75rem !important;
        white-space: nowrap;
    }

    /* --- 結果列 --- */
    [class*="result-bar"] {
        font-size: 0.9rem !important;
    }
}

/* ==================== 分組清單（常見問題、檔案下載共用） ==================== */
/* 上方分組捷徑用 .case-module-tabs／.case-module-tab；與下方內容的間距和其他頁的膠囊列相同 */
.content-group-nav {
    margin-bottom: 1.25rem;
}

/* 點分組捷徑時平滑捲動；只在有分組捷徑的頁面生效。
   使用者系統設定「減少動態效果」時維持直接跳轉 */
@media (prefers-reduced-motion: no-preference) {
    html:has(.content-group-nav) {
        scroll-behavior: smooth;
    }
}

/* 固定導覽列會蓋住錨點位置，跳轉時預留導覽列高度 */
.content-group {
    scroll-margin-top: calc(var(--nav-h) + 1rem);
}

.content-group + .content-group {
    margin-top: 3rem;
}

/* 分組標題（常見問題）：沿用頁面字體、靠左，尺寸小於頁面 h1 */
.content-group-title {
    font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.35;
    margin-bottom: 0.6rem;
}

/* ---- 時間軸式分組（檔案下載，加 .content-group--timeline） ----
   版面與最新消息時間軸共用（見 .timeline-group），分組間距改由 padding 負責；
   左欄是分組標題，樣式比照時間軸的年月標籤（淺灰、特粗、靠右）；
   分類名稱比年月長，左欄固定寬度讓右側清單對齊，過長時在欄內換行 */
.content-group--timeline + .content-group--timeline {
    margin-top: 0;
}

.content-group--timeline .content-group-title {
    flex: 0 0 7.5rem;
    margin: 0;
    padding-top: 0.1rem;
    text-align: right;
    font-size: 1.5rem;
    font-weight: 900;
    color: #c8c8c8;
    line-height: 1.2;
    /* 換行優先落在空格（MOU／備忘錄），沒有空格的長名稱才逐字斷行避免溢出 */
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* 標題開頭放大（比照時間軸月份 2.2rem 比年份大），顏色與其餘字相同。
   開頭由 title_lead 決定：有空格放大第一個詞（MOU 備忘錄），否則放大第一個字（合約範本） */
.content-group-title-lead {
    font-size: 2.2rem;
}

.content-group-body {
    flex: 1;
    min-width: 0;
}

@media (max-width: 600px) {
    .content-group--timeline .content-group-title {
        flex-basis: auto;
        text-align: left;
        font-size: 1.25rem;
    }
}

/* ==================== 標籤／徽章（案件、研究團隊、團隊成果共用） ==================== */
/* 小型狀態徽章：案件狀態、團隊系所、成果照片數。原本四個頁面 CSS 各抄一份 */
.cl-badge,
.team-badge,
.td-badge,
.achievement-card__meta span {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
}

/* 團隊成果的徽章原本就沒有字距與不換行設定，維持原樣 */
.cl-badge,
.team-badge,
.td-badge {
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* 案件狀態徽章比其他小標籤大一號，前面加同色圓點，清單上一眼看得出狀態；顏色在 cases/case_list.css */
.cl-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.cl-badge::before {
    content: '';
    flex-shrink: 0;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
}

/* 預設藍色；案件狀態徽章改由 .cl-badge--* 依狀態上色 */
.team-badge,
.td-badge,
.achievement-card__meta span {
    background: #e9f2ff;
    color: var(--color-primary);
}

/* 灰底小標籤：團隊系所／辦公室、成員數 */
.cl-tag,
.td-tag {
    display: inline-block;
    padding: 0.16rem 0.5rem;
    border: 1px solid #e4e7ec;
    border-radius: 7px;
    background: #f8fafc;
    color: #475467;
    font-size: 0.71rem;
}

/* 篩選中的條件標籤（案件、研究團隊），右側 × 較淡 */
.cl-active-tag,
.team-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.22rem 0.56rem;
    border: 1px solid #d4deee;
    border-radius: 999px;
    background: #eff4fb;
    color: var(--color-primary);
    font-family: inherit;
    font-size: 0.76rem;
    cursor: pointer;
    text-decoration: none;
}

.cl-active-tag:hover,
.team-active-tag:hover {
    background: #e6eefb;
    color: #2b4468;
}

.cl-active-tag-x,
.team-active-tag span {
    color: #8097ba;
    line-height: 1;
}

/* ==================== 多選下拉（details + checkbox；師資陣容專長／研究領域共用） ==================== */
/* 用法：templates/components/_filter_multi.html。summary 直接套 .filter-select（或各頁的 *-filter-select），
   外觀與單選下拉相同；面板的邊框、圓角、字級取自 .filter-select，陰影取自 .dropdown */
.filter-multi {
    position: relative;
}

.filter-multi > summary {
    display: inline-flex;
    align-items: center;
    list-style: none;
}

.filter-multi > summary::-webkit-details-marker {
    display: none;
}

.filter-multi-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    z-index: 5;
    min-width: 100%;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.5rem 0;
    background: #fff;
    border: 1px solid #d0d7e2;
    border-radius: 9px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.filter-multi-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.38rem 0.72rem;
    color: #4b5563;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
}

.filter-multi-option:hover {
    background: #f4f8ff;
}

.filter-multi-option input {
    margin: 0;
}

@media (max-width: 640px) {
    .filter-multi {
        width: 100%;
    }
}
