/* ==========================================================================
   CourseMate AI — stylesheet
   淺色主題。版面固定在視窗高度內，整頁不捲動，只有面板內部會捲。
   ========================================================================== */

:root {
    --bg:            #f5f6fa;
    --surface:       #ffffff;
    --surface-2:     #f2f4f9;
    --surface-3:     #e8ebf3;
    --border:        #e2e6ef;
    --border-strong: #cdd4e1;
    --text:          #1b2333;
    --text-soft:     #5b6478;
    --text-faint:    #8b94a8;
    --accent:        #4f46e5;
    --accent-hover:  #4338ca;
    --accent-soft:   #eef0fe;
    --ok:            #15a34a;
    --ok-soft:       #e7f7ed;
    --warn:          #d97706;
    --warn-soft:     #fdf3e3;
    --error:         #dc2626;
    --error-soft:    #fdeaea;
    --shadow-sm:     0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md:     0 4px 14px rgba(16, 24, 40, .09);
    --shadow-lg:     0 12px 34px rgba(16, 24, 40, .14);
    --radius:        12px;
    --radius-sm:     8px;
    --topbar-h:      60px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
            "Microsoft JhengHei", "PingFang TC", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* hidden 一定要藏得住：像 .checkbox-line、.btn 這類有設 display 的元素，不加這條會照樣顯示 */
[hidden] { display: none !important; }

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;              /* 整頁不捲動 */
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.01em; }

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
    height: var(--topbar-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
}

.brand-mark { width: 30px; height: 30px; display: block; flex-shrink: 0; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15.5px; }
.brand-text small { font-size: 11px; color: var(--text-faint); }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.back-link:hover { border-color: var(--border-strong); color: var(--text); }

.course-heading {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 0 8px;
}

.course-heading h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-heading p {
    margin: 1px 0 0;
    font-size: 11.5px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-heading .sep { margin: 0 6px; opacity: .5; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.page-course .topbar-actions { margin-left: 0; }

/*
 * 課程頁標題列最右邊：長庚大學的 logo，跟左邊的按鈕用一條細線隔開。
 * 高度固定 30px：寬度 1100px 以下由 <picture> 換成只有校徽的版本，不要把整張 logo 縮小
 * （中英文校名會縮到看不清楚，看起來跟旁邊的按鈕不成比例）。
 */
.partner-logos {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: 4px;
    padding-left: 14px;
    border-left: 1px solid var(--border);
}
.partner-logos picture { display: block; line-height: 0; }
.partner-logos img { display: block; width: auto; height: 30px; }

@media (max-width: 1100px) {
    .partner-logos { gap: 10px; padding-left: 10px; }
}
/* 手機上標題列放不下，影片標題比較重要 */
@media (max-width: 720px) {
    .partner-logos { display: none; }
}
/* 很窄的時候「← 課程列表」只留箭頭，右邊的語言切換與「設定」才不會被擠出畫面 */
@media (max-width: 480px) {
    .back-link { padding: 7px 10px; }
    .back-link .back-text { display: none; }
}

/* ==========================================================================
   Buttons / chips
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .14s ease, border-color .14s ease, opacity .14s ease;
}

a.btn { text-decoration: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-soft);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }

.btn-small { height: 30px; padding: 0 11px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 24px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-block { width: 100%; }

.link-btn {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   語言切換：左中右英的雙段開關，滑塊會滑到目前語言那一邊
   -------------------------------------------------------------------------- */

.lang-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 3px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
}

.lang-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 36px;
    height: 24px;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform .24s cubic-bezier(.4, 0, .2, 1);
}

.lang-switch[data-lang="en"] .lang-thumb { transform: translateX(36px); }

.lang-opt {
    position: relative;      /* 疊在滑塊上面 */
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 24px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-faint);
    text-decoration: none;
    transition: color .2s ease;
}

.lang-opt:hover { color: var(--text-soft); }
.lang-opt.is-active { color: var(--accent); }

/* 使用者要求減少動態時就不要滑 */
@media (prefers-reduced-motion: reduce) {
    .lang-thumb { transition: none; }
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.chip:hover { border-color: var(--border-strong); color: var(--text); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.dot-ok      { background: var(--ok); }
.dot-error   { background: var(--error); }
.dot-warn    { background: var(--warn); }
.dot-loading { background: var(--accent); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .25; } }

.spinner {
    width: 26px;
    height: 26px;
    border: 2.5px solid var(--surface-3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   課程列表頁
   ========================================================================== */

.list-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

.list-head {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 22px 0 16px;
}

.list-title h1 { margin: 0; font-size: 22px; }
.list-title p { margin: 3px 0 0; font-size: 13px; color: var(--text-faint); }

.list-tools { display: flex; align-items: center; gap: 8px; }

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    height: 38px;
    width: 240px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
}

.search-box input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.search-icon {
    position: absolute;
    left: 11px;
    color: var(--text-faint);
    pointer-events: none;
}

.search-box-sm input { height: 32px; width: 100%; font-size: 12.5px; }
.search-box-sm { flex: 1; }

.list-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;             /* 只有這裡捲動 */
    padding-bottom: 24px;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 16px;
}

.course-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}

.course-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.card-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--surface-3);
    overflow: hidden;
}

.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-duration {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(12, 16, 24, .82);
    color: #fff;
    font-family: var(--mono);
    font-size: 11.5px;
    padding: 2px 6px;
    border-radius: 4px;
}

.card-body { padding: 13px 14px 0; flex: 1; }

