/* =========================================
   1. 全域變數與基礎設定 (Global)
   ========================================= */
:root {
  --text-font-size: 22px;
  --text-font-size-mode-b: 18px;
  --text-color: #FFFFFF;
  --stroke-color: #000000;
  --stroke-width: 5px;
  --text-align: center;
  --body-background: #00FF00;
  --display-panel-height: 55%;
}

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

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--body-background);
  font-family: "Huninn", Arial, sans-serif;
  min-width: 950px;
  overflow-x: hidden;
  overflow-y: hidden;
}

/* =========================================
   2. 字幕顯示主區域 (Display Panel)
   ========================================= */
#display-panel {
  height: var(--display-panel-height);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 0px;
  margin: 0 auto;
  width: 100%;
  background-color: transparent;
  min-height: 290px;
  user-select: none;
  cursor: pointer; /* 提示可點擊切換最小化 */
  transition: height 0.3s ease;
}

#source-text { max-block-size: 2.6em; } /* 強制最高兩行 */
#source-text, #target-text-1, #target-text-2, #target-text-3 {
  display: flex;
  flex-direction: column;
  align-items: var(--text-align);
  text-align: var(--text-align);
  
  /* 字體設定 */
  color: var(--text-color);
  font-family: "Huninn", Arial, sans-serif;
  font-size: var(--text-font-size);
  line-height: 1.3em;
    
  -webkit-text-stroke: calc(var(--stroke-width)) var(--stroke-color);
  paint-order: stroke fill;
  /* ----------------------- */

  background-color: transparent;
  position: relative; /* 雖不再需要給偽元素定位，但保留作為其他可能的定位基準 */
  overflow: hidden;
  flex-shrink: 0;
}

/* =========================================
   3. 字幕溢出與縮放邏輯 (Overflow & Logic)
   ========================================= */
.overflow-normal { overflow: visible }

.overflow-truncate {
  display: -webkit-box ;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  font-size: var(--text-font-size);
  
}

#source-text.overflow-truncate { line-clamp: 1; -webkit-line-clamp: 1; }

#target-text-1.overflow-truncate, #target-text-2.overflow-truncate, #target-text-3.overflow-truncate {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  font-size: var(--text-font-size);
  line-clamp: 1;
  -webkit-line-clamp: 1;
}

#target-text-1.overflow-shrink, #target-text-2.overflow-shrink, #target-text-3.overflow-shrink {
  /* 移除 -webkit-box 與 line-clamp 以允許內容撐開並捲動 */
  display: block; 
  height: 1.3em;
  overflow-y: hidden; 
  /* 確保長單字換行 */
  white-space: pre-wrap;
  word-wrap: break-word;
  /* 視覺平滑化 */
  scroll-behavior: auto; /* JS 控制動畫，所以 CSS 設為 auto */
}

/* =========================================
   4. 介面框架佈局 (UI Framework)
   ========================================= */
#status-panel {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 5%;
  min-height: 30px;
  background-color: #FFF2DE;
  padding: 0 20px;
  gap: 5px;
  z-index: 2;
}

.status-info {
  display: flex;
  height: 90%;
  text-align: left;
  align-items: center;
  color: #6d1313;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

#control-panel {
  height: 40%;
  background-color: #FFF2DE;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  gap: 10px;
  margin: 0 auto;
  width: 100%;
  min-width: 1200px;
  min-height: 280px;
  z-index: 2;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom: 2px dashed #6d1313;
}

/* =========================================
   5. 錄音控制區 (Recorder)
   ========================================= */
#recorder-panel {
  width: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  background-color: #F8B8C4;
}

#logo { height: 130px; object-fit: contain; }

