:root {
  --border: #d0d0d0;
  --border-soft: #e5e5e5;
  --bg-panel: #f5f5f5;
  --bg-code: #eef;
  --bg-dark: #1e1e1e;
  --fg-dark: #d4d4d4;
  --text: #222;
  --text-muted: #666;
  --accent: #2b2b2b;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 1rem;
  color: var(--text);
  background: #fafafa;
  line-height: 1.45;
  overflow: hidden;
}

main {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 1rem;
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
}

aside.controls {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-radius: 6px;
  overflow: hidden;
}
.controls-header {
  padding: 0.85rem 1rem 0.7rem;
  border-bottom: 1px solid var(--border-soft);
}
.controls-header h1 {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}
.page-nav {
  display: flex;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.page-nav a {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  background: #fff;
}
.page-nav a.current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.controls-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.7rem 1rem 0.5rem;
}
.controls-body label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}
.controls-body input,
.controls-body select {
  width: 100%;
  padding: 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
}
.controls-body input[type="checkbox"] {
  width: auto;
  margin-right: 0.4rem;
  padding: 0;
  vertical-align: middle;
}

.field { margin: 0 0 0.65rem; }
.field > label { margin-bottom: 0.15rem; }

.hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.15rem;
  line-height: 1.35;
}
.hint code {
  background: rgba(0,0,0,0.06);
  padding: 0 0.2rem;
  border-radius: 2px;
}

.components-fieldset {
  border: none;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 0.5rem 0;
  margin: 0.2rem 0 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  background: none;
}
.components-fieldset legend {
  font-size: 0.75rem;
  padding: 0;
  margin-bottom: 0.2rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  float: left;
  width: 100%;
}
.components-fieldset label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
}
.components-fieldset input { width: auto; padding: 0; }

.controls-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-panel);
}
button.reload {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
}
button.reload:hover { background: #000; }

section.column {
  overflow-y: auto;
  min-width: 0;
  padding: 0 0.3rem 0 0.1rem;
}

.result { margin-bottom: 1.1rem; }
.result > h2 {
  margin: 0 0 0.35rem;
  padding: 0;
  background: none;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.result > .result-body { padding: 0; }
.result h2 .summary-note {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.35rem;
}

pre {
  background: var(--bg-dark);
  color: var(--fg-dark);
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.78rem;
  margin: 0;
  line-height: 1.4;
}

.code-block {
  word-break: break-all;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  background: var(--bg-code);
  padding: 0.55rem 0.7rem;
  border-radius: 4px;
  margin: 0;
}

.render-target {
  min-height: 60px;
  border: 1px dashed var(--border);
  padding: 1rem;
  border-radius: 4px;
  background: #fafafa;
}
.render-target.small { min-height: 40px; }
.render-target.flex {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.render-target.flex > *,
.render-target.flex paypal-basic-card-container > * {
  display: block;
  width: 100%;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
  display: block;
}
.empty-state code {
  font-style: normal;
  background: rgba(0,0,0,0.06);
  padding: 0 0.25rem;
  border-radius: 2px;
}

@media (max-width: 1100px) {
  html, body { height: auto; }
  body { overflow: auto; padding: 1rem; }
  main {
    grid-template-columns: 1fr;
    height: auto;
  }
  aside.controls { max-height: none; }
  .controls-body { overflow-y: visible; }
  section.column { overflow-y: visible; }
}
