:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-accent: #e7eefb;
  --panel: #ffffff;
  --panel-alt: #f9fbff;
  --text: #1d2433;
  --muted: #5b6578;
  --border: #d9e0ec;
  --primary: #0b63f6;
  --primary-soft: #e7f0ff;
  --success: #2e7d32;
  --warning: #b7791f;
  --danger: #c62828;
  --idle: #7f8aa3;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 1rem;
  --radius-sm: 0.75rem;
  --content-width: 1200px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(11, 99, 246, 0.12), transparent 36%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 30%, #eef2f8 100%);
}

body.is-busy {
  cursor: progress;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--text);
  color: #ffffff;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.page-header,
.layout {
  width: min(100% - 2rem, var(--content-width));
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 2.5rem 0 1.5rem;
}

.page-intro {
  max-width: 46rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: 1.35rem;
}

.page-summary,
.panel-heading p,
.field-help,
.security-note,
.status-text {
  color: var(--muted);
}

.status-panel {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.status-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--idle);
  box-shadow: 0 0 0 0.35rem rgba(127, 138, 163, 0.18);
  flex: 0 0 auto;
}

.status-dot[data-kind="connecting"] {
  background: var(--warning);
  box-shadow: 0 0 0 0.35rem rgba(183, 121, 31, 0.16);
}

.status-dot[data-kind="connected"] {
  background: var(--success);
  box-shadow: 0 0 0 0.35rem rgba(46, 125, 50, 0.18);
}

.status-dot[data-kind="error"] {
  background: var(--danger);
  box-shadow: 0 0 0 0.35rem rgba(198, 40, 40, 0.16);
}

.layout {
  display: grid;
  grid-template-columns: minmax(20rem, 26rem) minmax(0, 1fr);
  gap: 1.5rem;
  padding-bottom: 2.5rem;
}

.panel {
  padding: 1.5rem;
  border: 1px solid rgba(217, 224, 236, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.panel--sidebar {
  align-self: start;
}

.panel-heading {
  margin-bottom: 1.25rem;
}

.panel-heading--split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.selector-block,
.form,
.field-grid,
.message-shell {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field-label {
  font-size: 0.95rem;
  font-weight: 600;
}

.field-help,
.security-note {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.field-help code {
  padding: 0.08rem 0.35rem;
  border-radius: 0.45rem;
  background: rgba(11, 99, 246, 0.08);
  font-family: "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 0.95em;
}

.input {
  width: 100%;
  min-height: 3rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  color: var(--text);
  font: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 0.25rem rgba(11, 99, 246, 0.14);
  background: #ffffff;
}

.input:disabled {
  background: #eef2f8;
  color: var(--muted);
  cursor: not-allowed;
}

select.input {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.2rem) calc(50% - 0.14rem),
    calc(100% - 0.85rem) calc(50% - 0.14rem);
  background-size: 0.45rem 0.45rem, 0.45rem 0.45rem;
  background-repeat: no-repeat;
  padding-right: 2.6rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.25rem;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease, background-color 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(11, 99, 246, 0.18);
}

.button:focus-visible {
  outline: 0.2rem solid rgba(11, 99, 246, 0.25);
  outline-offset: 0.1rem;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button--secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

.button--secondary:hover:not(:disabled) {
  box-shadow: 0 10px 18px rgba(11, 99, 246, 0.1);
}

.button--ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.error-banner {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(198, 40, 40, 0.25);
  border-radius: var(--radius-sm);
  background: #fff1f1;
  color: var(--danger);
  font-weight: 500;
}

.error-banner[hidden] {
  display: none;
}

.warning-banner {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-radius: var(--radius-sm);
  background: #fff7e8;
  color: var(--warning);
  font-weight: 600;
}

.warning-banner[hidden] {
  display: none;
}

.message-shell {
  min-height: 26rem;
}

.empty-state {
  margin: 0;
  padding: 1.4rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel-alt);
  color: var(--muted);
  text-align: center;
}

.message-list {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.message-item {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-alt);
  border-left: 0.4rem solid var(--idle);
}

.message-item[data-event-group="negotiation"] {
  border-left-color: var(--primary);
}

.message-item[data-event-group="transfer"] {
  border-left-color: var(--success);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.message-source {
  font-weight: 600;
}

.message-time {
  color: var(--muted);
  font-size: 0.92rem;
}

.message-summary {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.message-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.message-event-code {
  width: fit-content;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(11, 99, 246, 0.14);
  border-radius: 999px;
  background: rgba(11, 99, 246, 0.08);
  color: var(--primary);
  font-family: "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 0.82rem;
}

.message-payload-label {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-body {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(217, 224, 236, 0.85);
  border-radius: var(--radius-sm);
  background: #ffffff;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 0.94rem;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .page-header,
  .panel-heading--split,
  .message-meta {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .status-panel {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .page-header,
  .layout {
    width: min(100% - 1rem, var(--content-width));
  }

  .page-header {
    padding-top: 1.5rem;
  }

  .panel {
    padding: 1.1rem;
  }

  .actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
