:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-2: #F3F2EE;
  --surface-3: #EAE8E1;
  --border: #E6E4DD;
  --border-strong: #CFCBC0;
  --ink: #1A1A18;
  --ink-2: #3A3935;
  --muted: #65635D;
  --accent: #2E4A8F;
  --accent-hover: #21376D;
  --accent-soft: #EDF1FA;
  --warn-bg: #FEF6E7;
  --warn-border: #F2D299;
  --warn-ink: #8A4F0B;
  --danger-bg: #FEF2F2;
  --danger-border: #F5C2C0;
  --danger-ink: #A61D24;
  --ok-bg: #EEF8F2;
  --ok-border: #B5DFC5;
  --ok-ink: #14633E;
  --radius: 10px;
  --radius-sm: 6px;
  --ctrl-h: 34px;
  --shadow-sm: 0 1px 2px rgba(26, 26, 24, 0.04);
  --font-sans: 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.status-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 500;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ok-ink);
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(26, 26, 24, 0.12);
  display: none;
}

.status-toast.visible {
  display: inline-block;
}

/* Buttons & Inputs — Unified Control Height */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctrl-h);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

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

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

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

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-sm {
  height: var(--ctrl-h);
  font-size: 12.5px;
  padding: 0 10px;
}

.icon-btn {
  width: var(--ctrl-h);
  height: var(--ctrl-h);
  padding: 0;
  gap: 0;
}

.icon-btn-sm {
  width: 28px;
  height: 28px;
  padding: 0;
  gap: 0;
}

.icon-btn svg,
.icon-btn-sm svg {
  display: block;
  flex-shrink: 0;
}

.input, .select {
  height: var(--ctrl-h);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.input-sm {
  height: var(--ctrl-h);
  font-size: 13px;
  padding: 0 9px;
  width: 100%;
}

.mobile-only {
  display: none;
}

/* Workspace */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 24px;
}

.nav-section {
  margin-bottom: 18px;
}

.nav-section-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 4px 8px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pack-box {
  margin-bottom: 10px;
}

.pack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.pack-meta-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: 999px;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.file-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
  transition: background 0.1s;
}

.file-link:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.file-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.25;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge-eval {
  background: var(--accent-soft);
  border-color: #CBD7F5;
  color: var(--accent);
}

.badge-md {
  background: #F4F1FA;
  border-color: #DCD3F2;
  color: #5B3D99;
}

.badge-jsonl {
  background: #EFF7F4;
  border-color: #C7E3D7;
  color: #1D6849;
}

.badge-json {
  background: #FFF7EB;
  border-color: #F2D7AE;
  color: #8A5410;
}

.raw-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}

.raw-open-link:hover {
  background: var(--surface-2);
  color: var(--accent);
  text-decoration: none;
}

.corpus-details summary {
  cursor: pointer;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
}

.corpus-details summary:hover {
  background: var(--surface-2);
}

.corpus-group-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 8px 2px;
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 28px 48px;
}

.main-content {
  max-width: 960px;
  margin: 0 auto;
}

.loading-box, .error-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--muted);
}

.error-box {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-ink);
}

/* Pack Summary Strip */
.pack-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.pack-strip-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pack-strip-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.pack-strip-stats {
  font-size: 13px;
  color: var(--muted);
}

.companion-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.companion-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  text-decoration: none;
}

.companion-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

/* Filter Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: 1.6fr 1fr 0.85fr 0.85fr auto auto auto;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
  overflow: visible;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  height: var(--ctrl-h);
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font-sans);
  transition: border-color 0.12s, background 0.12s;
}

.lang-toggle:hover {
  border-color: var(--accent);
}

.lang-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.lang-seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--ctrl-h) - 6px);
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.lang-seg.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(26, 26, 24, 0.08);
}

/* Custom In-DOM Dropdown (works reliably in Electron/Orca webviews & all browsers) */
.cselect {
  position: relative;
  min-width: 0;
}