.record-button {
  width: 150px;
  padding: 10px 30px;
  border-radius: 10px;
  border: none;
  background-color: #FFF2DE;
  color: #333;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
  font-family: "Huninn", Arial, sans-serif;
}
.record-button:hover { background-color: #E0E0E0; }
.record-button:disabled { background-color: #CCCCCC; color: #666; cursor: not-allowed; opacity: 0.6; }

/* =========================================
   6. 頂部操作列與輸入框 (Control Bar & Inputs)
   ========================================= */
#settings-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.top-control-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  margin-bottom: -2px;
  z-index: 5;
  gap: 10px;
  padding-left: 5px;
}

.mode-selector-group {
  display: flex;
  align-items: center;
  gap: 5px;
  background-color: #FFF2DE;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #D8BFD1;
  height: 30px;
}
.mode-selector-group label {
  font-size: 12px;
  font-weight: bold;
  color: #8B4513;
}
#translation-mode {
  height: 22px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background-color: #fff;
  cursor: pointer;
  font-family: "Huninn", Arial, sans-serif;
}

.link-wrapper {
  position: relative;
  flex: 1;
  height: 30px;
  display: none; 
}

#translation-link, #gas-script-id {
  display: block; 
  width: 100%;
  height: 100%;
  border-radius: 5px;
  border: 1px solid #aaa;
  padding-left: 32px; /* 留出問號按鈕空間 */
  padding-right: 30px; /* 留出眼睛按鈕空間 */
  font-family: "Huninn", Arial, sans-serif;
  font-size: 12px;
}

.link-help-btn {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #8B4513;
  opacity: 0.7;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s;
}
.link-help-btn:hover { opacity: 1; background-color: #FFF2DE; color: #D28BC4; }

.input-masked {
  -webkit-text-security: disc !important;
  -webkit-appearance: none;
  appearance: none;
}

.input-visible {
  -webkit-text-security: none !important;
}

.visibility-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  opacity: 0.6;
  z-index: 2;
}
.visibility-btn:hover { opacity: 1; color: #8B4513; }
.eye-icon { pointer-events: none; }

/* =========================================
   7. 頁籤選單與按鈕 (Menu & Tabs)
   ========================================= */
.menu-panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  border-radius: 5px;
  width: auto;
  height: 30px;
  background-color: #C7EFFF;
  margin-left: auto;
}

#menu {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  background-color: #C7EFFF;
  padding: 0 5px;
}

.menu-button, .menu3-button, .options-button {
  width: 100px;
  min-width: 100px;
  height: 25px;
  border-radius: 25px;
  border: 2px solid #8B4513;
  background-color: #D8BFD1;
  color: #333;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.3s;
  font-family: "Huninn", Arial, sans-serif;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-button:hover, .menu3-button:hover, .options-button:hover {
  background-color: #E0E0E0;
}
.menu-button.active, .menu3-button.active, .options-button.active {
  border: 2px solid #000000;
  background-color: #D28BC4;
}

.capsule-checkbox-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  min-width: 110px;
  height: 25px;
  border-radius: 15px;
  border: 2px solid #8B4513;
  background-color: #FFF2DE;
  color: #333;
  font-size: 12px;
  font-family: "Huninn", Arial, sans-serif;
  cursor: pointer;
  padding: 0 10px;
  user-select: none;
  transition: background-color 0.2s, border-color 0.2s;
}
.capsule-checkbox-label:hover { background-color: #E0E0E0; }
.capsule-checkbox-label:has(input:checked) {
  background-color: #D28BC4;
  border-color: #000000;
  font-weight: bold;
}
.capsule-checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: #8B4513;
  margin: 0;
}

/* =========================================
   8. 設定面板詳細元件 (Panels & Widgets)
   ========================================= */
