/* ─── 基礎變數 ──────────────────────────────────────────────────────────────── */
:root {
  --bg-primary:   #0e0e10;
  --bg-secondary: #18181b;
  --bg-card:      #1f1f23;
  --bg-elevated:  #26262c;
  --border:       #2d2d35;
  --text-1:       #efeff1;
  --text-2:       #adadb8;
  --text-3:       #848494;
  --accent:       #9147ff;
  --accent-hover: #a970ff;
  --accent-dim:   #6441a5;
  --gold:         #f9ca24;
  --green:        #00b894;
  --red:          #eb0400;
  --radius:       8px;
  --radius-lg:    12px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg-primary); color: var(--text-1); font-family: 'Noto Sans TC', system-ui, sans-serif; min-height: 100vh; overflow-x: hidden; }
.hidden { display: none !important; }

/* ─── 頂部導覽 ──────────────────────────────────────────────────────────────── */
.app-nav {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.5rem; height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
}
.nav-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--accent); font-size: 1rem; white-space: nowrap; }
.nav-logo { width: 22px; height: 22px; }
.nav-tabs { display: flex; gap: 0; flex: 1; justify-content: center; }
.nav-tab {
  padding: 0 1.25rem; height: 52px; border: none; background: transparent;
  color: var(--text-2); font-family: inherit; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s;
}
.nav-tab:hover { color: var(--text-1); background: var(--bg-elevated); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.nav-status { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--text-3); white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); }
.btn-auth {
  padding: 0.3rem 0.7rem; background: rgba(145,71,255,0.15); color: var(--accent);
  border: 1px solid rgba(145,71,255,0.35); border-radius: 6px;
  font-family: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s; white-space: nowrap; margin-left: 0.25rem;
}
.btn-auth:hover { background: var(--accent); color: #fff; }
.btn-auth.authorized { background: rgba(0,184,148,0.12); color: var(--green); border-color: rgba(0,184,148,0.3); cursor: default; }

/* ─── Tab 分頁 ──────────────────────────────────────────────────────────────── */
.tab-pane { display: flex; flex-direction: column; min-height: calc(100vh - 52px); }

/* ─── 統計卡片 ──────────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 1.25rem 1.5rem 0; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem; text-align: center;
}
.stat-card.highlight { border-color: var(--gold); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-1); }
.stat-card.highlight .stat-value { color: var(--gold); }
.stat-label { font-size: 0.8rem; color: var(--text-3); margin-top: 0.25rem; }

/* ─── 等級分布 ──────────────────────────────────────────────────────────────── */
.level-dist-wrap { padding: 1rem 1.5rem; }
.level-dist-title { font-size: 0.8rem; font-weight: 600; color: var(--text-3); margin-bottom: 0.5rem; }
.level-dist-bars { display: flex; gap: 0.4rem; align-items: flex-end; height: 48px; }
.dist-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dist-bar { width: 100%; border-radius: 3px 3px 0 0; min-height: 4px; transition: height 0.5s; }
.dist-count { font-size: 0.65rem; color: var(--text-3); }
.dist-lv { font-size: 0.6rem; color: var(--text-3); }

/* ─── 操作列 ────────────────────────────────────────────────────────────────── */
.table-toolbar {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.5rem;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-toolbar input[type=search] {
  flex: 1; min-width: 160px; padding: 0.5rem 0.75rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-1); font-family: inherit; font-size: 0.9rem; outline: none;
  transition: border-color 0.2s;
}
.table-toolbar input[type=search]:focus { border-color: var(--accent); }
.table-toolbar select {
  padding: 0.5rem 0.75rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-1); font-family: inherit; font-size: 0.85rem;
  outline: none; cursor: pointer;
}

/* ─── 按鈕 ──────────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 0.5rem 1rem; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-family: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-accent {
  padding: 0.5rem 1rem; background: rgba(249,202,36,0.15); color: var(--gold);
  border: 1px solid rgba(249,202,36,0.3); border-radius: var(--radius);
  font-family: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-accent:hover { background: var(--gold); color: #000; }
.btn-ghost {
  padding: 0.5rem 1rem; background: transparent; color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 0.9rem; cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--text-1); color: var(--text-1); }
.btn-danger {
  padding: 0.35rem 0.7rem; background: transparent; color: #ff6b6b;
  border: 1px solid rgba(235,4,0,0.3); border-radius: 6px;
  font-size: 0.78rem; cursor: pointer; transition: all 0.2s;
}
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm {
  padding: 0.35rem 0.7rem; background: var(--bg-elevated); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.78rem; cursor: pointer; transition: all 0.2s;
}
.btn-sm:hover { color: var(--text-1); border-color: var(--accent); }

/* ─── 觀眾表格 ──────────────────────────────────────────────────────────────── */
.table-wrap { flex: 1; overflow-x: auto; padding: 0 1.5rem 1rem; }
.viewers-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.viewers-table th {
  padding: 0.6rem 0.75rem; text-align: left; color: var(--text-3);
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.viewers-table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.viewers-table tbody tr:hover { background: var(--bg-elevated); cursor: pointer; }
.table-loading { text-align: center; color: var(--text-3); padding: 3rem; }
.rank-num { color: var(--text-3); font-size: 0.8rem; }
.viewer-name { font-weight: 600; }
.exp-val { font-weight: 700; color: var(--accent); }

/* 等級徽章 */
.level-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700;
  border: 1px solid; white-space: nowrap;
}
.level-badge.lv10 { animation: rainbow 3s linear infinite; }
@keyframes rainbow {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* EXP 進度條（表格內小條） */
.exp-bar-mini { width: 60px; height: 4px; background: var(--border); border-radius: 2px; margin-top: 3px; }
.exp-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }

