/* ─── Design tokens ─── */
:root {
  --blue:        #1a4fd6;
  --blue-hover:  #1541b8;
  --blue-light:  #eef2ff;
  --blue-xlight: #f5f7ff;
  --border-blue: #c7d3f5;

  --green:       #059669;
  --green-light: #ecfdf5;
  --green-border:#6ee7b7;

  --red:         #dc2626;
  --red-light:   #fef2f2;
  --red-border:  #fca5a5;

  --orange:      #d97706;
  --orange-light:#fffbeb;

  --text:        #111827;
  --text-mid:    #4b5563;
  --text-dim:    #9ca3af;

  --bg:          #f9fafb;
  --surface:     #ffffff;
  --border:      #e5e7eb;
  --border-mid:  #d1d5db;

  --code-bg:     #1e1e2e;
  --code-border: #313244;
  --code-text:   #cdd6f4;

  --font:        'DM Sans', system-ui, -apple-system, sans-serif;
  --mono:        'DM Mono', 'Fira Code', ui-monospace, monospace;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1), 0 12px 40px rgba(26,79,214,0.08);
}

/* ─── Reset & base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
button { font-family: var(--font); cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── No-select on question text; preserve inputs ─── */
.no-select {
  user-select: none;
  -webkit-user-select: none;
}
.no-select textarea,
.no-select input {
  user-select: text;
  -webkit-user-select: text;
}

/* ─── Hidden ─── */
.hidden { display: none !important; }

/* Gate: sign-in before test */
.gate-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}
.gate-screen.hidden { display: none !important; }
.gate-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.gate-sub {
  font-size: 0.95rem;
  color: var(--text-mid);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.gate-google-btn {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gate-origin-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 1rem;
  word-break: break-all;
  font-family: var(--mono);
}
.gate-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 1rem;
}
.gate-debug {
  margin-top: 1.25rem;
  font-size: 0.75rem;
}
.gate-debug-toggle, .gate-debug-copy {
  margin-right: 0.5rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-mid);
}
.gate-debug-toggle:hover, .gate-debug-copy:hover { background: var(--border); }
.gate-debug-log {
  margin-top: 0.5rem;
  padding: 0.5rem;
  max-height: 12rem;
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 0.7rem;
  white-space: pre-wrap;
  word-break: break-all;
}
.app-container.hidden { display: none !important; }

/* ════════════════════════════════════════
   APP SHELL: header + nav + content
   ════════════════════════════════════════ */

/* Sticky top bar: logo + timer */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.25rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.app-logo {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--blue);
  letter-spacing: -0.03em;
  flex-shrink: 0;
}
.app-logo:hover { color: var(--blue-hover); text-decoration: none; }

.header-title {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  flex: 1;
}