.cselect-trigger {
  width: 100%;
  height: var(--ctrl-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.cselect-trigger:hover {
  border-color: var(--accent);
}

.cselect.open .cselect-trigger,
.cselect-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.cselect-trigger.has-value {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.cselect-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cselect-chevron {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.12s;
}

.cselect.open .cselect-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.cselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: min(560px, 88vw);
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(26, 26, 24, 0.14);
  padding: 4px;
  z-index: 200;
}

.cselect-menu[hidden] {
  display: none;
}

.cselect.item-select .cselect-menu {
  width: min(620px, 88vw);
  max-width: min(620px, 88vw);
}

.cselect-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.cselect-option:hover,
.cselect-option:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.cselect-option.selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.cselect-opt-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cselect.item-select .cselect-opt-text {
  white-space: normal;
  word-break: keep-all;
}

.cselect-check {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

/* Item Navigator Bar */
.item-nav-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 14px;
}

.item-nav-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.item-select {
  flex: 1;
  min-width: 160px;
  max-width: 580px;
}

.item-pos {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  padding: 0 4px;
}

/* Passage Document Surface — Calm AI Output Style (Claude / ChatGPT / Antigravity) */
.card {
  background: var(--surface);
  border: 1px solid rgba(26, 26, 24, 0.09);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(26, 26, 24, 0.03);
  overflow: hidden;
}

.card-header {
  padding: 24px 32px 12px;
}

.card-eyebrow {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
  overflow: hidden;
}

.eval-id-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.3;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  white-space: nowrap;
  flex-shrink: 0;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.meta-pill.diff-advanced {
  background: #F6F0FC;
  border-color: #E3D6F5;
  color: #653C9E;
}

.meta-pill.diff-intermediate {
  background: var(--accent-soft);
  border-color: #D2DCF5;
  color: var(--accent);
}

.card-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.42;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.concept-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow: hidden;
}

.concept-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Minimal Underline Tabs */
.tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 32px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 18px;
}

.tab-btn {
  position: relative;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 2px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}

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

.tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.card-body {
  padding: 22px 32px 32px;
}

/* AI-Assistant Output Typography (Claude Code / ChatGPT / Antigravity) */
.ai-doc {
  font-size: 15px;
  line-height: 1.78;
  color: #242421;
}

.ai-doc p {
  margin: 0 0 13px;
  white-space: pre-line;
}

.ai-doc p:last-child {
  margin-bottom: 0;
}

.ai-doc h3 {
  margin: 22px 0 7px;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.ai-doc h3:first-child {
  margin-top: 0;
}

.ai-doc hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}

.ai-doc ol,
.ai-doc ul {
  margin: 6px 0 14px;
  padding-left: 20px;
}

.ai-doc li {
  margin-bottom: 7px;
  padding-left: 2px;
}

.ai-doc li:last-child {
  margin-bottom: 0;
}

.ai-doc blockquote {
  margin: 12px 0;
  padding: 6px 14px;
  border-left: 2.5px solid var(--border-strong);
  color: var(--ink-2);
}

.ai-doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  line-height: 1.5;
}

.ai-doc th,
.ai-doc td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

.ai-doc th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--ink);
}

.ai-doc-footer {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.ai-doc-footer code {
  font-size: 11px;
  background: var(--surface-2);
  border: none;
  padding: 1px 5px;
}

.prose-section {
  margin-bottom: 20px;
}

.prose-section:last-child {
  margin-bottom: 0;
}

.prose-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.prose-section h3:not(:first-child) {
  margin-top: 20px;
}

.prose-section p {
  margin: 0 0 10px;
  color: var(--ink);
  white-space: pre-line;
}

.question-list {
  margin: 0;
  padding-left: 20px;
}

.question-list li {
  margin-bottom: 10px;
  padding-left: 4px;
}

.notice-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 18px;
}

.notice-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-ink);
}

.notice-info {
  background: var(--accent-soft);
  border: 1px solid #CBD7F5;
  color: var(--accent);
}

.signal-list {
  margin: 0;
  padding-left: 20px;
}

.signal-list li {
  margin-bottom: 7px;
}

.trace-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink-2);
}

.trace-box div {
  margin-bottom: 4px;
}

.trace-box div:last-child {
  margin-bottom: 0;
}

/* Tables — Strictly Single-Line Rows with Floating Hover Tooltip */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

table.data-table th,
table.data-table td {
  padding: 0 10px;
  height: 36px;
  line-height: 36px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

table.data-table th {
  height: 32px;
  line-height: 32px;
  font-size: 11.5px;
  background: var(--surface-2);
  font-weight: 700;
  color: var(--muted);
}

table.data-table .col-id {
  width: 96px;
}

table.data-table .col-title {
  width: auto;
}

table.data-table .col-domain {
  width: 122px;
  color: var(--ink-2);
}

table.data-table .col-diff {
  width: 56px;
  text-align: center;
}

table.data-table .col-roles {
  width: 144px;
  color: var(--muted);
  font-size: 12px;
}

table.data-table .id-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  padding: 2px 5px;
  border-radius: 4px;
}

table.data-table tr.clickable-row {
  cursor: pointer;
}

table.data-table tr.clickable-row:hover td {
  background: var(--accent-soft);
}

/* Rich Floating Tooltip for Table Rows & Compact Badges */
.floating-tooltip {
  position: fixed;
  z-index: 400;
  max-width: 460px;
  background: #1C1B19;
  color: #F8F7F4;
  border-radius: 8px;
  padding: 10px 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}