/* 操作欄 */
.action-btns { display: flex; gap: 0.4rem; }

/* ─── 分頁 ──────────────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 0.4rem; justify-content: center; padding: 1rem; }
.page-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-2); cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.page-btn:hover { border-color: var(--accent); color: var(--text-1); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── 觀眾詳情 Modal ─────────────────────────────────────────────────────────── */
.modal-viewer {
  position: relative; background: var(--bg-secondary); border-radius: var(--radius-lg);
  border: 1px solid var(--border); width: 100%; max-width: 640px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
.viewer-detail { padding: 1.5rem; }
.viewer-detail-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.viewer-level-circle {
  width: 64px; height: 64px; border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; border: 3px solid; flex-shrink: 0;
}
.vlc-num { font-size: 1.4rem; font-weight: 900; line-height: 1; }
.vlc-label { font-size: 0.6rem; opacity: 0.8; }
.viewer-detail-name { font-size: 1.3rem; font-weight: 700; }
.viewer-detail-title { font-size: 0.85rem; margin-top: 0.2rem; }

.viewer-detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.vd-stat { background: var(--bg-elevated); border-radius: var(--radius); padding: 0.75rem; text-align: center; }
.vd-stat-val { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.vd-stat-lbl { font-size: 0.72rem; color: var(--text-3); margin-top: 0.2rem; }

.exp-bar-wrap { margin-bottom: 1.5rem; }
.exp-bar-info { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-3); margin-bottom: 0.4rem; }
.exp-bar-bg { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.exp-bar-progress { height: 100%; border-radius: 4px; transition: width 0.8s; }

.notes-section { margin-bottom: 1.5rem; }
.notes-label { font-size: 0.8rem; color: var(--text-3); margin-bottom: 0.4rem; }
.notes-input {
  width: 100%; padding: 0.6rem 0.75rem; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-1); font-family: inherit; font-size: 0.875rem; resize: vertical; outline: none;
}
.notes-input:focus { border-color: var(--accent); }

.history-title { font-size: 0.85rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.75rem; }
.history-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 280px; overflow-y: auto; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.75rem; background: var(--bg-elevated); border-radius: 6px; font-size: 0.82rem;
}
.history-reason { color: var(--text-2); flex: 1; }
.history-change { font-weight: 700; min-width: 50px; text-align: right; }
.history-change.pos { color: var(--green); }
.history-change.neg { color: #ff6b6b; }
.history-time { color: var(--text-3); font-size: 0.72rem; margin-top: 2px; }

.viewer-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ─── 小 Modal 通用 ──────────────────────────────────────────────────────────── */
.modal-sm {
  position: relative; background: var(--bg-secondary); border-radius: var(--radius-lg);
  border: 1px solid var(--border); width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
.modal-sm-header { padding: 1.1rem 1.25rem; font-weight: 700; border-bottom: 1px solid var(--border); }
.modal-sm-body { padding: 1.25rem; }
.modal-sm-footer { padding: 1rem 1.25rem; display: flex; justify-content: flex-end; gap: 0.5rem; border-top: 1px solid var(--border); }

.form-label { display: block; font-size: 0.82rem; color: var(--text-2); margin-bottom: 0.35rem; }
.form-input {
  width: 100%; padding: 0.6rem 0.75rem; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-1); font-family: inherit; font-size: 0.9rem; outline: none; transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-error { margin-top: 0.5rem; font-size: 0.82rem; color: #ff6b6b; }

.exp-type-tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.exp-type-btn {
  padding: 0.4rem 0.8rem; background: var(--bg-elevated); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 20px; font-family: inherit; font-size: 0.8rem;
  cursor: pointer; transition: all 0.2s;
}
.exp-type-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.exp-extra { margin-bottom: 0.75rem; }
.exp-preview {
  margin-top: 1rem; padding: 0.6rem 0.75rem; background: rgba(145,71,255,0.1);
  border: 1px solid rgba(145,71,255,0.25); border-radius: var(--radius);
  font-size: 0.875rem; color: var(--text-2);
}
.exp-preview strong { color: var(--accent); font-size: 1.1rem; }

/* ─── 剪輯分析（頁籤二）─────────────────────────────────────────────────────── */
.clip-view { display: flex; flex-direction: column; }
.search-wrap { max-width: 560px; width: 100%; padding: 4rem 2rem; margin: 0 auto; text-align: center; }
.logo-block { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.logo-icon { width: 32px; height: 32px; color: var(--accent); }
.logo-block h2 { font-size: 1.6rem; font-weight: 700; color: var(--text-1); }
.search-subtitle { color: var(--text-2); margin-bottom: 2rem; font-size: 0.9rem; }
.search-form { width: 100%; }
.search-input-wrap { display: flex; gap: 0.5rem; }
.search-input-wrap input {
  flex: 1; padding: 0.7rem 1rem; background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); color: var(--text-1); font-size: 0.95rem; font-family: inherit; outline: none; transition: border-color 0.2s;
}
.search-input-wrap input:focus { border-color: var(--accent); }
.search-input-wrap input::placeholder { color: var(--text-3); }
.search-input-wrap button {
  padding: 0.7rem 1.25rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  font-size: 0.95rem; font-family: inherit; font-weight: 600; cursor: pointer; transition: background 0.2s;
  display: flex; align-items: center; gap: 0.4rem; white-space: nowrap;
}
.search-input-wrap button:hover { background: var(--accent-hover); }
.search-input-wrap button:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
.error-msg { margin-top: 1rem; padding: 0.7rem 1rem; background: rgba(235,4,0,0.12); border: 1px solid rgba(235,4,0,0.3); border-radius: var(--radius); color: #ff6b6b; font-size: 0.875rem; }

.channel-header { background: var(--bg-secondary); border-bottom: 1px solid var(--border); padding: 0.9rem 1.5rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.back-btn { background: var(--bg-elevated); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.45rem 0.9rem; cursor: pointer; font-size: 0.85rem; font-family: inherit; white-space: nowrap; transition: all 0.2s; }
.back-btn:hover { color: var(--text-1); border-color: var(--accent); }
.channel-info { display: flex; align-items: center; gap: 1rem; flex: 1; }
.channel-avatar { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--accent); object-fit: cover; }
.channel-details h2 { font-size: 1.1rem; font-weight: 700; }
.channel-details p { color: var(--text-3); font-size: 0.8rem; max-width: 500px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-badge { display: inline-block; padding: 2px 6px; background: var(--accent-dim); color: #bf94ff; border-radius: 4px; font-size: 0.72rem; font-weight: 600; }
.clips-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1.5rem; background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
.period-tabs { display: flex; align-items: center; gap: 0.4rem; }
.toolbar-label { color: var(--text-3); font-size: 0.82rem; }
.period-btn { padding: 0.35rem 0.8rem; background: transparent; color: var(--text-2); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; font-size: 0.82rem; font-family: inherit; transition: all 0.2s; }
.period-btn:hover { border-color: var(--accent); color: var(--text-1); }
.period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.clips-count { color: var(--text-3); font-size: 0.82rem; }
.clips-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; padding: 1.25rem 1.5rem; }
.clip-card { background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; border: 1px solid var(--border); }
.clip-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(145,71,255,0.2); border-color: var(--accent); }
.clip-thumbnail-wrap { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--bg-secondary); }
.clip-thumbnail { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.clip-card:hover .clip-thumbnail { transform: scale(1.04); }
.clip-play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; background: rgba(0,0,0,0.4); transition: opacity 0.2s; }
.clip-card:hover .clip-play-overlay { opacity: 1; }
.clip-play-btn { width: 48px; height: 48px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.clip-play-btn svg { width: 20px; height: 20px; fill: #fff; margin-left: 3px; }
.clip-duration { position: absolute; bottom: 6px; right: 8px; background: rgba(0,0,0,0.75); color: #fff; font-size: 0.72rem; font-weight: 600; padding: 1px 5px; border-radius: 3px; }
.clip-views-badge { position: absolute; top: 6px; left: 8px; background: rgba(0,0,0,0.75); color: #fff; font-size: 0.7rem; padding: 1px 5px; border-radius: 3px; }
.clip-info { padding: 0.65rem 0.75rem; }
.clip-title { font-weight: 600; font-size: 0.875rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 0.35rem; }
.clip-meta-row { display: flex; align-items: center; gap: 0.4rem; color: var(--text-3); font-size: 0.75rem; flex-wrap: wrap; }
.clip-game-tag { background: var(--bg-elevated); color: var(--accent); padding: 1px 5px; border-radius: 3px; font-size: 0.7rem; }
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-card { border-radius: var(--radius-lg); border: 1px solid var(--border); }
.skeleton-thumb { aspect-ratio: 16/9; }
.skeleton-line { height: 12px; border-radius: 3px; margin: 0.5rem 0.75rem; }
.skeleton-line.short { width: 55%; }
.load-more-wrap { display: flex; justify-content: center; padding: 1.25rem; }
.load-more-btn { padding: 0.65rem 2rem; background: transparent; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 20px; cursor: pointer; font-size: 0.9rem; font-family: inherit; font-weight: 600; transition: all 0.2s; }
.load-more-btn:hover { background: var(--accent); color: #fff; }
.no-clips { text-align: center; padding: 4rem 2rem; color: var(--text-3); }

/* ─── 剪輯分析 Modal ─────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px); }
.modal-content { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 1100px; max-height: 90vh; background: var(--bg-secondary); border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,0.6); }
.modal-close { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 10; width: 30px; height: 30px; background: var(--bg-elevated); color: var(--text-2); border: 1px solid var(--border); border-radius: 50%; cursor: pointer; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.modal-close:hover { background: var(--red); color: #fff; border-color: var(--red); }
.modal-left { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border); }
.clip-player-wrap { aspect-ratio: 16/9; background: #000; flex-shrink: 0; }
.clip-player-wrap iframe { width: 100%; height: 100%; border: none; }
.clip-meta { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.clip-meta h3 { font-size: 0.9rem; font-weight: 600; line-height: 1.35; margin-bottom: 0.3rem; }
.clip-meta-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag { padding: 2px 7px; border-radius: 4px; font-size: 0.72rem; font-weight: 500; }
.tag-game { background: rgba(145,71,255,0.15); color: #bf94ff; }
.tag-views { background: rgba(0,184,148,0.12); color: #00d2a4; }
.tag-creator { background: var(--bg-elevated); color: var(--text-2); }
.chat-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1rem; background: var(--bg-primary); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-title { font-size: 0.82rem; font-weight: 600; color: var(--text-2); }
.chat-badge { background: var(--accent-dim); color: #bf94ff; font-size: 0.7rem; font-weight: 600; padding: 1px 5px; border-radius: 10px; }
.chat-list { flex: 1; overflow-y: auto; padding: 0.4rem 0; }
.chat-list::-webkit-scrollbar { width: 3px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--border); }
.chat-msg { padding: 0.25rem 1rem; font-size: 0.8rem; display: flex; gap: 0.35rem; }
.chat-msg:hover { background: var(--bg-elevated); }
.chat-time { color: var(--text-3); font-size: 0.72rem; margin-top: 1px; min-width: 28px; }
.chat-user { font-weight: 600; flex-shrink: 0; color: hsl(var(--hue,280),70%,65%); }
.chat-text { color: var(--text-1); word-break: break-word; }
.chat-empty { padding: 1.5rem; text-align: center; color: var(--text-3); font-size: 0.82rem; }
.modal-right { display: flex; flex-direction: column; overflow: hidden; }
.analysis-header { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg-primary); flex-shrink: 0; }
.analysis-title { font-size: 0.875rem; font-weight: 700; color: var(--text-2); }
.analysis-loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; color: var(--text-3); font-size: 0.875rem; }
.loading-spinner { width: 36px; height: 36px; border: 3px solid var(--bg-elevated); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.analysis-result { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; font-size: 0.86rem; line-height: 1.65; }
.analysis-result::-webkit-scrollbar { width: 3px; }
.analysis-result::-webkit-scrollbar-thumb { background: var(--border); }
.analysis-result h2 { font-size: 0.9rem; font-weight: 700; margin: 1.1rem 0 0.4rem; color: var(--accent); padding-bottom: 0.25rem; border-bottom: 1px solid var(--border); }
.analysis-result h2:first-child { margin-top: 0; }
.analysis-result p { margin-bottom: 0.5rem; }
.analysis-result strong { color: var(--text-1); }
.analysis-error { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; padding: 2rem; text-align: center; color: #ff6b6b; font-size: 0.875rem; }
.source-note { font-size: 0.76rem; padding: 0.4rem 0.6rem; border-radius: 5px; margin-bottom: 0.75rem; }
.source-ok { background: rgba(0,184,148,0.1); color: var(--green); }
.source-warn { background: rgba(132,132,148,0.1); color: var(--text-3); }

/* ─── 動畫 ──────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.analysis-result { animation: fadeIn 0.3s ease; }

/* ─── RWD ───────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .modal-content { grid-template-columns: 1fr; }
  .modal-left { border-right: none; border-bottom: 1px solid var(--border); }
  .chat-section { max-height: 180px; }
  .stats-row { grid-template-columns: 1fr; }
  .nav-tabs { gap: 0; }
  .nav-tab { padding: 0 0.75rem; font-size: 0.8rem; }
}
