/* ============================================================================
   DICOM Tag Editor — Design System (Dark & Light Themes)
   ============================================================================ */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;

  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --side-width: 410px;
}

:root[data-theme="dark"] {
  --bg-canvas: #0d1117;
  --bg-surface: #151b23;
  --bg-elevated: #1c2430;
  --bg-hover: #212b3a;
  --bg-selected: rgba(59, 130, 246, 0.22);
  --bg-input: #0f141c;

  --border: #263040;
  --border-strong: #37465c;

  --text-primary: #e6edf3;
  --text-secondary: #9aa7b8;
  --text-muted: #6c798a;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);

  --st-mod-color: #f59e0b;
  --st-mod-bg: rgba(245, 158, 11, 0.10);
  --st-add-color: #10b981;
  --st-add-bg: rgba(16, 185, 129, 0.11);
  --st-del-color: #f43f5e;
  --st-del-bg: rgba(244, 63, 94, 0.10);
  --st-err-color: #ef4444;
  --st-err-bg: rgba(239, 68, 68, 0.14);

  --vr-string-bg: rgba(59, 130, 246, 0.18);
  --vr-string-fg: #7dd3fc;
  --vr-number-bg: rgba(6, 182, 212, 0.18);
  --vr-number-fg: #67e8f9;
  --vr-date-bg: rgba(168, 85, 247, 0.20);
  --vr-date-fg: #d8b4fe;
  --vr-sequence-bg: rgba(245, 158, 11, 0.20);
  --vr-sequence-fg: #fcd34d;
  --vr-binary-bg: rgba(148, 163, 184, 0.18);
  --vr-binary-fg: #cbd5e1;
  --vr-tag-bg: rgba(236, 72, 153, 0.20);
  --vr-tag-fg: #f9a8d4;

  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

:root[data-theme="light"] {
  --bg-canvas: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-hover: #edf2f7;
  --bg-selected: rgba(37, 99, 235, 0.12);
  --bg-input: #ffffff;

  --border: #dde3ec;
  --border-strong: #c2ccd9;

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #7c8798;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.10);

  --st-mod-color: #d97706;
  --st-mod-bg: rgba(245, 158, 11, 0.12);
  --st-add-color: #059669;
  --st-add-bg: rgba(16, 185, 129, 0.12);
  --st-del-color: #e11d48;
  --st-del-bg: rgba(244, 63, 94, 0.10);
  --st-err-color: #dc2626;
  --st-err-bg: rgba(220, 38, 38, 0.10);

  --vr-string-bg: rgba(37, 99, 235, 0.12);
  --vr-string-fg: #1d4ed8;
  --vr-number-bg: rgba(8, 145, 178, 0.12);
  --vr-number-fg: #0e7490;
  --vr-date-bg: rgba(147, 51, 234, 0.12);
  --vr-date-fg: #7e22ce;
  --vr-sequence-bg: rgba(217, 119, 6, 0.14);
  --vr-sequence-fg: #b45309;
  --vr-binary-bg: rgba(100, 116, 139, 0.14);
  --vr-binary-fg: #475569;
  --vr-tag-bg: rgba(219, 39, 119, 0.12);
  --vr-tag-fg: #be185d;

  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12px;
}

.text-danger {
  color: var(--st-err-color);
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================================
   App Shell & Topbar
   ============================================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: grid;
  place-items: center;
  letter-spacing: -0.5px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 13.5px;
  font-weight: 700;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.file-meta-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.file-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.ts-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.change-summary {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--st-mod-bg);
  color: var(--st-mod-color);
  border: 1px solid rgba(245, 158, 11, 0.35);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

/* ============================================================================
   Buttons & Inputs
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger-ghost {
  color: var(--st-del-color);
  border-color: rgba(244, 63, 94, 0.32);
  background: transparent;
}
.btn-danger-ghost:hover:not(:disabled) {
  background: var(--st-del-bg);
  border-color: var(--st-del-color);
}

.btn-sm {
  padding: 5px 9px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 7px;
  font-size: 11.5px;
}

.btn-lg {
  padding: 10px 18px;
  font-size: 13.5px;
  border-radius: var(--radius-md);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-icon:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.lang-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 5px 8px;
  min-width: 56px;
}
.lang-toggle .lang-dim {
  opacity: 0.42;
  font-weight: 500;
}
.lang-toggle .lang-act {
  color: var(--accent);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}
.btn-link:hover {
  text-decoration: underline;
}

.input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.input-sm {
  padding: 4px 8px;
  font-size: 12px;
}

/* ============================================================================
   Welcome Screen
   ============================================================================ */
.welcome-view {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.welcome-card {
  max-width: 720px;
  width: 100%;
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 42px 36px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.welcome-card.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.welcome-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.welcome-card h1 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
}

.welcome-desc {
  margin: 0 0 24px;
  color: var(--text-secondary);
  line-height: 1.65;
  font-size: 13.5px;
}

.welcome-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 30px;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 22px;
}

.feat-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.feat-item strong {
  font-size: 12.5px;
}
.feat-item span {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ============================================================================
   Main Editor Workspace (Split Pane)
   ============================================================================ */
.editor-view {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.tree-pane {
  flex: 1;
  min-width: 360px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-canvas);
}

.pane-resizer {
  width: 5px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.12s;
}
.pane-resizer:hover,
.pane-resizer.active {
  background: var(--accent);
}

.side-pane {
  width: var(--side-width);
  min-width: 300px;
  max-width: 650px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-surface);
}

/* ============================================================================
   Filter Bar
   ============================================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  display: flex;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 6px 26px 6px 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
}
.search-box input:focus {
  border-color: var(--accent);
}

.search-clear {
  position: absolute;
  right: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.chip:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.chip-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 99px;
  background: rgba(128, 128, 128, 0.2);
}

.tree-util-btns {
  display: flex;
  gap: 4px;
}

/* ============================================================================
   Tag Tree Table
   ============================================================================ */
.tree-table-header,
.tree-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.8fr) 54px 40px 58px minmax(180px, 1.4fr);
  align-items: center;
  gap: 8px;
  padding-right: 12px;
}

