:root {
  /* Nord palette */
  --nord0: #2E3440;
  --nord1: #3B4252;
  --nord2: #434C5E;
  --nord3: #4C566A;
  --nord4: #D8DEE9;
  --nord5: #E5E9F0;
  --nord6: #ECEFF4;
  --nord7: #8FBCBB;
  --nord8: #88C0D0;
  --nord9: #81A1C1;
  --nord10: #5E81AC;
  --nord11: #BF616A;
  --nord13: #EBCB8B;
  --nord14: #A3BE8C;

  --bg-primary: #1a1e26;
  --bg-secondary: #242933;
  --bg-tertiary: #2e3440;
  --bg-card: rgba(59, 66, 82, 0.4);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-muted: rgba(255, 255, 255, 0.03);

  --text-primary: var(--nord6);
  --text-secondary: var(--nord4);
  --text-muted: #7b88a1;

  --accent: var(--nord8);
  --success: var(--nord14);
  --warning: var(--nord13);
  --error: var(--nord11);

  --mono: 'SF Mono', 'Fira Code', 'Fira Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);

  --transition: 150ms ease;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Main layout - full viewport, no separate header */
main {
  flex: 1 1 auto;
  display: flex;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar - full height left panel */
#sidebar {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
}

/* Sidebar header (replaces top-level header) */
.sidebar-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
}

.sidebar-header .logo {
  flex-shrink: 0;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sidebar-header .subtitle {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* Controls */
#controls {
  flex: 0 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.control-row {
  display: flex;
  gap: 8px;
}

.control-row button {
  flex: 1;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Buttons */
button {
  appearance: none;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border-subtle);
}

button:hover {
  background: var(--nord2);
  border-color: var(--border-subtle);
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--nord10);
  border-color: var(--nord10);
  color: white;
}

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

/* Compare button enabled state (with baseline) */
#compareBtn.btn-primary {
  background: var(--nord10);
  border-color: var(--nord10);
  color: white;
}

#compareBtn.btn-primary:hover {
  background: var(--nord9);
  border-color: var(--nord9);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Select */
select {
  appearance: none;
  background: var(--bg-tertiary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237b88a1' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}

select:hover {
  border-color: var(--nord3);
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(136, 192, 208, 0.15);
}

/* Paste section */
.paste-section {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.paste-section summary {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition);
}

.paste-section summary:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.paste-section[open] summary {
  border-bottom: 1px solid var(--border-subtle);
}

.paste-section textarea {
  display: block;
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: none;
  border-radius: 0;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}

.paste-section textarea:focus {
  outline: none;
}

.paste-section button {
  width: 100%;
  border-radius: 0;
  border-top: 1px solid var(--border-subtle);
}

/* Tests list */
#tests {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#tests h2 {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
}

#testsList {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 6px;
}

.test-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  transition: background var(--transition);
}

.test-item:hover {
  background: var(--bg-tertiary);
}

.test-item input[type="checkbox"] {
  flex-shrink: 0;
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.test-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.test-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.2;
}

.test-name label {
  cursor: pointer;
}

.test-title {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

.test-item button {
  flex-shrink: 0;
  padding: 4px 8px;
  font-size: 11px;
}

/* Results panel - maximized space */
#results {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Loading overlay for initial tests run */
#results.loading {
  position: relative;
}

.results-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Fully opaque overlay to completely obscure underlying UI while tests run */
  background: rgba(26,30,38,1);
  z-index: 1200;
  pointer-events: auto;
}

.results-overlay .overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}

.results-overlay .spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.06);
  border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}

.results-overlay .overlay-text {
  font-size: 13px;
  color: var(--text-muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#resultsHeader {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.results-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#resultsHeader h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

#summary {
  font-size: 13px;
  color: var(--text-muted);
}

#summary.has-diffs {
  color: var(--warning);
}

#summary.no-diffs {
  color: var(--success);
}

/* Tabs - compact */
.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  padding: 6px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.tab.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

/* Tab badge */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--warning);
  color: var(--bg-primary);
  border-radius: 9px;
}

.tab-badge.hidden {
  display: none;
}

/* Panels */
#panels {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 12px 16px;
}

.panel.active {
  display: flex;
}

/* Panel toolbar */
.panel-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.panel-toolbar-right {
  display: flex;
  gap: 6px;
}

/* Search box */
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  min-width: 280px;
  max-width: 350px;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(136, 192, 208, 0.15);
}

.search-box svg {
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  min-width: 80px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}

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

.search-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0 4px;
}

.search-count.has-matches {
  color: var(--success);
}

