/* Aligned with MapConfig/public/styles.css */
:root {
  --bg: #ebebeb;
  --text: #111827;
  --muted: #4b5563;
  --muted-light: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --surface: #ffffff;
  --surface-alt: #fafafa;
  --surface-code: #f4f4f5;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warn: #d97706;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --json-key: #1d4ed8;
  --json-string: #166534;
  --json-number: #b45309;
  --json-bool: #7c3aed;
  --json-null: #6b7280;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Open Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

main {
  margin: 0 auto;
  padding: 1rem;
  max-width: 1200px;
}

h1 {
  margin: 0 0 0.2rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.subtitle code {
  font-size: 0.8125rem;
  background: var(--surface-code);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.entry-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin: 0.5rem 0 1rem;
}

.entry-links a {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.entry-links a:hover {
  text-decoration: underline;
}

section {
  margin-bottom: 1rem;
}

.panel {
  background: var(--surface);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.panel-head,
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.panel-head h2,
.section-head h2,
section > h2 {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted-light);
}

section > h2 {
  margin-bottom: 0.75rem;
}

button,
.btn-primary {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

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

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

button.secondary,
#clear-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid var(--border-strong);
}

button.secondary:hover,
#clear-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
  color: #111827;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted-light);
  font-weight: 600;
  background: var(--surface-alt);
}

tr:last-child td {
  border-bottom: none;
}

td code {
  font-size: 0.8125rem;
  background: var(--surface-code);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted-light);
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
}

.client-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.packet-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.packet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.packet-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.packet-from {
  display: inline-flex;
  align-items: center;
}

.packet-meta .badge {
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

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

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

pre.json,
.payload-editor {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-code);
}

.payload-editor {
  display: block;
  width: 100%;
  min-height: 16rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  resize: vertical;
  color: var(--text);
}

.payload-editor:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.payload-editor.invalid {
  border-color: #fca5a5;
  background: var(--error-bg);
}

.json-key {
  color: var(--json-key);
}

.json-string {
  color: var(--json-string);
}

.json-number {
  color: var(--json-number);
}

.json-bool {
  color: var(--json-bool);
}

.json-null {
  color: var(--json-null);
}

.json-punct {
  color: var(--muted-light);
}

.json-invalid {
  color: #b91c1c;
}

#live-indicator {
  color: var(--success);
}

#live-indicator.stale {
  color: var(--warn);
}

#ws-status {
  font-size: 0.875rem;
  color: var(--muted-light);
}

#ws-status.connected {
  color: var(--success);
}

#ws-status.error {
  color: var(--error);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sent-log {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sent-entry {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.sent-entry:last-child {
  border-bottom: none;
}

.store-overview {
  list-style: none;
  padding-left: 0;
  margin: 0 0 1rem;
}

.store-overview li {
  margin: 0.2rem 0;
}

.store-overview pre {
  margin: 0;
  font-size: 0.75rem;
}

.store-overview > li:nth-child(odd) pre {
  margin-top: 0.65rem;
}

.store-overview .pair-a pre {
  background: var(--surface-alt);
}

.store-overview .pair-b pre {
  background: var(--surface-code);
}

.store-field {
  margin-bottom: 0.75rem;
}

.store-field label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.store-field input,
.store-field textarea {
  width: 100%;
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.store-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#ws-log {
  font-size: 0.75rem;
  max-height: 12rem;
  overflow: auto;
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
}

.log-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin: 0 0 0.35rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}

.log-line:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.log-line-meta {
  flex-shrink: 0;
  font-family: inherit;
  color: var(--muted);
}

.log-json-inline {
  flex: 1 1 0;
  min-width: 0;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  word-break: break-word;
}

#ws-log .json-key {
  color: var(--json-key);
}

#ws-log .json-str {
  color: var(--json-string);
}

#ws-log .json-num {
  color: var(--json-number);
}

#ws-log .json-bool,
#ws-log .json-null {
  color: var(--json-bool);
}

#store-files-list {
  margin: 0;
  padding-left: 1.1rem;
}

#store-files-list li {
  margin: 0.35rem 0;
}

/* Landing page */
main.landing {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

main.landing h1 {
  font-size: 1.75rem;
}

.landing-nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 2rem;
}

.landing-link {
  display: block;
  padding: 1.25rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 1.35rem;
  font-weight: 700;
  color: #000;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.landing-link:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  color: #000;
}
