/* ELAN web — application styles */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --border: #d9dde3;
  --border-strong: #c3c8d0;
  --text: #1d2330;
  --muted: #6b7382;
  --accent: #2f6fdb;
  --accent-soft: #e5eeff;
  --danger: #c92a2a;
  --ok: #2b8a3e;
  --shadow: 0 8px 28px rgba(20, 30, 50, 0.18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-annot: system-ui, -apple-system, "Segoe UI", "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --tl-bg: #ffffff;
  --tl-ruler-bg: #f1f3f6;
  --tl-line: #e3e6eb;
  --tl-tick: #9aa1ad;
  --tl-text: #1d2330;
  --tl-active-row: #eef3ff;
  --tl-selection: rgba(47, 111, 219, 0.18);
  --tl-crosshair: #e03131;
  --tl-wave: #3b5b92;
  --tl-wave-bg: #fafbfc;
  --tl-beyond: rgba(120, 130, 150, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181e;
    --panel: #1c2028;
    --panel-2: #222731;
    --border: #2e3440;
    --border-strong: #3b4252;
    --text: #e3e7ee;
    --muted: #8e97a8;
    --accent: #5b8def;
    --accent-soft: #25324a;
    --danger: #ff6b6b;
    --ok: #51cf66;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    --tl-bg: #1a1e25;
    --tl-ruler-bg: #20252e;
    --tl-line: #2b313c;
    --tl-tick: #6c7486;
    --tl-text: #e3e7ee;
    --tl-active-row: #232c3d;
    --tl-selection: rgba(91, 141, 239, 0.25);
    --tl-crosshair: #ff6b6b;
    --tl-wave: #8fb0f0;
    --tl-wave-bg: #171a20;
    --tl-beyond: rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15181e;
  --panel: #1c2028;
  --panel-2: #222731;
  --border: #2e3440;
  --border-strong: #3b4252;
  --text: #e3e7ee;
  --muted: #8e97a8;
  --accent: #5b8def;
  --accent-soft: #25324a;
  --danger: #ff6b6b;
  --ok: #51cf66;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  --tl-bg: #1a1e25;
  --tl-ruler-bg: #20252e;
  --tl-line: #2b313c;
  --tl-tick: #6c7486;
  --tl-text: #e3e7ee;
  --tl-active-row: #232c3d;
  --tl-selection: rgba(91, 141, 239, 0.25);
  --tl-crosshair: #ff6b6b;
  --tl-wave: #8fb0f0;
  --tl-wave-bg: #171a20;
  --tl-beyond: rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.mono { font-family: var(--mono); }
.pad { padding: 10px; }
.spacer { flex: 1; }
.bad { color: var(--danger); }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.row.gap { gap: 8px; }
.row.center { justify-content: center; }
.row.end { align-self: flex-end; }

/* ------------------------------------------------------------- header */

.app-header {
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  min-height: 34px;
  flex: none;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  color: var(--accent);
}

.menubar { display: flex; align-items: stretch; }

.menubar-item {
  padding: 7px 10px;
  cursor: default;
  user-select: none;
  border-radius: 4px;
  margin: 2px 0;
}

.menubar-item:hover, .menubar-item.open { background: var(--accent-soft); }

.doc-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-left: 16px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}

.doc-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--panel-2);
  cursor: pointer;
  white-space: nowrap;
  max-width: 260px;
}

.doc-tab span { overflow: hidden; text-overflow: ellipsis; }
.doc-tab.active { background: var(--bg); font-weight: 600; }

/* ---------------------------------------------------------- workspace */

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.no-doc .workspace { display: none; }
body:not(.no-doc) .welcome { display: none; }

.upper {
  display: flex;
  min-height: 60px;
  flex: none;
  background: var(--panel);
}

.media-pane {
  flex: none;
  background: #0d0f13;
  display: flex;
  min-width: 120px;
  overflow: hidden;
}

.video-area {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
}

.video-box {
  position: relative;
  flex: 1 1 45%;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-area .video-box:only-child { flex-basis: 100%; }
.video-box video { max-width: 100%; max-height: 100%; display: block; }

.video-label {
  position: absolute;
  left: 6px;
  bottom: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 5px;
  border-radius: 3px;
}

.video-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  color: #ffb3b3;
  text-align: center;
  padding: 12px;
}