.search-count.no-matches {
  color: var(--error);
}

.search-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.search-nav:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.search-nav:active {
  transform: scale(0.9);
}

/* JSON validity indicator */
.json-validity-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.json-validity-indicator.valid {
  display: flex;
  background: rgba(163, 190, 140, 0.15);
  color: var(--success);
}

.json-validity-indicator.invalid {
  display: flex;
  background: rgba(191, 97, 106, 0.15);
  color: var(--error);
}

.json-validity-indicator::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--nord2);
  color: var(--text-primary);
}

.btn-icon:active {
  transform: scale(0.95);
}

.btn-icon.active {
  background: var(--nord10);
  border-color: var(--nord10);
  color: white;
}

.btn-icon-danger:hover {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

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

.btn-icon:disabled:hover {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* Toolbar separator */
.toolbar-separator {
  width: 1px;
  height: 24px; /* slightly taller to align with icon buttons */
  background: var(--border-subtle);
  margin: 0 6px;
  align-self: center; /* vertically center within toolbar */
}

/* Temporary active feedback for toolbar buttons */
.btn-icon.active-temp {
  transform: scale(0.96);
  background: var(--nord2);
  color: var(--text-primary);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state.hidden {
  display: none;
}

/* Baseline editor placeholder shown when no baseline is loaded */
.editor-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  padding: 16px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
}

/* JSON output */
.json-output {
  display: none;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  resize: none;
  overflow: auto;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.json-output.has-content {
  display: block;
}

/* Hide fallback textarea when CodeMirror is active */
.json-output-fallback.cm-hidden {
  display: none !important;
}

.json-output.editable {
  border-color: var(--nord10);
  box-shadow: 0 0 0 2px rgba(94, 129, 172, 0.2);
  background: var(--bg-tertiary);
}

.json-output.invalid-json {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(191, 97, 106, 0.2);
}

/* CodeMirror editor wrapper */
.json-editor-wrapper {
  display: none;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.json-editor-wrapper.has-content {
  display: flex;
  flex-direction: column;
}

.json-editor-wrapper.editable {
  display: flex;
  flex-direction: column;
  border-color: var(--nord10);
  box-shadow: 0 0 0 2px rgba(94, 129, 172, 0.2);
}

.json-editor-wrapper.invalid-json {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(191, 97, 106, 0.2);
}

/* CodeMirror 5 Nord Theme */
.json-editor-wrapper .CodeMirror {
  flex: 1 1 auto;
  height: auto;
  min-height: 100%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

.json-editor-wrapper .CodeMirror-gutters {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.json-editor-wrapper .CodeMirror-linenumber {
  color: var(--text-muted);
}

.json-editor-wrapper .CodeMirror-cursor {
  border-left: 2px solid var(--accent);
}

.json-editor-wrapper .CodeMirror-selected {
  background: rgba(136, 192, 208, 0.25);
}

.json-editor-wrapper .CodeMirror-focused .CodeMirror-selected {
  background: rgba(136, 192, 208, 0.35);
}

.json-editor-wrapper .CodeMirror-activeline-background {
  background: rgba(67, 76, 94, 0.2);
}

.json-editor-wrapper .CodeMirror-activeline-gutter {
  background: rgba(67, 76, 94, 0.3);
}

.json-editor-wrapper .CodeMirror-matchingbracket {
  background: rgba(136, 192, 208, 0.3);
  color: var(--text-primary) !important;
  outline: 1px solid rgba(136, 192, 208, 0.5);
}

/* JSON syntax highlighting (Nord colors) */
.json-editor-wrapper .cm-string {
  color: #A3BE8C;
}

.json-editor-wrapper .cm-string-2 {
  color: #A3BE8C;
}

.json-editor-wrapper .cm-number {
  color: #B48EAD;
}

.json-editor-wrapper .cm-keyword {
  color: #81A1C1;
}

.json-editor-wrapper .cm-atom {
  color: #81A1C1;
}

.json-editor-wrapper .cm-property {
  color: #88C0D0;
}

.json-editor-wrapper .cm-punctuation,
.json-editor-wrapper .cm-bracket {
  color: #ECEFF4;
}

/* Search match highlighting */
.json-editor-wrapper .CodeMirror-searching {
  background: rgba(235, 203, 139, 0.4);
  outline: 1px solid rgba(235, 203, 139, 0.6);
}

/* Scrollbar styling for CodeMirror */
.json-editor-wrapper .CodeMirror-vscrollbar,
.json-editor-wrapper .CodeMirror-hscrollbar {
  outline: none;
}

.json-editor-wrapper .CodeMirror-scroll {
  overflow: auto !important;
}

/* CodeMirror fold gutter - bigger buttons */
.json-editor-wrapper .CodeMirror-foldgutter {
  width: 16px;
}

.json-editor-wrapper .CodeMirror-foldgutter-open,
.json-editor-wrapper .CodeMirror-foldgutter-folded {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  text-align: center;
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.json-editor-wrapper .CodeMirror-foldgutter-open:hover,
.json-editor-wrapper .CodeMirror-foldgutter-folded:hover {
  color: var(--accent);
}

.json-editor-wrapper .CodeMirror-foldgutter-open::after {
  content: "\25BC";  /* Down arrow - expanded */
  font-size: 10px;
}

.json-editor-wrapper .CodeMirror-foldgutter-folded::after {
  content: "\25B6";  /* Right arrow - collapsed */
  font-size: 10px;
}

/* Fold marker (collapsed region indicator) */
.json-editor-wrapper .CodeMirror-foldmarker {
  color: var(--accent);
  text-shadow: none;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  background: var(--bg-tertiary);
  padding: 0 4px;
  border-radius: 3px;
  margin: 0 2px;
}

/* Search highlight */
.json-output mark {
  background: var(--warning);
  color: var(--bg-primary);
  padding: 1px 2px;
  border-radius: 2px;
}

/* Diff tree */
.diff-tree {
  display: none;
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.diff-tree.has-content {
  display: block;
}

.diff-node {
  padding: 4px 0;
}

.diff-node details {
  margin: 0;
}

.diff-node summary {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  user-select: none;
  list-style: none;
}

.diff-node summary::-webkit-details-marker {
  display: none;
}

.diff-node summary::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: middle;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%237b88a1' d='M6 4l4 4-4 4'/%3E%3C/svg%3E");
  background-size: contain;
  transition: transform var(--transition);
}

.diff-node details[open] > summary::before {
  transform: rotate(90deg);
}

.diff-node summary:hover {
  background: var(--bg-tertiary);
}

.diff-node .key {
  font-weight: 600;
  color: var(--text-primary);
}

.diff-node .children {
  padding-left: 20px;
  border-left: 1px solid var(--border-subtle);
  margin-left: 7px;
}

.diff-leaf {
  padding: 6px 8px 6px 28px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.diff-leaf:hover {
  background: var(--bg-tertiary);
}

.diff-leaf .key {
  font-weight: 600;
}

.diff-added {
  color: var(--success);
}

.diff-removed {
  color: var(--error);
}

.diff-changed {
  color: var(--warning);
}

.diff-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

.diff-value-old {
  text-decoration: line-through;
  opacity: 0.7;
}

.diff-array-info {
  font-size: 12px;
  margin-top: 4px;
  padding-left: 28px;
}

.diff-array-preview {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Diff tree improvements for large diffs */
.diff-child-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: 4px;
}

.diff-lazy-placeholder {
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.diff-show-more {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-top: 4px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.diff-show-more:hover {
  background: var(--nord2);
  border-color: var(--accent);
}

.diff-arrow {
  color: var(--text-muted);
  margin: 0 4px;
}

.diff-array-details {
  margin-top: 4px;
}

.diff-array-details summary {
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.diff-array-details summary:hover {
  background: var(--bg-tertiary);
}

.diff-array-content {
  margin: 4px 0 0 16px;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow: auto;
}

/* Toast notifications */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  animation: toastIn 200ms ease, toastOut 200ms ease 2.8s forwards;
  pointer-events: auto;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--error);
}

.toast.info {
  border-left: 3px solid var(--accent);
}

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

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--nord3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--nord2);
}

/* Responsive */
@media (max-width: 900px) {
  main {
    flex-direction: column;
    height: auto;
  }

  #sidebar {
    flex: 0 0 auto;
    max-height: 45vh;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .sidebar-header {
    padding: 12px;
  }

  #controls {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .control-row {
    flex: 1 1 auto;
  }

  .control-group {
    flex: 1 1 100%;
  }

  .paste-section {
    flex: 1 1 100%;
  }

  #results {
    flex: 1 1 auto;
    min-height: 55vh;
  }
}

@media (max-width: 600px) {
  .sidebar-header {
    padding: 10px 12px;
  }

  .sidebar-header h1 {
    font-size: 14px;
  }

  #sidebar {
    flex: 0 0 auto;
    max-height: 40vh;
  }

  #controls {
    padding: 10px;
  }

  .control-row {
    flex-direction: column;
  }

  .control-row button {
    width: 100%;
  }

  .tabs {
    padding: 6px 12px;
    overflow-x: auto;
  }

  .tab {
    padding: 6px 10px;
    white-space: nowrap;
  }

  .panel {
    padding: 10px;
  }

  .suspicious-popup {
    width: 280px;
    right: -50px;
  }
}

/* Animation */
@media (prefers-reduced-motion: no-preference) {
  main, header {
    animation: fadeIn 300ms ease;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 20px;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-content h3 {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-body label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filename-input-row {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.filename-input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(136, 192, 208, 0.15);
}

.filename-input-row input {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.filename-input-row input::placeholder {
  color: var(--text-muted);
}

.filename-ext {
  padding: 10px 12px;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 13px;
  border-left: 1px solid var(--border-subtle);
}

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

.modal-footer button {
  min-width: 80px;
}

/* Test timing */
.test-timing {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  line-height: 1.2;
  margin-left: 8px;
  flex-shrink: 0;
}

.test-timing.fast {
  color: var(--success);
}

.test-timing.slow {
  color: var(--warning);
}

.test-timing.estimated {
  color: var(--text-muted);
  font-style: italic;
}

.test-timing.error {
  color: var(--error);
}

.test-timing.timeout {
  color: var(--error);
  font-weight: 600;
}

/* Test badges */
.test-badge {
  display: inline-block;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 1px 4px;
  border-radius: 2px;
  vertical-align: middle;
  line-height: 1.2;
}

.test-badge.long-running {
  background: rgba(235, 203, 139, 0.2);
  color: var(--warning);
}

.test-badge.category-system {
  background: rgba(129, 161, 193, 0.2);
  color: var(--nord9);
}

.test-badge.category-graphics {
  background: rgba(180, 142, 173, 0.2);
  color: #B48EAD;
}

.test-badge.category-media {
  background: rgba(163, 190, 140, 0.2);
  color: var(--success);
}

.test-badge.category-runtime {
  background: rgba(136, 192, 208, 0.2);
  color: var(--accent);
}

.test-badge.category-network {
  background: rgba(94, 129, 172, 0.2);
  color: var(--nord10);
}

.test-badge.category-hardware {
  background: rgba(143, 188, 187, 0.2);
  color: var(--nord7);
}

.test-badge.category-storage {
  background: rgba(235, 203, 139, 0.2);
  color: var(--warning);
}

.test-badge.category-security {
  background: rgba(191, 97, 106, 0.2);
  color: var(--error);
}

.test-badge.suspicious {
  background: rgba(235, 203, 139, 0.3);
  color: var(--warning);
  font-weight: 700;
  min-width: 14px;
  text-align: center;
}

/* Test item states */
.test-item.long-running {
  border-left: 2px solid var(--warning);
  margin-left: 0;
  padding-left: 6px;
}

.test-item.running {
  background: var(--bg-tertiary);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Summary states */
#summary.has-errors {
  color: var(--error);
}

/* Suspicious Summary - inline popup style */
.suspicious-inline {
  position: relative;
}

.suspicious-inline.hidden {
  display: none;
}

.suspicious-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(235, 203, 139, 0.15);
  border: 1px solid rgba(235, 203, 139, 0.3);
  border-radius: var(--radius-sm);
  color: var(--warning);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.suspicious-toggle:hover {
  background: rgba(235, 203, 139, 0.25);
  border-color: rgba(235, 203, 139, 0.5);
}

.suspicious-toggle .suspicious-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--warning);
  color: var(--bg-primary);
  border-radius: 9px;
}

.suspicious-popup {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 360px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.suspicious-popup.hidden {
  display: none;
}

.suspicious-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
}

.btn-icon-sm {
  width: 24px;
  height: 24px;
}

.btn-icon-sm svg {
  width: 14px;
  height: 14px;
}

.suspicious-popup-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.suspicious-section h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.suspicious-flags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suspicious-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(235, 203, 139, 0.15);
  color: var(--warning);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(235, 203, 139, 0.3);
  cursor: pointer;
  transition: all var(--transition);
}

.suspicious-flag:hover {
  background: rgba(235, 203, 139, 0.25);
  border-color: rgba(235, 203, 139, 0.5);
}

.suspicious-flag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.suspicious-flag .flag-source {
  font-size: 9px;
  opacity: 0.7;
  margin-left: 2px;
}

.suspicious-tests-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.suspicious-test {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.suspicious-test-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.suspicious-test-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--warning);
  background: rgba(235, 203, 139, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}