.floating-tooltip[hidden] {
  display: none;
}

.ft-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 11px;
  color: #C9C6BE;
}

.ft-id {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #93B4FF;
}

.ft-title {
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 6px;
  word-break: keep-all;
}

.ft-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: #D8D5CE;
}

.ft-concepts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.ft-chip {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  color: #EAE8E1;
}

/* Markdown Viewer */
.doc-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.doc-title-area h2 {
  margin: 0 0 2px;
  font-size: 16.5px;
}

.doc-meta {
  font-size: 12.5px;
  color: var(--muted);
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toc-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 14px;
}

.toc-box summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.toc-list {
  list-style: none;
  margin: 10px 0 4px;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
}

.toc-list li {
  margin-bottom: 4px;
  font-size: 13px;
}

.toc-list li.toc-h2 { padding-left: 12px; }
.toc-list li.toc-h3 { padding-left: 26px; color: var(--muted); }

.toc-jump {
  background: none;
  border: none;
  padding: 2px 4px;
  font-family: var(--font-sans);
  font-size: inherit;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}

.toc-jump:hover {
  text-decoration: underline;
}

.markdown-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}

.markdown-body h1 { font-size: 22px; margin: 0 0 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.markdown-body h2 { font-size: 18px; margin: 24px 0 10px; color: var(--ink); }
.markdown-body h3 { font-size: 15.5px; margin: 16px 0 8px; color: var(--accent); }
.markdown-body p { margin: 0 0 10px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.markdown-body blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: var(--bg);
  color: var(--ink-2);
}
.markdown-body ul, .markdown-body ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}
.markdown-body li {
  margin-bottom: 4px;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
.markdown-body th {
  background: var(--surface-2);
  font-weight: 700;
}

/* JSONL generic viewer */
.jsonl-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jsonl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.jsonl-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.jsonl-card-title {
  font-weight: 700;
  font-size: 15px;
}

.jsonl-card-body {
  font-size: 14px;
  color: var(--ink-2);
  white-space: pre-line;
  margin-bottom: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0;
}

/* Drag overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.drop-overlay[hidden] {
  display: none;
}

.drop-box {
  background: var(--surface);
  border: 2px dashed var(--accent);
  border-radius: 14px;
  padding: 36px 48px;
  text-align: center;
}

.drop-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

@media (max-width: 980px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 57px;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.08);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    padding: 14px 14px 36px;
  }
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }
}

/* A4 Print Sheet (Passage tab content only) */
.print-sheet {
  display: none;
}

@page {
  size: A4 portrait;
  margin: 16mm 18mm;
}

@media print {
  html, body {
    height: auto !important;
    overflow: visible !important;
    background: #FFFFFF !important;
    color: #111111 !important;
    font-size: 10.5pt !important;
    line-height: 1.68 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell,
  .drop-overlay,
  .floating-tooltip,
  .status-toast {
    display: none !important;
  }

  .print-sheet {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
    color: #111111;
  }

  .print-sheet-meta {
    font-size: 8.5pt;
    color: #555555;
    margin-bottom: 5px;
  }

  .print-sheet-title {
    margin: 0 0 14px;
    font-size: 14.5pt;
    font-weight: 700;
    line-height: 1.38;
    color: #111111;
    page-break-after: avoid;
    break-after: avoid;
  }

  .print-sheet .ai-doc {
    font-size: 10.5pt;
    line-height: 1.68;
    color: #1A1A1A;
  }

  .print-sheet .ai-doc h3 {
    margin: 14px 0 4px;
    font-size: 11pt;
    font-weight: 700;
    color: #111111;
    page-break-after: avoid;
    break-after: avoid;
  }

  .print-sheet .ai-doc p {
    margin: 0 0 9px;
    orphans: 3;
    widows: 3;
  }

  .print-sheet .ai-doc hr {
    border: none;
    border-top: 1px solid #D4D4D0;
    margin: 14px 0;
  }

  .print-sheet .ai-doc ol,
  .print-sheet .ai-doc ul {
    margin: 4px 0 10px;
    padding-left: 18px;
  }

  .print-sheet .ai-doc li {
    margin-bottom: 6px;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .print-sheet code {
    font-size: 9pt;
    background: #F2F2EE;
    border: 1px solid #E0DFD9;
    padding: 0.5px 4px;
    border-radius: 3px;
  }

  .print-sheet .ai-doc table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 9pt;
    line-height: 1.45;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .print-sheet .ai-doc th,
  .print-sheet .ai-doc td {
    border: 1px solid #D4D4D0;
    padding: 4px 7px;
    text-align: left;
    vertical-align: top;
  }

  .print-sheet .ai-doc th {
    background: #F3F2EE;
    font-weight: 600;
  }
}
