/* ========================================================================
   FEPS – Style Sheet
   Premium engineering-software aesthetic with dark sidebar + light canvas
   ======================================================================== */

:root {
  /* ─ Palette ─ */
  --bg-dark: #1a1d24;
  --bg-panel: #22262e;
  --bg-panel-alt: #282c35;
  --bg-canvas: #f4f5f7;
  --bg-input: #2d323c;
  --bg-toolbar: #1e2128;
  --border: #33384380;
  --accent: #4f8cff;
  --accent-hover: #3a74e8;
  --accent-dim: #4f8cff28;
  --danger: #ef5350;
  --success: #66bb6a;
  --warn: #ffa726;
  --text: #e0e3ea;
  --text-dim: #8b909c;
  --text-dark: #333;
  --header-h: 44px;
  --tab-h: 36px;
  --status-h: 26px;
  --panel-w: 280px;
  --radius: 6px;
  --radius-sm: 4px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Menlo', monospace;
  --transition: .18s ease;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
}

/* ════════════════════ TOOLBAR ════════════════════ */
#toolbar {
  height: var(--header-h);
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 6px;
  flex-shrink: 0;
  z-index: 10;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
}

.logo-text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .3px;
  color: #fff;
}

.tb-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.tb-combo {
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.tb-combo:focus {
  border-color: var(--accent);
}

.tb-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.tb-btn:hover {
  background: var(--bg-panel-alt);
  border-color: #505668;
}

.tb-btn.accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.tb-btn.accent:hover {
  background: var(--accent-hover);
}

.model-info {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}

/* ════════════════════ TABS ════════════════════ */
#tab-bar {
  height: var(--tab-h);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding-left: 12px;
  flex-shrink: 0;
}

.tab {
  position: relative;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 0 18px;
  cursor: pointer;
  transition: color var(--transition);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* ════════════════════ MAIN LAYOUT ════════════════════ */
#app {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Side panel ── */
#side-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

#side-panel::-webkit-scrollbar {
  width: 5px;
}

#side-panel::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

.panel-content {
  display: none;
  padding: 10px;
}

.panel-content.active {
  display: block;
}

.panel-section {
  background: var(--bg-panel-alt);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ── Fields ── */
.field-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.field-row label {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 56px;
  white-space: nowrap;
}

.field-row input[type="number"],
.field-row input[type="text"] {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  transition: border-color var(--transition);
}

.field-row input:focus {
  border-color: var(--accent);
}

.field-row.compact {
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Checkboxes ── */
.chk {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 4px;
}

.chk input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

/* ── Range slider ── */
input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.range-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
}

/* Compact numeric companion to a range slider */
.slider-num-input {
  width: 58px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  text-align: right;
  flex-shrink: 0;
}

.slider-num-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Hide browser spin buttons for a cleaner look */
.slider-num-input::-webkit-inner-spin-button,
.slider-num-input::-webkit-outer-spin-button {
  opacity: 0.5;
}

/* ── Combo box ── */
.combo {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
}

.combo:focus {
  border-color: var(--accent);
}

.combo option {
  background: var(--bg-panel);
  color: var(--text);
}

.combo optgroup {
  color: var(--text-dim);
  font-weight: 600;
}

/* ── Buttons inside panel ── */
.panel-btn {
  width: 100%;
  padding: 5px 0;
  margin-top: 4px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

.panel-btn:hover {
  background: #4f8cff3f;
}

.panel-btn.draw-toggle.active {
  background: #FF6F0033;
  border-color: #FF6F00;
  color: #FF6F00;
}

#feps-canvas.draw-mode {
  cursor: crosshair;
}

/* ── Item lists (materials, BCs, etc.) ── */
.item-list {
  margin-top: 6px;
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.item-list .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-bottom: 3px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
}

.item .del-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.item .del-btn:hover {
  color: #ff1744;
}

.item .edit-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

.item .edit-btn:hover {
  color: var(--accent);
}

/* Highlight item currently being edited */
.item.editing {
  background: rgba(79, 140, 255, 0.12);
  outline: 1px solid rgba(79, 140, 255, 0.35);
}

.item.editing .edit-btn {
  color: var(--accent);
}

/* ── Results table ── */
.results-table-wrap {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--mono);
}

