:root {
  --bg: #f6f1e6;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7480;
  --accent: #1d3557;
  --accent-hover: #163455;
  --border: #d9cfb9;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Iowan Old Style', Palatino, Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

header {
  padding: 1rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0.2rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

#controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  height: fit-content;
  position: sticky;
  top: 1rem;
}

#controls details {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

#controls details:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

#controls details[open] {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#controls summary {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

#controls summary::-webkit-details-marker {
  display: none;
}

#controls summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.45rem;
  transition: transform 0.12s ease;
}

#controls details[open] summary::before {
  transform: rotate(90deg);
}

#controls label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

#controls label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

#controls select,
#controls input[type="number"] {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  background: white;
  border-radius: 3px;
  color: var(--ink);
}

#controls input[type="range"] {
  width: 100%;
  margin: 0;
}

#controls output {
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  align-self: flex-end;
  margin-top: -0.3rem;
}

#controls button {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.8rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s;
}

#controls button:hover {
  background: var(--accent-hover);
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

#preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-height: 600px;
}

#svgWrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#svgWrap svg {
  max-width: 100%;
  max-height: 75vh;
  height: auto;
  border: 1px solid var(--border);
  background: white;
}

.meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: 'Menlo', 'Consolas', monospace;
}

footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}