.card-title {
    margin: 0 0 4px;
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-author { font-size: 12px; color: var(--text-faint); margin: 0 0 10px; }

.card-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.badge-ok    { background: var(--ok-soft);    color: #0f7a37; border-color: #bfe6cd; }
.badge-warn  { background: var(--warn-soft);  color: #9a5b06; border-color: #f2ddb6; }
.badge-idle  { background: var(--surface-2);  color: var(--text-faint); border-color: var(--border); }
.badge-info  { background: var(--accent-soft); color: var(--accent); border-color: #d6d8fb; }

.card-actions {
    display: flex;
    gap: 8px;
    padding: 0 14px 14px;
}

.card-actions .btn { flex: 1; height: 34px; font-size: 12.5px; padding: 0 10px; }

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
}

.empty-state h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.empty-state p { margin: 0 0 16px; font-size: 13.5px; }

/* ==========================================================================
   上課畫面
   ========================================================================== */

/* 上課畫面整片是同一張白底，左右兩欄只用一條細線分開，不做成兩張卡片 */
body.page-course { background: var(--surface); }

/*
 * 影片與右邊的面板佔滿整個寬度，跟上面的標題列對齊。
 * 以前限制最寬 1800px、置中：螢幕比 1800px 寬（例如 1920）時，右邊的頁籤會比標題列的 logo 短一截。
 */
.course-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 60fr) minmax(360px, 40fr);
    width: 100%;
}

.video-pane {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px;
}

.player-shell {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

/* 很寬的螢幕：影片寬度跟著變大，但不要高到把下面的「本段重點」擠掉（放不下就置中） */
@media (min-width: 1801px) {
    .player-shell { max-width: calc((100vh - var(--topbar-h) - 206px) * 16 / 9); align-self: center; }
    body.theater .player-shell { max-width: none; }
}

.player-shell iframe,
.player-shell > div {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* 本段重點：填滿影片下方的空間，並跟著播放進度更新 */
.now-playing {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px 2px 4px;
    display: flex;
    flex-direction: column;
}

.now-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.now-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 3px 10px;
}

.now-progress {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text-faint);
}

/* 「從 12:34 繼續」：原本在播放列，播放列拿掉後改放這裡 */
.resume-btn { margin-left: auto; margin-right: 12px; font-size: 11.5px; }

.now-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.45;
}

.now-points {
    margin: 0;
    padding-left: 19px;
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text-soft);
}

.now-points li { margin-bottom: 3px; }

/* 沒有外框之後，按鈕要跟在重點下面，不要被推到視窗最底下 */
.now-nav {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-shrink: 0;
}

.now-nav .btn { flex: 1; }

/* 劇院模式：影片吃滿寬度，右側面板收起 */
body.theater .course-shell { grid-template-columns: minmax(0, 1fr); }
body.theater .panel,
body.theater .now-playing { display: none; }
body.theater .player-shell { max-height: calc(100vh - var(--topbar-h) - 96px); }
body.theater .video-pane { align-items: center; }
body.theater .player-shell { width: min(100%, calc((100vh - var(--topbar-h) - 96px) * 16 / 9)); }

/* ==========================================================================
   右側面板 + 頁籤
   ========================================================================== */

.panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    overflow: hidden;
}

.tabs {
    display: flex;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    padding: 0 4px;
    gap: 2px;
}

.tab {
    flex: 1;
    height: 42px;
    border: 0;
    background: none;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-faint);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color .14s ease;
}

.tab:hover { color: var(--text-soft); }

.tab.is-active { color: var(--accent); }

.tab.is-active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}

.tab-panel {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.tab-panel.is-active { display: flex; }

.panel-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px 18px;
}

.panel-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.panel-foot {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-faint);
}

.panel-foot .hint { min-width: 0; }

/* ==========================================================================
   對話
   ========================================================================== */

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message { display: flex; gap: 10px; animation: fade-in .18s ease; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

.message-avatar {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.message-body {
    min-width: 0;
    font-size: 14.5px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.message-body p { margin: 0 0 8px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body ul, .message-body ol { margin: 6px 0 8px; padding-left: 21px; }
.message-body li { margin-bottom: 3px; }
.message-body code {
    font-family: var(--mono);
    font-size: .88em;
    background: var(--surface-3);
    padding: 1px 5px;
    border-radius: 4px;
}

/* 學生自己的提問：藍色泡泡靠右，一眼分得出誰在說話 */
.message-user { flex-direction: row-reverse; }
.message-user .message-avatar { background: var(--accent); color: #fff; font-size: 11px; }
.message-user .message-body {
    background: var(--accent);
    color: #fff;
    padding: 9px 14px;
    border-radius: 14px 14px 4px 14px;
    max-width: 84%;
}

/* 助教的頭像用黑貓 logo（圓形徽章，2026-10-07 換成使用者提供的圖；改圖時一起改 ?v= 讓瀏覽器重抓） */
.message-assistant .message-avatar {
    background-color: #fcf7ee;
    background-image: url("../img/cat-64.png?v=20261007");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
}

/* 助教的回答不加框，整段直接排出來，長答案讀起來才不擠 */
.message-assistant .message-body {
    flex: 1;
    padding: 2px 0 0;
    max-width: 100%;
}

.message-error .message-body {
    background: var(--error-soft);
    border: 1px solid #f5c6c6;
    padding: 11px 14px;
    border-radius: 14px;
}

.message-note { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

/* 等待時的狀態說明（例如「正在查詢網路資料…」） */
.typing-note { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.typing-note:empty { display: none; }

/* --------------------------------------------------------------------------
   回答裡的 Markdown
   -------------------------------------------------------------------------- */

.message-body .md-h {
    margin: 14px 0 6px;
    line-height: 1.45;
    font-weight: 650;
}
.message-body .md-h:first-child { margin-top: 0; }
.message-body h3.md-h { font-size: 16px; }
.message-body h4.md-h { font-size: 14.8px; }
.message-body h5.md-h { font-size: 14px; color: var(--text-soft); }

.message-body hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

.message-body blockquote {
    margin: 8px 0;
    padding: 2px 0 2px 12px;
    border-left: 3px solid var(--border-strong);
    color: var(--text-soft);
}
.message-body blockquote p:last-child { margin-bottom: 0; }

.message-body .code-block {
    margin: 8px 0;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}
.message-body .code-block code {
    display: block;
    background: none;
    padding: 0;
    font-family: var(--mono);
    font-size: 12.8px;
    line-height: 1.6;
    white-space: pre;
}

.message-body .md-table-wrap { overflow-x: auto; margin: 8px 0; }
.message-body .md-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13.5px;
}
.message-body .md-table th,
.message-body .md-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}
.message-body .md-table th { background: var(--surface-2); font-weight: 650; }

.message-body a { color: var(--accent); }
.message-body del { color: var(--text-faint); }
.message-body ul ul,
.message-body ul ol,
.message-body ol ul,
.message-body ol ol { margin: 3px 0 0; }

/* 串流中：在最後一段文字尾巴放一個閃爍游標 */
.message-body.is-streaming > :last-child::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -0.15em;
    background: var(--accent);
    animation: caret-blink 1s steps(2, start) infinite;
}

@keyframes caret-blink {
    to { visibility: hidden; }
}

.timestamp {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-family: var(--mono);
    font-size: .9em;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid #d6d8fb;
    border-radius: 5px;
    padding: 0 6px;
    margin: 0 1px;
    cursor: pointer;
    vertical-align: baseline;
    transition: background .12s ease, color .12s ease;
}

.timestamp:hover { background: var(--accent); color: #fff; }

.message-user .timestamp {
    background: rgba(255, 255, 255, .2);
    border-color: rgba(255, 255, 255, .32);
    color: #fff;
}

/* 網路來源：一排小圖標，不要整條列出來佔版面 */
.sources { margin-top: 10px; }

.sources-title {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--text-faint);
    margin-bottom: 5px;
}

.source-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 190px;
    padding: 3px 9px 3px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 11.5px;
    text-decoration: none;
    transition: border-color .12s ease, color .12s ease;
}

.source-chip:hover { border-color: var(--accent); color: var(--accent); }

.source-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border-radius: 3px;
}

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

.quick-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px 0;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.quick-actions::-webkit-scrollbar { display: none; }

.quick-action {
    flex-shrink: 0;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-family: var(--font);
    font-size: 12.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .12s ease;
}

.quick-action:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.quick-action:disabled { opacity: .5; cursor: not-allowed; }

.composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 11px 14px 4px;
    flex-shrink: 0;
}

.composer textarea {
    flex: 1;
    min-height: 42px;
    max-height: 150px;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
}

.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }

