/* ---------- BASE ---------- */
* { box-sizing: border-box; margin: 0; }

:root {
  --ink: #1e2430;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --match: #dcfae6;
  --match-ink: #067647;
  --kept: #fef3c7;
  --kept-ink: #92400e;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}

body {
  min-height: 100vh;
  background: #f6f7fb;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top { max-width: 1060px; margin: 0 auto; padding: 28px 16px 8px; }
.top h1 { font-size: clamp(24px, 4vw, 34px); letter-spacing: -.5px; }
.top p { color: var(--muted); margin-top: 6px; }

.page {
  max-width: 1060px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.picker, .query, .result { grid-column: 1 / -1; }

.panel { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.panel h2 { margin-bottom: 10px; font: 700 16px var(--mono); color: var(--accent); }
.panel h2 small { color: var(--muted); font: 400 13px system-ui, sans-serif; margin-left: 4px; }
.source-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
/* ---------- END BASE ---------- */

/* ---------- PICKER ---------- */
.joins { display: flex; flex-wrap: wrap; gap: 6px; }
.join-btn, .reset {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: 600 13px var(--mono);
  cursor: pointer;
}
.reset { padding: 4px 10px; font-size: 12px; margin-bottom: 10px; }
.join-btn:hover, .reset:hover { border-color: #a5b4fc; }
.join-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.join-btn:focus-visible, .reset:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* ---------- END PICKER ---------- */

/* ---------- TABLES ---------- */
.data { width: 100%; border-collapse: collapse; font-size: 14px; }
.data th { padding: 0 10px 7px; border-bottom: 1px solid var(--line); color: var(--muted); font: 600 12px var(--mono); text-align: left; }
.data td { padding: 7px 10px; border-bottom: 1px solid #f2f4f7; font-family: var(--mono); font-size: 13.5px; transition: background .2s, color .2s; }
.data select { padding: 2px 4px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: inherit; font: 13px var(--mono); }

tr.is-matched td { background: var(--match); }
tr.is-kept td { background: var(--kept); }
tr.is-dropped td { color: #98a2b3; text-decoration: line-through; }
tr.is-dropped select { color: #98a2b3; }
tr.hover td { box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }

.null { color: var(--kept-ink); font-style: italic; }
.output tbody tr { animation: row-in .25s ease both; }
.empty { padding: 18px 10px; color: var(--muted); font-family: inherit; }
.scroll { overflow-x: auto; }
/* ---------- END TABLES ---------- */

/* ---------- QUERY ---------- */
.query { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: center; }
.venn { display: block; width: 100%; }
.region { fill: #eef0f4; transition: fill .2s; }
.region.on { fill: #a5b4fc; }
.edge { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.venn text { fill: var(--ink); font: 700 8px system-ui, sans-serif; text-anchor: middle; }

.query pre { padding: 14px 16px; border-radius: 10px; background: #111827; color: #e5e7eb; font: 14px/1.6 var(--mono); overflow-x: auto; }
.sql .kw { color: #93c5fd; font-weight: 700; }
.meaning { margin-top: 10px; font-size: 14.5px; line-height: 1.5; }
/* ---------- END QUERY ---------- */

/* ---------- LEGEND ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }
.legend li::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; border: 1px solid var(--line); }
.legend .matched::before { background: var(--match); }
.legend .kept::before { background: var(--kept); }
.legend .dropped { text-decoration: line-through; }
.legend .dropped::before { background: #fff; }
/* ---------- END LEGEND ---------- */

/* ---------- KEYFRAMES ---------- */
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  .output tbody tr { animation: none; }
  .region, .data td { transition: none; }
}
/* ---------- END KEYFRAMES ---------- */

/* ---------- SMALL SCREENS ---------- */
@media (max-width: 760px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .query { grid-template-columns: minmax(0, 1fr); }
  .venn { max-width: 240px; margin: 0 auto; }
  .data td, .data th { padding-left: 6px; padding-right: 6px; }
}
/* ---------- END SMALL SCREENS ---------- */