.no-video {
  color: #aab2c0;
  text-align: center;
  padding: 16px;
  align-self: center;
}

.audio-only { font-size: 15px; }
.missing { color: #ffb3b3; margin-top: 6px; }

.split-v {
  width: 5px;
  cursor: col-resize;
  background: var(--border);
  flex: none;
}

.split-h {
  height: 5px;
  cursor: row-resize;
  background: var(--border);
  flex: none;
}

.split-v:hover, .split-h:hover { background: var(--accent); }

.viewer-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 4px 6px 0;
  background: var(--panel-2);
  flex: none;
}

.tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  padding: 5px 12px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  color: var(--muted);
}

.tab.active {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
  margin-bottom: -1px;
}

.tab-body { flex: 1; min-height: 0; position: relative; }

.tab-panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.active { display: flex; }

.view-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  flex: none;
  flex-wrap: wrap;
}

.view-toolbar input[type=search] { flex: 1; min-width: 120px; }

/* ------------------------------------------------------ player controls */

.player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: none;
  flex-wrap: wrap;
}

.ctl-group { display: flex; align-items: center; gap: 3px; }

.ctl {
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
}

.ctl:hover { border-color: var(--accent); }
.ctl.play { min-width: 44px; font-size: 15px; background: var(--accent); color: white; border-color: var(--accent); }
.ctl.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ctl.dim { opacity: 0.5; }

.time-display {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  padding: 2px 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 5px;
  cursor: pointer;
  min-width: 140px;
  font-variant-numeric: tabular-nums;
}

.sel-display {
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel-2);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.sel-display.empty { color: var(--muted); }
.player-controls input[type=range] { width: 110px; }

/* ------------------------------------------------------------ bottom */

.bottom {
  flex: 1;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.timeline, .interlinear-pane, .transcription-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.interlinear-pane, .transcription-pane { overflow: hidden; }

.tl-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.tl-labels {
  flex: none;
  overflow: hidden;
  position: relative;
  border-right: 1px solid var(--border);
  background: var(--panel-2);
  user-select: none;
}

.tl-label-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}

.tl-wave-label {
  position: absolute;
  left: 0;
  right: 0;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-labels-inner { will-change: transform; }

.tl-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
  border-bottom: 1px solid var(--tl-line);
  white-space: nowrap;
  cursor: pointer;
  font-size: 12px;
}

.tl-label.active { background: var(--tl-active-row); font-weight: 600; }
.tl-label.drop-target { box-shadow: inset 0 2px 0 var(--accent); }
.tl-name { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tl-count { color: var(--muted); font-size: 10px; font-weight: 400; }

.tl-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: none;
  display: inline-block;
}

.tl-canvas-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.tl-canvas { display: block; outline: none; touch-action: none; }

.tl-hscroll, .tl-vscroll {
  position: relative;
  background: var(--panel-2);
  flex: none;
}

.tl-hscroll { height: 12px; border-top: 1px solid var(--border); margin-left: 0; }
.tl-vscroll { width: 12px; border-left: 1px solid var(--border); }

.tl-thumb {
  position: absolute;
  background: var(--border-strong);
  border-radius: 6px;
  cursor: grab;
}

.tl-hscroll .tl-thumb { top: 2px; height: 7px; }
.tl-vscroll .tl-thumb { left: 2px; width: 7px; }
.tl-thumb:hover { background: var(--accent); }

.tl-editor {
  position: absolute;
  z-index: 5;
  padding: 3px 5px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: var(--panel);
  resize: none;
  font: 13px/1.35 var(--font-annot);
  box-shadow: var(--shadow);
  overflow: hidden;
  outline: none;
}