.btn-send { height: 42px; padding: 0 17px; }

.composer-foot {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 14px 11px;
    font-size: 11px;
    color: var(--text-faint);
}

/* 這部影片還可以問幾題（每部影片的提問上限），用完了變紅字 */
.chat-calls { margin-left: auto; font-variant-numeric: tabular-nums; }
.chat-calls.is-empty { color: var(--error); font-weight: 600; }

/* ==========================================================================
   大綱
   ========================================================================== */

.outline-summary {
    padding: 0 0 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.topic-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.topic-tag {
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
}

/* 章節一段一段往下排，用細線分隔就好，不要每段都框一個方塊 */
.chapter-list { display: flex; flex-direction: column; }

.chapter {
    display: flex;
    gap: 11px;
    padding: 11px 10px 11px 9px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    border-radius: 0;
    background: none;
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
    transition: background .14s ease, border-left-color .14s ease;
}

.chapter:last-child { border-bottom: 0; }

.chapter:hover { background: var(--surface-2); }

/* 目前播放的章節：左側一條色帶，比整個框起來安靜 */
.chapter.is-current {
    border-left-color: var(--accent);
    background: var(--accent-soft);
}

.chapter-time {
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--accent);
    padding-top: 2px;
    min-width: 52px;
}

.chapter-main { min-width: 0; }

.chapter-title {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 3px;
}

.chapter-points {
    margin: 0;
    padding-left: 16px;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.65;
}

/* ==========================================================================
   逐字稿
   ========================================================================== */

.transcript-line {
    display: flex;
    gap: 10px;
    padding: 5px 8px;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-size: 13.5px;
    line-height: 1.65;
    border-left: 3px solid transparent;
}

.transcript-line:hover { background: var(--surface-2); }

/* 跟大綱一致：目前這句用左側色帶標示，不整句框起來 */
.transcript-line.is-current {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.transcript-time {
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-faint);
    padding-top: 2px;
    min-width: 48px;
}

.transcript-line.is-current .transcript-time { color: var(--accent); font-weight: 700; }

.transcript-text { min-width: 0; }

.transcript-text mark {
    background: #fde68a;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* ==========================================================================
   資訊
   ========================================================================== */

.info-section { margin-bottom: 26px; }

.info-section h3 {
    margin: 0 0 9px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.info-text { font-size: 13.5px; line-height: 1.75; color: var(--text-soft); margin: 0; }

/* 規格列表：名稱在左、數值在右，只用細線分隔 */
.spec { margin: 0; }

.spec-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}

.spec-row:last-child { border-bottom: 0; }

.spec-row dt {
    font-size: 13px;
    color: var(--text-soft);
    white-space: nowrap;
}

.spec-row dd {
    margin: 0;
    min-width: 0;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text);
    text-align: right;
    overflow-wrap: anywhere;
}

.info-note {
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-faint);
    margin: 10px 0 0;
}

.info-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   尚未準備好的課程
   ========================================================================== */

.prepare-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.prepare-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 34px 30px;
    max-width: 520px;
    width: 100%;
    text-align: center;
}

.prepare-icon { font-size: 42px; line-height: 1; margin-bottom: 12px; }
.prepare-card h2 { margin: 0 0 8px; font-size: 19px; }
.prepare-card > p { margin: 0 0 20px; font-size: 13.5px; color: var(--text-soft); line-height: 1.7; }
.prepare-hint { margin: 18px 0 0; font-size: 12px; color: var(--text-faint); }
.prepare-hint a { color: var(--accent); }

/* ==========================================================================
   進度清單
   ========================================================================== */

.progress-list { list-style: none; margin: 18px 0 0; padding: 0; text-align: left; }

.progress-list li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.progress-list li:last-child { border-bottom: 0; }

