:root { color-scheme: light; }
body {
  font-family: system-ui, sans-serif;
  margin: 24px;
  max-width: 980px;
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
h1 { margin: 0 0 6px; }
p { margin: 0 0 18px; opacity: 0.9; }

/* Layout */
.sections { display: grid; gap: 16px; flex: 1; min-height: 0; overflow: hidden; }
@media (min-width: 980px) {
  .sections { grid-template-columns: 300px 1fr; align-items: start; }
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow: auto;
  padding-right: 6px;
  padding-bottom: 16px;
}
.main { display: grid; gap: 16px; overflow: auto; padding-right: 6px; }

/* Card-ish fieldsets */
fieldset {
  border: 1px solid #ddd;
  border-radius: 16px;
  padding: 14px 14px 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
  background: #fff;
  min-width: 0;
}
legend {
  padding: 0 8px;
  font-weight: 650;
  font-size: 14px;
}

/* Form grid inside a section */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 40px; /* row-gap col-gap */
  margin-top: 10px;
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 720px) {
  .grid, .grid.grid-3 { grid-template-columns: 1fr; }
}
.sidebar .grid,
.sidebar .grid-3 {
  grid-template-columns: 1fr;
  gap: 12px;
}

.field label { display:block; font-size: 12px; opacity: 0.85; margin: 0 0 6px; }
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 12px;
  box-sizing: border-box;
  font-size: 14px;
}
.hint { font-size: 12px; opacity: 0.7; margin-top: 6px; line-height: 1.3; }

.row { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.sidebar-actions {
  background: #fff;
  border: 1px solid #e1e1e1;
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
button {
  padding: 12px 14px; border: 0; border-radius: 12px; cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

textarea {
  width: 100%; height: 340px; padding: 12px;
  border: 1px solid #ccc; border-radius: 14px; box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
}
.visually-hidden { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.codeview {
  width: 100%; height: 340px; padding: 12px;
  border: 1px solid #ccc; border-radius: 14px; box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px; white-space: pre; overflow: auto;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}
.tok-comment { color: #5b6b73; font-style: italic; }
.tok-gm { color: #0b6e4f; font-weight: 700; }
.tok-axis { color: #8a2be2; }
.tok-num { color: #b02a37; }
.tok-feed { color: #0a58ca; font-weight: 600; }

.err { color: #b00020; white-space: pre-wrap; margin: 8px 0 0; }

.preview-wrap { display: grid; gap: 10px; }
.preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid #cfd3d7;
  border-radius: 16px;
  background: linear-gradient(135deg, #f9f6ee 0%, #eef3f8 100%);
}
.preview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  opacity: 0.9;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.15); }
.legend-stock { background: rgba(18, 84, 142, 0.24); border-color: rgba(18, 84, 142, 0.75); }
.legend-cut { background: rgba(196, 72, 18, 0.28); border-color: rgba(196, 72, 18, 0.85); }
.preview-meta { font-size: 12px; opacity: 0.8; line-height: 1.35; }
