:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d7dde2;
  --accent: #0f766e;
  --accent-soft: #e2f3f1;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 16px;
  max-width: 1440px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stats span,
.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(160px, 220px) auto;
  gap: 12px;
  max-width: 1440px;
  margin: 0 auto 16px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus,
.type-card:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 1px;
  border-color: var(--accent);
}

.checkbox-filter {
  align-content: end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding-bottom: 1px;
}

.checkbox-filter input {
  width: 18px;
  min-height: 18px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
}

.type-browser,
.detail-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.type-browser {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 118px);
  overflow: hidden;
}

.browser-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.browser-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.type-list {
  max-height: calc(100vh - 172px);
  overflow: auto;
  padding: 8px;
}

.type-card {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  margin: 0;
  padding: 10px;
  text-align: left;
}

.type-card:hover,
.type-card.active {
  border-color: #a9c9c6;
  background: var(--accent-soft);
}

.type-card-title,
.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.type-code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  font-weight: 800;
}

.type-name {
  font-weight: 800;
}

.type-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.badge.inferred {
  border-color: #ebc76a;
  background: var(--warn-soft);
  color: var(--warn);
}

.detail-panel {
  overflow: hidden;
}

.detail-header {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin: 0;
  font-size: 24px;
}

.summary {
  margin: 0;
  color: var(--muted);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.usage {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 10px;
}

.usage span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

code {
  font-family: Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.note {
  margin: 0;
  border-left: 4px solid var(--warn);
  background: var(--warn-soft);
  color: #614700;
  padding: 9px 11px;
}

.table-wrap {
  overflow: auto;
  padding: 0 18px 18px;
}

.table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #26323d;
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
}

td:first-child,
td:nth-child(2).pcode-cell {
  width: 150px;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
}

tr:hover td {
  background: #f8fbfb;
}

.empty-state,
.error-state {
  padding: 28px;
  color: var(--muted);
}

.error-state h2 {
  color: #8a1f11;
}

mark {
  border-radius: 3px;
  background: #fff0a8;
  padding: 0 2px;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .type-browser {
    position: static;
    max-height: none;
  }

  .type-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    max-height: 360px;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 24px;
  }

  .toolbar {
    padding: 10px;
  }

  .detail-title-row,
  .table-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  table {
    min-width: 520px;
  }
}
