* { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --primary: #1e3a8a;
    --primary-light: #3b82f6;
    --accent: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-light: #64748b;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --neutral: #94a3b8;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding: 1rem;
    min-height: 100vh;
  }
  .container { max-width: 800px; margin: 0 auto; }

  /* ============ REGISTRO ============ */
  .reg-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 1rem; overflow-y: auto;
  }
  .reg-card {
    background: white; border-radius: 16px; max-width: 540px; width: 100%;
    padding: 2rem; box-shadow: var(--shadow); max-height: 95vh; overflow-y: auto;
  }
  .reg-card h2 { color: var(--primary); margin-bottom: 0.4rem; font-size: 1.5rem; }
  .reg-card .reg-subtitle {
    color: var(--text-light); font-size: 0.88rem; margin-bottom: 1.5rem;
  }
  .reg-field { margin-bottom: 1rem; }
  .reg-field label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--text); margin-bottom: 0.35rem;
  }
  .reg-field input[type=text], .reg-field input[type=email], .reg-field input[type=tel] {
    width: 100%; padding: 0.65rem 0.85rem; border: 1px solid #cbd5e1;
    border-radius: 8px; font-size: 0.95rem; font-family: inherit;
  }
  .reg-field input:focus { outline: none; border-color: var(--primary-light); }
  .reg-field .reg-error {
    color: var(--danger); font-size: 0.78rem; margin-top: 0.25rem; display: none;
  }
  .reg-field.has-error input { border-color: var(--danger); }
  .reg-field.has-error .reg-error { display: block; }

  .reg-consent {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 0.85rem; font-size: 0.78rem; color: var(--text-light);
    margin-bottom: 1rem; max-height: 140px; overflow-y: auto; line-height: 1.55;
  }
  .reg-consent strong { color: var(--text); }
  .reg-consent a { color: var(--primary); }

  .reg-check {
    display: flex; gap: 0.6rem; align-items: flex-start;
    margin-bottom: 1.25rem; font-size: 0.85rem; color: var(--text);
  }
  .reg-check input { margin-top: 0.2rem; flex-shrink: 0; cursor: pointer; }
  .reg-check label { cursor: pointer; line-height: 1.5; }

  .reg-btn {
    width: 100%; padding: 0.85rem; background: var(--primary); color: white;
    border: none; border-radius: 10px; font-size: 1rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
  }
  .reg-btn:hover { background: var(--primary-light); }
  .reg-btn:disabled { background: var(--neutral); cursor: not-allowed; }
  .reg-status {
    text-align: center; font-size: 0.85rem; margin-top: 0.85rem; min-height: 1.2em;
  }
  .reg-status.error { color: var(--danger); }
  .reg-status.ok { color: var(--success); }

  /* ============ APP PRINCIPAL ============ */
  .app { display: none; }
  .app.visible { display: block; }

  header { text-align: center; margin-bottom: 1rem; }
  header h1 { color: var(--primary); font-size: 1.55rem; margin-bottom: 0.25rem; }
  header .subtitle { color: var(--text-light); font-size: 0.85rem; }
  header .user-info {
    font-size: 0.78rem; color: var(--text-light); margin-top: 0.4rem;
  }
  header .user-info .sync-state { font-weight: 600; }
  .sync-ok { color: var(--success); }
  .sync-pending { color: var(--accent); }
  .sync-error { color: var(--danger); }

  .stats {
    display: flex; justify-content: center; gap: 0.5rem;
    flex-wrap: wrap; margin-bottom: 1rem; font-size: 0.82rem;
  }
  .stat {
    background: white; padding: 0.45rem 0.85rem;
    border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }
  .stat strong { color: var(--primary); }

  .progress-bar {
    height: 6px; background: #e2e8f0; border-radius: 4px;
    overflow: hidden; margin-bottom: 0.4rem;
  }
  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #22c55e);
    transition: width 0.3s;
  }
  .progress-text {
    text-align: center; font-size: 0.78rem;
    color: var(--text-light); margin-bottom: 1rem;
  }

  .controls {
    display: flex; gap: 0.5rem; margin-bottom: 1rem;
    flex-wrap: wrap; justify-content: center;
  }
  .btn {
    padding: 0.55rem 1rem; border: none; border-radius: 8px;
    background: var(--primary); color: white; cursor: pointer;
    font-size: 0.85rem; font-weight: 500; transition: background 0.15s;
    font-family: inherit;
  }
  .btn:hover { background: var(--primary-light); }
  .btn:disabled { background: var(--neutral); cursor: not-allowed; }
  .btn-outline {
    background: white; color: var(--primary); border: 1px solid var(--primary);
  }
  .btn-outline:hover { background: var(--bg); }
  .btn-success { background: var(--success); }
  .btn-success:hover { background: #15803d; }
  .btn-large {
    padding: 0.85rem 2rem; font-size: 1rem; border-radius: 10px;
  }

  .card {
    background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
    padding: 2rem 1.5rem; margin-bottom: 1rem;
    min-height: 400px; display: flex; flex-direction: column;
  }

  .stage-term {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; align-items: center; text-align: center;
    padding: 2rem 1rem;
  }
  .stage-term .label {
    font-size: 0.75rem; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 1rem;
  }
  .stage-term .term-text {
    font-size: 2rem; font-weight: 700; color: var(--primary);
    margin-bottom: 2rem; line-height: 1.2;
  }
  .stage-term .hint {
    font-size: 0.85rem; color: var(--text-light); margin-top: 1.5rem;
  }

  .stage-options { padding: 0.5rem; }
  .stage-options .term-reminder {
    text-align: center; margin-bottom: 1rem; padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
  }
  .stage-options .term-reminder .label {
    font-size: 0.7rem; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .stage-options .term-reminder .term-text {
    font-size: 1.3rem; font-weight: 700; color: var(--primary); margin-top: 0.2rem;
  }
  .stage-options .question {
    text-align: center; color: var(--text); font-size: 0.95rem; margin-bottom: 1.25rem;
  }
  .options-list { display: flex; flex-direction: column; gap: 0.7rem; }
  .option-btn {
    display: flex; align-items: flex-start; gap: 0.8rem;
    padding: 0.85rem 1rem; background: white; border: 2px solid #e2e8f0;
    border-radius: 10px; cursor: pointer; text-align: left;
    font-family: inherit; font-size: 0.92rem; line-height: 1.45;
    color: var(--text); transition: all 0.15s; width: 100%;
  }
  .option-btn:hover { border-color: var(--primary-light); background: #f8fafc; }
  .option-letter {
    flex-shrink: 0; width: 28px; height: 28px;
    background: #e2e8f0; color: var(--text); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
  }
  .option-text { flex: 1; }

  .stage-answer .term-reminder {
    text-align: center; margin-bottom: 1rem; padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
  }
  .stage-answer .term-reminder .label {
    font-size: 0.7rem; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .stage-answer .term-reminder .term-text {
    font-size: 1.3rem; font-weight: 700; color: var(--primary); margin-top: 0.2rem;
  }
  .stage-answer .result-banner {
    text-align: center; padding: 0.85rem; border-radius: 10px;
    margin-bottom: 1rem; font-weight: 600; font-size: 1rem;
  }
  .stage-answer .result-banner.correct { background: var(--success-bg); color: var(--success); }
  .stage-answer .result-banner.incorrect { background: var(--danger-bg); color: var(--danger); }
  .stage-answer .options-review { display: flex; flex-direction: column; gap: 0.55rem; }
  .option-review {
    display: flex; align-items: flex-start; gap: 0.7rem;
    padding: 0.7rem 0.9rem; border: 2px solid #e2e8f0;
    border-radius: 10px; font-size: 0.88rem; line-height: 1.45; background: white;
  }
  .option-review.is-correct { background: var(--success-bg); border-color: var(--success); }
  .option-review.is-incorrect-selected { background: var(--danger-bg); border-color: var(--danger); }
  .option-review.is-neutral { opacity: 0.6; }
  .option-review .mark {
    flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
  }
  .option-review.is-correct .mark { background: var(--success); color: white; }
  .option-review.is-incorrect-selected .mark { background: var(--danger); color: white; }
  .option-review.is-neutral .mark { background: #e2e8f0; color: var(--text-light); }

  .ref-box {
    margin-top: 1.25rem; padding: 0.85rem 1rem;
    background: #f8fafc; border-left: 3px solid var(--primary-light);
    border-radius: 6px; font-size: 0.8rem; color: var(--text-light); line-height: 1.55;
  }
  .ref-box strong { color: var(--text); }

  .badges {
    display: flex; gap: 0.5rem; flex-wrap: wrap;
    justify-content: center; margin: 1rem 0 0.5rem;
  }
  .badge {
    display: inline-block; padding: 0.3rem 0.7rem; border-radius: 999px;
    font-size: 0.72rem; font-weight: 600;
  }
  .badge-tema { background: #dbeafe; color: #1e40af; }
  .badge-eco { background: #fef3c7; color: #92400e; }
  .badge-srs { background: #ede9fe; color: #6d28d9; }

  .actions {
    display: flex; gap: 0.6rem; margin-top: 1.25rem;
    justify-content: center; flex-wrap: wrap;
  }

  .empty-state {
    text-align: center; padding: 3rem 1rem;
  }
  .empty-state h3 { color: var(--primary); margin-bottom: 0.5rem; }
  .empty-state p { color: var(--text-light); margin-bottom: 1.5rem; }

  .footer {
    text-align: center; font-size: 0.75rem; color: var(--text-light); margin-top: 2rem;
  }
  .footer a { color: var(--primary); text-decoration: none; }

  @media (max-width: 480px) {
    .stage-term .term-text { font-size: 1.5rem; }
    .card { padding: 1.5rem 1rem; min-height: 350px; }
    header h1 { font-size: 1.3rem; }
  }