*{box-sizing:border-box}html,body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,'Noto Sans',Ubuntu,'Helvetica Neue',Arial,sans-serif;color:#0f172a;background:#ffffff}
.container{max-width:1040px;margin:0 auto;padding:16px}
.header{display:flex;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid #e5e7eb;background:#fff;position:sticky;top:0;z-index:10}
.brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:20px}
.logo{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;background:#14b8a6;color:white;font-size:22px;box-shadow:0 6px 18px rgba(20,184,166,.35)}
nav a{margin-left:12px;color:#334155;text-decoration:none}
nav a:hover{text-decoration:underline}
.hero{display:grid;grid-template-columns:1.1fr .9fr;align-items:center;gap:24px;padding-block:24px}
.hero h1{font-size:36px;line-height:1.15;margin:.2em 0}
.hero p{color:#475569;max-width:52ch}
.cta{background:#f97316;color:#fff;border:0;border-radius:10px;padding:12px 16px;font-weight:700;cursor:pointer;box-shadow:0 8px 20px rgba(249,115,22,.35)}
.cta:hover{filter:brightness(.95)}
.how .steps{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.step{background:#f8fafc;border:1px solid #e2e8f0;border-radius:12px;padding:14px}
.tools .card{border:1px solid #e2e8f0;border-radius:14px;padding:16px;margin:18px 0;background:#fcfcff}
.tool-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
label{display:block;margin-bottom:8px;font-weight:600}
input,select,button{padding:10px;border:1px solid #cbd5e1;border-radius:8px}
input:focus,select:focus{outline:2px solid #93c5fd;border-color:#93c5fd}
#render{background:#3b82f6;color:#fff;border:0;font-weight:700}
.canvas-wrap{display:grid;place-items:center;background:#fff;border:1px dashed #d1d5db;border-radius:12px;padding:8px;min-height:220px}
#canvas{max-width:100%;height:auto}
.frac-text{margin-top:10px;font-size:22px;font-weight:800}
.scripts{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.script-box{margin-top:8px;padding:12px;border-radius:10px;background:#f1f5f9;border:1px solid #e2e8f0;min-height:48px}
.progress-row{display:flex;align-items:center;gap:10px;margin:10px 0}
.progress-bar{flex:1;height:10px;background:#e2e8f0;border-radius:999px;overflow:hidden}
.progress-fill{height:100%;width:0%;background:linear-gradient(90deg,#34d399,#14b8a6);border-radius:999px;transition:width .35s ease}
.progress-label{font-size:12.5px;color:#475569;font-weight:700;white-space:nowrap}
.streak-label{font-size:12.5px;color:#c2410c;font-weight:700;white-space:nowrap}
.missions li.celebrate{animation:celebratePulse .5s ease}
@keyframes celebratePulse{
  0%{background:#f8fafc}
  35%{background:#bbf7d0; transform:scale(1.02)}
  100%{background:#f0fdf4; transform:scale(1)}
}
.missions-head,.history-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:6px;margin-bottom:6px}
.missions-label{font-weight:700;color:#334155;font-size:14px;text-transform:uppercase;letter-spacing:.03em}
.history-head{margin-top:18px;border-top:1px dashed #e2e8f0;padding-top:14px}
.missions{list-style:none;padding:0;margin:0;display:grid;gap:8px}
.missions li{display:flex;align-items:center;gap:10px;background:#f8fafc;border:1px solid #e2e8f0;border-radius:10px;padding:10px}
.missions input[type=checkbox]{transform:scale(1.2)}
.missions .mission-text{flex:1}
.missions .save-btn{margin-left:auto;background:transparent;border:1px solid #cbd5e1;border-radius:8px;padding:6px 10px;cursor:pointer;font-size:15px;line-height:1}
.missions .save-btn:hover{background:#eef2ff;border-color:#93c5fd}
.hint{color:#64748b;font-size:13px;margin:6px 0 0}
.missions.history li{background:#f0fdf4;border-color:#bbf7d0;justify-content:space-between;align-items:baseline}
.missions.history .history-date{color:#16a34a;font-size:12px;white-space:nowrap;margin-left:10px}
.missions.saved li{background:#fffbeb;border-color:#fde68a;justify-content:space-between}
.missions.history .history-empty,.missions.saved .history-empty{color:#94a3b8;font-style:italic;background:transparent;border:1px dashed #e2e8f0}
.btn-soft{background:#eef2ff;color:#3730a3;border:1px solid #c7d2fe;border-radius:999px;padding:9px 16px;font-weight:700;font-size:13.5px;cursor:pointer;transition:background .15s, transform .1s}
.btn-soft:hover{background:#e0e7ff}
.btn-soft:active{transform:scale(0.97)}
.accordion-toggle{width:100%;display:flex;align-items:center;justify-content:space-between;gap:10px;background:#fffbeb;border:1px solid #fde68a;border-radius:10px;padding:10px 14px;margin-top:18px;cursor:pointer;text-align:left}
.accordion-toggle:hover{background:#fef3c7}
.accordion-toggle .chevron{font-size:16px;color:#92400e;transition:transform .2s}
.accordion-toggle[aria-expanded="true"] .chevron{transform:rotate(180deg)}
.missions.saved,.missions.history{margin-top:8px;overflow:hidden;max-height:1000px;transition:max-height .25s ease}
.missions.saved.collapsed,.missions.history.collapsed{max-height:0;margin-top:0}
.tips .bullets{display:grid;gap:8px}
.footer{border-top:1px solid #e5e7eb;margin-top:24px;padding-block:24px;color:#64748b}
@media (max-width:900px){.hero{grid-template-columns:1fr}.how .steps{grid-template-columns:1fr}.tool-grid{grid-template-columns:1fr}.missions-head,.history-head{flex-direction:column;align-items:flex-start}}

/* ---- profile bar ---- */
.profile-bar{display:flex;align-items:center;gap:10px;padding-top:10px;padding-bottom:10px}
.profile-icon{font-size:18px}
#profileSelect{padding:9px 10px;border:1px solid #cbd5e1;border-radius:8px;background:#fff;font-weight:600}
.theme-btn{margin-left:auto}

/* ---- onboarding modal ---- */
.modal-overlay{position:fixed;inset:0;background:rgba(15,23,42,0.55);display:flex;align-items:center;justify-content:center;z-index:100;padding:16px}
.modal-overlay.hidden{display:none}
.modal-box{background:#fff;border-radius:16px;padding:24px;max-width:420px;width:100%;box-shadow:0 20px 50px rgba(0,0,0,0.3)}
.modal-box h2{margin-top:0}
.onboard-list{list-style:none;padding:0;display:grid;gap:10px;margin:14px 0}
.onboard-list li{background:#f8fafc;border:1px solid #e2e8f0;border-radius:10px;padding:10px;font-size:14px;line-height:1.4}
.profile-name-input{width:100%;padding:11px 12px;border:1px solid #cbd5e1;border-radius:8px;font-size:15px;margin:6px 0 4px}
.modal-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:14px}

/* ---- auth gate ---- */
#authGate{z-index:200}
.auth-box{max-width:380px}
.auth-forms{display:grid;gap:10px;margin-top:8px}
.auth-google{background:#fff;color:#0f172a;border:1px solid #cbd5e1;box-shadow:none;display:flex;align-items:center;justify-content:center;gap:8px}
.auth-google:hover{background:#f8fafc;filter:none}
.auth-divider{display:flex;align-items:center;gap:10px;color:#94a3b8;font-size:12.5px;margin:2px 0}
.auth-divider::before,.auth-divider::after{content:"";flex:1;height:1px;background:#e2e8f0}
.auth-actions{display:flex;gap:10px;margin-top:2px}
.auth-actions button{flex:1}
.auth-error{background:#fef2f2;border:1px solid #fecaca;color:#b91c1c;border-radius:8px;padding:8px 10px;font-size:13px}
.auth-info{font-size:13px;color:#475569;font-weight:600;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#authConfigNote{margin-top:6px}
[data-theme="dark"] .auth-google{background:#0f172a;color:#e2e8f0;border-color:#334155}
[data-theme="dark"] .auth-google:hover{background:#1e293b}
[data-theme="dark"] .auth-divider{color:#64748b}
[data-theme="dark"] .auth-divider::before,[data-theme="dark"] .auth-divider::after{background:#334155}
[data-theme="dark"] .auth-error{background:#3f1d1d;border-color:#7f1d1d;color:#fca5a5}
[data-theme="dark"] .auth-info{color:#94a3b8}

/* ---- dark mode ---- */
[data-theme="dark"]{color-scheme:dark}
[data-theme="dark"] html,[data-theme="dark"] body{background:#0f172a;color:#e2e8f0}
[data-theme="dark"] .header{background:#0f172a;border-bottom-color:#1e293b}
[data-theme="dark"] nav a{color:#cbd5e1}
[data-theme="dark"] .hero p,[data-theme="dark"] .missions-label,[data-theme="dark"] .progress-label,[data-theme="dark"] .hint{color:#94a3b8}
[data-theme="dark"] .step,[data-theme="dark"] .tools .card,[data-theme="dark"] .script-box{background:#1e293b;border-color:#334155;color:#e2e8f0}
[data-theme="dark"] input,[data-theme="dark"] select,[data-theme="dark"] #profileSelect{background:#1e293b;border-color:#334155;color:#e2e8f0}
[data-theme="dark"] .canvas-wrap{background:#1e293b;border-color:#334155}
[data-theme="dark"] .missions li{background:#1e293b;border-color:#334155}
[data-theme="dark"] .missions.history li{background:#0f2e1c;border-color:#166534}
[data-theme="dark"] .missions.saved li{background:#2e2410;border-color:#92400e}
[data-theme="dark"] .accordion-toggle{background:#2e2410;border-color:#92400e}
[data-theme="dark"] .accordion-toggle .chevron{color:#fbbf24}
[data-theme="dark"] .btn-soft{background:#312e81;color:#c7d2fe;border-color:#4338ca}
[data-theme="dark"] .btn-soft:hover{background:#3730a3}
[data-theme="dark"] .progress-bar{background:#334155}
[data-theme="dark"] .footer{color:#94a3b8;border-top-color:#1e293b}
[data-theme="dark"] .modal-box{background:#1e293b;color:#e2e8f0}
[data-theme="dark"] .onboard-list li{background:#0f172a;border-color:#334155}
[data-theme="dark"] .profile-name-input{background:#0f172a;border-color:#334155;color:#e2e8f0}