/* Timer */
.timer-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--blue-xlight);
  border: 1.5px solid var(--border-blue);
  border-radius: 10px;
  padding: 0.3rem 0.75rem 0.3rem 0.5rem;
  flex-shrink: 0;
  transition: background 0.3s, border-color 0.3s;
}
.timer-ring { width: 28px; height: 28px; flex-shrink: 0; }
.timer-ring svg { transform: rotate(-90deg); display: block; }
.timer-ring-bg   { fill: none; stroke: var(--border-blue); stroke-width: 3; }
.timer-ring-fill {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--blue);
  line-height: 1;
}
.timer-val {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--blue);
  min-width: 56px;
  line-height: 1;
  letter-spacing: -0.01em;
}
.timer-wrap.warn  { background: var(--orange-light); border-color: #fcd34d; }
.timer-wrap.warn  .timer-label,
.timer-wrap.warn  .timer-val  { color: var(--orange); }
.timer-wrap.warn  .timer-ring-fill { stroke: var(--orange); }
.timer-wrap.critical { background: var(--red-light); border-color: var(--red-border); }
.timer-wrap.critical .timer-label,
.timer-wrap.critical .timer-val  { color: var(--red); }
.timer-wrap.critical .timer-ring-fill { stroke: var(--red); }
@keyframes blink { 50% { opacity: 0.5; } }
.timer-wrap.critical .timer-val { animation: blink 0.8s infinite; }

/* Primary nav tabs */
.nav-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0;
  padding: 0 1.5rem;
  flex-shrink: 0;
  overflow-x: auto;
}
.nav-tab {
  padding: 0 1.125rem;
  height: 44px;
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-mid);
  border: none;
  background: transparent;
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* Question sub-tabs (below main nav, only when Test active) */
.q-tabs-row {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.q-tabs-row.hidden { display: none !important; }

/* Tab panes */
.tab-pane {
  display: none;
  flex: 1;
  overflow: auto;
}
.tab-pane.active { display: flex; flex-direction: column; }

/* ════════════════════════════════════════
   START PANE
   ════════════════════════════════════════ */
.start-pane {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  background: var(--bg);
}

.start-card {
  background: var(--surface);
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  padding: 2.5rem clamp(1.75rem, 4vw, 3rem);
  width: 100%;
  max-width: none;
  box-shadow: none;
  text-align: center;
}
.start-logo {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--blue);
  letter-spacing: -0.03em;
  display: block;
  margin-bottom: 1.25rem;
}
.start-badge {
  display: inline-block;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.8rem;
  border-radius: 20px;
  margin-bottom: 1.1rem;
}
.start-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
.start-title span { color: var(--blue); }
.start-sub {
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 1.75rem;
}
.start-intro {
  margin-bottom: 1.75rem;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}