.results-table th {
  position: sticky;
  top: 0;
  background: var(--bg-panel-alt);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-dim);
  padding: 3px 4px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.results-table td {
  padding: 2px 4px;
  text-align: right;
  color: var(--text);
  border-bottom: 1px solid #2a2e37;
}

.results-table tr:hover td {
  background: #2d323c;
}

.muted {
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
  padding: 10px;
}

/* ════════════════════ CANVAS ════════════════════ */
#canvas-wrap {
  flex: 1;
  position: relative;
  background: var(--bg-canvas);
  overflow: hidden;
}

#feps-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Floating canvas toolbar ── */
#canvas-toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 6;
}

.canvas-tb-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(30, 33, 40, .82);
  color: #e0e3ea;
  border: 1px solid rgba(80, 86, 104, .6);
  border-radius: 5px;
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  backdrop-filter: blur(6px);
}

.canvas-tb-btn:hover {
  background: rgba(40, 44, 53, .95);
  border-color: var(--accent);
}

/* ── Color bar (post-process overlay) ── */
.color-bar {
  position: absolute;
  top: 16px;
  right: 16px;
  width: auto;
  background: rgba(24, 26, 32, .8);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  z-index: 5;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.color-bar.hidden {
  display: none;
}

.color-bar .cb-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin-bottom: 6px;
}

.color-bar .cb-band {
  display: flex;
  align-items: center;
}

.color-bar .cb-swatch {
  width: 30px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, .15);
  flex-shrink: 0;
}

.color-bar .cb-label {
  font-size: 13px;
  font-family: var(--mono);
  color: #e0e3ea;
  margin-left: 8px;
  white-space: nowrap;
}

/* ════════════════════ STATUS BAR ════════════════════ */
#status-bar {
  height: var(--status-h);
  background: var(--bg-toolbar);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

#status-version {
  margin-left: auto;
  color: var(--text-dim);
  opacity: 0.6;
  font-size: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ════════════════════ FOCUS RING ════════════════════ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ════════════════════ SELECTION MODE ════════════════════ */
.panel-btn.sel-toggle.active {
  background: #4CAF5033;
  border-color: #4CAF50;
  color: #4CAF50;
}

.panel-btn.accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.panel-btn.accent:hover {
  background: var(--accent-hover);
}

.panel-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#feps-canvas.sel-mode {
  cursor: pointer;
}