/* 狀態點：綠色完成、紅色失敗、灰色略過、轉圈處理中 */
.progress-mark { flex-shrink: 0; width: 10px; height: 10px; margin: 6px 4px 0; border-radius: 50%; background: var(--border-strong); }
.progress-mark.is-ok { background: var(--ok); }
.progress-mark.is-error { background: var(--error); }
.progress-mark.is-skip { background: var(--surface); border: 1.5px solid var(--border-strong); }
.progress-mark.is-running { background: none; border: 2px solid var(--surface-3); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.progress-main { min-width: 0; display: flex; flex-direction: column; }
.progress-name { font-weight: 600; }
.progress-detail { font-size: 12px; color: var(--text-faint); line-height: 1.55; }
.progress-list li.is-error .progress-detail { color: var(--error); }

/* ==========================================================================
   Dialog
   ========================================================================== */

.dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 0;
    max-width: 600px;
    width: calc(100vw - 32px);
    box-shadow: var(--shadow-lg);
}

.dialog::backdrop { background: rgba(15, 20, 30, .45); }

.dialog-body { padding: 22px; }
.dialog-body h3 { margin: 0 0 8px; font-size: 17px; }
.dialog-desc { margin: 0 0 16px; font-size: 13px; color: var(--text-soft); line-height: 1.65; }

.field { display: block; margin-bottom: 14px; }

.field > span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
}

.field textarea { font-family: var(--mono); font-size: 12px; resize: vertical; line-height: 1.6; }

.field input:focus,
.field select:focus,
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 14px;
    cursor: pointer;
}