.tree-table-header {
  height: 30px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  padding-left: 12px;
}

.tree-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  user-select: none;
}

.tree-row {
  min-height: 31px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.08);
  border-left: 3px solid transparent;
  padding-left: 4px;
  cursor: pointer;
  outline: none;
}

.tree-row:hover {
  background: var(--bg-hover);
}

.tree-row.selected {
  background: var(--bg-selected) !important;
  border-left-color: var(--accent);
}

/* Status color coding */
.tree-row.status-modified {
  background: var(--st-mod-bg);
  border-left-color: var(--st-mod-color);
}
.tree-row.status-added {
  background: var(--st-add-bg);
  border-left-color: var(--st-add-color);
}
.tree-row.status-deleted {
  background: var(--st-del-bg);
  border-left-color: var(--st-del-color);
  opacity: 0.72;
}
.tree-row.status-deleted .tag-code,
.tree-row.status-deleted .tag-name,
.tree-row.status-deleted .val-text {
  text-decoration: line-through;
}
.tree-row.has-error {
  border-left-color: var(--st-err-color);
}

.tree-row.is-private .tag-name {
  color: var(--text-secondary);
  font-style: italic;
}

.tree-row.is-sequence .tag-name {
  font-weight: 600;
}

/* Section & SQ Item rows */
.tree-section-row {
  display: flex;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 5px 10px;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.tree-section-row.section-meta {
  border-left-color: #6366f1;
}
.tree-section-row.section-main {
  border-left-color: var(--accent);
}
.col-tag-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.tree-item-row {
  background: rgba(245, 158, 11, 0.04);
}

.item-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--vr-sequence-bg);
  color: var(--vr-sequence-fg);
  flex-shrink: 0;
}

