@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* =========================================================
   ✅ 디자인 토큰 (EpubMerge 언어 + Bootstrap 호환)
   ========================================================= */
:root {
  /* 색상 팔레트 (라이트) */
  --bg-primary:      #f0f4f9;
  --bg-secondary:    #ffffff;
  --bg-tertiary:     #e4eaf3;
  --surface:         #ffffff;
  --surface-hover:   #f7f9fd;
  --text-primary:    #0f172a;
  --text-secondary:  #334155;
  --text-muted:      #64748b;
  --accent:          #3b82f6;
  --accent-rgb:      59, 130, 246;
  --accent-2:        #8b5cf6;
  --accent-3:        #06b6d4;
  --success:         #10b981;
  --warning:         #f59e0b;
  --danger:          #ef4444;
  --border:          rgba(100, 116, 139, 0.2);
  --shadow-sm:       0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.06);
  --shadow:          0 10px 25px -5px rgba(15,23,42,.1), 0 4px 10px -5px rgba(15,23,42,.06);
  --shadow-lg:       0 20px 40px -10px rgba(15,23,42,.15);
  --glow:            0 0 0 3px rgba(59,130,246,.2);

  /* Bootstrap 매핑 */
  --bs-primary:            #3b82f6;
  --bs-primary-rgb:        59, 130, 246;
  --bs-secondary:          #64748b;
  --bs-body-bg:            var(--bg-primary);
  --bs-body-color:         var(--text-secondary);
  --bs-border-color:       var(--border);
  --bs-card-bg:            var(--surface);
  --bs-light:              #e4eaf3;
  --bs-accordion-active-bg: rgba(59,130,246,.07);

  --utility-bar-width: 52px;
}

[data-bs-theme="dark"] {
  --bg-primary:      #0f172a;
  --bg-secondary:    #1e293b;
  --bg-tertiary:     #2a3a52;
  --surface:         #1e293b;
  --surface-hover:   #273449;
  --text-primary:    #f1f5f9;
  --text-secondary:  #cbd5e1;
  --text-muted:      #94a3b8;
  --border:          rgba(148,163,184,.15);
  --shadow-sm:       0 1px 3px rgba(0,0,0,.3);
  --shadow:          0 10px 25px -5px rgba(0,0,0,.4), 0 4px 10px -5px rgba(0,0,0,.3);
  --shadow-lg:       0 20px 40px -10px rgba(0,0,0,.5);
  --glow:            0 0 0 3px rgba(96,165,250,.25);

  --bs-primary:            #60a5fa;
  --bs-primary-rgb:        96, 165, 250;
  --accent:                #60a5fa;
  --accent-rgb:            96, 165, 250;
  --bs-body-bg:            var(--bg-primary);
  --bs-body-color:         var(--text-secondary);
  --bs-border-color:       var(--border);
  --bs-card-bg:            var(--surface);
  --bs-light:              #2a3a52;
  --bs-accordion-active-bg: rgba(96,165,250,.1);
}

/* =========================================================
   ✅ 리셋 & 베이스
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; min-height: 100%; }

@media (min-width: 769px) {
  html:has(body.layout-vertical) { height: auto; overflow-y: auto; }
  body.layout-vertical { height: auto; overflow-y: auto !important; }
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Noto Sans KR", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(59,130,246,.1) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,.07) 0%, transparent 60%);
  overflow: hidden;
}

[data-bs-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(59,130,246,.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,.12) 0%, transparent 60%);
}

/* =========================================================
   ✅ 타이포그래피
   ========================================================= */
.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .35rem;
}

/* =========================================================
   ✅ 폼 컨트롤
   ========================================================= */
.form-control,
.form-select {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: 8px;
  font-size: 13px;
  transition: border-color .2s, box-shadow .2s;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: rgba(15,23,42,.6) !important;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: var(--glow) !important;
  outline: none;
}

.form-control::placeholder { color: var(--text-muted); opacity: .7; }

.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.form-check-input:focus {
  box-shadow: var(--glow);
}

.settings-field-header { min-height: 1.5rem; }

/* =========================================================
   ✅ 버튼 시스템
   ========================================================= */

/* Ghost 버튼 (아이콘 전용) */
.btn-ghost {
  --bs-btn-color: var(--text-muted);
  --bs-btn-hover-color: var(--text-primary);
  --bs-btn-hover-bg: var(--bg-tertiary);
  --bs-btn-hover-border-color: var(--border);
  --bs-btn-active-color: var(--text-primary);
  --bs-btn-active-bg: rgba(var(--accent-rgb), .12);
  --bs-btn-active-border-color: var(--border);
  --bs-btn-disabled-color: var(--text-muted);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: transparent;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 8px;
  transition: all .18s ease;
  padding: .3rem .55rem;
}