.checkbox-line input { width: auto; margin: 0; }
.checkbox-inline { margin-bottom: 0; font-size: 12px; white-space: nowrap; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dialog-error { margin: 12px 0 0; color: var(--error); font-size: 13px; }

.model-list {
    font-family: var(--mono);
    font-size: 12px;
    white-space: pre-wrap;
    max-height: 180px;
    overflow-y: auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-top: 10px;
}

/* ==========================================================================
   捲軸
   ========================================================================== */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ==========================================================================
   平板 / 手機
   ========================================================================== */

@media (max-width: 1080px) {
    /* 窄螢幕改成上下排列，這時允許整頁捲動 */
    html, body { overflow: auto; height: auto; min-height: 100%; }

    .course-shell {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }

    /* 疊成上下之後，分隔線要改到上緣 */
    .panel {
        height: 72vh;
        min-height: 460px;
        border-left: 0;
        border-top: 1px solid var(--border);
    }

    body.theater .player-shell { width: 100%; }
}

@media (max-width: 720px) {
    .topbar { padding: 0 12px; gap: 10px; }
    .brand-text small { display: none; }
    .course-heading { text-align: left; }

    .list-shell { padding: 0 14px; }
    .list-head { padding: 16px 0 12px; align-items: stretch; }
    .list-tools { flex-wrap: wrap; }
    .search-box { flex: 1; }
    .search-box input { width: 100%; }

    .course-grid { grid-template-columns: 1fr; }
    .video-pane { padding: 12px; gap: 12px; }

    .tab { font-size: 12px; }
    .message-user .message-body,
    .message-assistant .message-body { max-width: 100%; }
}

/* ==========================================================================
   右上角、公開狀態、我的影片
   ========================================================================== */

.chip-accent {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: #d6d8fb;
}
.chip-accent:hover { color: var(--accent-hover); border-color: var(--accent); }
/* 目前所在的那一頁 */
.chip.is-current { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* 登入的老師：名字（連到「我的帳號」）、登出按鈕；管理者只顯示「管理者」，不是連結 */
.user-chip { max-width: 180px; }
.user-chip .user-name { overflow: hidden; text-overflow: ellipsis; }
span.user-chip { cursor: default; }
.inline-form { display: inline-flex; margin: 0; }
button.chip { font-family: var(--font); }

@media (max-width: 720px) {
    .user-chip { max-width: 110px; }
}

/*
 * 窄螢幕的標題列（課程列表、我的影片、管理頁）：右上角的按鈕放不下時可以左右滑，不會被切掉。
 * 再窄一點先收掉重複的：「課程列表」（點左上角的 logo 一樣回課程列表）、只是標示身分的「管理者」，
 * 最後收掉網站名稱，只留貓咪 logo。
 */
@media (max-width: 720px) {
    .page-list .topbar-actions {
        flex-shrink: 1;
        min-width: 0;
        padding: 4px 2px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .page-list .topbar-actions::-webkit-scrollbar { display: none; }
    .page-list .topbar-actions > * { flex-shrink: 0; }
    span.user-chip { display: none; }
}
@media (max-width: 640px) {
    .chip-home { display: none; }
}
@media (max-width: 540px) {
    .page-list .brand-text { display: none; }
}
@media (max-width: 440px) {
    .page-list .topbar-actions { gap: 5px; }
    .page-list .topbar-actions .chip { padding: 0 9px; }
}
@media (max-width: 400px) {
    .user-chip { max-width: 84px; }
}

/* AI 暫停中的提示條（課程列表、我的影片、產生字幕） */
.ai-banner {
    flex-shrink: 0;
    margin: 0 0 14px;
    padding: 10px 14px;
    border: 1px solid #f2ddb6;
    border-radius: var(--radius);
    background: var(--warn-soft);
    color: #7a4a06;
    font-size: 13px;
    line-height: 1.6;
}
/* 從這台電腦開的時候後面接「到設定輸入 Key」的連結 */
.ai-banner a { margin-left: 4px; color: inherit; font-weight: 600; }

/* 對話框被停用時的說明（AI 暫停） */
.message-notice .message-avatar { background: var(--warn-soft); }
.message-notice .message-avatar::before { content: "!"; font-size: 13px; font-weight: 700; color: #9a5b06; }
.message-notice .message-body {
    background: var(--warn-soft);
    border: 1px solid #f2ddb6;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 13.5px;
}
/* .message-body a 會把連結染成主色，按鈕要蓋回白字，不然字跟底色一樣看不見 */
.message-notice .message-body .btn { margin-top: 2px; color: #fff; text-decoration: none; }
.composer textarea:disabled { cursor: not-allowed; opacity: .7; }

.flash {
    flex-shrink: 0;
    margin: 0 0 12px;
    padding: 9px 14px;
    border: 1px solid #bfe6cd;
    border-radius: var(--radius-sm);
    background: var(--ok-soft);
    color: var(--text);
    font-size: 13px;
}
.flash-error { background: var(--error-soft); border-color: #f5c6c6; color: var(--error); }
.flash a { margin-left: 8px; color: inherit; font-weight: 600; }

.badge-error { background: var(--error-soft); color: var(--error); border-color: #f5c6c6; }

.btn-danger {
    background: var(--surface-2);
    border-color: color-mix(in srgb, var(--error) 35%, var(--border));
    color: var(--error);
}
.btn-danger:hover:not(:disabled) { background: var(--error-soft); border-color: var(--error); }

/* 卡片標題也能點進課程（縮圖本來就能點） */
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--accent); }

/* 觀看次數 */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--text-soft);
}
.card-author + .card-meta { margin-top: -6px; }
.card-meta .sep { margin: 0 6px; opacity: .5; }

/*
 * 我的影片、產生字幕：一個項目一列（產生字幕的欄位在下面的 .sub-table 另外設定）。
 * 我的影片的欄位：影片｜狀態｜觀看次數｜AI 提問｜新增日期｜誰可以看｜操作。
 * 欄位標題捲動時固定在上面；窄螢幕（1100px 以下）時每一列疊成幾行。
 */
.studio-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.studio-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 132px 64px 92px 88px 112px 236px;
    align-items: center;
    column-gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}
.studio-row:first-child { border-top: 0; }
.studio-row:not(.studio-head):hover { background: #fafbfd; }
.studio-cell { min-width: 0; }

.studio-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-top: 9px;
    padding-bottom: 9px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface-2);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
}
.studio-sort {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.studio-sort:hover,
.studio-sort.is-active { color: var(--text); }
.studio-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.studio-video { display: flex; align-items: center; gap: 12px; }
.studio-thumb {
    position: relative;
    flex-shrink: 0;
    width: 96px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 6px;
    background: var(--surface-3);
}
.studio-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.studio-thumb .card-duration { right: 4px; bottom: 4px; padding: 0 4px; font-size: 10.5px; }
.studio-video-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.studio-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
}
.studio-title:hover { color: var(--accent); }
.studio-sub { overflow: hidden; font-size: 12px; color: var(--text-faint); text-overflow: ellipsis; white-space: nowrap; }
.studio-sub.is-error { color: var(--error); white-space: normal; }
/* 等字幕的影片：下一步的說明（會換行）與到「產生字幕」的連結 */
.studio-sub.studio-awaiting { color: var(--text-soft); line-height: 1.45; white-space: normal; }
.studio-sub a,
.sub-state-text a { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.studio-sub a:hover,
.sub-state-text a:hover { text-decoration: underline; }

.studio-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.studio-num,
.studio-date { font-size: 13px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.studio-num { text-align: right; }
.studio-vis select {
    width: 100%;
    height: 30px;
    padding: 0 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 12.5px;
    cursor: pointer;
}
.studio-vis select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.studio-row-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }

/* 學生進課程要輸入的數字密碼，放在「複製連結」左邊 */
.studio-code {
    margin-right: 2px;
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
}
.studio-code strong {
    margin-left: 2px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    user-select: all;
}

/* 「⋯」：列上只放「複製連結」，重設連結、更新字幕、刪除收在這個選單裡 */
.row-menu-btn { width: 32px; padding: 0; justify-content: center; }
.row-menu-btn svg { display: block; fill: currentColor; }
.row-menu-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.row-menu {
    position: fixed;
    z-index: 60;
    min-width: 132px;
    padding: 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}
.row-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.row-menu button:hover,
.row-menu button:focus-visible { background: var(--surface-2); outline: none; }
.row-menu button.is-danger { color: var(--error); }
.row-menu button.is-danger:hover,
.row-menu button.is-danger:focus-visible { background: #fdecec; }
.row-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

/* 老師看到的說明：學生要輸入的數字密碼、「複製連結」會一起複製 */
.studio-note { flex-shrink: 0; margin: 0 0 12px; font-size: 12.5px; color: var(--text-faint); }

/* 管理者才有：影片標題底下換上傳者的選單 */
.studio-owner { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--text-faint); }
.studio-owner select {
    min-width: 0;
    max-width: 220px;
    height: 26px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-soft);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
}
.studio-owner select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* AI 提問：「已經問了幾題 / 上限」，管理者點一下改上限（老師只看得到數字）；用完了標紅字 */
.studio-calls { text-align: right; }
.studio-calls-text { font-size: 13px; color: var(--text-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.studio-calls-text.is-full { color: var(--error); font-weight: 600; }
.studio-calls-btn {
    padding: 3px 6px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-soft);
    font-family: var(--font);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    cursor: pointer;
}
.studio-calls-btn::after { content: " ✎"; font-size: 11px; color: var(--text-faint); }
.studio-calls-btn:hover { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.studio-calls-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.studio-calls-btn.is-full { color: var(--error); font-weight: 600; }
.studio-calls-btn.is-off { color: var(--text-faint); }

/* AI 提問設定：「關閉」的勾選（底下一行小字說明）、已經問了幾題與「清除 AI 提問紀錄」 */
.chat-off-line { align-items: flex-start; color: var(--text); }
.chat-off-line input { margin-top: 3px; }
.chat-off-line small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--text-faint); }
.limit-usage { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: -4px 0 14px; font-size: 13px; color: var(--text-soft); }
.limit-usage .link-btn { font-size: 12.5px; }
.field input:disabled { opacity: .55; cursor: not-allowed; }

/* 修改標題：YouTube 原本的標題與「改回 YouTube 的標題」 */
.title-youtube { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; overflow-wrap: anywhere; }
.title-youtube .link-btn { flex-shrink: 0; }

/* 自動複製失敗時讓老師自己選取的文字 */
.copy-text {
    width: 100%;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.7;
    resize: none;
}

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

@media (max-width: 1100px) {
    .studio-head { display: none; }
    .studio-head + .studio-row { border-top: 0; }
    .studio-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "video video"
            "state vis"
            "num date"
            "calls calls"
            "actions actions";
        row-gap: 10px;
        padding: 12px 14px;
    }
    .studio-video { grid-area: video; }
    .studio-state { grid-area: state; }
    .studio-vis { grid-area: vis; }
    .studio-vis select { width: auto; }
    .studio-num { grid-area: num; text-align: left; }
    .studio-date { grid-area: date; text-align: right; }
    .studio-calls { grid-area: calls; text-align: left; font-size: 13px; }
    .studio-num::before,
    .studio-date::before,
    .studio-calls::before { content: attr(data-label) "　"; color: var(--text-faint); }
    .studio-calls-btn { padding-left: 0; padding-right: 0; }
    .studio-row-actions { grid-area: actions; }
}