.unified-settings-view, .unified-options-view {
  display: none;
  flex-direction: row;
  width: 100%;
  height: 100%;
  gap: 10px;
  padding: 5px;
  background-color: #F1C6D2;
  border-radius: 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.settings-left-col {
  flex: 0 0 65%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 5px;
}
.setting-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  background-color: #FFF;
  border-radius: 8px;
  padding: 5px 10px;
  gap: 10px;
  height: 43px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.source-row { background-color: #FFF9E6; border: 1px solid #FFD700; }

.row-label {
  width: 60px;
  font-size: 12px;
  font-weight: bold;
  color: #8B4513;
  text-align: right;
  margin-right: 5px;
}
.setting-row select {
  flex: 2;
  min-width: 100px;
  height: 30px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-family: "Huninn", Arial, Helvetica, sans-serif;
}

.control-group { display: flex; gap: 5px; align-items: center; }
.setting-row input[type="color"] { width: 30px; height: 30px; border: none; cursor: pointer; background: none; }
.slider-group { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 80px; }
.tiny-label { font-size: 10px; color: #666; margin-bottom: 7px; }
.setting-row input[type="range"] { width: 100%; height: 5px; cursor: pointer; margin: 0; }

/* =========================================
   9. 麥克風資訊與隱私遮罩 (Mic Info & Privacy)
   ========================================= */
.info-right-col {
  flex: 0 0 34%;
  display: flex;
  flex-direction: column;
  background-color: #F8E6F0;
  border-radius: 8px;
  padding: 10px;
  border: 1px solid #D8BFD1;
  height: 100%;
  max-height: 197px;
}
.info-header {
  font-size: 14px;
  font-weight: bold;
  color: #8B4513;
  margin-bottom: 5px;
  text-align: center;
  border-bottom: 1px dashed #8B4513;
  padding-bottom: 5px;
  line-height: 1.2em;
}

.mic-info { flex: 1; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 5px; }
.mic-info-block { width: 100%; white-space: pre-wrap; word-break: break-all; }

#default-mic { background-color: #E8F5E9; border-left: 5px solid #ff6363; border-radius: 4px; padding: 10px; font-size: 12px; position: relative; }
#default-mic::before { content: "🎙️ 現在のマイク (Active)"; display: block; font-size: 10px; margin-bottom: 5px; font-weight: normal; }
#other-mic { background-color: #FAFAFA; border: 1px solid #EEE; border-radius: 4px; padding: 10px; font-size: 11px; color: #666; position: relative; white-space: pre-line; }
#other-mic::before { content: "📋 検出された他のデバイス"; display: block; font-size: 10px; color: #999; margin-bottom: 5px; border-bottom: 1px dashed #DDD; padding-bottom: 3px; font-weight: bold; }

.privacy-toggle { cursor: pointer; font-size: 14px; user-select: none; display: flex; align-items: center; }
.privacy-toggle input { display: none; }
.privacy-toggle .lock-icon { filter: grayscale(100%); opacity: 0.5; transition: all 0.2s; }
.privacy-toggle input:checked + .lock-icon { filter: grayscale(0%); opacity: 1; transform: scale(1.1); }

.privacy-cover {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-color: #F8E6F0;
  z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border-radius: 4px; backdrop-filter: blur(2px);
}
.privacy-cover img  { width: 120px; height: 120px; object-fit: contain; opacity: 0.5; }
.privacy-cover span { font-size: 12px; font-weight: bold; color: #D8BFD1; letter-spacing: 2px; }

/* =========================================
   10. 進階選項卡片與說明 (Options Cards)
   ========================================= */
.options-column { flex: 1; display: flex; flex-direction: column; gap: 15px; }

.option-card {
  background-color: #FFFFFF;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(139, 69, 19, 0.1);
  display: flex; flex-direction: column; gap: 10px;
}
.full-height-card { height: 100%; }
.card-title { font-size: 14px; font-weight: bold; color: #8B4513; border-bottom: 2px dashed #F1C6D2; padding-bottom: 5px; margin-bottom: 5px; }
.card-row   { display: flex; align-items: center; justify-content: space-between; }
.card-label { font-size: 13px; color: #333; font-weight: bold; }

.alignment-group       { display: flex; gap: 10px; background-color: #FFF9E6; padding: 5px 10px; border-radius: 20px; border: 1px solid #FFE4B5; }
.alignment-group label { font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 3px; }
.option-color-picker { width: 50px; height: 30px; border: none; background: none; cursor: pointer; }

.card-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 13px;
  background-color: #FAFAFA;
  color: #333;
  font-family: "Huninn", Arial, sans-serif;
  cursor: pointer;
  outline: none;
  height: 28px;
}
.card-select:hover { border-color: #8B4513; }

.overflow-options-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; width: 100%; }
.radio-box {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background-color: #F8F9FA; border-radius: 6px; border: 1px solid #EEE;
  cursor: pointer; transition: all 0.2s; width: 100%; box-sizing: border-box;
}
.radio-box:hover { background-color: #FFF5E6; border-color: #FFD700; }
.radio-box span  { font-size: 13px; color: #333; }

.help-text-box {
  background-color: #F0F8FF; border-radius: 6px; padding: 12px;
  font-size: 12px; color: #4682B4; line-height: 1.6;
  flex: 1; width: 100%; box-sizing: border-box; border: 1px solid #D6EAF8;
}
.help-text-box p     { margin: 0 0 8px 0; }
.help-text-box ul    { margin: 0; padding-left: 18px; }
.help-text-box li    { margin-bottom: 4px; }
.help-text-box .note { margin-top: 10px; color: #999; font-size: 11px; text-align: right; }

/* =========================================
   11. 特殊排版邏輯：強制單行 (Visual Push Up)
   ========================================= */
.visual-single-line {
  display: block !important; 
  height: calc(var(--text-font-size) * 1.3) !important; 
  justify-content: flex-start !important;
  overflow: hidden !important;
  white-space: normal !important;
  scroll-behavior: smooth;
}

/* 原本的方式先保留
.visual-single-line {
  鎖定固定高度並強制底部對齊，利用 Overflow 推升舊文字 
  height: calc(var(--text-font-size) * 1.2) !important; 
  overflow: hidden !important;
  justify-content: flex-end !important;
}
*/

/* =========================================
   12. 響應式調整 (Media Queries)
   ========================================= */
@media screen and (max-width: 1200px) {
  body { min-width: 750px; overflow-x: auto; }
  #control-panel { min-width: 100%; padding: 10px; }

  .top-control-bar { flex-wrap: wrap; height: auto; padding-bottom: 5px; }
  .menu-panel { margin-left: 0px; width: auto; flex: 1; }
  .link-wrapper { min-width: 200px; }
}

@media screen and (max-width: 950px) {
  .unified-settings-view { flex-direction: column; overflow-y: auto; }
  .settings-left-col { flex: none; width: 100%; padding-right: 0; overflow-y: visible; }
  .info-right-col { flex: none; width: 100%; height: auto; min-height: 150px; margin-top: 10px; }
  .unified-options-view { flex-direction: column; }
  .record-button { width: auto; min-width: 100px; }
  .options-column { width: 100%; }

  #options-panel { overflow-y: auto; }
  #logo { height: 100px; object-fit: contain; }
  #recorder-panel { width: 120px; }
}

/* =========================================
   13. 字幕顯示的方式、一種背景全透明字幕、一種當素材用的字幕
   ========================================= */
#Subtitle-style {
  display: flex;
  flex-direction: column;
  margin: 0 0;
  
  background-color: transparent;
  padding: 0px;
  border-radius: 0px;
  border: 1px solid transparent;
  backdrop-filter: blur(0px);
  box-shadow: none;

  transition: 
    background-color 0.3s ease,
    padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.3s ease,
    backdrop-filter 0.3s ease,
    box-shadow 0.3s ease;
  
  z-index: 10;
}

/* OBS當素材用的字幕顯示方式 */
#Subtitle-style.active-style {
  margin: 0 auto;
  background-color: #ffffff; 
  width: 600px;
  height: 230px;
  padding: 15px 30px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  gap: 4px;
  
  /* 特效 */
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#Subtitle-style.active-style #source-text {
  height: 2.7em;
  padding: 0px 5px;
  font-size: var(--text-font-size-mode-b) !important;
  overflow: hidden !important;
}
#Subtitle-style.active-style #target-text-1,
#Subtitle-style.active-style #target-text-2,
#Subtitle-style.active-style #target-text-3 {
  font-size: var(--text-font-size-mode-b) !important;
  height: 3.9em;
  padding: 0px 5px;
  /* 動畫 */
  transition: line-height 0.3s ease;
}
/* 素材模式下語言三隱藏，因為不夠放 */
#Subtitle-style.active-style #target-text-3 {
  display: none;
}

input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(100%);
}

/* =========================================
   14. OBS Bridge Card Specific Styles
   ========================================= */
.obs-input-group {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.obs-input-group input.card-select {
  width: 100%;
  box-sizing: border-box;
}