.btn-ghost:hover:not(:disabled):not(.disabled), .btn-ghost:focus-visible {
  background: var(--bg-tertiary);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-ghost-danger {
  --bs-btn-color: var(--text-muted);
  --bs-btn-hover-color: var(--danger);
  --bs-btn-hover-bg: rgba(239,68,68,.1);
  --bs-btn-hover-border-color: rgba(239,68,68,.25);
  --bs-btn-active-color: var(--danger);
  --bs-btn-active-bg: rgba(239,68,68,.18);
  --bs-btn-active-border-color: rgba(239,68,68,.25);
  --bs-btn-disabled-color: var(--text-muted);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: transparent;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 8px;
  transition: all .18s ease;
  padding: .3rem .55rem;
}

.btn-ghost-danger:hover:not(:disabled):not(.disabled), .btn-ghost-danger:focus-visible {
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.25);
  color: var(--danger);
}

.btn-ghost:focus-visible, .btn-ghost-danger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}
.btn-ghost:disabled, .btn-ghost-danger:disabled {
  opacity: .45;
  background: transparent;
  border-color: transparent;
}

/* Primary 버튼 – 그라디언트 */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), .35);
  border-radius: 8px;
  transition: all .2s ease;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), .45);
  transform: translateY(-1px);
  color: #fff;
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; }

/* Outline 버튼 개선 */
.btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border);
  border-radius: 8px;
  transition: all .18s ease;
}

.btn-outline-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn-outline-success { border-radius: 8px; transition: all .18s ease; }
.btn-outline-success:hover { box-shadow: 0 0 8px rgba(16,185,129,.3); }

.btn-outline-danger { border-radius: 8px; transition: all .18s ease; }
.btn-outline-danger:hover { box-shadow: 0 0 8px rgba(239,68,68,.3); }

.btn-link { color: var(--text-muted); transition: color .15s; }
.btn-link:hover { color: var(--accent); }

/* 실행 버튼 상태 */
#run-translation-btn { gap: .35rem; font-weight: 600; min-width: 80px; }

#run-translation-btn.is-running {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  box-shadow: 0 4px 14px rgba(239,68,68,.4);
}

#run-translation-btn.is-paused {
  background: linear-gradient(135deg, var(--warning), #d97706);
  border: none;
  box-shadow: 0 4px 14px rgba(245,158,11,.4);
  color: #fff;
}

/* =========================================================
   ✅ 테마 토글 아이콘
   ========================================================= */
.theme-icon-dark,
[data-bs-theme="light"] .theme-icon-dark { display: none; }

[data-bs-theme="dark"] .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark  { display: inline-block; }

/* =========================================================
   ✅ 레이아웃 토글 아이콘
   ========================================================= */
.layout-icon-v { display: none; }
body.layout-vertical .layout-icon-h { display: none; }
body.layout-vertical .layout-icon-v { display: inline-block; }

/* =========================================================
   ✅ 유틸리티 바 (좌/우 사이드바)
   ========================================================= */
.utility-bar {
  position: fixed;
  top: 0;
  height: 100vh;
  width: var(--utility-bar-width);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .6rem .4rem;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-color: var(--border);
}

[data-bs-theme="dark"] .utility-bar {
  background: rgba(30,41,59,.88);
}

.utility-bar-left  { left: 0;  border-right: 1px solid var(--border); }
.utility-bar-right { right: 0; border-left:  1px solid var(--border); }

.utility-bar .btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px !important;
  color: var(--text-muted);
  transition: all .18s ease;
  border: 1px solid transparent !important;
  font-size: 1rem;
}

.utility-bar .btn:hover {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary);
  border-color: var(--border) !important;
}

.utility-bar .btn.active {
  background: rgba(var(--accent-rgb), .12) !important;
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), .3) !important;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), .18);
}

.utility-bar .btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.utility-bar hr {
  border-color: var(--border);
  opacity: 1;
  width: 80%;
}

.vr { background-color: var(--border); opacity: 1; }
hr  { border-color: var(--border); opacity: 1; }

/* =========================================================
   ✅ 메인 레이아웃
   ========================================================= */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.split-container {
  display: flex;
  padding-left:  var(--utility-bar-width);
  padding-right: var(--utility-bar-width);
  height: 100vh;
  animation: fadeInUp .45s ease-out;
}

.main-content {
  flex: 1 1 0%;
  min-width: 0;
  transition: flex-basis .35s ease;
}

/* 데스크탑 – 메인 카드 (full-bleed) */
@media (min-width: 769px) {
  .main-content > .container-fluid {
    background: var(--surface);
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0 !important;
    padding: 1rem 1.25rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* flex 체인: container → tab → fieldset → drop-zone → list */
  .main-tab-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  #file-management-controls {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
}

/* =========================================================
   ✅ 리사이저
   ========================================================= */
#resizer {
  flex: 0 0 1px;
  position: relative;
  cursor: col-resize;
  background: transparent;
  display: none;
  transition: background .2s;
}

#resizer::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: var(--border);
}
#resizer:hover, .is-resizing #resizer { background: rgba(var(--accent-rgb), .12); }
#resizer:hover::before, .is-resizing #resizer::before { background: var(--accent); }
.is-resizing   { user-select: none; }

/* =========================================================
   ✅ 설정 패널
   ========================================================= */
