
  :root {
    --bg-dark: #0a0a0c;
    --panel-bg: #141417;
    --panel-border: #23232b;
    --accent: #d97706;
    --accent-light: #fbbf24;
    --accent-glow: rgba(251, 191, 36, 0.22);
    --cyan: #38bdf8;
    --red: #ef4444;
    --emerald: #10b981;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --btn-bg: #1e1e24;
    --btn-hover: #292933;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }

  body {
    display: flex;
    flex-direction: row;
  }

  /* BARRA LATERAL */
  #sidebar {
    width: 380px;
    height: 100%;
    flex: none;
    background: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    z-index: 20;
    box-shadow: 4px 0 24px rgba(0,0,0,0.55);
  }

  h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--accent-light);
    border-bottom: 2px solid #b45309;
    padding-bottom: 5px;
  }

  .author-tag {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: -6px;
    margin-bottom: 2px;
  }

  .section-title {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent);
    margin-top: 3px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: var(--btn-bg);
    color: var(--text-main);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
    user-select: none;
  }

  .btn:hover {
    background: var(--btn-hover);
    border-color: var(--accent);
  }
  .btn:active { transform: scale(0.98); }

  .btn-upload {
    background: #78350f;
    border-color: #b45309;
    color: #fef3c7;
  }
  .btn-upload:hover { background: #92400e; }

  .btn-move-all {
    background: #78350f;
    border-color: #d97706;
    color: #fffbeb;
    box-shadow: 0 0 12px var(--accent-glow);
  }
  .btn-move-all.active {
    background: #d97706;
    border-color: #fbbf24;
    color: #121214;
    font-weight: 700;
  }

  .btn-export {
    background: #065f46;
    border-color: #059669;
    color: #ecfdf5;
  }
  .btn-export:hover { background: #047857; }

  .btn-export-grid {
    background: #1e3a8a;
    border-color: #2563eb;
    color: #eff6ff;
  }
  .btn-export-grid:hover { background: #1d4ed8; }

  label {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  input[type=range], select {
    width: 100%;
    margin-top: 4px;
    accent-color: var(--accent-light);
    cursor: pointer;
    background: #0d0d10;
    border: 1px solid #282834;
    color: #e5e7eb;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
  }

  /* ASISTENTE DIDÁCTICO PASO A PASO */
  .stepper-card {
    background: #101014;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .stepper-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }

  .step-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent-light);
    background: rgba(217, 119, 6, 0.15);
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(217, 119, 6, 0.35);
  }

  .step-text {
    font-size: 0.78rem;
    line-height: 1.45;
    color: #d1d5db;
    background: #18181d;
    padding: 8px 9px;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
  }
  .step-text b { color: #fef08a; }

  .step-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  /* NUDGE - AJUSTE FINO DIRECCIONAL */
  .nudge-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-width: 170px;
    margin: 4px auto 0 auto;
  }
  .nudge-btn {
    padding: 6px 0;
    font-size: 0.85rem;
    font-weight: bold;
    text-align: center;
  }

  .toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    background: #101014;
    border: 1px solid #22222a;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
  }
  .toggle-row:hover { border-color: #383848; }

  .toggle-row input[type=checkbox] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
  }

  .toggle-row span {
    font-size: 0.78rem;
    color: #e5e7eb;
    flex: 1;
  }

  .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
  }

  /* PANEL DE EXTENSIÓN MODULAR */
  .ext-box {
    background: #101014;
    border: 1px solid #242430;
    border-radius: 8px;
    padding: 9px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* ÁREA DEL LIENZO */
  #stage {
    flex: 1;
    height: 100%;
    position: relative;
    background: #08080a;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    touch-action: pan-x pan-y;
  }

  #canvas-wrapper {
    position: relative;
    box-shadow: 0 12px 48px rgba(0,0,0,0.9);
    border-radius: 4px;
    background: #18181b;
  }

  canvas {
    display: block;
    cursor: crosshair;
    border-radius: 4px;
    touch-action: none;
  }

  #hud {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(15, 15, 18, 0.9);
    border: 1px solid #2e2e3a;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--accent-light);
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(5px);
  }

  #step-toast {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 22, 0.94);
    border: 1px solid #d97706;
    color: #fef3c7;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0,0,0,0.7);
    z-index: 15;
    text-align: center;
    letter-spacing: 0.3px;
  }

  @media (max-width: 820px) {
    body { flex-direction: column-reverse; }
    #sidebar { width: 100%; height: 50%; border-right: none; border-top: 1px solid var(--panel-border); }
    #stage { height: 50%; padding: 8px; }
  }
