:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #d4d4d8;
  --primary: #09090b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --ring: #18181b;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--foreground);
  background: var(--background);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 14px;
}

.hero-copy,
.rule-box,
.memo-panel,
.schema-card,
.rule-grid article,
.gate-list article,
.model-controls {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.hero-copy {
  padding: 22px 24px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 650;
  flex-wrap: wrap;
}

.triangle {
  width: 25px;
  height: 22px;
  display: inline-block;
  background: var(--foreground);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 18px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.04;
  font-weight: 760;
}

.hero-copy > p {
  max-width: 760px;
  margin-top: 12px;
  color: var(--muted-foreground);
  font-size: 15px;
  line-height: 1.55;
}

.rule-box {
  padding: 18px;
  background: #fbfbfb;
}

.eyebrow {
  display: block;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rule-box strong {
  display: block;
  margin-top: 10px;
  font-size: 17px;
  line-height: 1.35;
}

.rule-box p {
  margin-top: 11px;
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--primary-foreground);
  background: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.badge.secondary {
  color: var(--secondary-foreground);
  background: var(--secondary);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 14px;
  padding: 4px;
  background: rgba(244, 244, 245, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
}

.tabs button {
  min-height: 38px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  color: var(--muted-foreground);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 760;
}

.tabs button.is-active {
  color: var(--foreground);
  background: var(--background);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.source-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfbfb;
}

.source-note p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.4;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.wide {
  grid-column: span 1;
}

.memo-panel {
  padding: 18px;
}

.memo-panel h2 {
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.18;
  font-weight: 720;
}

.memo-panel h3,
.gate-list h3,
.rule-grid h3 {
  font-size: 15px;
  line-height: 1.25;
}

.memo-panel p {
  margin-top: 12px;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.55;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.rule-grid article {
  padding: 16px;
}

.rule-grid span {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
}

.rule-grid h3 {
  margin-top: 12px;
}

.rule-grid p,
.gate-list p {
  margin-top: 9px;
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.45;
}

.questions {
  margin-top: 16px;
}

ul {
  margin: 14px 0 0;
  padding-left: 18px;
}

li {
  margin: 9px 0;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.45;
}

.data-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.data-layout .memo-panel {
  grid-column: span 2;
}

.schema-card {
  padding: 18px;
}

.schema-card h3 {
  margin-bottom: 12px;
  font-size: 15px;
}

code {
  display: block;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  color: var(--foreground);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.sql-panel {
  margin-top: 14px;
}

pre {
  margin: 15px 0 0;
  overflow-x: auto;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #09090b;
}

pre code {
  display: block;
  padding: 0;
  border: 0;
  color: #e8edf4;
  line-height: 1.55;
}

.model-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 14px;
}

.model-controls {
  align-self: start;
  display: grid;
  gap: 18px;
  padding: 18px;
}

.model-controls label {
  display: grid;
  gap: 9px;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 760;
}

.model-controls output {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 650;
}

select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--input);
  border-radius: 6px;
  background: var(--background);
  color: var(--foreground);
  padding: 0 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.model-output,
.table-panel,
.lever-panel {
  grid-column: 2;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.metric-grid div {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fafafa;
}

.metric-grid span {
  display: block;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 720;
}

.metric-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 23px;
}

.lever-panel ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  padding-left: 18px;
}

table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.35;
  vertical-align: top;
}

th {
  color: var(--muted-foreground);
  background: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.gate-layout {
  display: grid;
  gap: 14px;
}

.gate-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.gate-list article {
  padding: 18px;
}

.status {
  display: block;
  width: 10px;
  height: 10px;
  margin-bottom: 13px;
  border-radius: 999px;
}

.status.pass {
  background: var(--green);
}

.status.warn {
  background: var(--amber);
}

.status.fail {
  background: var(--red);
}

.closing {
  max-width: 780px;
}

@media (max-width: 980px) {
  .hero,
  .section-grid,
  .model-layout {
    grid-template-columns: 1fr;
  }

  .model-output,
  .table-panel,
  .lever-panel {
    grid-column: auto;
  }

  .rule-grid,
  .gate-list,
  .data-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .page-shell {
    padding: 18px 14px 30px;
  }

  .hero-copy,
  .rule-box,
  .memo-panel,
  .schema-card,
  .rule-grid article,
  .gate-list article,
  .model-controls {
    padding: 17px;
  }

  .tabs {
    overflow-x: auto;
  }

  .rule-grid,
  .gate-list,
  .data-layout,
  .metric-grid,
  .lever-panel ul {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 720px;
  }

  .table-panel {
    overflow-x: auto;
  }
}