/* ════════════════════ MODAL DIALOG ════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  min-width: 340px;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
}

.modal-dialog.hidden {
  display: none;
}

.modal-dialog h3 {
  color: var(--text);
  font-size: 15px;
  margin-bottom: 8px;
}

.modal-dialog .muted {
  text-align: left;
  padding: 0 0 8px 0;
}

.modal-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.modal-fieldset legend {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 0 6px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

.modal-actions .panel-btn {
  width: auto;
  padding: 6px 20px;
  margin: 0;
}

.dlg-beam-only.hidden-dof {
  display: none;
}

/* BC checkboxes column inside modal */
.bc-checks {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* One DOF row: [✓ Fix Ux] [=] [displacement load input] */
.bc-disp-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.bc-disp-row .chk {
  min-width: 90px;
  flex-shrink: 0;
  margin: 0;
}

.bc-disp-row input[type=number] {
  width: 80px;
  font-size: 11px;
}

.bc-disp-label {
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Half-width inputs for paired fields (qx / qy) */
.inp-half {
  width: 62px !important;
  flex-shrink: 0;
}

/* Solid element edge surface load list */
.esurf-face-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.esurf-face-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  gap: 4px;
}

.esurf-del-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.esurf-del-btn:hover { background: rgba(244,67,54,.2); color: #F44336; }

/* Read-only value display inside modal */
.field-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Node input grid inside element editor */
#dlg-elem-nodes-wrap .field-row {
  margin-bottom: 4px;
}

/* ════════════════════ ELEMENT CODE EDITOR MODAL ════════════════════ */

/* Wide dialog container for the code editor */
.ee-dialog {
  width: 860px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Editor body: left code column + right info column */
.ee-body {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 8px;
}

/* Left column: textarea */
.ee-col-code {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Right column: element list + log */
.ee-col-right {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.ee-log-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Small section heading */
.ee-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

/* Code textarea */
#ee-code {
  flex: 1;
  min-height: 320px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: #1a1a2e;
  color: #d4e0f7;
  border: 1px solid #3a3a5c;
  border-radius: var(--radius-sm);
  padding: 10px;
  resize: none;
  tab-size: 4;
  outline: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  transition: border-color var(--transition);
}

#ee-code:focus {
  border-color: var(--accent);
}

/* Registered elements list */
#ee-elem-list {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 80px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
}

/* Execution log */
#ee-log {
  flex: 1;
  background: #1a1a2e;
  color: #90ee90;
  border: 1px solid #3a3a5c;
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 11px;
  font-family: var(--mono);
  min-height: 160px;
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Editor footer: file I/O left, management right */
.ee-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-shrink: 0;
}

/* Toolbar button — element editor (distinct blue-violet tint) */
#btn-elem-editor {
  background: #2a3060;
  border-color: #4a5aaa;
  color: #a8c0ff;
}

#btn-elem-editor:hover {
  background: #343d80;
  border-color: var(--accent);
  color: #fff;
}

/* ========================================================================
   Debug Viewer — 디버그 뷰어 모달 (element-debug-ui.js)
   ======================================================================== */

/* ── 디버그 오버레이: 리사이즈 후 스크롤 지원 ── */
#modal-debug-overlay {
  align-items: flex-start;
  padding: 4vh 0;
  overflow: auto;
}

/* ── 디버그 대화상자 ── */
.dbg-dialog {
  width: min(92vw, 900px);      /* .modal-dialog max-width:440px 의 약 2배 */
  max-width: none;              /* .modal-dialog 의 max-width:440px 덮어쓰기 */
  min-width: 480px;
  height: min(86vh, 820px);
  min-height: 320px;
  margin: 0 auto;               /* 오버레이 내 수평 중앙 정렬 */
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  resize: both;                 /* 마우스 드래그로 크기 조정 */
}