.settings-panel {
  width: 0;
  transition: width .35s ease;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.settings-panel-is-open .main-content { width: 50%; }
body.settings-panel-is-open #resizer       { display: block; }
body.settings-panel-is-open .settings-panel { width: 50%; }

@media (min-width: 769px) {
  body.settings-panel-is-open .settings-panel {
    background: var(--surface);
    border: none;
    border-left: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    overflow: hidden;
    width: 50%;
  }
  body.settings-panel-is-open #resizer {
    margin: 0;
  }
}

.settings-panel-header {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.settings-panel-header h5 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

.panel-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff !important;
  font-size: .82rem;
  flex-shrink: 0;
  /* Bootstrap Icons은 ::before 사용 — span 자체에 bi 클래스 추가 시 동작 */
}

.settings-panel-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

/* 패널 섹션 구분 */
.panel-section {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.panel-section + .panel-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.panel-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .6rem;
}

/* =========================================================
   ✅ 모드별 표시/숨김
   ========================================================= */
body.translator-active #translator-utils  { display: flex; }
body.translator-active #file-utils,
body.translator-active #split-options     { display: none; }
body.translator-active #translator-run-button-wrapper,
body.translator-active #run-translation-btn { display: flex; }

body.fileutil-active #file-utils          { display: flex; }
body.fileutil-active #split-options       { display: block; }
body.fileutil-active #translator-utils    { display: none !important; }

/* =========================================================
   ✅ 폴더 선택기
   ========================================================= */
.folder-selector {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

.section-header {
  min-height: 2rem;
  flex-shrink: 0;
  color: var(--text-primary);
}
.section-header .tip-trigger { margin-left: 0; }
.folder-selector .choose-folder-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  flex-shrink: 0;
  padding: 0 .65rem;
  font-size: .78rem;
  border-radius: 8px;
}

.folder-name-label {
  font-size: .78rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
   ✅ 파일 드롭존
   ========================================================= */
.drop-zone {
  border: 1.5px solid var(--border) !important;
  border-radius: 12px !important;
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s, background .2s;
  overflow: hidden;
}

.drop-zone.drag-over {
  border-color: var(--accent-3) !important;
  background: rgba(6,182,212,.05) !important;
  box-shadow: 0 0 0 3px rgba(6,182,212,.18), inset 0 0 24px rgba(6,182,212,.04);
}

/* 파일 컨트롤 헤더 */
.file-controls-header {
  background: var(--bg-tertiary) !important;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 3rem;
  gap: .5rem;
}

.file-controls-header > div:last-child { gap: .25rem !important; }
.file-controls-header .btn,
.preview-header .btn-ghost,
.preview-header .btn-ghost-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  min-width: 2rem;
  padding: 0 .5rem;
  border-radius: 8px;
  font-size: .8rem;
  flex-shrink: 0;
}
.file-controls-header .form-check-input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  float: none;
  flex-shrink: 0;
}
.file-controls-header .vr {
  height: 1.25rem;
  align-self: center;
  flex-shrink: 0;
}

/* 파일 카운트 뱃지 */
.file-count-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .1rem .5rem;
}

/* 드롭존 플레이스홀더 */
.drop-zone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.drop-zone-placeholder .placeholder-icon {
  font-size: 2.5rem;
  opacity: .2;
  margin-bottom: .75rem;
  display: block;
}

.drop-zone-placeholder .placeholder-title {
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .25rem;
  color: var(--text-muted);
}

/* =========================================================
   ✅ 파일 목록
   ========================================================= */
#file-list-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px;
}

.list-group-flush .list-group-item {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
  font-size: .82rem;
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
}

.list-group-flush .list-group-item:hover {
  background: rgba(var(--accent-rgb), .05);
}

#file-list-wrapper .list-group-item {
  height: 2.5rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

#file-list-wrapper .form-check-label {
  min-width: 0;
}

#file-list-wrapper .btn-ghost,
#file-list-wrapper .btn-ghost-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.5rem;
  flex-shrink: 0;
}

.list-group-flush .list-group-item .file-type-icon {
  font-size: .85rem;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: .7;
}

.list-group-flush .list-group-item .file-status {
  flex-shrink: 0;
  font-size: .72rem;
}

/* 파일 목록 내 ghost 버튼 크기 축소 */
.list-group-item .btn-ghost,
.list-group-item .btn-ghost-danger {
  padding: .15rem .35rem;
  font-size: .8rem;
}

.file-status-done    { color: var(--success); }
.file-status-saved   { color: var(--accent); }
.file-status-pending { color: var(--text-muted); opacity: .5; }

.file-size-label {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.glossary-drop-zone {
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

/* =========================================================
   ✅ 용어 사전 툴바
   ========================================================= */
.glossary-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: .5rem;
  padding-bottom: .75rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* =========================================================
   ✅ 로그 패널
   ========================================================= */
#log-panel-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

#log-panel-content > .position-relative {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#log-output {
  padding-right: 2.5rem !important;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: .78em;
  min-height: 100%;
  max-height: none;
  height: 100%;
  border-radius: 0;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: none;
  line-height: 1.6;
  flex: 1 1 auto;
}

[data-bs-theme="dark"] #log-output {
  background: var(--bg-primary);
}

