:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #16202a;
  --muted: #5f6b7a;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 32px auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 18px;
}

p,
dd {
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metrics article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metrics strong {
  display: block;
  font-size: 28px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.sectionHeader,
form,
dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.accessControls {
  display: grid;
  gap: 8px;
}

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

dl {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

dt {
  font-weight: 700;
}

dd {
  margin: 0;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
}

pre {
  white-space: pre-wrap;
  background: #f2f5f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  overflow: auto;
}

.summaryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.messageList {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.tokenList,
.eventList {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tokenRow,
.eventRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

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

.tokenRow span,
.eventRow span,
.eventRow small {
  color: var(--muted);
}

.settingsForm {
  align-items: end;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-top: 16px;
}

.settingsForm label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.checkboxLabel {
  align-items: center;
  display: flex !important;
}

.messageRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.messageRow:hover {
  background: #f2f7f6;
}

.messageRow span {
  display: grid;
  gap: 3px;
}

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

.summaryCard {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}

.messageRow.opened strong {
  color: var(--accent-dark);
}

.messageRow.opened {
  border-color: var(--accent);
}

.messageRow .opencount {
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .topbar,
  .sectionHeader,
  form,
  dl div {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .messageRow {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .tokenRow {
    align-items: stretch;
    flex-direction: column;
  }

  .settingsForm {
    grid-template-columns: 1fr;
  }

  /* 16px inputs stop iOS Safari from auto-zooming on focus; 44px tap targets. */
  input,
  button {
    font-size: 16px;
    min-height: 44px;
  }

  .messageRow .opencount {
    white-space: normal;
  }
}