.cv-list {
  position: absolute;
  z-index: 6;
  min-width: 220px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.cv-item { padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.cv-item.sel, .cv-item:hover { background: var(--accent-soft); }
.cv-item.empty { color: var(--muted); cursor: default; }
.cv-desc { color: var(--muted); }

/* ------------------------------------------------------------- views */

.grid-wrap { flex: 1; overflow: auto; }

table.data { border-collapse: collapse; width: 100%; font-size: 12px; }

table.data th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: left;
  font-weight: 600;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

table.data td { padding: 4px 8px; border-bottom: 1px solid var(--tl-line); vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; color: var(--muted); width: 1%; }
table.data td.time { font-family: var(--mono); white-space: nowrap; width: 1%; font-variant-numeric: tabular-nums; }
table.data td.value { white-space: pre-wrap; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.path { font-family: var(--mono); font-size: 11px; word-break: break-all; }
table.selectable tbody tr { cursor: pointer; }
table.selectable tbody tr:hover { background: var(--panel-2); }
table.data tr.sel { background: var(--accent-soft) !important; }
table.data tr.current td { box-shadow: inset 3px 0 0 var(--tl-crosshair); }
table.data td textarea, table.data td select { width: 100%; }
table.stats td.num { color: var(--text); text-align: right; width: auto; font-variant-numeric: tabular-nums; }

table.transcription td.cell { padding: 2px 4px; }

table.transcription textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  padding: 4px 6px;
  font: 14px/1.35 var(--font-annot);
  min-height: 30px;
}

table.transcription textarea:focus { border-color: var(--accent); background: var(--panel); outline: none; }

.text-view {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  font: 15px/1.8 var(--font-annot);
}

.text-ann { cursor: pointer; border-radius: 3px; padding: 0 1px; }
.text-ann:hover { background: var(--panel-2); }
.text-ann.current { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }

.subtitles {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
}

.sub-line { display: flex; flex-direction: column; gap: 2px; }
.sub-tier { font-size: 11px; font-weight: 600; }
.sub-text { font: 20px/1.4 var(--font-annot); min-height: 1.4em; }

.interlinear { flex: 1; overflow: auto; padding: 8px 12px; }

.il-block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: var(--panel);
}

.il-block.current { border-color: var(--tl-crosshair); }
.il-time { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 3px; cursor: pointer; }
.il-grid { display: grid; gap: 1px 14px; align-items: baseline; justify-content: start; overflow-x: auto; }
.il-label { font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.il-cell { cursor: pointer; border-radius: 3px; padding: 0 2px; font: 14px/1.5 var(--font-annot); white-space: nowrap; }
.il-cell:hover { background: var(--panel-2); }
.il-cell.sel { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }

.search-form { padding: 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.search-form input[type=search], .search-form input[type=text] { flex: 1; }
.search-results { flex: 1; overflow: auto; }

.search-row {
  display: flex;
  gap: 10px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--tl-line);
  cursor: pointer;
  align-items: baseline;
}

.search-row:hover { background: var(--panel-2); }
.sr-tier { width: 110px; flex: none; font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-time { font-family: var(--mono); font-size: 11px; color: var(--muted); flex: none; }
.sr-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
mark { background: #ffe066; color: #1d2330; border-radius: 2px; }

.controls-view { padding: 10px 14px; overflow: auto; }
.controls-view h3 { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.ctrl-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.ctrl-label { width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ status */

.status-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex: none;
  white-space: nowrap;
  overflow: hidden;
}

.st-file { color: var(--text); overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.badge { background: var(--accent); color: white; border-radius: 4px; padding: 0 6px; font-weight: 600; }

/* ----------------------------------------------------------- welcome */

.welcome { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; }

.welcome-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 40px;
  width: min(620px, 92vw);
  text-align: center;
  box-shadow: 0 2px 10px rgba(20, 30, 50, 0.06);
}

.welcome-box h1 { margin: 0; font-size: 38px; color: var(--accent); letter-spacing: 0.05em; }
.recent { text-align: left; margin-top: 24px; }
.recent h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }

.recent-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.recent-item:hover { background: var(--accent-soft); }
.recent-item span { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body.dropping::after {
  content: 'Drop files to open them';
  position: fixed;
  inset: 12px;
  border: 3px dashed var(--accent);
  border-radius: 14px;
  background: rgba(47, 111, 219, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
  z-index: 100;
  pointer-events: none;
}

/* -------------------------------------------------------------- menus */

.menu {
  position: fixed;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  box-shadow: var(--shadow);
  padding: 4px;
  min-width: 220px;
  user-select: none;
}

.menu.submenu { position: absolute; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 4px;
  border-radius: 4px;
  cursor: default;
  white-space: nowrap;
}

.menu-item.hover, .menu-item:hover:not(.disabled) { background: var(--accent); color: white; }
.menu-item.hover .menu-shortcut, .menu-item:hover:not(.disabled) .menu-shortcut { color: rgba(255, 255, 255, 0.85); }
.menu-item.disabled { color: var(--muted); opacity: 0.6; }
.menu-check { width: 16px; text-align: center; flex: none; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; max-width: 480px; }
.menu-shortcut { color: var(--muted); font-size: 11px; margin-left: 24px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.menu-header { padding: 4px 10px; font-size: 11px; color: var(--muted); font-weight: 600; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ dialogs */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 25, 0.35);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog {
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.dialog-header h2 { margin: 0; font-size: 15px; }
.dialog-body { padding: 4px 16px 12px; overflow: auto; }
.dialog-body h3 { font-size: 12px; margin: 14px 0 6px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.dialog-footer .left:first-child { margin-right: auto; }
.dialog-footer .left + .left { margin-right: auto; }
.message { margin: 4px 0 8px; white-space: pre-wrap; }

.btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  cursor: pointer;
}

.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.danger { color: var(--danger); }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn.small { padding: 3px 9px; font-size: 12px; }

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.icon-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }

.link { border: none; background: none; color: var(--accent); cursor: pointer; padding: 0 4px; }

input[type=text], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 5px 7px;
  background: var(--panel);
  min-width: 0;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; flex: 1; min-width: 120px; }
.field > label { font-size: 12px; font-weight: 600; }
.hint { font-size: 11px; color: var(--muted); margin: 2px 0 6px; }
.check { display: flex; align-items: center; gap: 4px; margin: 5px 0; cursor: pointer; }
.check.small { font-size: 12px; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid > .field:first-child { grid-column: 1 / -1; }
.form-grid > .check { grid-column: 1 / -1; }

.check-list-wrap { border: 1px solid var(--border); border-radius: 6px; }
.check-tools { padding: 3px 6px; border-bottom: 1px solid var(--border); font-size: 11px; }
.check-list { max-height: 220px; overflow: auto; padding: 2px 8px; }

.info-grid { display: grid; grid-template-columns: 110px 1fr; gap: 3px 12px; margin-bottom: 8px; font-size: 12px; }
.info-grid span:nth-child(odd) { color: var(--muted); }
.kv-rows { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.kv input { flex: 1; }

.cv-editor { display: flex; gap: 12px; min-height: 360px; }
.cv-names { width: 190px; flex: none; border: 1px solid var(--border); border-radius: 6px; overflow: auto; max-height: 460px; }
.cv-name { padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--tl-line); }
.cv-name.sel { background: var(--accent-soft); font-weight: 600; }
.cv-entries { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cv-table-wrap { flex: 1; overflow: auto; max-height: 260px; border: 1px solid var(--border); border-radius: 6px; }
.cv-entries .row input { flex: 1; }

.file-dialog { display: flex; flex-direction: column; gap: 8px; }
.path-input { flex: 1; font-family: var(--mono); font-size: 12px; }
.file-list { height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; outline: none; }

.file-row {
  display: grid;
  grid-template-columns: 22px 1fr 80px 90px;
  gap: 6px;
  padding: 4px 8px;
  cursor: default;
  align-items: center;
  user-select: none;
}

.file-row:hover { background: var(--panel-2); }
.file-row.sel { background: var(--accent); color: white; }
.file-row.sel .file-size, .file-row.sel .file-date { color: rgba(255, 255, 255, 0.8); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size, .file-date { color: var(--muted); font-size: 11px; text-align: right; }
.media-choice { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.media-choice .path { font-family: var(--mono); font-size: 11px; flex: 1; word-break: break-all; }

.shortcuts td.kbd { font-family: var(--mono); white-space: nowrap; width: 1%; padding-right: 20px; }

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(20px);
  background: #232937;
  color: white;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
  max-width: min(640px, 90vw);
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ------------------------------------------------------------ tools & jobs */

.job { display: flex; flex-direction: column; gap: 8px; }
.job-progress { width: 100%; height: 14px; }
.job-log, .result-text {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.job-log:empty { display: none; }
.result-text { max-height: 60vh; }
.table-scroll { max-height: 60vh; overflow: auto; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover { background: var(--accent-soft); }

.file-set {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  max-height: 160px;
  overflow: auto;
}
.file-set .path { font-family: var(--mono); font-size: 11px; flex: 1; word-break: break-all; }

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  margin: 1px 2px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}
button.chip { cursor: pointer; }
button.chip:hover { background: var(--accent-soft); border-color: var(--accent); }

.lexan-row { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin-bottom: 8px; }
.check-list.small { max-height: 110px; }
.sugg-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.sugg-set {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
}
.sugg-set:hover { border-color: var(--accent); }
.sugg-set.sel { background: var(--accent-soft); border-color: var(--accent); }
.sugg-tier { font-size: 10px; color: var(--muted); }
.sugg-children { padding-left: 14px; border-left: 2px solid var(--border); margin: 2px 0 2px 4px; }

.spell-results { max-height: 60vh; overflow: auto; }
.spell-row { border-bottom: 1px solid var(--tl-line); padding: 6px 0; }
.spell-value { cursor: pointer; white-space: pre-wrap; }
.spell-value:hover { color: var(--accent); }
.spell-word { margin: 3px 0 0 10px; }
.misspelled { text-decoration: underline wavy var(--danger); }

.tierset { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--tl-line); padding: 6px 0; }
.tierset .grow, .grow { flex: 1; min-width: 0; }

/* character palette */
.char-palette {
  position: fixed;
  right: 20px;
  bottom: 60px;
  width: 360px;
  z-index: 900;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px;
}
.char-head { display: flex; align-items: center; gap: 8px; cursor: move; margin-bottom: 6px; }
.char-head select { flex: 1; }
.char-grid { display: flex; flex-wrap: wrap; gap: 3px; }
.char {
  min-width: 30px;
  height: 30px;
  font-size: 17px;
  font-family: var(--font-annot);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
.char:hover { background: var(--accent-soft); border-color: var(--accent); }

/* comments and metadata viewers */
.viewer-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.viewer-toolbar input[type=search] { flex: 1; min-width: 120px; }
.tab-panel .comment-list, .tab-panel .metadata { flex: 1; overflow: auto; padding: 4px 8px; }
.tab-panel[data-tab=comments], .tab-panel[data-tab=metadata] { flex-direction: column; }
.comment { border-bottom: 1px solid var(--tl-line); padding: 6px 0; }
.comment.resolved { opacity: 0.6; }
.comment-head { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.comment-head .spacer { flex: 1; }
.comment-text { white-space: pre-wrap; margin-top: 3px; }
.metadata h3 { margin: 8px 0 4px; font-size: 13px; }
.md-node { margin-left: 12px; }
.md-node > summary { cursor: pointer; }
.md-leaf { margin-left: 26px; font-size: 12px; }
.md-node > summary { font-size: 12px; }

/* printing */
.print-view { display: none; }
@media print {
  body.printing > *:not(.print-view) { display: none !important; }
  body.printing .print-view { display: block; color: #000; background: #fff; font-family: var(--font-annot); }
  body.printing { background: #fff; overflow: visible; height: auto; }
  .print-view h1 { font-size: 18px; margin: 0 0 2px; }
  .print-block { break-inside: avoid; margin: 10px 0; }
  .print-table { border-collapse: collapse; width: 100%; font-size: 11pt; }
  .print-table td { padding: 1px 6px; vertical-align: top; }
  .pt-tier { color: #555; font-size: 9pt; width: 1%; white-space: nowrap; }
  .pt-time { color: #555; font-size: 9pt; font-family: var(--mono); white-space: nowrap; }
}

/* lexicons and data categories */
.lex-names { min-height: 260px; }
.lex-right { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lex-table { max-height: 46vh; }
.row.wrap { flex-wrap: wrap; }
.entry-editor { max-height: 70vh; overflow: auto; padding-right: 4px; }
.sense-box { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin: 0 0 8px; }
.sense-box legend { font-size: 12px; color: var(--muted); }
.tl-rows { display: flex; flex-direction: column; gap: 4px; }
.tl-rows .row input:first-child { flex: 1; }
.dc-table { max-height: 50vh; }
.lexv-results { flex: 1; overflow: auto; padding: 4px 8px; }
.tab-panel[data-tab=lexicon] { flex-direction: column; }
.lexv-entry { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; margin: 4px 0; cursor: pointer; }
.lexv-entry:hover { border-color: var(--accent); }
.lexv-entry.sel { background: var(--accent-soft); border-color: var(--accent); }
.lexv-tree { margin: 2px 0 0 0; padding-left: 16px; font-size: 12px; }