/* 로그 패널 활성 시 settings-panel-body padding 제거 */
.settings-panel-body:has(#log-panel-content[style*="flex"]) {
  padding: 0;
  overflow: hidden;
}

/* 로그 색상 */
.log-info    { color: var(--text-secondary); }
.log-success { color: var(--success); }
.log-warn    { color: var(--warning); }
.log-error   { color: var(--danger); }

#clear-log-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  z-index: 10;
  opacity: .35;
  transition: opacity .2s;
}

#clear-log-btn:hover { opacity: 1; }

/* =========================================================
   ✅ 글로사리 테이블
   ========================================================= */
td.editing { padding: 0 !important; vertical-align: middle; }

.inline-editor {
  width: 100%;
  height: 100%;
  min-height: 2.2em;
  padding: .25rem .5rem;
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-family: inherit;
  line-height: 1.5;
  background: transparent;
  border: none;
  outline: none;
}

.table-glossary-fixed {
  width: 100%;
  table-layout: fixed;
}

.table-glossary-fixed td {
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.terms-table   th:nth-child(1), .terms-table   td:nth-child(1) { width: 50%; }
.terms-table   th:nth-child(2), .terms-table   td:nth-child(2) { width: 50%; }
.terms-table   th:nth-child(3), .terms-table   td:nth-child(3) { width: 50px; text-align: center; }

.glossary-table th:nth-child(1), .glossary-table td:nth-child(1),
.glossary-table th:nth-child(2), .glossary-table td:nth-child(2),
.glossary-table th:nth-child(3), .glossary-table td:nth-child(3) { width: calc((100% - 1.5rem) / 3); }
.glossary-table .glossary-action-cell { width: 1.5rem; padding-left: 0; padding-right: 0; text-align: right; }
.glossary-table .delete-glossary-item-btn { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; }

/* 테이블 공통 */
.table { color: var(--text-secondary); font-size: .82rem; }

.table th {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-color: var(--border);
  padding: .45rem .5rem;
}

.table td { border-color: var(--border); }

.table-hover tbody tr:hover {
  background: rgba(var(--accent-rgb), .05);
}

/* =========================================================
   ✅ 스크롤바
   ========================================================= */
::-webkit-scrollbar               { width: 5px; height: 5px; }
::-webkit-scrollbar-track         { background: transparent; }
::-webkit-scrollbar-thumb         { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover   { background: var(--text-muted); }

/* =========================================================
   ✅ 모달
   ========================================================= */
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  border-color: var(--border);
  background: var(--bg-tertiary);
  padding: .85rem 1.1rem;
}

.modal-footer {
  position: relative;
  border-color: var(--border);
  background: var(--bg-tertiary);
  padding: .6rem 1rem;
}

.modal-body { padding: 0; }

.modal-title { font-size: .9rem; font-weight: 600; color: var(--text-primary); }

.nav-center-buttons {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .3rem;
}

/* =========================================================
   ✅ 결과 뷰어 (싱글 뷰)
   ========================================================= */
.single-view-layout {
  min-height: 55vh;
}

#single-view-wrapper {
  overflow-y: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: .88em;
  --line-font-size: .88rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.line-pair {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.line-pair .line-number {
  display: flex;
  flex-shrink: 0;
  width: 44px;
  padding: .2rem 0;
  text-align: center;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  user-select: none;
  border-right: 1px solid var(--border);
  font-size: .78em;
  background: var(--bg-tertiary);
}

.line-pair .line-texts  { flex-grow: 1; font-size: var(--line-font-size); }

.line-pair .line-content {
  padding: .2rem .75rem;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 1.4em;
}

.line-pair .line-content.original {
  opacity: var(--original-text-opacity, .5);
  background: var(--bg-primary);
}

.line-pair .line-content.translated {
  background: var(--surface);
  border-top: 1px dashed var(--border);
}

[data-bs-theme="dark"] .line-pair .line-content.translated {
  background: rgba(30,41,59,.6);
}

/* 편집 모드 */
#result-preview-content .line-content[contenteditable="true"] {
  outline: none !important;
  background: rgba(var(--accent-rgb), .06) !important;
  cursor: text;
}

/* =========================================================
   ✅ 찾기 & 바꾸기
   ========================================================= */
#find-replace-bar {
  background: var(--bg-tertiary);
  border-color: var(--border) !important;
}

.find-replace-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  align-items: center;
}

.find-replace-grid > .input-group,
.find-replace-grid > input[type="text"]  { grid-column: 1 / 2; }

#find-replace-bar .input-group-text {
  background: var(--bg-tertiary) !important;
  border-color: var(--border);
  font-size: .8em;
  line-height: 1;
  display: flex;
  align-items: center;
}

[data-bs-theme="dark"] #find-replace-bar .input-group-text {
  background: rgba(15,23,42,.5) !important;
}

#find-replace-bar .input-group-text label {
  font-size: .8em;
  color: var(--text-muted);
  cursor: pointer;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}

