:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d1c1a;
  --muted: #6d6a64;
  --line: #e2ded6;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --canvas-bg: #e9e5dd;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --panel: #201f1d;
    --ink: #eeebe5;
    --muted: #a09b92;
    --line: #34322e;
    --accent: #ff7a3d;
    --accent-ink: #1a0d05;
    --canvas-bg: #2a2825;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.top { padding: 24px 24px 8px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; gap: 14px; align-items: flex-start; }
.logo {
  font-size: 28px; line-height: 1; color: var(--accent);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px;
}
h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.brand p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }

.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 20px;
  padding: 16px 24px 32px; max-width: 1280px; margin: 0 auto;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px 24px; }
  .top { padding: 16px 16px 4px; }
}

.panel, .preview {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.group { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 10px; }

.row { display: flex; gap: 10px; align-items: flex-end; margin-top: 8px; }
.row > label { flex: 1; min-width: 0; }
label { display: block; font-size: 13px; font-weight: 500; }
input[type=number], select {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit;
}
input:focus, select:focus, button:focus-visible, .drop:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 6px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 22px 12px; border: 2px dashed var(--line); border-radius: var(--radius);
  cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.drop span { color: var(--muted); font-size: 13px; font-weight: 400; }
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }

.stepper { display: flex; margin-top: 4px; }
.stepper input { margin: 0; border-radius: 0; text-align: center; }
.stepper button {
  width: 36px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 18px; cursor: pointer;
}
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }

.primary {
  width: 100%; padding: 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  font: 600 15px/1 inherit; font-family: inherit; cursor: pointer;
}
.primary:disabled { opacity: .45; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stats div { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.stats span { display: block; font-size: 12px; color: var(--muted); }
.stats strong { font-size: 16px; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.canvasWrap {
  position: relative; background: var(--canvas-bg); border-radius: 8px;
  min-height: 420px; display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow: hidden;
}
#canvas { max-width: 100%; height: auto; display: block; box-shadow: 0 2px 12px rgba(0,0,0,.15); }
#canvas:not(.on) { display: none; }
.empty { color: var(--muted); }
.legend { margin-top: 10px; }

/* Selector de tipo de salida */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; height: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); transition: border-color .15s, background .15s;
}
.seg small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
.seg input:checked + span {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
}
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { flex: 1.3; margin: 0 0 6px; }
.extras { margin-top: 10px; }