/* ── 헤더 (드롭다운 + 닫기) ── */
.dbg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── 탭 버튼 바 ── */
.dbg-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dbg-tab-btn {
  padding: 7px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.dbg-tab-btn:hover {
  color: var(--text);
}

.dbg-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── 패널 컨테이너 ── */
.dbg-panes {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.dbg-pane {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 16px 18px;
}

.dbg-pane.hidden {
  display: none;
}

/* ── 요약 테이블 / 벡터 테이블 ── */
.dbg-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.dbg-info-table {
  border-collapse: collapse;
  font-size: 12px;
  width: auto;
}

.dbg-info-table th,
.dbg-info-table td {
  padding: 4px 12px;
  border: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.dbg-info-table th {
  background: var(--bg-panel);
  color: var(--text-dim);
  font-weight: 500;
}

.dbg-info-table td {
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* ── EFT 레이블 ── */
.dbg-eft-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
}

/* ── 행렬 스크롤 래퍼 ── */
.dbg-mat-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(88vh - 200px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ── 행렬 테이블 ── */
.dbg-mat {
  border-collapse: collapse;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.dbg-mat th,
.dbg-mat td {
  padding: 3px 8px;
  border: 1px solid #2a2d3522;
  text-align: right;
  min-width: 80px;
}

.dbg-mat thead th {
  background: var(--bg-panel);
  color: var(--text-dim);
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 10px;
}

/* 행 번호 열 (첫 번째 th) */
.dbg-mat th.dbg-idx {
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 10px;
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: center;
  min-width: 44px;
}

.dbg-mat thead .dbg-idx {
  z-index: 3;
}

.dbg-mat tbody tr:nth-child(even) td {
  background: #1c1f2888;
}

/* 대각선 셀 강조 */
.dbg-mat .dbg-diag {
  background: #1e3a5f !important;
  color: #60a5fa;
  font-weight: 600;
}

/* 영에 가까운 값 — 흐리게 */
.dbg-mat .dbg-zero,
.dbg-info-table .dbg-zero,
span.dbg-zero {
  color: #44485a;
}

/* ── 힌트 / 경고 메시지 ── */
.dbg-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
}

.dbg-warn {
  background: #2c1a0a;
  border: 1px solid #7c3700;
  border-radius: var(--radius-sm);
  color: var(--warn);
  font-size: 12px;
  padding: 10px 14px;
  line-height: 1.55;
}

/* ── 전체 K 요소 색상 범례 ── */
.dbg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.dbg-legend-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-right: 2px;
  white-space: nowrap;
}

.dbg-legend-item {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
}

/* ── 디버그 툴바 버튼 (active = ON 상태 강조) ── */
#btn-debug.accent {
  background: #0d2d1a;
  border-color: var(--success);
  color: var(--success);
}

#btn-debug-viewer {
  font-size: 11px;
}

/* ══════════════════════════════════════════════════════════
   HELP MODAL (구버전 — help.html 전환으로 대부분 불필요하나
   .help-toc-loading 등 잔여 클래스 유지)
   ══════════════════════════════════════════════════════════ */

.help-dialog {
  width: min(96vw, 1140px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

/* ── 헤더 ── */
.help-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-toolbar);
}

/* ── 본문 레이아웃 ── */
.help-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ── 좌측 TOC ── */
.help-toc {
  width: 230px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 14px 6px 14px 14px;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar, var(--bg-toolbar));
}

.help-toc-loading {
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 4px;
}

.help-toc a {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 4px;
  padding: 3px 8px;
  transition: background 0.1s, color 0.1s;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.help-toc a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.help-toc a.active {
  background: rgba(79, 140, 255, 0.15);
  color: var(--accent);
}

.help-toc a.h1 {
  font-weight: 600;
  color: var(--text);
  margin-top: 8px;
  font-size: 12px;
}

.help-toc a.h2 {
  font-weight: 500;
  margin-top: 4px;
  padding-left: 10px;
}

.help-toc a.h3 {
  font-weight: 400;
  font-size: 11px;
  padding-left: 20px;
  color: var(--text-dim);
}

/* ── 우측 내용 (rendered markdown) ── */
.help-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 40px;
  min-width: 0;
  scroll-behavior: smooth;
}

.help-content h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.help-content h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 32px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.help-content h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin: 20px 0 8px;
}

.help-content h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 6px;
}

.help-content p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 10px;
}

.help-content ul,
.help-content ol {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 10px;
  padding-left: 20px;
}

.help-content li {
  margin-bottom: 3px;
}

.help-content code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--accent);
}

.help-content pre {
  background: var(--bg-sidebar, #1a1f2e);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 8px 0 14px;
}

.help-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--text);
}

.help-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 10px 0;
  padding: 6px 14px;
  background: rgba(79, 140, 255, 0.06);
  border-radius: 0 4px 4px 0;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.65;
}

.help-content blockquote p {
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.help-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0 16px;
  font-size: 12.5px;
}

.help-content th {
  background: var(--bg-toolbar);
  color: var(--text);
  font-weight: 600;
  padding: 7px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.help-content td {
  padding: 6px 12px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.help-content tr:nth-child(even) td {
  background: var(--bg-input);
}

.help-content a {
  color: var(--accent);
  text-decoration: none;
}

.help-content a:hover {
  text-decoration: underline;
}

.help-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.help-content strong {
  color: var(--text);
  font-weight: 600;
}