:root {
  --bg: #ffffff;
  --bg-alt: #f5f6f8;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e2e4e9;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --error-border: #fca5a5;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --bg-alt: #1c1f26;
    --text: #e6e7eb;
    --text-muted: #9aa0ab;
    --border: #2b2f38;
    --accent: #60a5fa;
    --accent-text: #0b1220;
    --error-bg: #2a1416;
    --error-text: #fca5a5;
    --error-border: #7f1d1d;
  }
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f5f6f8;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e2e4e9;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --error-border: #fca5a5;
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --bg-alt: #1c1f26;
  --text: #e6e7eb;
  --text-muted: #9aa0ab;
  --border: #2b2f38;
  --accent: #60a5fa;
  --accent-text: #0b1220;
  --error-bg: #2a1416;
  --error-text: #fca5a5;
  --error-border: #7f1d1d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.lsd-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  font-size: 0.8rem;
  text-align: center;
}
.lsd-banner:hover { opacity: 0.92; }
.lsd-banner-cta { font-weight: 600; white-space: nowrap; }

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  background: var(--bg-alt);
}
.ad-slot--top { height: 90px; margin: 0 auto; max-width: 728px; }
.ad-slot--inline { height: 90px; margin: 24px auto; max-width: 728px; }
.ad-slot::before { content: "Ad placeholder"; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.site-header h1 { font-size: 1.25rem; margin: 0; }
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1rem;
}

.tool {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 24px;
  min-height: 60vh;
}
@media (max-width: 768px) {
  .tool { grid-template-columns: 1fr; }
}

.pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-alt);
}

.pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.pane-title { font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }

.pane-actions { display: flex; gap: 8px; align-items: center; }

button, .upload-btn {
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
button:hover, .upload-btn:hover { border-color: var(--accent); }

.view-tabs { display: flex; gap: 4px; }
.view-tab {
  border-radius: 6px 6px 0 0;
  border-bottom: none;
}
.view-tab.is-active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.json-input, .json-output {
  flex: 1;
  margin: 0;
  padding: 12px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  border: none;
  resize: none;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.json-input:focus { outline: none; }

.json-tree {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.tree-actions { display: flex; gap: 8px; margin-bottom: 8px; }

.tree-node { margin-left: 16px; }
.tree-node.tree-root { margin-left: 0; }
.tree-toggle {
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  margin-right: 4px;
  display: inline-block;
  width: 12px;
}
.tree-key { color: var(--accent); }
.tree-value-string { color: #16a34a; }
.tree-value-number { color: #d97706; }
.tree-value-boolean { color: #9333ea; }
.tree-value-null { color: var(--text-muted); font-style: italic; }
.tree-children.is-collapsed { display: none; }

.error-banner {
  padding: 10px 12px;
  background: var(--error-bg);
  color: var(--error-text);
  border-top: 1px solid var(--error-border);
  font-size: 0.8rem;
}

.size-warning {
  padding: 6px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}

.site-footer {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
}
