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

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

/* ── Dark theme (OLED Pattern) ── */
[data-theme="dark"] {
  --bg: #020617; --bg2: #0F172A; --bg3: #1E293B; --border: #334155;
  --text: #F8FAFC; --text2: #94A3B8; --accent: #22C55E;
  --bull: #22C55E; --bear: #EF4444; --neutral: #94A3B8; --mixed: #F59E0B;
  --badge-bull-bg: rgba(34, 197, 94, 0.15); --badge-bear-bg: rgba(239, 68, 68, 0.15);
  --badge-neutral-bg: rgba(148, 163, 184, 0.15); --badge-mixed-bg: rgba(245, 158, 11, 0.15);
  --strong-color: #FFFFFF;
  --lightbox-bg: rgba(0,0,0,.92);
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
  --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* ── Light theme (default) ── */
:root, [data-theme="light"] {
  --bg: #F8FAFC; --bg2: #FFFFFF; --bg3: #F1F5F9; --border: #E2E8F0;
  --text: #0F172A; --text2: #64748B; --accent: #16A34A;
  --bull: #16A34A; --bear: #DC2626; --neutral: #64748B; --mixed: #D97706;
  --badge-bull-bg: #DCFCE7; --badge-bear-bg: #FEE2E2;
  --badge-neutral-bg: #F1F5F9; --badge-mixed-bg: #FEF3C7;
  --strong-color: #020617;
  --lightbox-bg: rgba(0,0,0,.8);
  --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body { background: var(--bg); color: var(--text); font-family: 'Fira Sans', system-ui, sans-serif; font-size: clamp(14px, 0.95vw, 20px); height: 100dvh; display: flex; flex-direction: column; overflow: hidden; transition: background .3s ease, color .3s ease; }

header { display: flex; align-items: center; justify-content: space-between; padding: clamp(8px, 0.6vw, 14px) clamp(12px, 1vw, 24px); border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.header-left { display: flex; align-items: center; gap: 8px; }
header h1 { font-size: clamp(14px, 1vw, 20px); font-weight: 700; cursor: pointer; user-select: none; }
header h1:hover { opacity: .8; }
header h1 span { color: var(--accent); }
.header-right { display: flex; align-items: center; gap: clamp(6px, 0.5vw, 12px); }
#updated { font-size: clamp(11px, 0.7vw, 14px); color: var(--text2); }

/* Header navigation tabs */
.header-nav { display: flex; align-items: center; gap: 2px; margin-left: clamp(8px, 0.8vw, 16px); padding-left: clamp(8px, 0.8vw, 16px); border-left: 1px solid var(--border); }
.nav-link { padding: clamp(4px, 0.3vw, 6px) clamp(8px, 0.6vw, 14px); border-radius: 6px; font-size: clamp(12px, 0.78vw, 15px); color: var(--text2); text-decoration: none; cursor: pointer; transition: all .12s; font-weight: 500; }
.nav-link:hover { color: var(--text); background: var(--bg3); }
.nav-link.active { color: var(--accent); background: rgba(22, 163, 74, 0.08); font-weight: 600; cursor: default; }
[data-theme="dark"] .nav-link.active { background: rgba(34, 197, 94, 0.1); }

/* Header buttons */
.h-btn { background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: clamp(3px, 0.3vw, 6px) clamp(6px, 0.5vw, 10px); cursor: pointer; font-size: clamp(14px, 0.9vw, 18px); line-height: 1; transition: all .15s; color: var(--text); }
.h-btn:hover { border-color: var(--accent); }
#sync-btn { background: var(--accent); border-color: var(--accent); color: #fff; font-size: clamp(11px, 0.75vw, 15px); padding: clamp(4px, 0.3vw, 8px) clamp(8px, 0.6vw, 14px); border-radius: 6px; cursor: pointer; border: none; font-weight: 600; transition: opacity .15s; }
#sync-btn:hover { opacity: .85; }
#sync-btn:disabled { opacity: .5; cursor: not-allowed; }
#sync-msg { font-size: clamp(11px, 0.7vw, 14px); color: var(--text2); }

.layout { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar: 用 vw 比例寬度，大螢幕自動變寬 ── */
.sidebar { width: clamp(300px, 22vw, 500px); border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg2); flex-shrink: 0; transition: background .2s; }
.sidebar-top { padding: clamp(8px, 0.6vw, 14px); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: clamp(4px, 0.4vw, 8px); }
#search { width: 100%; padding: clamp(6px, 0.4vw, 10px) clamp(8px, 0.6vw, 14px); background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: clamp(13px, 0.85vw, 16px); outline: none; }
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text2); }
.filter-group { display: flex; flex-direction: column; gap: clamp(3px, 0.25vw, 6px); }
.filter-label { font-size: clamp(10px, 0.65vw, 13px); color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.filters { display: flex; gap: clamp(3px, 0.25vw, 6px); flex-wrap: wrap; }
.fbtn { padding: clamp(2px, 0.2vw, 4px) clamp(6px, 0.5vw, 12px); border-radius: 14px; border: 1px solid var(--border); background: transparent; color: var(--text2); cursor: pointer; font-size: clamp(11px, 0.72vw, 14px); transition: all .12s; white-space: nowrap; }
.fbtn.active, .fbtn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.fbtn[data-s="看多"].active { background: var(--bull); border-color: var(--bull); color: #fff; }
.fbtn[data-s="看空"].active { background: var(--bear); border-color: var(--bear); color: #fff; }
.fbtn[data-s="中性"].active { background: var(--neutral); border-color: var(--neutral); color: #fff; }
.fbtn[data-s="混合"].active { background: var(--mixed); border-color: var(--mixed); color: #fff; }
.cbtn { padding: clamp(2px, 0.2vw, 4px) clamp(6px, 0.5vw, 12px); border-radius: 14px; border: 1px solid var(--border); background: transparent; color: var(--text2); cursor: pointer; font-size: clamp(11px, 0.72vw, 14px); transition: all .12s; white-space: nowrap; }
.cbtn.active, .cbtn:hover { background: var(--bg3); border-color: var(--accent); color: var(--accent); }

#article-count { font-size: clamp(11px, 0.7vw, 14px); color: var(--text2); padding: clamp(3px, 0.25vw, 6px) clamp(8px, 0.6vw, 14px); }
.article-list { overflow-y: auto; flex: 1; }
.article-list::-webkit-scrollbar { width: 3px; }
.article-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.a-item { padding: clamp(8px, 0.6vw, 14px) clamp(10px, 0.7vw, 16px); border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.a-item:hover { background: var(--bg3); }
.a-item.active { background: var(--bg3); border-left: 3px solid var(--accent); }
.a-title { font-size: clamp(13px, 0.85vw, 17px); font-weight: 500; line-height: 1.4; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.a-meta { display: flex; align-items: center; gap: clamp(4px, 0.35vw, 8px); flex-wrap: wrap; }
.badge { padding: clamp(1px, 0.15vw, 3px) clamp(6px, 0.5vw, 10px); border-radius: 10px; font-size: clamp(10px, 0.68vw, 14px); font-weight: 600; }
.badge-bull { background: var(--badge-bull-bg); color: var(--bull); }
.badge-bear { background: var(--badge-bear-bg); color: var(--bear); }
.badge-neutral { background: var(--badge-neutral-bg); color: var(--neutral); }
.badge-mixed { background: var(--badge-mixed-bg); color: var(--mixed); }
.badge-none { background: var(--bg3); color: var(--text2); }
.m-date { font-size: clamp(10px, 0.65vw, 13px); color: var(--text2); }
.m-target { font-size: clamp(10px, 0.65vw, 13px); color: var(--accent); }

/* ── Main ── */
.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text2); gap: 8px; }
.empty-state .icon { font-size: 48px; }

/* ── Detail ── */
.detail { display: none; flex-direction: row; height: 100%; }
.detail.visible { display: flex; }
.detail-left { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.detail-right { width: clamp(280px, 34vw, 480px); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; background: var(--bg2); }
.d-header { padding: clamp(10px, 0.7vw, 18px) clamp(14px, 1vw, 24px); border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.d-header h2 { font-size: clamp(16px, 1.1vw, 24px); font-weight: 600; line-height: 1.4; margin-bottom: 6px; }
.d-header-meta { display: flex; align-items: center; gap: clamp(6px, 0.5vw, 12px); flex-wrap: wrap; }
.d-header-meta span { font-size: clamp(12px, 0.8vw, 16px); color: var(--text2); }
.d-header-meta a { font-size: clamp(12px, 0.8vw, 16px); color: var(--accent); text-decoration: none; }
.d-header-meta a:hover { text-decoration: underline; }
.back-btn { display: none; padding: 3px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 5px; color: var(--text2); font-size: clamp(12px, 0.8vw, 15px); cursor: pointer; margin-right: 6px; }

/* ── Tabs ── */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.tab { padding: clamp(6px, 0.5vw, 12px) clamp(12px, 0.9vw, 22px); font-size: clamp(12px, 0.8vw, 16px); font-weight: 600; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; transition: all .12s; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }
.tab-content { flex: 1; overflow-y: auto; }
.tab-content::-webkit-scrollbar { width: 3px; }
.tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.tab-panel { display: none; padding: clamp(12px, 1vw, 24px); }
.tab-panel.active { display: block; }

/* ── Original layout: desktop = left text + right images ── */
.original-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 45%);
  gap: clamp(12px, 1vw, 20px);
  max-width: 1400px;
}
.original-text { min-width: 0; }
.original-images { position: sticky; top: 0; align-self: flex-start; max-height: calc(100dvh - 200px); overflow-y: auto; }
.original-images::-webkit-scrollbar { width: 3px; }
.original-images::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.original-images .img-gallery { display: flex; flex-direction: column; gap: clamp(6px, 0.5vw, 12px); }
.original-images .img-gallery img { max-width: 100%; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; transition: transform .15s; }
.original-images .img-gallery img:hover { transform: scale(1.02); opacity: .95; }

/* ── Original content ── */
.content-body { font-size: clamp(14px, 0.95vw, 20px); line-height: 1.8; color: var(--text); overflow-wrap: break-word; word-break: break-word; }
.content-body p { margin-bottom: clamp(8px, 0.5vw, 14px); }
.content-body strong { color: var(--strong-color); }
.original-layout .content-body img { display: none !important; }
.content-body span[style] { font-size: inherit !important; }
.content-body br { display: block; content: ''; margin-top: 4px; }
.img-gallery { display: flex; flex-wrap: wrap; gap: clamp(6px, 0.5vw, 12px); margin-bottom: clamp(10px, 0.7vw, 16px); }
.img-gallery img { width: auto; max-width: clamp(200px, 40%, 400px); max-height: clamp(140px, 14vw, 260px); border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; object-fit: contain; transition: transform .15s; }
.img-gallery img:hover { transform: scale(1.03); opacity: .95; }
.tags-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.tag { padding: clamp(2px, 0.15vw, 4px) clamp(6px, 0.4vw, 10px); border-radius: 4px; font-size: clamp(10px, 0.65vw, 13px); background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }

/* ── Analysis ── */
.a-section { margin-bottom: clamp(12px, 1vw, 20px); }
.a-label { font-size: clamp(10px, 0.68vw, 14px); color: var(--text2); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.a-summary { font-size: clamp(13px, 0.9vw, 18px); line-height: 1.7; background: var(--bg3); padding: clamp(8px, 0.6vw, 16px) clamp(10px, 0.8vw, 18px); border-radius: 8px; border-left: 3px solid var(--accent); box-shadow: var(--card-shadow); }
.chip-row { display: flex; flex-wrap: wrap; gap: clamp(4px, 0.3vw, 8px); }
.chip { padding: clamp(2px, 0.2vw, 5px) clamp(8px, 0.5vw, 12px); border-radius: 10px; font-size: clamp(11px, 0.75vw, 15px); background: var(--bg3); border: 1px solid var(--border); color: var(--text); }
.chip-t { border-color: var(--accent); color: var(--accent); }
.ca-meta { font-size: clamp(12px, 0.8vw, 16px); color: var(--text2); margin-bottom: 8px; }
.ca-meta b { color: var(--text); }
/* Box level cards */
.box-card { display: flex; align-items: stretch; gap: 0; margin-bottom: clamp(6px, 0.4vw, 10px); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--bg3); font-size: clamp(12px, 0.8vw, 16px); box-shadow: var(--card-shadow); transition: transform 0.2s, box-shadow 0.2s; }
.box-card:hover { transform: translateY(-2px); box-shadow: var(--hover-shadow); }
.box-color-bar { width: clamp(5px, 0.35vw, 8px); flex-shrink: 0; }
.box-info { padding: clamp(6px, 0.5vw, 12px) clamp(8px, 0.6vw, 16px); flex: 1; }
.box-info .box-head { font-weight: 700; margin-bottom: 2px; }
.box-info .box-range { color: var(--text2); font-family: 'Fira Code', monospace; font-size: clamp(11px, 0.72vw, 15px); }
.box-info .box-note { color: var(--text2); font-size: clamp(11px, 0.72vw, 15px); margin-top: 2px; }
.box-role-support { border-left: 3px solid var(--bull); }
.box-role-pressure { border-left: 3px solid var(--bear); }
.box-role-other { border-left: 3px solid var(--mixed); }
/* Signal cards */
.sig-card { display: flex; align-items: center; gap: clamp(6px, 0.5vw, 10px); margin-bottom: clamp(5px, 0.35vw, 8px); padding: clamp(6px, 0.5vw, 12px) clamp(8px, 0.6vw, 16px); border-radius: 8px; background: var(--bg3); border: 1px solid var(--border); font-size: clamp(12px, 0.8vw, 16px); box-shadow: var(--card-shadow); transition: transform 0.2s, box-shadow 0.2s; }
.sig-card:hover { transform: translateY(-2px); box-shadow: var(--hover-shadow); }
.sig-type { font-weight: 700; white-space: nowrap; padding: clamp(2px, 0.2vw, 5px) clamp(6px, 0.5vw, 12px); border-radius: 6px; font-size: clamp(11px, 0.72vw, 15px); }
.sig-long { background: #14532d; color: var(--bull); }
.sig-short { background: #450a0a; color: var(--bear); }
.sig-wait { background: var(--badge-neutral-bg); color: var(--neutral); }
.sig-body { flex: 1; }
.sig-cond { color: var(--text); }
.sig-price { color: var(--text2); font-family: 'Fira Code', monospace; font-size: clamp(11px, 0.72vw, 15px); }
/* Arrow cards */
.arrow-card { display: inline-flex; align-items: center; gap: 6px; padding: clamp(3px, 0.25vw, 6px) clamp(8px, 0.5vw, 12px); border-radius: 6px; background: var(--bg3); border: 1px solid var(--border); font-size: clamp(12px, 0.8vw, 16px); margin: 0 4px 4px 0; }
.arrow-dir { font-size: clamp(14px, 1vw, 20px); }
.sig-text, .box-text { white-space: pre-wrap; font-size: clamp(12px, 0.8vw, 16px); line-height: 1.6; color: var(--text2); background: var(--bg3); padding: clamp(8px, 0.6vw, 14px) clamp(10px, 0.7vw, 16px); border-radius: 8px; font-family: 'Fira Code', monospace; }

/* ── Chat ── */
.chat-container { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-toggle-btn { display: none; margin-left: auto; }
.chat-messages { flex: 1; overflow-y: auto; padding: clamp(8px, 0.6vw, 14px); display: flex; flex-direction: column; gap: clamp(8px, 0.5vw, 12px); }
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-msg { max-width: 85%; padding: clamp(8px, 0.6vw, 14px) clamp(10px, 0.8vw, 18px); border-radius: 12px; font-size: clamp(13px, 0.88vw, 17px); line-height: 1.7; word-break: break-word; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 4px; white-space: normal; }
.chat-msg.assistant b { color: var(--strong-color); }
.chat-msg.assistant ul, .chat-msg.assistant ol { margin: 4px 0 4px 18px; }
.chat-msg.assistant li { margin-bottom: 2px; }
.chat-msg.assistant code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.chat-msg.assistant pre { background: var(--bg); padding: 8px 12px; border-radius: 6px; overflow-x: auto; margin: 6px 0; }
.chat-msg.assistant pre code { background: none; padding: 0; }
.chat-msg.assistant hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.chat-msg.system-info { align-self: center; color: var(--text2); font-size: clamp(11px, 0.72vw, 14px); background: none; padding: 4px 8px; }
.chat-input-row { display: flex; gap: clamp(6px, 0.4vw, 10px); padding: clamp(8px, 0.6vw, 14px); border-top: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; flex-wrap: wrap; align-items: flex-end; position: relative; }
.chat-charcount { font-size: clamp(10px, 0.62vw, 12px); color: var(--text2); position: absolute; right: clamp(80px, 7vw, 110px); bottom: clamp(12px, 0.8vw, 18px); pointer-events: none; }
.chat-charcount.warn { color: var(--bear); font-weight: 600; }
.chat-input { flex: 1; padding: clamp(8px, 0.5vw, 12px) clamp(10px, 0.7vw, 16px); background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: clamp(13px, 0.88vw, 17px); outline: none; resize: none; font-family: inherit; min-height: 42px; max-height: 120px; }
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text2); }
.chat-send { padding: clamp(8px, 0.5vw, 12px) clamp(14px, 1vw, 22px); background: var(--accent); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: clamp(13px, 0.88vw, 17px); font-weight: 600; transition: opacity .15s; white-space: nowrap; }
.chat-send:hover { opacity: .85; }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }
.chat-typing { display: inline-block; }
.chat-typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text2); margin: 0 2px; animation: chatDot 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
.chat-model-label { padding: clamp(3px, 0.2vw, 6px) clamp(8px, 0.6vw, 14px); background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); font-size: clamp(11px, 0.72vw, 14px); font-weight: 600; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: clamp(6px, 0.4vw, 10px) clamp(8px, 0.6vw, 14px); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-header-left { display: flex; align-items: center; gap: 8px; font-size: clamp(11px, 0.72vw, 14px); color: var(--text2); }
.chat-clear { padding: 3px 10px; background: transparent; border: 1px solid var(--border); border-radius: 5px; color: var(--text2); font-size: clamp(11px, 0.72vw, 14px); cursor: pointer; transition: all .12s; }
.chat-clear:hover { border-color: var(--bear); color: var(--bear); }
.chat-saved-count { font-size: clamp(11px, 0.72vw, 14px); color: var(--accent); font-weight: 600; }
.chat-msg-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.chat-save-btn { background: transparent; border: 1px solid var(--border); border-radius: 5px; padding: 2px 8px; font-size: clamp(10px, 0.65vw, 13px); color: var(--text2); cursor: pointer; transition: all .12s; }
.chat-save-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-save-btn.saved { color: var(--accent); border-color: var(--accent); cursor: default; }
.saved-qa-section { margin: 4px 0; border: 1px solid var(--border); border-radius: 8px; background: var(--bg2); overflow: hidden; }
.saved-qa-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; cursor: pointer; font-size: clamp(12px, 0.78vw, 15px); font-weight: 600; color: var(--text2); background: var(--bg3); user-select: none; }
.saved-qa-header:hover { color: var(--text); }
.saved-qa-toggle { transition: transform .2s; font-size: 10px; }
.saved-qa-section.collapsed .saved-qa-toggle { transform: rotate(-90deg); }
.saved-qa-section.collapsed .saved-qa-list { display: none; }
.saved-qa-list { padding: 8px; display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.saved-qa-list::-webkit-scrollbar { width: 3px; }
.saved-qa-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.saved-qa-item { padding: 8px 10px; border-radius: 6px; background: var(--bg3); border: 1px solid var(--border); font-size: clamp(12px, 0.8vw, 15px); }
.saved-qa-q { color: var(--accent); margin-bottom: 4px; font-size: clamp(12px, 0.78vw, 15px); }
.saved-qa-a { color: var(--text); line-height: 1.6; word-break: break-word; }
.saved-qa-a b { color: var(--strong-color); }
.saved-qa-a ul, .saved-qa-a ol { margin: 4px 0 4px 18px; }
.saved-qa-a li { margin-bottom: 2px; }
.saved-qa-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; font-size: clamp(10px, 0.62vw, 12px); color: var(--text2); }
.saved-qa-delete { background: transparent; border: none; color: var(--text2); cursor: pointer; font-size: clamp(10px, 0.62vw, 12px); padding: 2px 6px; border-radius: 4px; transition: all .12s; }
.saved-qa-delete:hover { color: var(--bear); background: var(--badge-bear-bg); }
.m-saved { font-size: clamp(10px, 0.65vw, 13px); color: var(--accent); }
@media (max-width: 700px) {
  .chat-msg { max-width: 92%; }
}

/* ── Image lightbox ── */
.lightbox { display: none; position: fixed; inset: 0; z-index: 100; background: var(--lightbox-bg); align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 4px; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .sidebar { width: 100%; position: absolute; z-index: 10; height: calc(100dvh - 45px); }
  .sidebar.hidden { display: none; }
  .main { width: 100%; }
  .back-btn { display: inline-block; }
  .tab-panel { padding: 10px; }
  header { padding: 8px 10px; }
  header h1 { font-size: 14px; }
  .header-nav { margin-left: 6px; padding-left: 6px; }
  .nav-link { font-size: 11px; padding: 3px 6px; }
  .header-right { gap: 6px; }
  #updated { display: none; }
  #sync-btn { font-size: 11px; padding: 5px 10px; }
  .detail { flex-direction: column; }
  .detail-right { width: 100%; border-left: none; border-top: 1px solid var(--border); flex-shrink: 0; height: 45dvh; display: none; }
  .detail-right.open { display: flex; }
  .chat-toggle-btn { display: flex; }
  .original-layout { display: block; }
  .original-images { display: none; }
  .original-layout .content-body img { display: block !important; }
  .content-body img,
  .content-body img[style],
  .content-body img.fr-fic,
  .content-body img.fr-dib,
  .content-body img.fr-dii,
  .content-body img.fr-fic.fr-dib {
    max-width: 100% !important;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    display: block !important;
    float: none !important;
    margin: 10px 0 !important;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: zoom-in;
  }
  .img-gallery { flex-direction: column; gap: 8px; }
  .img-gallery img { max-width: 100% !important; width: 100% !important; max-height: none !important; height: auto !important; }
  .content-body { font-size: 15px; }
  .a-summary { font-size: 14px; }
  .a-title { font-size: 14px; }
}

/* ── Password overlay ── */
.pw-overlay { position: fixed; inset: 0; z-index: 9999; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.pw-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 340px; max-width: 90vw; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.15); }
.pw-box h2 { font-size: 18px; margin-bottom: 6px; }
.pw-box p { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
.pw-box input { width: 100%; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 15px; outline: none; text-align: center; letter-spacing: 2px; }
.pw-box input:focus { border-color: var(--accent); }
.pw-box button { margin-top: 14px; width: 100%; padding: 10px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity .15s; }
.pw-box button:hover { opacity: .85; }
.pw-box button:disabled { opacity: .4; cursor: not-allowed; }
.pw-error { color: var(--bear); font-size: 13px; margin-top: 10px; display: none; }
