:root {
  --bg: #09090b;
  --surface: #111113;
  --surface-2: #18181b;
  --surface-3: #1f1f23;
  --border: #27272a;
  --border-2: #3f3f46;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #6366f1;
  --accent-2: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.1);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.1);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 28px 80px;
}

.hidden {
  display: none !important;
}

.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60vh;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-icon {
  width: 52px;
  height: 52px;
  background: var(--red-bg);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
}

#error h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

#error p {
  color: var(--text-2);
  font-size: 14px;
  max-width: 380px;
  text-align: center;
  line-height: 1.6;
}

.dump-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}

.dump-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, var(--accent-glow) 0%, transparent 60%);
  pointer-events: none;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  position: relative;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.header-brand h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.header-brand .subtitle {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 2px;
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-2);
}

.btn-primary {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent);
  color: #fff;
}

.header-meta {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  position: relative;
}

.meta-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--text-2);
  border-right: 1px solid var(--border);
  font-weight: 400;
}

.meta-pill:first-child {
  padding-left: 0;
}

.meta-pill:last-child {
  border-right: none;
}

.meta-pill strong {
  color: var(--text);
  font-weight: 700;
}

.section-group {
  margin-bottom: 36px;
}

.group-title {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-3);
  margin-bottom: 10px;
  padding-left: 2px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.section-header:hover {
  background: var(--surface-2);
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.section-header h2 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron {
  color: var(--text-3);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.section.collapsed .chevron {
  transform: rotate(-90deg);
}

.section.collapsed .section-body {
  display: none;
}

.section-body {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.kv-grid {
  display: grid;
  grid-template-columns: minmax(160px, 28%) 1fr;
  gap: 6px 16px;
}

.kv-grid .kv-key {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  padding-top: 3px;
  word-break: break-word;
}

.kv-grid .kv-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  word-break: break-all;
  line-height: 1.6;
}

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

.data-table thead th {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: 0 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.data-table tbody td {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--surface-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  border-radius: 4px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-green {
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-red {
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-blue {
  color: var(--blue);
  background: var(--blue-bg);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-yellow {
  color: var(--yellow);
  background: var(--yellow-bg);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-gray {
  color: var(--text-3);
  background: var(--surface-3);
  border: 1px solid var(--border);
}

.cfg-root {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.8;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
}

.cfg-line {
  display: block;
}

.cfg-key {
  color: #818cf8;
  font-weight: 600;
}

.cfg-key-meta {
  color: var(--red);
  font-style: italic;
}

.cfg-primitive {
  color: #86efac;
}

.cfg-null {
  color: var(--text-3);
  font-style: italic;
}

.cfg-empty {
  color: var(--text-3);
}

.cfg-dash {
  color: var(--yellow);
  margin-right: 4px;
}

.empty-note {
  color: var(--text-3);
  font-size: 13px;
  font-style: italic;
}

footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-weight: 500;
}

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-2);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 9999;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 700px) {
  #app {
    padding: 24px 16px 60px;
  }

  .dump-header {
    padding: 20px 18px;
  }

  .header-top {
    flex-direction: column;
    gap: 16px;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .header-meta {
    gap: 0;
  }

  .meta-pill {
    padding: 5px 10px;
    font-size: 12px;
  }

  .kv-grid {
    grid-template-columns: 1fr;
    gap: 3px 0;
  }

  .kv-grid .kv-key {
    padding-top: 8px;
    color: var(--text-2);
    font-size: 11px;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 8px 10px;
  }

  .cfg-root {
    font-size: 11.5px;
    padding: 12px 14px;
  }
}
