:root {
    --nav-bg: #0f172a; --accent: #3b82f6; --border: #e2e8f0;
    --header-h: 45px; --slider-h: 45px; --resizer-h: 24px;
    --bg-main: #f1f5f9; --bg-content: white; --text-color: #1e293b;
}

body.dark-mode {
    --nav-bg: #020617; --border: #334155;
    --bg-main: #0f172a; --bg-content: #1e293b; --text-color: #f8fafc;
    --accent: #60a5fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: "Microsoft JhengHei", sans-serif; }

html, body { height: 100%; overflow-y: auto; overflow-x: hidden; background: var(--bg-main); color: var(--text-color); transition: background-color 0.3s, color 0.3s; }

#app-container { height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 10; flex-shrink: 0; }

header { height: var(--header-h); background: var(--nav-bg); z-index: 9999; flex-shrink: 0; }
.nav-container { width: 100%; max-width: 1400px; margin: 0 auto; display: flex; align-items: center; height: 100%; padding: 0 10px; }
#nav-root { display: flex; list-style: none; height: 100%; align-items: center; overflow-x: auto; -webkit-overflow-scrolling: touch; }
#nav-root::-webkit-scrollbar { display: none; }
#nav-root a { padding: 0 15px; color: #cbd5e1; text-decoration: none; cursor: pointer; font-size: 16px; white-space: nowrap; line-height: var(--header-h); font-weight: bold; }
.mega-menu { display: none; position: absolute; top: var(--header-h); left: 50%; transform: translateX(-50%); min-width: 200px; background: var(--bg-content); box-shadow: 0 10px 30px rgba(0,0,0,0.5); padding: 10px; border-radius: 0 0 8px 8px; z-index: 10000; border: 1px solid var(--border); }
.mega-sub-item { padding: 5px 15px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.mega-sub-item a { color: var(--text-color) !important; font-size: 14px !important; padding: 0 !important; line-height: 1.5; font-weight: normal; }
#nav-root li:hover .mega-menu { display: block !important; }

#main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-content); }
#top-section { height: 50%; min-height: 200px; border-bottom: 1px solid var(--border); flex-shrink: 0; display: flex; flex-direction: column; }
#bottom-section { flex: 1; min-height: 150px; }
.resizable-section { overflow: hidden; position: relative; }

.content-box { flex: 1; position: relative; overflow: hidden; background: var(--bg-content); display: flex; flex-direction: column; }
#frame-wrapper, #forum-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: transparent; }
#frame-wrapper iframe { width: 100%; height: calc(100% + 1px); border: none; display: block; vertical-align: bottom; }

.control-bar { display: flex; justify-content: space-between; align-items: center; background: var(--bg-main); border-top: 1px solid var(--border); height: 40px; flex-shrink: 0; position: relative; z-index: 2; }
.excel-tabs { display: flex; flex: 1; height: 100%; overflow-x: auto; }
.tab { padding: 0 20px; display: flex; align-items: center; cursor: pointer; border-right: 1px solid var(--border); font-size: 13px; white-space: nowrap; color: #64748b; height: 100%; }
.tab.active { background: var(--bg-content); color: var(--accent); font-weight: bold; border-top: 3px solid var(--accent); position: relative; top: -1px; }

.toolbar-right { display: flex; align-items: center; gap: 15px; padding: 0 15px; flex-shrink: 0; }
#market-clock { font-size: 11.5px; font-family: 'Courier New', monospace; font-weight: bold; color: var(--text-color); background: rgba(0,0,0,0.05); padding: 5px 10px; border-radius: 4px; display: flex; align-items: center; gap: 8px; }
body.dark-mode #market-clock { background: rgba(255,255,255,0.08); }

#theme-toggle { background: var(--nav-bg); color: white; border: none; padding: 5px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; font-weight: bold; transition: 0.2s; white-space: nowrap; }
#theme-toggle:hover { background: var(--accent); }

#slider-section { height: var(--slider-h); flex-shrink: 0; background: #020617; overflow: hidden; position: relative; border-bottom: 1px solid #1e293b; }
.slider-track { display: flex; height: 100%; transition: transform 0.5s ease-in-out; }
.slider-item { min-width: 100%; height: 100%; cursor: pointer; display: flex; align-items: center; justify-content: center; background: #0f172a; }
.slider-item img { width: 100%; height: 100%; object-fit: cover; }
.slider-text-wrapper { display: flex; align-items: center; font-size: 15px; font-weight: bold; letter-spacing: 1px; padding: 0 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slider-title { margin-right: 8px; }

.resizer { height: var(--resizer-h); background: #cbd5e1; cursor: row-resize; display: flex; justify-content: center; align-items: center; color: #475569; font-size: 12px; font-weight: bold; flex-shrink: 0; position: relative; z-index: 2; border-top: 1px solid #94a3b8; border-bottom: 1px solid #94a3b8; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.resizer:hover { background: var(--accent); color: white; border-color: var(--accent); }
body.dark-mode .resizer { background: #334155; color: #cbd5e1; border-color: #1e293b; }
body.dark-mode .resizer:hover { background: var(--accent); color: white; }

body.is-resizing iframe { pointer-events: none !important; }

/* [大改版] 警語排版優化：靠左、行距加大、消除上方多餘空白 */
#global-disclaimer { 
    width: 100%; 
    padding: 15px 20px 40px 20px; /* 上方 padding 縮減至 15px */
    background: var(--bg-content); 
    text-align: left; /* 改為靠左對齊 */
    line-height: 1.6; /* 增加行距，讓長篇文字更好閱讀 */
    border-top: 4px solid var(--border); 
    position: relative; 
    z-index: 5; 
}

#bio-sidebar { position: fixed !important; left: -320px; top: 50%; transform: translateY(-50%); width: 300px; background: var(--bg-content); color: var(--text-color); box-shadow: 15px 0 40px rgba(0,0,0,0.5); transition: 0.5s; z-index: 99999 !important; padding: 30px; border-radius: 0 20px 20px 0; border: 1px solid var(--border); }
#bio-sidebar.active { left: 0 !important; }
.bio-trigger { position: absolute; right: -42px; top: 40px; background: var(--nav-bg); color: white; padding: 20px 10px; cursor: pointer; writing-mode: vertical-lr; border-radius: 0 10px 10px 0; font-size: 14px; white-space: nowrap; letter-spacing: 3px; font-weight: bold; border: 1px solid var(--border); border-left: none; }

/* 新增個介名片內容排版 */
.bio-contact-row { margin-bottom: 8px; font-size: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.bio-contact-label { font-weight: bold; color: var(--accent); margin-right: 5px; }

@media (max-width: 768px) {
    #app-container { height: auto; }
    #main-content { height: auto; flex-direction: column; overflow: visible; }
    #top-section, #bottom-section { flex: none; height: 50vh; min-height: 400px; }
    .resizer { display: none; }
    #market-clock { display: none; }
}