/* 하이라이트 */
.highlight       { background: #ffd966; border-radius: 3px; }
.highlight.active { background: #f9b500; box-shadow: 0 0 5px #f9b500; }

[data-bs-theme="dark"] .highlight        { background: #a37b00; color: #fff; }
[data-bs-theme="dark"] .highlight.active { background: #d4a000; }

/* =========================================================
   ✅ 폼 스위치
   ========================================================= */
.form-switch .form-check-input {
  width: 2em;
  margin-left: -2.5em;
  background-position: left center;
  border-radius: 2em;
  transition: background-position .15s;
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280,0,0,0.25%29'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked {
  background-position: right center;
  background-color: var(--accent);
  border-color: var(--accent);
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* =========================================================
   ✅ 스크롤 가능 컨테이너 (공통)
   ========================================================= */
#terms-table-container,
#glossary-table-container,
#translation-settings-content,
#gemini-settings-content {
  flex: 1 1 auto;
  max-height: none;
  overflow-y: auto;
  padding: 0 2px;
}

/* =========================================================
   ✅ 파일 드롭존 레이아웃
   ========================================================= */
#file-drop-zone.drop-zone {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#file-drop-zone .file-controls-header { flex: 0 0 auto; }

/* =========================================================
   ✅ 용어 사전 패널
   ========================================================= */
#basic-glossary-content,
#user-glossary-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

#basic-glossary-content > .glossary-toolbar,
#user-glossary-content  > .glossary-toolbar { flex: 0 0 auto; }

/* =========================================================
   ✅ 번역/Gemini 설정 패널
   ========================================================= */
#gemini-settings-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding-bottom: 1rem;
}

#translation-settings-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding-bottom: 1rem;
}

.translation-guidance-input {
  height: 42vh;
  min-height: 180px;
  max-height: 580px;
  resize: vertical;
}

#api-key-list { overflow-y: auto; }

/* =========================================================
   ✅ 반응형 높이 조정
   ========================================================= */
@media (max-height: 900px) {
  #basic-glossary-content,
  #user-glossary-content,
  #translation-settings-content,
  #log-panel-content,
  #gemini-settings-content       { height: 88vh; }
  .translation-guidance-input            { height: 50vh; }
}

@media (max-height: 700px) {
  #basic-glossary-content,
  #user-glossary-content,
  #translation-settings-content,
  #log-panel-content,
  #gemini-settings-content       { height: 85vh; }
  .translation-guidance-input            { height: 38vh; }
}

@media (max-height: 600px) {
  #basic-glossary-content,
  #user-glossary-content,
  #translation-settings-content,
  #log-panel-content,
  #gemini-settings-content       { height: 80vh; }
  .translation-guidance-input            { height: 28vh; }
}

/* =========================================================
   ✅ 세로 레이아웃 (EpubMerge 스타일) — 데스크탑 전용
   ========================================================= */
@media (min-width: 769px) {

body.layout-vertical .split-container {
  flex-direction: column;
  height: auto;
  min-height: 100vh;
  padding-left: var(--utility-bar-width);
  padding-right: var(--utility-bar-width);
  align-items: center;
  gap: 0;
}

body.layout-vertical .main-content {
  width: 100%;
  max-width: 780px;
  flex: none;
}

body.layout-vertical .main-content > .container-fluid {
  height: auto !important;
  border-radius: 0 !important;
  border: none !important;
  border-top: 1px solid var(--border) !important;
  box-shadow: none !important;
  background: var(--surface) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.layout-vertical .main-tab-content,
body.layout-vertical #file-management-controls {
  flex: none;
}

body.layout-vertical #file-drop-zone.drop-zone {
  flex: none;
  min-height: 0;
}

body.layout-vertical #file-list-wrapper {
  max-height: 40vh;
  flex: none;
}

body.layout-vertical .drop-zone {
  border-radius: 12px !important;
  border-left: 1.5px solid var(--border) !important;
  border-right: 1.5px solid var(--border) !important;
}

body.layout-vertical #resizer { display: none !important; }

body.layout-vertical.settings-panel-is-open .main-content {
  width: 100% !important;
  flex: none;
}

/* settings panel: max-height 기반 열기/닫기 */
body.layout-vertical .settings-panel {
  width: 100% !important;
  max-width: 780px;
  max-height: 0;
  transition: max-height .4s ease-out, opacity .25s ease;
  opacity: 0;
  border-radius: 0 !important;
  border: none !important;
  border-top: 1px solid var(--border) !important;
  box-shadow: none !important;
  background: var(--surface) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.layout-vertical.settings-panel-is-open .settings-panel {
  max-height: 65vh;
  opacity: 1;
  width: 100% !important;
}

} /* end @media (min-width: 769px) — 세로 레이아웃 */

/* =========================================================
   ✅ 모바일 반응형
   ========================================================= */
@media (max-width: 768px) {
  #layout-toggle-btn { display: none !important; }

  body {
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
    background-image: none;
  }

  /* 전체를 세로로 붙이기 — 공백/gap 없음 */
  .split-container {
    flex-direction: column;
    gap: 0;
    padding: 0;
    height: auto;
    animation: none;
  }

  /* 메인 콘텐츠 — 테두리/radius 없이 꽉 채움 */
  .main-content { width: 100% !important; }

  .main-content > .container-fluid {
    margin: 0 !important;
    padding: 1rem;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
    backdrop-filter: none;
  }

  /* 유틸리티 바 — 상단에 붙어서 flat하게 */
  .utility-bar {
    position: static;
    width: 100%;
    height: auto;
    padding: .25rem .5rem;
    border-radius: 0;
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    background: var(--surface);
    backdrop-filter: none;
    box-shadow: none;
  }

  [data-bs-theme="dark"] .utility-bar { background: var(--surface); }

  .utility-bar-left,
  .utility-bar-right {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
  }

  .utility-bar .vstack {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: .15rem !important;
    width: 100%;
  }

  .utility-bar hr { display: none; }

  .utility-bar .btn {
    width: 32px;
    height: 32px;
    font-size: .85rem;
  }

  #translator-utils, #file-utils { display: none; }

  body.translator-active #translator-utils,
  body.fileutil-active   #file-utils { display: flex; }

  #resizer { display: none !important; }

  /* 설정 패널 — 바로 아래 붙임 */
  .settings-panel {
    width: 100% !important;
    display: none;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: var(--surface);
    backdrop-filter: none;
    overflow: hidden;
    box-shadow: none;
  }

  body.settings-panel-is-open .settings-panel {
    display: flex;
    width: 100% !important;
    margin: 0;
  }

  body.settings-panel-is-open .main-content { width: 100% !important; }

  .settings-panel-header {
    padding: .75rem 1rem;
    border-radius: 0;
  }

  .settings-panel-body { padding: .75rem 1rem 1rem; }

  .settings-panel-content .row > [class*="col-"],
  #translation-settings-content .row > [class*="col-"],
  #gemini-settings-content      .row > [class*="col-"] { width: 100%; }

  #file-management-controls,
  #file-drop-zone { min-height: 0; }

  #file-list-wrapper { max-height: 40vh; }

  .file-controls-header {
    flex-wrap: wrap;
    gap: .5rem;
    background: transparent !important;
  }

  #log-output {
    min-height: 220px;
    max-height: none;
    height: auto;
    border-radius: 0;
  }

  /* drop-zone radius 제거 */
  .drop-zone {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }
}

