:root {
  color-scheme: light;
  --background: #f7f8fa;
  --surface: #ffffff;
  --surface-hover: #f5f7fa;
  --border: #dfe3e8;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #b42318;
  --success: #16794b;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: var(--sans);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1280px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px;
}

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

.gate {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
}

.gate-card {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(31, 41, 55, 0.08);
}

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

.gate h1 {
  margin-bottom: 10px;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.gate-copy {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.token-form {
  display: grid;
  gap: 9px;
}

.token-form label {
  font-size: 13px;
  font-weight: 600;
}

.token-row {
  display: flex;
  gap: 10px;
}

.token-row input {
  min-width: 0;
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 13px;
}

.token-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.primary-button,
.utility-button {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  font-weight: 600;
}

.primary-button {
  padding: 10px 16px;
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

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

.brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.utility-button {
  padding: 8px 12px;
  font-size: 13px;
}

.utility-button:hover {
  border-color: #b9c0c9;
  background: var(--surface-hover);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(420px, 1.2fr);
  min-height: calc(100vh - 120px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.stream-panel,
.detail-panel {
  min-width: 0;
  padding: 20px;
}

.stream-panel {
  border-right: 1px solid var(--border);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.status {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status[data-tone='error'] {
  color: var(--danger);
}

.status[data-tone='live'] {
  color: var(--success);
}

.event-list {
  display: grid;
  gap: 8px;
}

.event-card {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: inherit;
  text-align: left;
  background: var(--surface);
}

.event-card:hover {
  background: var(--surface-hover);
}

.event-card[aria-pressed='true'] {
  border-color: var(--accent);
  background: #eff6ff;
}

.method {
  align-self: start;
  padding: 3px 6px;
  border-radius: 4px;
  color: #1e40af;
  background: #dbeafe;
  font: 700 10px/1.2 var(--mono);
}

.event-id {
  display: block;
  overflow: hidden;
  margin-bottom: 5px;
  font: 12px/1.4 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-meta {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.load-more {
  width: 100%;
  margin-top: 10px;
}

.empty-state {
  display: grid;
  min-height: 260px;
  padding: 20px;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.detail-stack {
  display: grid;
  gap: 14px;
}

.detail-block {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.detail-label {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-hover);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
}

.detail-content {
  margin: 0;
  padding: 13px;
  overflow: auto;
  color: #374151;
  font: 12px/1.6 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.fact {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.fact:nth-child(odd) {
  border-right: 1px solid var(--border);
}

.fact dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.fact dd {
  margin: 0;
  overflow-wrap: anywhere;
  font: 12px/1.45 var(--mono);
}

@media (max-width: 820px) {
  .shell {
    padding: 16px;
  }

  .gate {
    min-height: calc(100vh - 32px);
  }

  .gate-card {
    padding: 24px;
  }

  .token-row,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-grid {
    display: block;
  }

  .stream-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}