.start-intro .start-intro-h {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 1rem;
  margin-bottom: 0.35rem;
}
.start-intro .start-intro-h:first-child { margin-top: 0; }
.start-intro p {
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 0.5rem;
}
.start-objectives {
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.6;
  margin: 0.5rem 0 0 1.25rem;
  padding-left: 0.25rem;
}
.start-objectives li { margin-bottom: 0.35rem; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.75rem;
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 520px) {
  .info-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.info-item {
  background: var(--blue-xlight);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.9rem 1rem;
  text-align: center;
}
.info-item-icon { font-size: 1.1rem; margin-bottom: 0.2rem; }
.info-item-val   { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.info-item-label { font-size: 0.68rem; color: var(--text-dim); margin-top: 0.1rem; }

/* Test structure (3 parts) */
.test-structure {
  background: var(--blue-xlight);
  border: 1px solid var(--border-blue);
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  text-align: left;
}
.test-structure h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.test-structure p {
  font-size: 0.875rem;
  color: var(--text-mid);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.structure-parts {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-mid);
  line-height: 1.6;
}
.structure-parts li { margin-bottom: 0.5rem; }
.structure-parts li:last-child { margin-bottom: 0; }

.rules-list {
  list-style: none;
  text-align: left;
  margin-bottom: 1.75rem;
}
.rules-list li {
  display: flex;
  gap: 0.6rem;
  font-size: 0.86rem;
  color: var(--text-mid);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.rules-list li:last-child { border-bottom: none; }
.rules-list .ri { flex-shrink: 0; margin-top: 0.05rem; }

.btn-start {
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 0.875rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  letter-spacing: -0.01em;
}
.btn-start:hover {
  background: var(--blue-hover);
  box-shadow: 0 4px 16px rgba(26,79,214,0.3);
  transform: translateY(-1px);
}
.btn-start:active { transform: none; }

/* ════════════════════════════════════════
   TEST PANE — split layout
   ════════════════════════════════════════ */
.test-pane {
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
  flex: 1;
}
.test-pane.active {
  display: flex;
  flex-direction: row; /* override .tab-pane.active column — side-by-side: left=explanation, right=query */
}

/* Left: expandable explanation | Right: query area */
.sidebar { order: 1; }
.layout-resizer { order: 2; }
.work-area { order: 3; }

/* Left sidebar */
.sidebar {
  width: 340px;
  min-width: 240px;
  max-width: 560px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.15s;
}
.sidebar.collapsed { width: 44px; min-width: 44px; }
.sidebar.collapsed .sidebar-body { opacity: 0; pointer-events: none; overflow: hidden; }

.sidebar-header {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-header-title { opacity: 0; }
.sidebar-toggle {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text-mid);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.sidebar-toggle:hover { background: var(--blue-light); color: var(--blue); border-color: var(--border-blue); }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem 2rem;
  transition: opacity 0.15s;
}
.sidebar-panel { display: block; }
.sidebar-panel.hidden { display: none; }

/* Sidebar content styles */
.sidebar-section {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--blue);
  margin: 1.25rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--blue-light);
}
.sidebar-section:first-child { margin-top: 0; }

/* Compact schema: always visible next to every question (no explanations) */
.sidebar-schema-quick {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-schema-quick .sidebar-section { margin-bottom: 0.5rem; }
.schema-quick-tables { font-size: 0.78rem; color: var(--text-mid); }
.schema-quick-table {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}
.schema-quick-table > code {
  font-weight: 700;
  font-size: 0.85em;
  color: var(--blue);
  background: var(--blue-xlight);
  border: 1px solid var(--border-blue);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.schema-quick-cols { margin-left: 0.35rem; }
.schema-quick-cols code {
  font-size: 0.9em;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 0;
}

.sidebar-block { margin-bottom: 1rem; }
.sidebar-block h4 {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.35rem;
}
.sidebar-block p,
.sidebar-block ul {
  font-size: 0.825rem;
  color: var(--text-mid);
  line-height: 1.55;
  margin: 0.3rem 0 0;
}
.sidebar-block ul { padding-left: 1.1rem; }
.sidebar-block li { margin-bottom: 0.2rem; }

.sidebar-block code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--blue-xlight);
  padding: 0.08em 0.3em;
  border-radius: 3px;
  border: 1px solid var(--border-blue);
  color: var(--blue);
}
/* Table names in schema: stand out */
.sidebar-block h4 code {
  font-size: 0.9em;
  font-weight: 700;
  background: var(--blue-xlight);
  border: 1px solid var(--border-blue);
  color: var(--blue);
  padding: 0.12em 0.4em;
}
/* Column names in schema: muted so they don't match table names */
.sidebar-block .schema-list li code {
  font-weight: 500;
  font-size: 0.78em;
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 0;
}

.schema-list { list-style: none; padding-left: 0; }
.schema-list li { margin-bottom: 0.3rem; }
.grade-list { list-style: none; padding-left: 0; margin: 0.3rem 0 0; }
.grade-list li { position: relative; padding-left: 1rem; margin-bottom: 0.35rem; font-size: 0.82rem; color: var(--text-dim); }
.grade-list li::before { content: "·"; position: absolute; left: 0; font-weight: 700; color: var(--accent); }
.grade-cold { font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; margin: 0.25rem 0 0; }

.sidebar-note {
  margin-top: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--green-light);
  border-left: 3px solid var(--green-border);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.5;
}

.sidebar-example {
  margin: 0.4rem 0 0;
  padding: 0.65rem 0.75rem;
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

/* Resizer */
.layout-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--border);
  transition: background 0.15s;
  position: relative;
}
.layout-resizer::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: 0 -4px;
}
.layout-resizer:hover,
.layout-resizer:active { background: var(--blue); }
.sidebar.collapsed + .layout-resizer { display: none; }

/* Main work area */
.work-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Question tabs (inside q-tabs-row) */
.q-tabs-row .q-tabs {
  display: flex;
  gap: 0;
  padding: 0 1.25rem;
  overflow-x: auto;
  border-bottom: none;
}
.q-tab {
  padding: 0 0.875rem;
  height: 42px;
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  border: none;
  background: transparent;
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.q-tab:hover { color: var(--text-mid); }
.q-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.q-tab.has-run::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* Answer panel */
.answer-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 2rem;
}

.question-desc {
  font-size: 0.9rem;
  color: var(--text-mid);
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: var(--blue-xlight);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  line-height: 1.5;
}

/* "Before you start" rules */
.rules-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  border-left: 4px solid var(--blue);
}
.rules-panel h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.test-rules-list {
  list-style: none;
  font-size: 0.875rem;
  color: var(--text-mid);
  line-height: 1.6;
}
.test-rules-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.test-rules-list li:last-child { border-bottom: none; }