/* Keep stored request IDs readable within the scrollable history table. */
.history-table .history-id { min-width: 12rem; max-width: 24rem; }

#history .history-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-secondary);
  --bs-table-hover-bg: rgba(var(--accent-rgb), .05);
  --bs-table-hover-color: var(--text-primary);
}
#history .history-table td { padding: .5rem .65rem; }
#history .history-table th { padding: .55rem .65rem; }
#history .history-group td { background: var(--bg-tertiary); padding: .4rem .75rem; }
.history-file-name { font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.history-run-time, .history-secondary { color: var(--text-muted); font-size: .75rem; }
.history-run-time { white-space: nowrap; }
.history-check { width: 2.5rem; text-align: center; }
.history-empty { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); font-size: .82rem; }
#history-detail {
  margin: 0;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .75rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.translation-progress { color: var(--text-muted); font-size: .72rem; white-space: nowrap; flex-shrink: 0; }
#result-translation-progress { font-weight: 400; }
@media (max-width: 576px) {
  #result-preview-content .preview-header > div:first-child { flex-wrap: wrap; }
  #result-translation-progress { flex-basis: 100%; margin-left: 1.5rem !important; }
}

.original-opacity-control { display: flex; flex-direction: column; align-items: center; color: var(--text-muted); width: 2.75rem; flex-shrink: 0; }
.original-opacity-control .opacity-arrow { padding: 0 .4rem; font-size: .6rem; line-height: 1; border-radius: 4px; }
#original-opacity-value { font-size: .72rem; line-height: 1.2; font-variant-numeric: tabular-nums; cursor: ns-resize; touch-action: none; user-select: none; border-radius: 4px; padding: .1rem .2rem; }
#original-opacity-value:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

