
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

  :root {
    --grf-green: #5abf35;
    --grf-green-dark: #3d9e1e;
    --grf-green-light: #e8f8e0;
    --grf-green-pale: #f2fbee;
    --bg: #f5f7f4;
    --surface: #ffffff;
    --surface-2: #f0f4ee;
    --text: #1a2318;
    --text-muted: #6b7c68;
    --border: #dce8d8;
    --shadow: 0 4px 24px rgba(50,90,40,0.10);
    --shadow-lg: 0 12px 48px rgba(50,90,40,0.16);
    --radius: 12px;
    --radius-sm: 8px;
  }


  /* Hero / intro screen */
  #intro-screen {
    max-width: 560px;
    width: 100%;
    text-align: center;
    animation: fadeUp 0.6s ease both;
  }

  .logo-wrap {
    width: 52px; height: 52px;
    background: var(--grf-green);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 4px 16px rgba(90,191,53,0.35);
    font-size: 24px;
  }

  #intro-screen h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 12px;
  }

  #intro-screen h1 span { color: var(--grf-green); }

  #intro-screen p {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 12px;
  }

  .role-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }

  .role-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
  }

  .role-card:hover {
    border-color: var(--grf-green);
    background: var(--grf-green-pale);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }

  .role-card .icon { font-size: 1.4rem; margin-bottom: 6px; }
  .role-card h3 { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
  .role-card p { font-size: 0.72rem; color: var(--text-muted); line-height: 1.3; }

  .role-card-both {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted);
    font-size: 0.78rem;
  }
  .role-card-both:hover {
    border-color: var(--grf-green);
    color: var(--text);
    background: var(--grf-green-pale);
  }

  /* Chat screen */
  #chat-screen {
    display: none;
    width: 100%;
    max-width: 760px;
    height: 90vh;
    top: 10px !important;
    max-height: calc(100vh - 140px);
    background: var(--surface);
    border-radius: 0 0 10px 10px;
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    overflow: hidden;
    animation: fadeUp 0.4s ease both;
  }

  .chat-header {
    background: var(--grf-green);
    padding: 10px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 0;
    flex-shrink: 0;
  }

  .chat-header-avatar {
    width: 28px; height: 28px;
    background: rgba(255,255,255,0.25);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
  }

  .chat-header-info h2 {
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0px;
  }

  .chat-header-info p {
    color: rgba(255,255,255,0.8);
    font-size: 0.7rem;
    margin-bottom: 0px;
  }

  .chat-header-role {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 500;
    white-space: nowrap;
  }

  .chat-header-reset {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    border-radius: 7px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 0.68rem;
    font-family: inherit;
    transition: background 0.15s;
    flex-shrink: 0;
  }
  .chat-header-reset:hover { background: rgba(255,255,255,0.28); }

  .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
  }

  .chat-messages::-webkit-scrollbar { width: 4px; }
  .chat-messages::-webkit-scrollbar-track { background: transparent; }
  .chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .msg {
    display: flex;
    gap: 10px;
    animation: fadeUp 0.3s ease both;
  }

  .msg.user { flex-direction: row-reverse; }

  .msg-avatar {
    width: 26px; height: 26px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
  }

  .msg.bot .msg-avatar { background: var(--grf-green-light); }
  .msg.user .msg-avatar { background: var(--surface-2); }

  .msg-bubble {
    max-width: 80%;
    padding: 8px 11px;
    border-radius: 11px;
    line-height: 1.45;
    font-size: 0.8rem;
  }

  .msg.bot .msg-bubble {
    background: var(--grf-green-pale);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
    color: var(--text);
  }

  .msg.user .msg-bubble {
    background: var(--grf-green);
    color: #fff;
    border-top-right-radius: 4px;
  }

  .msg-bubble strong { font-weight: 600; }
  .msg-bubble ul { padding-left: 16px; margin: 8px 0; }
  .msg-bubble li { margin-bottom: 4px; }
  .msg-bubble .tip {
    display: inline-block;
    background: rgba(90,191,53,0.15);
    border-left: 3px solid var(--grf-green);
    border-radius: 0 8px 8px 0;
    padding: 6px 10px;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--grf-green-dark);
    font-style: italic;
  }

  /* Typing indicator */
  .typing-indicator {
    display: flex; gap: 10px; align-items: flex-end;
  }

  .typing-dots {
    background: var(--grf-green-pale);
    border: 1px solid var(--border);
    border-radius: 16px;
    border-top-left-radius: 4px;
    padding: 14px 18px;
    display: flex; gap: 5px; align-items: center;
  }

  .typing-dots span {
    width: 7px; height: 7px;
    background: var(--grf-green);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
  }
  .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
  .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

  /* Quick replies */
  .quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 0 10px 10px;
  }

  .qr-btn {
    background: var(--surface);
    border: 1.5px solid var(--grf-green);
    color: var(--grf-green-dark);
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
  }

  .qr-btn:hover {
    background: var(--grf-green);
    color: #fff;
    transform: translateY(-1px);
  }

  /* Input area */
  .chat-input-wrap {
    border-top: 1px solid var(--border);
    padding: 8px 10px;
    display: flex;
    gap: 7px;
    align-items: flex-end;
    flex-shrink: 0;
    background: var(--surface);
  }

  #user-input {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 6px 10px;
    font-size: 0.62rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
    outline: none;
    resize: none;
    min-height: 28px;
    max-height: 80px;
    line-height: 1.35;
    transition: border-color 0.15s;
  }

  #user-input:focus { border-color: var(--grf-green); background: #fff; }
  #user-input::placeholder { color: var(--text-muted); }

  #send-btn {
    width: 32px; height: 32px;
    background: var(--grf-green);
    border: none;
    border-radius: 9px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
    color: #fff;
    font-size: 13px;
  }

  #send-btn:hover { background: var(--grf-green-dark); transform: scale(1.05); }
  #send-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

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

  @keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
  }

  /* Progress chips */
  .progress-chips {
    display: flex; flex-wrap: wrap; gap: 4px;
    padding: 6px 10px 0;
  }
  .chip {
    background: var(--grf-green-light);
    color: var(--grf-green-dark);
    border-radius: 14px;
    padding: 2px 7px;
    font-size: 0.65rem;
    font-weight: 500;
  }

  @media (max-width: 500px) {
    .role-cards { grid-template-columns: 1fr; }
    #intro-screen h1 { font-size: 1.6rem; }
    #chat-screen { height: 100vh; max-height: none; border-radius: 0; }
  }

  /* ── Quiz button in header ── */
  .chat-header-quiz {
    background: rgba(255,255,255,0.22);
    border: 1.5px solid rgba(255,255,255,0.5);
    color: #fff;
    border-radius: 7px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 0.68rem;
    font-family: inherit;
    font-weight: 600;
    transition: background 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .chat-header-quiz:hover { background: rgba(255,255,255,0.35); }

  /* ── Quiz body ── */
  .quiz-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .quiz-body::-webkit-scrollbar { width: 4px; }
  .quiz-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .quiz-question-wrap { animation: fadeUp 0.35s ease both; }

  .quiz-question-num {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--grf-green);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 6px;
  }

  .quiz-question-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 14px;
  }

  .quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }

  .quiz-option {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: inherit;
    color: var(--text);
    text-align: left;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .quiz-option:hover:not(:disabled) {
    border-color: var(--grf-green);
    background: var(--grf-green-pale);
    transform: translateX(3px);
  }

  .quiz-option.correct {
    border-color: #22c55e;
    background: #f0fdf4;
    color: #15803d;
    cursor: default;
  }

  .quiz-option.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    color: #b91c1c;
    cursor: default;
  }

  .quiz-option.correct-highlight {
    border-color: #22c55e;
    background: #dcfce7;
    color: #15803d;
    cursor: default;
  }

  .quiz-option:disabled { cursor: default; transform: none; }

  .quiz-option-letter {
    width: 22px; height: 22px;
    border-radius: 6px;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
  }

  .quiz-option.correct .quiz-option-letter { background: #22c55e; color: #fff; }
  .quiz-option.wrong .quiz-option-letter { background: #ef4444; color: #fff; }
  .quiz-option.correct-highlight .quiz-option-letter { background: #22c55e; color: #fff; }

  .quiz-feedback {
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    margin-bottom: 12px;
    font-size: 0.76rem;
    line-height: 1.5;
    animation: fadeUp 0.25s ease both;
  }

  .quiz-feedback.success {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    color: #15803d;
  }

  .quiz-feedback.error {
    background: #fef2f2;
    border: 1.5px solid #fca5a5;
    color: #b91c1c;
  }

  .quiz-next-btn {
    background: var(--grf-green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    align-self: flex-start;
  }
  .quiz-next-btn:hover { background: var(--grf-green-dark); transform: translateY(-1px); }

  .quiz-progress-bar-wrap {
    height: 4px;
    background: var(--border);
    flex-shrink: 0;
  }
  .quiz-progress-bar {
    height: 100%;
    background: var(--grf-green);
    transition: width 0.4s ease;
  }

  /* ── Congrats screen ── */
  .congrats-wrap {
    position: relative;
    width: 100%;
    max-width: 560px;
    overflow: hidden;
  }

  .congrats-confetti {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
  }

  .confetti-piece {
    position: absolute;
    width: 10px; height: 10px;
    border-radius: 2px;
    animation: confettiFall linear forwards;
  }

  @keyframes confettiFall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(600px) rotate(720deg); opacity: 0; }
  }

  .congrats-card {
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    text-align: center;
    position: relative;
    z-index: 1;
  }

  .congrats-badge {
    font-size: 2.8rem;
    margin-bottom: 12px;
    animation: popIn 0.5s cubic-bezier(0.175,0.885,0.32,1.275) both;
    animation-delay: 0.2s;
  }

  @keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
  }

  .congrats-card h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
  }

  .congrats-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
  }

  .congrats-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
  }

  .congrats-stat {
    background: var(--grf-green-pale);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    min-width: 110px;
  }

  .congrats-stat-val {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--grf-green);
    line-height: 1;
    margin-bottom: 4px;
  }

  .congrats-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
  }

  .congrats-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 32px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }

  .congrats-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .congrats-btn-primary {
    background: var(--grf-green);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
  }
  .congrats-btn-primary:hover { background: var(--grf-green-dark); }

  .congrats-btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
  }
  .congrats-btn-secondary:hover { border-color: var(--grf-green); color: var(--grf-green-dark); }


  #intro-screen {
    flex: 1;
    overflow-y: auto;
    padding: 24px 18px;
    box-sizing: border-box;
  }
  #chat-screen {
    flex: 1 !important;
    min-height: 0;
  }
  #quiz-screen {
    flex: 1;
    min-height: 0;
  }
  #congrats-screen {
    flex: 1;
    overflow-y: auto;
  }
  .congrats-wrap {
    min-height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 14px;
    box-sizing: border-box;
  }
  .congrats-card { padding: 24px 18px; width: 100%; }
  .chat-header { padding: 12px 14px; flex-wrap: wrap; gap: 6px; }
  .chat-header-quiz, .chat-header-reset { font-size: 0.72rem; padding: 5px 8px; }
  .chat-messages { padding: 14px; }
  .quick-replies { padding: 0 10px 10px; }
  .chat-input-wrap { padding: 8px 10px; }
  .role-card { padding: 14px 12px; }
  #intro-screen h1 { font-size: 1.6rem; }

  /* ── 2-row header layout ── */
  .chat-header-row1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
  }
  .chat-header-row2 {
    display: flex;
    align-items: center;
    gap: 6px;
  }
