:root {
    --ink: #0D1117;
    --paper: #F7F4EF;
    --cream: #EDE9E1;
    --gold: #C9A84C;
    --gold-light: #F0E4C0;
    --teal: #1A6B6B;
    --teal-light: #E0F0F0;
    --coral: #D4522A;
    --coral-light: #FAE8E2;
    --sage: #4A7C59;
    --sage-light: #E3EEE7;
    --violet: #5B4A8A;
    --violet-light: #EDE9F7;
    --sky: #2A6FA8;
    --sky-light: #E2EEF7;
    --border: rgba(13,17,23,0.12);
    --shadow: 0 4px 24px rgba(13,17,23,0.08);
    --shadow-lg: 0 12px 48px rgba(13,17,23,0.14);
  }

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

  body {
    font-family: 'Sora', sans-serif;
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* ── HEADER ── */
  header {
    background: var(--ink);
    padding: 0 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .logo-mark {
    width: 36px;
    height: 36px;
    background: var(--gold);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    color: var(--ink);
    font-weight: 400;
  }

  .logo-text {
    font-size: 18px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.3px;
  }

  .logo-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    font-weight: 400;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-top: 1px;
  }

  .header-badge {
    background: rgba(201,168,76,0.2);
    border: 1px solid rgba(201,168,76,0.4);
    color: var(--gold);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.5px;
  }

  /* ── PROGRESS BAR ── */
  .progress-bar {
    height: 3px;
    background: var(--cream);
    position: sticky;
    top: 68px;
    z-index: 99;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--teal));
    transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
    width: 0%;
  }

  /* ── MAIN ── */
  main {
    max-width: 860px;
    margin: 0 auto;
    padding: 64px 32px 120px;
  }

  /* ── STEP SYSTEM ── */
  .step { display: none; animation: fadeUp 0.4s ease; }
  .step.active { display: block; }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── STEP HEADER ── */
  .step-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 12px;
  }

  .step-title {
    font-family: 'DM Serif Display', serif;
    font-size: 42px;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: 16px;
  }

  .step-title em {
    font-style: italic;
    color: var(--teal);
  }

  .step-desc {
    font-size: 16px;
    line-height: 1.7;
    color: rgba(13,17,23,0.6);
    max-width: 600px;
    margin-bottom: 40px;
  }

  /* ── ROLE CARDS ── */
  .role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
  }

  .role-card {
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    position: relative;
    overflow: hidden;
  }

  .role-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--accent, var(--gold));
    transform: scaleX(0);
    transition: transform 0.2s ease;
  }

  .role-card:hover { border-color: var(--accent, var(--gold)); transform: translateY(-2px); box-shadow: var(--shadow); }
  .role-card:hover::before { transform: scaleX(1); }
  .role-card.selected { border-color: var(--accent, var(--gold)); background: var(--accent-light, var(--gold-light)); box-shadow: var(--shadow); }
  .role-card.selected::before { transform: scaleX(1); }

  .role-icon { font-size: 32px; margin-bottom: 12px; }
  .role-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
  .role-desc { font-size: 13px; color: rgba(13,17,23,0.55); line-height: 1.5; }

  .role-outputs {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .output-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(13,17,23,0.06);
    color: rgba(13,17,23,0.5);
    letter-spacing: 0.3px;
  }

  /* ── FORM FIELDS ── */
  .field-group { margin-bottom: 28px; }

  .field-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    display: block;
    color: rgba(13,17,23,0.7);
  }

  .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

  input, select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'Sora', sans-serif;
    font-size: 15px;
    background: white;
    color: var(--ink);
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
  }

  input:focus, select:focus { border-color: var(--teal); }

  .select-wrapper { position: relative; }
  .select-wrapper::after {
    content: '↓';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: rgba(13,17,23,0.4);
    font-size: 14px;
  }

  /* ── LD SELECTION ── */
  .ld-section { margin-bottom: 32px; }
  .ld-section-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(13,17,23,0.5);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .ld-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
  }

  .ld-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: white;
    font-size: 14px;
    font-weight: 500;
  }

  .ld-chip:hover { border-color: var(--chip-color, var(--teal)); background: var(--chip-bg, var(--teal-light)); }
  .ld-chip.selected { border-color: var(--chip-color, var(--teal)); background: var(--chip-bg, var(--teal-light)); }
  .ld-chip.selected .ld-check { opacity: 1; }

  .ld-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--chip-color, var(--teal));
    flex-shrink: 0;
  }

  .ld-check {
    margin-left: auto;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--chip-color, var(--teal));
  }

  .ld-combo-notice {
    margin-top: 16px;
    padding: 14px 18px;
    background: var(--gold-light);
    border: 1px solid rgba(201,168,76,0.4);
    border-radius: 10px;
    font-size: 13px;
    color: rgba(13,17,23,0.7);
    display: none;
  }

  .ld-combo-notice.show { display: block; }

  /* ── IEP GOALS ── */
  .goal-builder {
    border: 2px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: white;
  }

  .goal-builder-header {
    padding: 16px 20px;
    background: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .goal-builder-title { color: white; font-size: 14px; font-weight: 600; }

  .add-goal-btn {
    background: var(--gold);
    color: var(--ink);
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-family: 'Sora', sans-serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
  }

  .add-goal-btn:hover { opacity: 0.85; }

  .goal-list { padding: 8px; }

  .goal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--cream);
    animation: fadeUp 0.25s ease;
  }

  .goal-domain-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .goal-item input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 14px;
  }

  .goal-item input:focus { outline: none; }

  .goal-remove {
    background: none;
    border: none;
    color: rgba(13,17,23,0.3);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    transition: color 0.15s;
  }

  .goal-remove:hover { color: var(--coral); }

  .goal-empty {
    padding: 32px;
    text-align: center;
    color: rgba(13,17,23,0.35);
    font-size: 14px;
  }

  /* ── OUTPUT FORMAT ── */
  .output-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
  }

  .output-card {
    padding: 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    background: white;
  }

  .output-card:hover { border-color: var(--teal); }
  .output-card.selected { border-color: var(--teal); background: var(--teal-light); }

  .output-card-icon { font-size: 24px; margin-bottom: 8px; }
  .output-card-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
  .output-card-desc { font-size: 12px; color: rgba(13,17,23,0.5); line-height: 1.5; }

  /* ── BUTTONS ── */
  .btn-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 40px;
  }

  .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 32px;
    background: var(--ink);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: 'Sora', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: -0.2px;
  }

  .btn-primary:hover { background: var(--teal); transform: translateY(-1px); box-shadow: var(--shadow); }
  .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

  .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: transparent;
    color: var(--ink);
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'Sora', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
  }

  .btn-secondary:hover { border-color: var(--ink); }

  /* ── GENERATING SCREEN ── */
  #step-generating {
    text-align: center;
    padding: 80px 0;
  }

  .gen-spinner {
    width: 64px;
    height: 64px;
    border: 4px solid var(--cream);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 32px;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  .gen-title {
    font-family: 'DM Serif Display', serif;
    font-size: 32px;
    margin-bottom: 12px;
  }

  .gen-status {
    font-size: 14px;
    color: rgba(13,17,23,0.5);
    font-family: 'DM Mono', monospace;
    margin-top: 24px;
    min-height: 20px;
  }

  .gen-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 32px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
  }

  .gen-step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: rgba(13,17,23,0.4);
    padding: 10px 16px;
    border-radius: 8px;
    transition: all 0.3s;
  }

  .gen-step-item.active { color: var(--ink); background: var(--cream); }
  .gen-step-item.done { color: var(--sage); }
  .gen-step-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

  /* ── OUTPUT SCREEN ── */
  .output-header {
    background: var(--ink);
    border-radius: 16px;
    padding: 32px 40px;
    margin-bottom: 32px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
  }

  .output-header-left {}
  .output-role-badge {
    display: inline-block;
    background: rgba(201,168,76,0.25);
    border: 1px solid rgba(201,168,76,0.5);
    color: var(--gold);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
  }

  .output-student-name {
    font-family: 'DM Serif Display', serif;
    font-size: 28px;
    color: white;
    margin-bottom: 6px;
  }

  .output-meta {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    line-height: 1.8;
  }

  .output-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }

  .action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-family: 'Sora', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    white-space: nowrap;
  }

  .action-btn-gold { background: var(--gold); color: var(--ink); }
  .action-btn-gold:hover { opacity: 0.85; }
  .action-btn-outline { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); }
  .action-btn-outline:hover { background: rgba(255,255,255,0.15); }

  /* ── TABS ── */
  .tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--cream);
    padding: 4px;
    border-radius: 12px;
    overflow-x: auto;
  }

  .tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: 'Sora', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: rgba(13,17,23,0.5);
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .tab-btn.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(13,17,23,0.08); }

  .tab-content { display: none; }
  .tab-content.active { display: block; animation: fadeUp 0.3s ease; }

  /* ── FRAMEWORK SECTIONS ── */
  .fw-section {
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 20px;
    background: white;
  }

  .fw-section-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
  }

  .fw-section-header:hover { background: var(--cream); }

  .fw-section-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
  }

  .fw-section-title { font-size: 15px; font-weight: 700; flex: 1; }
  .fw-section-subtitle { font-size: 12px; color: rgba(13,17,23,0.45); margin-top: 2px; }
  .fw-section-toggle { color: rgba(13,17,23,0.3); font-size: 18px; transition: transform 0.2s; }
  .fw-section.open .fw-section-toggle { transform: rotate(180deg); }

  .fw-section-body {
    display: none;
    padding: 0 24px 24px;
    border-top: 1px solid var(--border);
  }

  .fw-section.open .fw-section-body { display: block; }

  /* ── PROTOCOL CARD ── */
  .protocol-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    background: var(--paper);
  }

  .protocol-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
  }

  .protocol-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ink);
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .protocol-name { font-size: 14px; font-weight: 700; }
  .protocol-std { font-size: 11px; font-weight: 600; color: var(--teal); margin-top: 2px; font-family: 'DM Mono', monospace; }

  .protocol-steps { list-style: none; }
  .protocol-steps li {
    padding: 8px 0 8px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(13,17,23,0.7);
    border-bottom: 1px solid var(--border);
    position: relative;
  }

  .protocol-steps li:last-child { border-bottom: none; }
  .protocol-steps li::before {
    content: attr(data-step);
    position: absolute;
    left: 0;
    font-weight: 700;
    color: var(--gold);
    font-size: 11px;
    top: 10px;
  }

  /* ── PROMPT LIBRARY ── */
  .prompt-card {
    background: var(--ink);
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 12px;
    position: relative;
  }

  .prompt-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
  }

  .prompt-text {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    line-height: 1.7;
  }

  .prompt-copy {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.5);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Sora', sans-serif;
  }

  .prompt-copy:hover { background: rgba(255,255,255,0.2); color: white; }

  /* ── STD TABLE ── */
  .std-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
  .std-table th { background: var(--ink); color: white; padding: 10px 14px; text-align: left; font-weight: 600; font-size: 12px; }
  .std-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); line-height: 1.5; }
  .std-table tr:nth-child(even) td { background: var(--cream); }
  .std-code { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--teal); font-weight: 500; }

  /* ── IEP GOAL CARD ── */
  .iep-goal-card {
    border-left: 4px solid var(--gold);
    padding: 16px 20px;
    background: var(--gold-light);
    border-radius: 0 10px 10px 0;
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.7;
    color: rgba(13,17,23,0.8);
  }

  .iep-goal-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(13,17,23,0.45);
    margin-bottom: 6px;
  }

  /* ── BRAIN PROFILE ── */
  .brain-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
  }

  .bp-card {
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
  }

  .bp-card-label { font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: rgba(13,17,23,0.4); margin-bottom: 8px; }
  .bp-card-content { font-size: 13px; line-height: 1.6; color: rgba(13,17,23,0.75); }

  /* ── RESTART ── */
  .restart-row {
    display: flex;
    justify-content: center;
    margin-top: 48px;
  }

  /* ── RESPONSIVE ── */
  @media (max-width: 640px) {
    header { padding: 0 20px; }
    main { padding: 40px 20px 80px; }
    .step-title { font-size: 30px; }
    .field-row { grid-template-columns: 1fr; }
    .output-grid { grid-template-columns: 1fr; }
    .brain-profile-grid { grid-template-columns: 1fr; }
    .output-header { flex-direction: column; }
    .output-actions { flex-direction: row; }
  }

  /* ── FOOTER ── */
  .dap-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--ink);
    color: rgba(255,255,255,0.5);
    font-size: 11px;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    border-top: 1px solid rgba(255,255,255,0.08);
  }
  .dap-footer-brand { display:flex;align-items:center;gap:8px;font-weight:700;color:var(--gold);font-size:12px;letter-spacing:0.3px; }
  .dap-footer-brand span { color:rgba(255,255,255,0.4);font-weight:400; }
  .dap-footer-id { font-family:'DM Mono',monospace;font-size:10px;color:rgba(255,255,255,0.3); }
  .dap-footer-tracker { font-size:10px;color:rgba(255,255,255,0.3);display:flex;align-items:center;gap:6px; }
  .tracker-dot { width:6px;height:6px;border-radius:50%;background:var(--sage);animation:pulse 2s infinite; }
  @keyframes pulse { 0%,100%{opacity:1}50%{opacity:0.3} }
  body { padding-bottom: 44px; }

  @media print {
    header,.progress-bar,.btn-row,.action-btn,.tab-bar,.restart-row,.dap-footer { display:none !important; }
    .step { display:block !important; }
    .step:not(#step-output) { display:none !important; }
    .tab-content { display:block !important;page-break-inside:avoid;margin-bottom:24px; }
    .fw-section-body { display:block !important; }
    body { background:white;padding:0; }
    main { padding:20px;max-width:100%; }
    .output-header { background:#0D1117 !important;-webkit-print-color-adjust:exact;print-color-adjust:exact;border-radius:8px;margin-bottom:20px; }
    .print-footer { display:flex !important;position:fixed;bottom:0;left:0;right:0;border-top:2px solid #C9A84C;padding:6px 20px;justify-content:space-between;align-items:center;font-size:9px;color:#555;background:white; }
    .print-footer-brand { font-weight:700;color:#0D1117;font-size:10px; }
    .print-footer-id { font-family:monospace;color:#888; }
    .print-footer-url { color:#1A6B6B; }
  }
  .print-footer { display:none; }