/* Schema panel (Before you start) */
.schema-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
  border-left: 4px solid var(--blue);
}
.schema-panel h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.schema-tables {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.schema-table {
  background: var(--blue-xlight);
  border: 1px solid var(--border-blue);
  border-radius: var(--r-sm);
  padding: 0.75rem 1rem;
}
/* Table name: bold, prominent */
.schema-table code:first-child {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--blue);
  background: var(--blue-xlight);
  border: 1px solid var(--border-blue);
  padding: 0.2em 0.5em;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.5rem;
}
.schema-table ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-mid);
  line-height: 1.5;
}
.schema-table li { margin-bottom: 0.25rem; }
/* Column names: muted, clearly secondary to table name */
.schema-table li code {
  font-size: 0.78em;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 0;
}
.schema-note {
  font-size: 0.82rem;
  color: var(--text-mid);
  margin: 0;
  line-height: 1.5;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Sidebar: match “Before you start” schema panel (blue border, table cards) */
.schema-panel--sidebar {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  margin-top: 0;
}
.schema-panel--sidebar h3 {
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}
.schema-sidebar-lead {
  font-size: 0.78rem;
  color: var(--text-mid);
  margin: 0 0 0.65rem;
  line-height: 1.45;
}
.schema-tables--sidebar {
  grid-template-columns: 1fr;
  gap: 0.65rem;
}
.schema-tables--sidebar .schema-table {
  padding: 0.55rem 0.75rem;
}
.schema-tables--sidebar .schema-table ul {
  font-size: 0.76rem;
}
.schema-panel--sidebar .schema-note {
  font-size: 0.76rem;
  padding-top: 0.45rem;
}

.brief-rules-panel,
.brief-eval-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}
.brief-rules-panel h3,
.brief-eval-panel h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.brief-rules-panel ul,
.brief-eval-panel ul {
  font-size: 0.875rem;
  color: var(--text-mid);
  line-height: 1.6;
  margin: 0;
  padding-left: 1.25rem;
}
.brief-rules-panel li,
.brief-eval-panel li { margin-bottom: 0.35rem; }

/* Test connection panel */
.test-connection-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
  border-left: 4px solid var(--green);
}
.test-connection-panel h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.test-connection-hint {
  font-size: 0.82rem;
  color: var(--text-mid);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* SQL / text inputs */
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}
.sql-area {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.55;
  padding: 0.75rem 1rem;
  border: 1px solid var(--code-border);
  border-radius: var(--r-sm);
  background: var(--code-bg);
  color: var(--code-text);
  resize: vertical;
  min-height: 130px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sql-area::placeholder { color: #585b70; }
.sql-area:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,79,214,0.15);
}

.prose-area {
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.65;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 110px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.prose-area:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,79,214,0.15);
}

.field-group { margin-bottom: 1rem; }
.field-group + .field-group { margin-top: 0.75rem; }

/* Run / Check button row */
.action-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.85rem 0 0;
  flex-wrap: wrap;
}
.action-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0.5rem 0 0;
  line-height: 1.5;
}
.submit-feedback {
  font-size: 0.875rem;
  color: var(--green);
  margin-left: 0.5rem;
  align-self: center;
}
.submit-auth-hint {
  font-size: 0.875rem;
  color: var(--text-mid);
  margin-top: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border-mid);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-xlight); }

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

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-mid);
  color: var(--text-mid);
  font-size: 0.8rem;
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-xlight); }

/* Output area */
.output-area {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Result table (replaces JSON output) */
.result-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: auto;
  max-height: 280px;
}
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.result-table th,
.result-table td {
  padding: 0.4rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
}
.result-table th {
  background: var(--blue-xlight);
  font-weight: 600;
  color: var(--blue);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.result-table tbody tr:hover td { background: var(--bg); }
.result-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 0.5rem 0.75rem;
  margin: 0;
  border-top: 1px solid var(--border);
}
.result-types { font-family: var(--font); }
.result-error { color: var(--red); padding: 0.75rem 1rem; margin: 0; font-size: 0.875rem; }
.result-loading { color: var(--text-mid); padding: 0.75rem 1rem; display: block; }