.visibility-help { margin: -4px 0 14px; font-size: 12.5px; color: var(--text-soft); }

.spinner-inline {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin: 0;
    border-width: 2px;
}

/* 找不到課程、只能從本機開啟等訊息頁的按鈕列 */
.message-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

/* ==========================================================================
   設定（只有這台電腦 localhost 開得到）
   ========================================================================== */

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    max-width: 960px;
}

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
}
.settings-card:first-child { grid-row: span 2; }
.settings-card h2 { margin: 0 0 10px; font-size: 15px; }
.settings-card code { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.settings-card .badge { margin: 0 6px 4px 0; }

.settings-form { margin-top: 16px; }
.settings-form + .settings-form { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.settings-actions { display: flex; gap: 10px; }
.settings-note { margin: 12px 0 0; font-size: 12.5px; color: var(--text-soft); line-height: 1.65; }

/* 存好 Key 之後，列出設定檔裡的模型這把 Key 看不看得到 */
.settings-checks { margin: 6px 0 0; padding-left: 18px; }
.settings-checks .is-missing { color: var(--error); font-weight: 600; }

@media (max-width: 720px) {
    .settings-grid { grid-template-columns: 1fr; }
    .settings-card:first-child { grid-row: auto; }
}

/* ==========================================================================
   老師登入
   ========================================================================== */

.auth-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 20px;
    overflow-y: auto;
}
/* 登入頁：這台電腦還沒有管理者密碼時，「設定管理者密碼」疊在登入表單上面 */
.auth-stack { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 400px; }
.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 28px 28px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.auth-card h1 { margin: 0 0 6px; font-size: 20px; }
/* 驗證碼：輸入框、圖片（點一下換一張）、「換一張」 */
.captcha-row { display: flex; align-items: center; gap: 8px; }
.field .captcha-row input { flex: 1 1 auto; width: auto; min-width: 0; }
.field .captcha-row input:not(:placeholder-shown) { letter-spacing: 0.2em; }
.captcha-img {
    flex-shrink: 0;
    width: 132px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f5f6fb;
    cursor: pointer;
}
.captcha-refresh { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 400px) {
    .captcha-row { flex-wrap: wrap; }
    .field .captcha-row input { flex-basis: 100%; }
}
.auth-desc { margin: 0 0 18px; font-size: 13px; line-height: 1.65; color: var(--text-soft); }
.auth-note {
    margin: 0 0 16px;
    padding: 9px 12px;
    border: 1px solid #d6d8fb;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    font-size: 12.5px;
    line-height: 1.6;
}
.auth-note a { color: var(--accent); font-weight: 600; }
.auth-card .btn-block { margin-top: 4px; }
.auth-foot { margin: 14px 0 0; font-size: 12px; color: var(--text-faint); text-align: center; }
.auth-foot + .auth-foot { margin-top: 6px; }
.auth-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

/* 進課程前輸入數字密碼：上面是哪一門課（縮圖、標題、上傳者） */
.gate-course {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -4px 0 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.gate-thumb { flex-shrink: 0; width: 112px; height: 63px; border-radius: 6px; object-fit: cover; background: var(--surface-3); }
.gate-course-text { min-width: 0; }
.gate-course-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.45;
}
.gate-course-owner { margin: 3px 0 0; font-size: 12px; color: var(--text-faint); }
.field input.gate-code { font-family: var(--mono); font-size: 18px; text-align: center; }
.field input.gate-code:not(:placeholder-shown) { letter-spacing: 0.3em; }

/* ==========================================================================
   使用者管理（只有這台電腦 localhost 開得到）
   ========================================================================== */

.users-grid .users-list { grid-column: 1 / -1; }
.users-how { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.75; color: var(--text-soft); }
.users-how li + li { margin-top: 6px; }
.users-how code { font-family: var(--mono); font-size: 12px; color: var(--text); overflow-wrap: anywhere; }

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    padding: 0 10px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-faint);
    text-align: left;
    white-space: nowrap;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table code { font-family: var(--mono); font-size: 12.5px; }
.data-table tr.is-disabled td { color: var(--text-faint); }
.data-table .row-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.data-table .row-actions form { margin: 0; }

/* 表格裡直接改顯示名稱：點名字展開一個小表單 */
.rename summary { cursor: pointer; list-style: none; }
.rename summary::-webkit-details-marker { display: none; }
.rename summary span { font-size: 11px; color: var(--text-faint); }
.rename-form { display: flex; gap: 6px; margin-top: 6px; }
.rename-form input {
    width: 150px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12.5px;
}

/* 剛產生的初始密碼：只顯示這一次 */
.one-time { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.one-time-secret {
    padding: 4px 10px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: var(--mono);
    font-size: 15px;
    letter-spacing: .04em;
    color: var(--text);
    user-select: all;
}
.one-time-note { margin: 6px 0 0; font-size: 12px; color: var(--text-soft); }

/* ==========================================================================
   我的影片／產生字幕：上方的頁籤（樣式跟上課畫面的頁籤一致）
   ========================================================================== */

.page-tabs {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    margin-top: 14px;
    border-bottom: 1px solid var(--border);
}

.page-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px;
    color: var(--text-faint);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color .14s ease;
}
.page-tab:hover { color: var(--text-soft); }
.page-tab.is-active { color: var(--accent); }
.page-tab.is-active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}
.page-tabs + .list-head { padding-top: 16px; }

