:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1c2026;
  --muted: #5f6873;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --ok-bg: #dafbe1;
  --err: #cf222e;
  --err-bg: #ffebe9;
  --warn: #9a6700;
  --warn-bg: #fff8c5;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f252d;
    --border: #2d343e;
    --text: #e6e9ed;
    --muted: #8d96a1;
    --accent: #58a6ff;
    --ok: #3fb950;
    --ok-bg: #12301c;
    --err: #f85149;
    --err-bg: #3a1618;
    --warn: #d29922;
    --warn-bg: #33270b;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f252d;
  --border: #2d343e;
  --text: #e6e9ed;
  --muted: #8d96a1;
  --accent: #58a6ff;
  --ok: #3fb950;
  --ok-bg: #12301c;
  --err: #f85149;
  --err-bg: #3a1618;
  --warn: #d29922;
  --warn-bg: #33270b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--accent);
}

code,
pre,
textarea {
  font-family: var(--mono);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.top {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px 8px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
}

.brand h1 span {
  color: var(--muted);
  font-weight: 400;
}

.brand p {
  margin: 4px 0 0;
  max-width: 70ch;
  color: var(--muted);
}

.theme {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.theme button {
  border: 0;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.theme button + button {
  border-left: 1px solid var(--border);
}

.theme button[aria-checked="true"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.pane-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pane-head h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 420px;
  flex: 1;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

textarea.dragging {
  outline: 2px dashed var(--accent);
}

.error {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 13px;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.samples button {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.samples button:hover {
  border-color: var(--accent);
}

.samples button.link {
  border: 0;
  background: none;
  color: var(--accent);
}

#sample-buttons {
  display: contents;
}

.message {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.message-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2);
  font-size: 13px;
}

.badge {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.err {
  background: var(--err-bg);
  color: var(--err);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

td.obis,
td.num {
  font-family: var(--mono);
  white-space: nowrap;
}

td.num {
  text-align: right;
}

td.bytes {
  font-family: var(--mono);
  word-break: break-all;
}

.sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}

details {
  margin-top: 4px;
}

summary {
  cursor: pointer;
  font-size: 13px;
}

#log {
  max-height: 480px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
}

footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

@media (max-width: 900px) {
  .top {
    flex-direction: column;
  }

  .panes {
    grid-template-columns: minmax(0, 1fr);
  }

  textarea {
    min-height: 200px;
  }
}