.col-tree {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.tree-chevron {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.tree-chevron:hover {
  color: var(--text-primary);
}
.tree-chevron-spacer {
  width: 18px;
  flex-shrink: 0;
}

.tag-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.tag-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-vr {
  display: flex;
  align-items: center;
}

.col-vm,
.col-len {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
  padding-right: 4px;
  white-space: nowrap;
}

.col-val {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.val-text {
  font-family: var(--font-mono);
  font-size: 12px;
}
.val-seq {
  color: var(--vr-sequence-fg);
  font-size: 11.5px;
}
.val-binary {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}
.val-empty {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}

.inline-edit-input {
  width: 100%;
  padding: 3px 6px;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

/* VR & Status Badges */
.vr-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  min-width: 30px;
}
.vr-cat-string { background: var(--vr-string-bg); color: var(--vr-string-fg); }
.vr-cat-number { background: var(--vr-number-bg); color: var(--vr-number-fg); }
.vr-cat-date   { background: var(--vr-date-bg); color: var(--vr-date-fg); }
.vr-cat-sequence { background: var(--vr-sequence-bg); color: var(--vr-sequence-fg); }
.vr-cat-binary { background: var(--vr-binary-bg); color: var(--vr-binary-fg); }
.vr-cat-tag    { background: var(--vr-tag-bg); color: var(--vr-tag-fg); }

.mini-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.badge-private {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-secondary);
}
.badge-meta {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}
.badge-err {
  background: var(--st-err-bg);
  color: var(--st-err-color);
  padding: 2px;
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
}
.st-unchanged { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }
.st-modified  { background: var(--st-mod-bg); color: var(--st-mod-color); }
.st-added     { background: var(--st-add-bg); color: var(--st-add-color); }
.st-deleted   { background: var(--st-del-bg); color: var(--st-del-color); }

.tree-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* Statusbar */
.statusbar {
  height: 27px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.status-hints {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================================
   Right Sidebar: Tag Inspector
   ============================================================================ */
.inspector-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 180px;
}

.inspector-empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.6;
}

.insp-section {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
}

.insp-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.insp-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.insp-section-header .insp-section-title {
  margin-bottom: 0;
}

.insp-breadcrumb {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.insp-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 5px;
}

.insp-tag-code {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.insp-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.insp-keyword {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.insp-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 8px 0 12px;
}

/* VR Spec Card */
.vr-spec-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.vr-spec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.vr-spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 12px;
  margin-bottom: 8px;
}
.vr-spec-grid > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.vr-spec-grid .lbl {
  font-size: 10.5px;
  color: var(--text-muted);
}

.vr-spec-hint {
  font-size: 11.5px;
  color: var(--text-primary);
  padding-top: 7px;
  border-top: 1px dashed var(--border);
  margin-bottom: 4px;
}

.vr-spec-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Value Editor */
.insp-input,
.insp-textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.quick-helpers {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}
.quick-helpers input[type="date"] {
  max-width: 150px;
}

.mv-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mv-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mv-idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}
.mv-input {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.insp-metrics-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.val-feedback {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.4;
}
.val-feedback svg {
  flex-shrink: 0;
  margin-top: 1px;
}
.val-ok {
  background: var(--st-add-bg);
  color: var(--st-add-color);
}
.val-warn {
  background: var(--st-mod-bg);
  color: var(--st-mod-color);
}
.val-error {
  background: var(--st-err-bg);
  color: var(--st-err-color);
}

.binary-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}

.hex-dump {
  margin: 8px 0 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  overflow-x: auto;
  max-height: 190px;
}

.diff-orig {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  word-break: break-all;
}

.insp-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================================
   Pixel Preview Dock
   ============================================================================ */
.pixel-dock {
  flex-shrink: 0;
  border-top: 2px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
}

.pixel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 13px;
  border-bottom: 1px solid var(--border);
}

.pixel-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

.pixel-meta-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.pixel-canvas-wrap {
  position: relative;
  background: #000;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: crosshair;
}

.pixel-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.pixel-hud {
  position: absolute;
  bottom: 6px;
  left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  pointer-events: none;
}

.pixel-controls {
  padding: 9px 13px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wl-row {
  display: grid;
  grid-template-columns: 38px 1fr 48px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.wl-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.wl-num {
  font-family: var(--font-mono);
  text-align: right;
  font-size: 11px;
}

.pixel-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.pixel-empty,
.pixel-unsupported {
  padding: 18px 14px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.pixel-ts-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--st-mod-bg);
  color: var(--st-mod-color);
  margin-bottom: 6px;
}

/* ============================================================================
   Modals, Drag Overlay, Toasts
   ============================================================================ */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.78);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  pointer-events: none;
}

.drag-overlay-box {
  padding: 36px 52px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--accent);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}
.drag-overlay-box span {
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 80;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-md { max-width: 540px; }
.modal-lg { max-width: 820px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.modal-body {
  padding: 16px 18px;
}
.modal-scroll {
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.modal-empty {
  padding: 36px;
  text-align: center;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 13px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dict-suggestions {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg-input);
}

.dict-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: none;
  border-bottom: 1px solid rgba(128, 128, 128, 0.08);
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.dict-item:hover {
  background: var(--bg-hover);
}
.dict-kw {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dict-empty {
  padding: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.vr-mini-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  margin-bottom: 13px;
}

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.diff-table th {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}
.diff-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.diff-cell-old {
  color: var(--text-muted);
  max-width: 180px;
  word-break: break-all;
}
.diff-cell-new {
  color: var(--text-primary);
  max-width: 200px;
  word-break: break-all;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  font-weight: 500;
  max-width: 360px;
  animation: toastIn 0.18s ease-out;
}
.toast-ok { border-left: 4px solid var(--st-add-color); }
.toast-warn { border-left: 4px solid var(--st-mod-color); }
.toast-error { border-left: 4px solid var(--st-err-color); }
.toast-info { border-left: 4px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive narrow viewport */
@media (max-width: 920px) {
  .editor-view {
    flex-direction: column;
  }
  .pane-resizer {
    display: none;
  }
  .side-pane {
    width: 100% !important;
    max-width: none;
    height: 46%;
    border-top: 2px solid var(--border);
  }
  .welcome-features {
    grid-template-columns: 1fr;
  }
  .tree-table-header,
  .tree-row {
    grid-template-columns: minmax(190px, 1.6fr) 46px 34px 48px minmax(120px, 1fr);
  }
}
