* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f0f4f8; color: #1a2b3c; min-height: 100vh; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(20,50,90,.15); text-align: center; }
.logo { font-size: 1.6rem; font-weight: 700; color: #4f46e5; }
.login-card h1 { margin: 12px 0 4px; font-size: 1.4rem; }
.sub { color: #64748b; margin-bottom: 24px; font-size: .95rem; }
.login-card input[type=email] { width: 100%; padding: 12px 14px; border: 1.5px solid #cbd5e1; border-radius: 10px; font-size: 1rem; margin-bottom: 12px; }
.login-card button { width: 100%; padding: 12px; background: #4f46e5; color: #fff; border: 0; border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: #4338ca; }
.msg { margin-top: 12px; font-size: .92rem; min-height: 1.2em; }
.msg.ok { color: #15803d; } .msg.err { color: #b91c1c; }
.alert { background: #fee2e2; color: #b91c1c; padding: 10px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; }
.fine { color: #94a3b8; font-size: .8rem; margin-top: 16px; }

/* APP */
header { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 14px 24px; box-shadow: 0 1px 6px rgba(0,0,0,.08); position: sticky; top: 0; z-index: 10; }
header .user { font-size: .85rem; color: #64748b; }
header a { color: #4f46e5; text-decoration: none; }
main { max-width: 860px; margin: 24px auto; padding: 0 20px 80px; }

/* QUIZ LIST */
.quiz-card { background: #fff; border-radius: 14px; padding: 20px 24px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.06); cursor: pointer; transition: transform .1s; }
.quiz-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.quiz-card h3 { font-size: 1.02rem; color: #1e293b; }
.quiz-card .meta { color: #94a3b8; font-size: .82rem; margin-top: 4px; }
.best { color: #15803d; font-weight: 600; }

/* QUIZ RUN */
.qheader { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.qheader h2 { font-size: 1.15rem; }
.progress { background: #e2e8f0; border-radius: 999px; height: 8px; margin-bottom: 22px; overflow: hidden; }
.progress .bar { background: linear-gradient(90deg,#4f46e5,#7c3aed); height: 100%; transition: width .3s; }
.qcard { background: #fff; border-radius: 14px; padding: 26px; box-shadow: 0 2px 10px rgba(0,0,0,.07); }
.qcard .qnum { color: #7c3aed; font-weight: 700; font-size: .85rem; margin-bottom: 8px; }
.qcard .qtext { font-size: 1.1rem; font-weight: 600; margin-bottom: 18px; line-height: 1.5; }
.opt { display: block; width: 100%; text-align: left; padding: 13px 16px; margin-bottom: 10px; border: 1.5px solid #e2e8f0; border-radius: 10px; background: #fff; cursor: pointer; font-size: .97rem; line-height: 1.4; transition: all .15s; }
.opt:hover { border-color: #4f46e5; background: #f5f5ff; }
.opt.sel { border-color: #4f46e5; background: #eef2ff; }
.opt.correct { border-color: #16a34a; background: #f0fdf4; }
.opt.wrong { border-color: #dc2626; background: #fef2f2; }
.opt:disabled { cursor: default; }
.explain { margin-top: 12px; padding: 12px 14px; border-radius: 10px; font-size: .9rem; line-height: 1.5; display: none; }
.explain.good { background: #f0fdf4; color: #166534; }
.explain.bad { background: #fef2f2; color: #991b1b; }
.qnav { display: flex; gap: 10px; margin-top: 18px; justify-content: space-between; align-items: center; }
.btn { padding: 10px 20px; border-radius: 10px; border: 0; cursor: pointer; font-weight: 600; font-size: .95rem; background: #4f46e5; color: #fff; }
.btn.ghost { background: #fff; color: #4f46e5; border: 1.5px solid #c7d2fe; }
.btn:disabled { opacity: .4; cursor: default; }

/* RESULTS */
.result-card { background: #fff; border-radius: 16px; padding: 36px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.score { font-size: 3rem; font-weight: 800; color: #4f46e5; margin: 10px 0; }
.result-card .btn { margin: 8px 6px 0; }
.review { text-align: left; margin-top: 24px; }
.review .r-item { padding: 12px; border-radius: 10px; margin-bottom: 8px; font-size: .9rem; }
.r-item.ok { background: #f0fdf4; } .r-item.ko { background: #fef2f2; }

/* CHAT */
#chatBtn { position: fixed; bottom: 22px; right: 22px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: #4f46e5; color: #fff; font-size: 1.4rem; cursor: pointer; box-shadow: 0 4px 16px rgba(79,70,229,.4); z-index: 50; }
#chatPanel { position: fixed; bottom: 88px; right: 22px; width: 370px; max-width: calc(100vw - 40px); height: 480px; max-height: 70vh; background: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.25); display: none; flex-direction: column; z-index: 60; overflow: hidden; }
#chatPanel.open { display: flex; }
.chat-head { background: #4f46e5; color: #fff; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.chat-head button { background: none; border: 0; color: #fff; font-size: 1rem; cursor: pointer; }
#chatMsgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.c-msg { max-width: 85%; padding: 10px 13px; border-radius: 12px; font-size: .92rem; line-height: 1.45; white-space: pre-wrap; }
.c-msg.user { align-self: flex-end; background: #4f46e5; color: #fff; border-bottom-right-radius: 4px; }
.c-msg.bot { align-self: flex-start; background: #f1f5f9; border-bottom-left-radius: 4px; }
.chat-input { display: flex; border-top: 1px solid #e2e8f0; }
.chat-input input { flex: 1; border: 0; padding: 12px 14px; font-size: .93rem; outline: none; }
.chat-input button { border: 0; background: none; font-size: 1.1rem; padding: 0 16px; cursor: pointer; color: #4f46e5; }
.thinking { color: #94a3b8; font-style: italic; }

@media (max-width: 600px) { .qcard { padding: 18px; } header { padding: 12px 16px; } }