/* 新增影片視窗底下：影片沒有字幕的話，可以先去產生字幕 */
.dialog-note { margin: 14px 0 0; font-size: 12.5px; color: var(--text-soft); }
.dialog-note a { color: var(--accent); font-weight: 600; }

/* ==========================================================================
   產生字幕檔
   ========================================================================== */

/*
 * 字幕列表：共用「我的影片」的 .studio-table / .studio-row，欄位換成
 * 影片｜狀態｜語言｜建立日期｜操作。狀態欄底下放目前的進度（加一條細進度條）或做好的結果。
 */
.sub-table .studio-row { grid-template-columns: minmax(240px, 1fr) 232px 104px 96px 300px; }
.sub-table .studio-row-actions { flex-wrap: wrap; }
.sub-lang { font-size: 13px; color: var(--text-soft); }
.studio-sub .is-warn { color: #9a5b06; }

.sub-state-text { flex-basis: 100%; font-size: 12px; line-height: 1.45; color: var(--text-soft); }
.sub-state-text.is-warn { color: #9a5b06; }
.sub-bar { flex-basis: 100%; height: 4px; overflow: hidden; border-radius: 2px; background: var(--surface-3); }
.sub-bar > span { display: block; height: 100%; border-radius: 2px; background: var(--accent); transition: width .6s ease; }

/* 查看修正：列表放不下的結果細節，以及請使用者對照影片確認的地方 */
.sub-review-summary { margin-bottom: 2px; }
.sub-review-meta { margin: 0 0 12px; font-size: 12px; color: var(--text-faint); }
.sub-review-warnings {
    margin: 0 0 12px;
    padding: 9px 12px;
    border: 1px solid #f2ddb6;
    border-radius: var(--radius-sm);
    background: var(--warn-soft);
}
.sub-warnings-title { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; color: #7a4a06; }
.sub-warnings { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.6; color: #9a5b06; }
.sub-warnings li { position: relative; padding-left: 12px; }
.sub-warnings li::before { content: ""; position: absolute; left: 2px; top: .65em; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* 跟上面「我的影片」同一個寬度疊起來，不然兩邊的欄位設定會互相打架 */
@media (max-width: 1100px) {
    .sub-table .studio-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "video video"
            "state state"
            "lang date"
            "actions actions";
    }
    .sub-table .sub-lang { grid-area: lang; }
    .sub-table .sub-lang::before { content: attr(data-label) "　"; color: var(--text-faint); }
}

/* 還沒有字幕時：說明怎麼用 */
.sub-empty h3 { margin-bottom: 4px; }
.sub-how {
    list-style: none;
    display: grid;
    gap: 10px;
    max-width: 470px;
    margin: 16px auto 22px;
    padding: 0;
    text-align: left;
}
.sub-how li { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; line-height: 1.6; color: var(--text-soft); }
.sub-how-num {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

/* 新增視窗 */
.dialog-wide { max-width: 820px; }
.field-help { margin: -8px 0 14px; font-size: 12px; line-height: 1.6; color: var(--text-faint); }
.field textarea.text-plain { font-family: var(--font); font-size: 13px; }

.file-drop {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    padding: 12px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.file-drop:hover,
.file-drop.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.file-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.file-drop input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; opacity: 0; pointer-events: none; }

.file-list { list-style: none; margin: -6px 0 14px; padding: 0; font-size: 12.5px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.file-list .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-size { flex-shrink: 0; color: var(--text-faint); }

/* 查看修正 */
.sub-terms {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-height: 92px;
    margin: 0 0 12px;
    overflow-y: auto;
}
.sub-terms-label { margin-right: 2px; font-size: 12px; font-weight: 600; color: var(--text-soft); }

.sub-review-list {
    max-height: min(58vh, 560px);
    margin-bottom: 14px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.sub-review-list .empty-state { padding: 30px 20px; }
.sub-change { display: flex; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.6; }
.sub-change:last-child { border-bottom: 0; }
.sub-change.is-big { background: var(--warn-soft); }
.sub-change-time { flex-shrink: 0; width: 58px; padding-top: 1px; font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.sub-change-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sub-change-old { color: var(--text-faint); }
.sub-change-old del { padding: 0 1px; border-radius: 3px; background: var(--error-soft); color: var(--error); }
.sub-change-new { color: var(--text); }
.sub-change-new ins { padding: 0 1px; border-radius: 3px; background: var(--ok-soft); color: #0f7a37; font-weight: 600; text-decoration: none; }
.sub-change-badges { display: flex; gap: 5px; margin-top: 4px; }
.sub-review-empty { margin: 0; padding: 22px 12px; text-align: center; font-size: 13px; color: var(--text-faint); }

/*
 * 每一句用哪個版本（採用修正／保持原樣／自己改）：選的那一行是黑字、不一樣的字標綠；沒選的變淡、標紅。
 * 還沒儲存的句子左邊一條色線。
 */
.sub-change.is-dirty { box-shadow: inset 3px 0 0 var(--accent); }
.sub-change.is-use-raw .sub-change-old { color: var(--text); }
.sub-change.is-use-raw .sub-change-old del { background: var(--ok-soft); color: #0f7a37; font-weight: 600; text-decoration: none; }
.sub-change.is-use-raw .sub-change-new { color: var(--text-faint); }
.sub-change.is-use-raw .sub-change-new ins { background: var(--error-soft); color: var(--error); font-weight: 400; text-decoration: line-through; }
.sub-change.is-use-custom .sub-change-new { color: var(--text-faint); }
.sub-change.is-use-custom .sub-change-new ins { background: var(--surface-3); color: inherit; font-weight: 400; }
.sub-change-input {
    display: block;
    width: 100%;
    margin: 6px 0 2px;
    padding: 5px 9px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.sub-change-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.sub-change-pick {
    flex-shrink: 0;
    align-self: flex-start;
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.sub-change-pick button {
    padding: 3px 9px;
    border: 0;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--text-soft);
    font-family: var(--font);
    font-size: 12px;
    line-height: 1.5;
    white-space: nowrap;
    cursor: pointer;
}
.sub-change-pick button:first-child { border-left: 0; }
.sub-change-pick button:hover { background: var(--surface-2); color: var(--text); }
.sub-change-pick button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sub-change-pick button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sub-review-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 0 0 8px; }
.sub-review-tools .checkbox-line { margin: 0; }
.sub-review-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-left: auto; font-size: 12.5px; color: var(--text-soft); }
.sub-review-bulk .link-btn { font-size: 12.5px; }
.sub-review-more { display: block; margin: 10px auto; font-size: 12.5px; }
.sub-review-status { margin: -6px 0 12px; font-size: 12.5px; line-height: 1.6; color: var(--text-soft); }
.sub-review-status.is-pending { color: var(--accent); }
.sub-review-status.is-ok { color: #0f7a37; }
.sub-review-status.is-error { color: var(--error); }
.sub-review-status a { margin-left: 4px; color: inherit; font-weight: 600; }
.sub-review-actions { flex-wrap: wrap; }
.sub-review-actions #sub-review-raw { margin-right: auto; }

/* 上面的說明與下面的按鈕固定，只有中間的句子列表捲動：「儲存選擇」永遠看得到 */
#sub-review-dialog { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
#sub-review-dialog .dialog-body { display: flex; flex-direction: column; max-height: calc(100vh - 34px); max-height: calc(100dvh - 34px); }
#sub-review-dialog .dialog-body > * { flex-shrink: 0; }
#sub-review-dialog .sub-review-warnings { max-height: 120px; overflow-y: auto; }
#sub-review-dialog .sub-review-list { flex: 0 1 auto; min-height: 0; max-height: none; }
/* 很矮的視窗（手機橫放）：整個視窗一起捲，列表才不會被擠到看不見 */
@media (max-height: 560px) {
    #sub-review-dialog .dialog-body { display: block; max-height: none; }
    #sub-review-dialog .sub-review-list { max-height: 70vh; }
}

@media (max-width: 720px) {
    .page-tabs { margin-top: 8px; }
    .sub-change-time { width: 46px; }
}

/* 手機：選項換到文字底下（跟文字對齊） */
@media (max-width: 600px) {
    .sub-change { flex-wrap: wrap; row-gap: 6px; }
    .sub-change-main { flex-basis: calc(100% - 58px); }
    .sub-change-pick { margin-left: 58px; }
}

/* ==========================================================================
   長庚帳號登入、課程列表的分類（2026-10 DEMO 版併入正式版時從舊版搬過來）
   ========================================================================== */

/* 課程列表上方的登入提示：夾在 list-head 與可捲動的 list-body 之間，不能被壓縮 */
.login-hint {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px;
    padding: 10px 14px;
    border: 1px solid #d6d8fb;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--text);
    font-size: 13px;
}
.login-hint-text { flex: 1; min-width: 0; }

/* 課程列表上方的分類，仿 YouTube 首頁那排 chip */
.filter-chips {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 0 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }

.filter-chip {
    flex-shrink: 0;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background .14s ease, color .14s ease;
}
.filter-chip:hover { background: #dde1ea; }
.filter-chip.is-active { background: var(--text); color: #fff; }
.filter-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 登入頁的「學生、教職員」長庚帳號登入卡（在老師帳號表單上面） */
.auth-sso-title { margin: 0 0 6px; font-size: 18px; }
.auth-sso .auth-desc { margin-bottom: 14px; }
.auth-sso .btn-sso { font-size: 14px; }

@media (max-width: 720px) {
    .login-hint { flex-wrap: wrap; }
}

/* ==========================================================================
   進站的載入畫面（includes/auth.php 的 cm_render_splash()、common.js 的 initSplash()）
   每個分頁第一次打開課程列表或課程頁時出現：黑貓 logo 跳出來、載入條跑完，約 1.5 秒後淡出。
   底色跟 logo 圖的底色一樣（#fcf7ee）。JS 沒跑起來的話 4 秒後自己收起來（splash-auto-hide）。
   ========================================================================== */

.splash { display: none; }
html.cm-splash .splash {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #fcf7ee;
    cursor: pointer;
    animation: splash-auto-hide .4s ease 4s forwards;
}
.splash-inner { display: flex; flex-direction: column; align-items: center; text-align: center; }
/* 圖載好才開始跳（initSplash 加 is-ready），不然第一次來的人會看到空的動畫 */
.splash-logo { display: block; width: 200px; height: 200px; opacity: 0; }
.splash-logo.is-ready {
    opacity: 1;
    animation: splash-pop .7s cubic-bezier(.2, .9, .3, 1.25) both, splash-bob 2.4s ease-in-out .7s infinite;
}
.splash-name {
    margin-top: 18px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: .3px;
    color: #3b2418;
    animation: splash-rise .5s ease .2s both;
}
.splash-tagline { margin-top: 4px; font-size: 14px; color: #8a6a4f; animation: splash-rise .5s ease .3s both; }
.splash-bar { width: 168px; height: 5px; margin-top: 22px; border-radius: 99px; background: #eedcc0; overflow: hidden; }
.splash-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #e9a23b;
    transform-origin: left center;
    animation: splash-load 1.35s cubic-bezier(.4, 0, .2, 1) both;
}
html.cm-splash .splash.is-leaving { animation: splash-leave .45s ease forwards; }

@keyframes splash-pop  { from { opacity: 0; transform: scale(.7) translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes splash-bob  { 50% { transform: translateY(-6px); } }
@keyframes splash-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes splash-load { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes splash-leave { to { opacity: 0; transform: scale(1.03); visibility: hidden; } }
@keyframes splash-auto-hide { to { opacity: 0; visibility: hidden; pointer-events: none; } }

@media (max-width: 480px) {
    .splash-logo { width: 160px; height: 160px; }
    .splash-name { font-size: 22px; }
}
/* 不要動畫的人：直接顯示，只保留淡出 */
@media (prefers-reduced-motion: reduce) {
    .splash-logo.is-ready, .splash-name, .splash-tagline, .splash-bar span { animation: none; }
    html.cm-splash .splash.is-leaving { animation: splash-auto-hide .2s ease forwards; }
}