body.localjobs-active #translator-utils, body.localjobs-active #file-utils { display: none !important; }
#localjobs { min-height: 0; }
#localjobs .drop-zone { min-height: 0; }
#local-jobs-list { min-height: 0; }
.local-jobs-table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(var(--accent-rgb), .05); --bs-table-hover-color: var(--text-primary); }
.local-jobs-table td { padding: .6rem .65rem; }
#localjobs .form-check-input, #history .form-check-input {
  display: block;
  width: 1rem;
  height: 1rem;
  margin: 0;
  float: none;
  flex-shrink: 0;
}
.local-jobs-table td.history-check,
#history .history-table .history-check {
  width: 3rem;
  min-width: 3rem;
  padding-left: 1rem;
  padding-right: 1rem;
  vertical-align: middle;
  text-align: left;
}
.local-jobs-table .local-selected td { background: rgba(var(--accent-rgb), .08); }
.local-file-cell { min-width: 8rem; overflow-wrap: anywhere; }
.local-file-name { color: var(--text-primary); font-size: .82rem; overflow-wrap: anywhere; }
.settings-panel-body:has(#result-preview-content[style*="flex"]) { padding: 0; min-height: 0; overflow: hidden; }
#result-preview-content { flex-direction: column; flex: 1 1 auto; min-height: 0; height: 100%; }
.preview-header, .preview-footer { display: flex; align-items: center; flex-shrink: 0; padding: .6rem .75rem; background: var(--bg-tertiary); }
.preview-header { border-bottom: 1px solid var(--border); }
.preview-footer { position: relative; border-top: 1px solid var(--border); gap: .3rem; }
.preview-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.preview-header .modal-title { font-size: .85rem; }
.preview-body .single-view-layout { min-height: 0; }
#result-preview-content #single-view-wrapper { overflow: visible; }
@media (max-width: 576px) {
  .preview-footer { flex-wrap: wrap; }
  .preview-footer .nav-center-buttons { position: static; transform: none; }
}

body.preview-panel-is-open #settings-panel > .settings-panel-header { display: none; }
#result-preview-content #single-view-wrapper:empty { border: none; }
#result-preview-content .single-view-layout:has(#single-view-wrapper:empty) { display: none; }

body.history-active #translator-utils, body.history-active #file-utils { display: none !important; }
#history, #history .drop-zone, #history-list { min-height: 0; }
.history-id-link { font-size: .75rem; color: var(--text-primary); }
.history-table .history-selected td { background: rgba(var(--accent-rgb), .08); }
.settings-panel-body:has(#history-detail-content[style*="flex"]) { padding: 0; min-height: 0; overflow: hidden; }
#history-detail-content { flex-direction: column; flex: 1 1 auto; min-height: 0; height: 100%; }
/* Shared help trigger and tooltip appearance across settings and management views. */
.tip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-left: .2rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: .78rem;
  line-height: 1;
  vertical-align: middle;
  text-decoration: none;
  cursor: help;
  flex-shrink: 0;
}
.tip-trigger:hover, .tip-trigger:focus-visible { color: var(--text-primary); background: var(--bg-tertiary); }
.tip-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-tooltip {
  --bs-tooltip-max-width: 320px;
  --bs-tooltip-bg: var(--text-primary);
  --bs-tooltip-color: var(--surface);
  --bs-tooltip-opacity: 1;
  --bs-tooltip-border-radius: 8px;
  --bs-tooltip-font-size: .75rem;
  --bs-tooltip-padding-x: .7rem;
  --bs-tooltip-padding-y: .5rem;
}
.app-tooltip .tooltip-inner { text-align: left; line-height: 1.6; overflow-wrap: anywhere; }

#result-preview-content #single-view-layout { margin: 0; padding: 0; width: 100%; }
#result-preview-content #single-view-wrapper { margin: 0; border: 0; border-radius: 0; width: 100%; }

@media (min-width: 769px) {
  body:is(.localjobs-active, .history-active, .preview-panel-is-open):not(.layout-vertical).settings-panel-is-open #main-content-pane {
    width: var(--main-pane-width, calc((100% - 1px) / 2)) !important;
    flex: 0 0 auto;
    max-width: none;
  }
  body:is(.localjobs-active, .history-active, .preview-panel-is-open):not(.layout-vertical).settings-panel-is-open #settings-panel {
    width: var(--detail-pane-width, calc((100% - 1px) / 2)) !important;
    flex: 0 0 auto;
    max-width: none;
  }
  body:is(.localjobs-active, .history-active, .preview-panel-is-open):not(.layout-vertical).settings-panel-is-open #resizer {
    display: block !important;
    align-self: stretch;
    z-index: 1;
  }
}

#user-glossary-content { overflow-y: auto; }
#user-glossary-content #glossary-table-container { flex: 0 0 auto; overflow: visible; }
#glossary-review-panel { flex: 0 0 auto; border-top: 1px solid var(--border); margin-top: 1rem; padding: 1rem 0; }
.glossary-review-table { --bs-table-bg: transparent; color: var(--text-primary); }
.glossary-review-table td { padding: .5rem; overflow-wrap: anywhere; }
#glossary-review-runs { display: flex; flex-direction: column; gap: .5rem; }
#glossary-review-runs .history-secondary { min-width: 0; overflow-wrap: anywhere; }

#basic-glossary-content { overflow-y: auto; }
#basic-glossary-content #terms-table-container { flex: 0 0 auto; overflow: visible; }
.term-entry-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: .5rem; align-items: end; width: 100%; }
.glossary-entry-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: .5rem; align-items: end; width: 100%; }
.term-entry-arrow { align-self: end; padding-bottom: .4rem; color: var(--text-muted); }
.term-add-btn { width: 2rem; height: 2rem; padding: 0; }
.terms-rules-table { table-layout: fixed; width: 100%; --bs-table-bg: transparent; }
.terms-rules-table .term-enable-cell { width: 2rem; text-align: center; }
.terms-rules-table .term-actions-cell { width: 4.5rem; padding-left: 0; padding-right: 0; }
.terms-rules-table .term-text-cell { overflow-wrap: anywhere; white-space: pre-wrap; }
.terms-rules-table .term-disabled .term-text-cell { opacity: .45; }
#basic-glossary-content .form-check-input { width: 1rem; height: 1rem; flex-shrink: 0; }
.term-options-row > td { background: var(--bg-tertiary); padding: .5rem; }
.term-options-row[hidden] { display: none; }
#terms-preview-panel { border-top: 1px solid var(--border); margin-top: 1rem; padding: 1rem 0; flex-shrink: 0; }
#terms-preview-output { margin: 0; padding: .75rem; min-height: 3rem; background: var(--bg-tertiary); border-radius: 8px; font-size: .82rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.settings-advanced > summary { cursor: pointer; padding-block: .25rem; }
.settings-advanced > summary::marker { color: var(--bs-secondary-color); }