.run-result {
  background: #181825;
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: var(--r-sm);
  padding: 0.75rem 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
}

.check-result {
  padding: 0.65rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1.5px solid transparent;
}
.check-result.pass {
  background: var(--green-light);
  border-color: var(--green-border);
  color: var(--green);
}
.check-result.fail {
  background: var(--red-light);
  border-color: var(--red-border);
  color: var(--red);
}
.check-result.loading {
  background: var(--blue-xlight);
  border-color: var(--border-blue);
  color: var(--blue);
}
.check-msg {
  font-size: 0.825rem;
  font-weight: 400;
  color: var(--text-mid);
  margin-top: 0.3rem;
}

.grade-line {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-mid);
}

/* ════════════════════════════════════════
   SUBMIT PANE
   ════════════════════════════════════════ */
.submit-pane { background: var(--bg); padding: 2rem 1.5rem; }

.submit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2rem;
  max-width: 480px;
  box-shadow: var(--shadow);
}
.submit-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.submit-card p {
  font-size: 0.875rem;
  color: var(--text-mid);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.form-group { margin-bottom: 1.1rem; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  font-family: var(--font);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,79,214,0.12);
}
.form-input::placeholder { color: var(--text-dim); }
.form-hint { font-size: 0.775rem; color: var(--text-dim); margin-top: 0.3rem; line-height: 1.4; }

/* API URL box */
.api-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid var(--orange);
  border-radius: var(--r-sm);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}
.api-box .form-label { color: #92400e; }
.api-box .form-hint { color: #a16207; }
.api-box .form-input { border-color: #fde68a; }
.api-box .form-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }

/* Auth */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.signed-in-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.9rem;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--r-sm);
  margin-bottom: 0.75rem;
}
.signed-in-label { font-size: 0.875rem; color: var(--text); }
.signed-in-label strong { color: var(--green); }

.submit-result {
  margin-top: 0.85rem;
  font-size: 0.875rem;
  color: var(--text-mid);
  min-height: 1.4em;
}

/* ════════════════════════════════════════
   RESULTS PANE
   ════════════════════════════════════════ */
.results-pane {
  background: var(--bg);
  padding: 2rem 1.5rem;
  align-items: flex-start;
}

.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  max-width: 600px;
  width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.results-hero {
  background: linear-gradient(135deg, #0f2060 0%, var(--blue) 100%);
  padding: 2.25rem 2rem;
  text-align: center;
  color: #fff;
}
.results-emoji { font-size: 2.25rem; display: block; margin-bottom: 0.6rem; }
.results-score {
  font-size: 3rem;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}
.results-pct   { font-size: 1.1rem; opacity: 0.85; margin-bottom: 0.5rem; }
.results-label { font-size: 0.8rem; opacity: 0.65; }

.results-body { padding: 1.75rem 2rem 2rem; }

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}
.breakdown-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.85rem 1rem;
}
.breakdown-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.breakdown-name { font-size: 0.78rem; font-weight: 600; color: var(--text-mid); }
.breakdown-score { font-family: var(--mono); font-size: 0.875rem; font-weight: 700; }
.breakdown-score.pass { color: var(--green); }
.breakdown-score.fail { color: var(--red); }
.bar-track { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar-fill   { height: 100%; border-radius: 2px; }

.results-msg {
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}
.results-next {
  background: var(--blue-xlight);
  border: 1px solid var(--border-blue);
  border-radius: var(--r);
  padding: 1.1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-mid);
  line-height: 1.5;
}
.results-next strong { color: var(--text); display: block; margin-bottom: 0.15rem; }

/* ════════════════════════════════════════
   MISC UTILITIES
   ════════════════════════════════════════ */
.hidden-storage {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .test-pane { flex-direction: column; }
  .sidebar {
    width: 100% !important;
    max-width: none;
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .layout-resizer { display: none; }
}