/* Management views follow the same desktop layout choice as the translator. */
@media (min-width: 769px) {
  body:is(.localjobs-active, .history-active, .preview-panel-is-open):not(.layout-vertical) .split-container {
    flex-direction: row;
    height: 100vh;
    align-items: stretch;
  }
  body:is(.localjobs-active, .history-active, .preview-panel-is-open):not(.layout-vertical).settings-panel-is-open .settings-panel {
    height: 100vh;
  }
  body:is(.localjobs-active, .history-active).layout-vertical #history-list,
  body:is(.localjobs-active, .history-active).layout-vertical #local-jobs-list {
    flex: 0 1 auto;
    max-height: 40vh;
    overflow-y: auto;
  }
  body.preview-panel-is-open.layout-vertical.settings-panel-is-open .settings-panel {
    height: 65vh;
    max-height: 65vh;
    flex: none;
  }
}

/* Small screens stack the list and detail, with rows that fit the viewport. */
@media (max-width: 768px) {
  body:is(.localjobs-active, .history-active) .split-container { width: 100%; }
  body:is(.localjobs-active, .history-active) .main-content { flex: none; min-width: 0; }
  body:is(.localjobs-active, .history-active) .main-content > .container-fluid { height: auto; padding: .75rem; }
  #history-list, #local-jobs-list { flex: 0 1 auto; max-height: 40vh; }
  body.preview-panel-is-open.settings-panel-is-open .settings-panel {
    height: 65vh;
    height: 65dvh;
    flex: none;
    min-width: 0;
  }
  #history .history-table, .local-jobs-table,
  #history .history-table tbody, .local-jobs-table tbody { display: block; width: 100%; }
  .management-row { display: grid; grid-template-columns: 3rem minmax(0, 1fr); border-bottom: 1px solid var(--border); }
  #history .history-table .management-row > td,
  .local-jobs-table .management-row > td { border: 0; min-width: 0; max-width: none; padding: .25rem .65rem; }
  #history .history-table .management-row > .history-check,
  .local-jobs-table .management-row > .history-check { grid-column: 1; grid-row: 1; padding: .6rem 1rem; width: 3rem; }
  .management-title { grid-column: 2; padding-top: .6rem !important; overflow-wrap: anywhere; }
  .management-meta { grid-column: 2; white-space: normal !important; overflow-wrap: anywhere; }
  .management-actions { grid-column: 2; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .25rem; padding-bottom: .6rem !important; }
  .management-actions .btn { min-width: 36px; min-height: 36px; }
  #history .history-group, #history .history-group > td { display: block; width: 100%; }
  #history-list .table-responsive, #local-jobs-list .table-responsive { overflow-x: hidden; }
  .preview-header { flex-wrap: wrap; min-width: 0; }
  .preview-header > .flex-grow-1 { min-width: 0; flex-basis: 100%; margin-right: 0 !important; }
  .preview-body { overscroll-behavior: contain; }
  #history-detail { padding: .75rem !important; }
  #find-replace-bar > .d-flex { flex-wrap: wrap; }
  #find-replace-bar input { min-width: 0; }
  .folder-name-label { min-width: 0; overflow-wrap: anywhere; }
}
.guidance-markdown-preview {
  overflow: auto;
  padding: .75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-sm);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: .875rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.guidance-markdown-preview h1 { font-size: 1.35rem; }
.guidance-markdown-preview h2 { font-size: 1.15rem; }
.guidance-markdown-preview h3, .guidance-markdown-preview h4,
.guidance-markdown-preview h5, .guidance-markdown-preview h6 { font-size: 1rem; }
.guidance-markdown-preview :is(h1, h2, h3, h4, h5, h6) { margin: 1rem 0 .5rem; }
.guidance-markdown-preview > :first-child { margin-top: 0; }
.guidance-markdown-preview > :last-child { margin-bottom: 0; }
.guidance-markdown-preview :is(pre, table) { max-width: 100%; overflow: auto; }
.guidance-markdown-preview pre { padding: .5rem; background: var(--bg-tertiary); }
.guidance-markdown-preview blockquote { border-left: 3px solid var(--bs-border-color); padding-left: .75rem; }
.guidance-markdown-preview th, .guidance-markdown-preview td { border: 1px solid var(--bs-border-color); padding: .35rem; }
