:root{
  --blue:#1977f3;
  --blue-dark:#115dd0;
  --border:#d8dee9;
  --bg:#eef2f7;
  --text:#1f2937;
  --muted:#667085;
}
*{box-sizing:border-box}
body{margin:0;font-family:"Microsoft JhengHei",system-ui,sans-serif;background:var(--bg);color:var(--text)}
a{text-decoration:none}
button{outline:none}
.login-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}
.login-shell{width:100%;max-width:520px}
.login-brand{font-size:44px;font-weight:700;color:var(--blue);text-align:center;margin-bottom:24px}
.login-card{background:#fff;border-radius:20px;padding:28px;box-shadow:0 10px 30px rgba(17,24,39,.08)}
.login-tabs{display:flex;background:#eef4ff;border-radius:12px;padding:4px;margin-bottom:20px}
.login-tabs button{flex:1;border:none;background:transparent;padding:10px 12px;border-radius:10px;font-weight:700;color:#486284}
.login-tabs button.active{background:#fff;color:var(--blue);box-shadow:0 1px 4px rgba(0,0,0,.08)}
.auth-btn,#anonBtn{height:46px;font-weight:700}
.topbar{height:72px;background:#fff;border-bottom:1px solid #dfe5ee;display:flex;align-items:center;padding:0 20px;position:sticky;top:0;z-index:40}
.menu-btn{width:36px;height:36px;border:1px solid var(--blue);background:#fff;border-radius:4px;color:var(--blue);font-size:18px;line-height:1}
.topbar-title{font-size:20px;font-weight:700;color:var(--blue);margin-left:18px}
.topbar-right{margin-left:auto;display:flex;align-items:center;gap:14px;font-size:14px}
.link-btn{border:none;background:transparent;color:var(--blue);padding:0}
.setup-main,.exam-main{padding:24px}
.setup-card-wrap,.exam-card{max-width:980px;margin:0 auto;background:#fff;border-radius:18px;padding:26px;box-shadow:0 6px 22px rgba(15,23,42,.06)}
.setup-title{font-size:20px;color:var(--blue);font-weight:700;text-align:center;margin-bottom:18px}
.setup-block{border-top:1px solid #dfe5ee;padding-top:18px;margin-top:18px}
.setup-block:first-of-type{border-top:none;padding-top:0;margin-top:0}
.setup-block h3,.setup-block-title-row h3{font-size:16px;margin:0 0 14px 0;font-weight:700;color:#222}
.setup-block-title-row{display:flex;justify-content:space-between;align-items:center;gap:12px}
.group-grid{display:grid;grid-template-columns:1fr 1fr;gap:0;border:1px solid var(--border);border-radius:12px;padding:14px;background:#fff}
.group-item{padding:10px 8px;font-size:15px}
.group-item:nth-child(odd){border-right:1px solid #e5e7eb}
.inline-checks{display:flex;flex-wrap:wrap;gap:18px}
.check-inline,.radio-inline{display:inline-flex;align-items:center;gap:6px;font-size:14px}
.check-inline.block{display:flex;margin-bottom:8px}
.range-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.setup-select{width:110px}
.lang-buttons{display:flex;gap:12px}
.lang-btn,.lang-pill{border:1px solid var(--border);background:#fff;padding:8px 18px;border-radius:999px;font-weight:700;color:#475467}
.lang-btn.active,.lang-pill.active{background:var(--blue);color:#fff;border-color:var(--blue)}
.start-btn{width:100%;height:48px;border:none;background:var(--blue);color:#fff;border-radius:8px;font-size:18px;font-weight:700;margin-top:24px}
.start-btn:hover,.primary-pill:hover{background:var(--blue-dark)}
.drawer-backdrop{position:fixed;inset:0;background:rgba(15,23,42,.3);display:none;z-index:49}
.drawer-backdrop.show{display:block}
.side-drawer{position:fixed;left:-360px;top:0;bottom:0;width:340px;background:#fff;z-index:50;box-shadow:6px 0 24px rgba(0,0,0,.18);transition:left .25s ease;display:flex;flex-direction:column;overflow:hidden}
.side-drawer.open{left:0}
.drawer-large{width:380px;max-width:92vw}
.drawer-head{height:72px;padding:0 18px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #e5e7eb;font-size:18px;font-weight:700;color:var(--blue)}
.drawer-close{border:none;background:transparent;font-size:28px;line-height:1;color:#64748b}
.drawer-body{padding:16px;overflow:auto}
.drawer-item{padding:10px 0;border-bottom:1px solid #edf2f7}
.drawer-item button{border:none;background:transparent;padding:0}
.drawer-section{margin-bottom:18px}
.drawer-section-title{font-size:14px;font-weight:700;margin-bottom:10px;color:#475467}
.exam-top-actions{gap:10px}
.exam-head-row{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:14px}
.question-title{font-size:24px;font-weight:700;color:var(--blue)}
.question-type{font-size:14px;color:var(--muted);margin-top:6px}
.exam-head-actions{display:flex;gap:10px;align-items:center}
.outline-pill,.primary-pill,.nav-btn{border-radius:999px;padding:9px 16px;font-weight:700}
.outline-pill{border:1px solid var(--border);background:#fff}
.primary-pill{border:none;background:var(--blue);color:#fff}
.image-area{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin-bottom:18px}
.image-card{background:#f8fafc;border:1px solid #e5e7eb;border-radius:12px;padding:10px;display:flex;align-items:center;justify-content:center;min-height:140px}
.image-card img{max-width:100%;max-height:360px;border-radius:8px}
.question-text{font-size:20px;line-height:1.8;margin:8px 0 18px 0}
.answer-area{display:flex;flex-direction:column;gap:12px}
.option-item{border:2px solid #dde3ec;border-radius:12px;padding:14px 16px;background:#fff;cursor:pointer;font-size:17px;line-height:1.7;display:flex;gap:12px;align-items:flex-start}
.option-item.selected{border-color:var(--blue);background:#f0f7ff}
.option-item.correct{border-color:#16a34a;background:#edfdf1}
.option-item.wrong{border-color:#dc2626;background:#fef2f2}
.option-prefix{font-weight:700;color:var(--blue);min-width:28px}
.nav-row{display:flex;justify-content:space-between;align-items:center;margin-top:22px;gap:12px}
.nav-btn{border:1px solid var(--border);background:#fff;min-width:100px}
.progress-text{font-weight:700;color:#475467}
.drag-layout{display:grid;grid-template-columns:1fr 1fr;gap:18px}
.drag-bank,.drag-target-wrap{background:#f8fafc;border:1px solid #e5e7eb;border-radius:14px;padding:14px}
.drag-bank-title,.drag-target-title{font-size:15px;font-weight:700;margin-bottom:10px}
.drag-token{background:#fff;border:1px solid #cfd8e3;border-radius:10px;padding:10px 12px;margin-bottom:10px;cursor:grab}
.drag-token.selected{border-color:var(--blue);background:#eef6ff}
.drag-target{min-height:74px;border:2px dashed #bfd0ea;border-radius:12px;padding:10px;margin-bottom:12px;background:#fff}
.drag-target.active{border-color:var(--blue);background:#f0f7ff}
.drag-target-head{font-weight:700;color:#334155;margin-bottom:8px}
.result-area{margin-top:22px;border-top:1px solid #e5e7eb;padding-top:18px}
.result-block{margin-bottom:18px}
.result-label{font-size:14px;color:#667085;margin-bottom:6px;font-weight:700}
.answer-chip{display:inline-flex;align-items:center;border-radius:999px;padding:8px 12px;background:#f3f4f6;margin:0 8px 8px 0;font-size:14px}
.answer-chip.correct{background:#dcfce7;color:#166534}.answer-chip.wrong{background:#fee2e2;color:#991b1b}
.analysis-details{border:1px solid #e5e7eb;border-radius:12px;margin-bottom:12px;background:#fff;overflow:hidden}
.analysis-details summary{cursor:pointer;list-style:none;padding:14px 16px;font-weight:700;background:#f8fafc}
.analysis-details[open] summary{border-bottom:1px solid #e5e7eb}
.analysis-content{padding:14px 16px;font-size:15px;line-height:1.75}
.palette-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}
.palette-btn{height:38px;border:1px solid #d7dee8;background:#fff;border-radius:8px;font-weight:700}
.palette-btn.current{background:var(--blue);border-color:var(--blue);color:#fff}
.palette-btn.answered{border-color:#16a34a}.palette-btn.favorite{box-shadow:inset 0 0 0 2px #f59e0b}
.wrong-item,.favorite-item,.history-item{border:1px solid #e5e7eb;border-radius:10px;padding:10px 12px;margin-bottom:10px;background:#fff}
.wrong-item button,.favorite-item button{border:none;background:#fff;color:var(--blue);padding:0}
.small-muted{font-size:13px;color:#667085}
.hidden{display:none!important}
.box-note,.box-ok,.box-warn,.box-bad{padding:10px 12px;margin:8px 0;border-radius:8px}
.box-note{background:#f8fafc;border-left:4px solid #94a3b8}.box-ok{background:#f0fdf4;border-left:4px solid #22c55e}.box-warn{background:#fff7ed;border-left:4px solid #f97316}.box-bad{background:#fef2f2;border-left:4px solid #ef4444}
.hl-blue{color:#0ea5e9;font-weight:700}.hl-red{color:#ef4444;font-weight:700}.hl-green{color:#16a34a;font-weight:700}.hl-orange{color:#f59e0b;font-weight:700}.hl-purple{color:#7c3aed;font-weight:700}
@media (max-width: 768px){
  .setup-main,.exam-main{padding:14px}
  .setup-card-wrap,.exam-card{padding:18px}
  .group-grid,.drag-layout{grid-template-columns:1fr}
  .group-item:nth-child(odd){border-right:none}
  .topbar{padding:0 12px}
  .topbar-title{margin-left:12px;font-size:18px}
  .question-title{font-size:22px}
  .question-text{font-size:18px}
  .nav-row{flex-wrap:wrap}
}

.drawer-body{scrollbar-width:none;-ms-overflow-style:none;}
.drawer-body::-webkit-scrollbar{width:0;height:0}
.loading-overlay{position:fixed;inset:0;background:rgba(255,255,255,.82);display:none;align-items:center;justify-content:center;flex-direction:column;gap:14px;z-index:80}
.loading-overlay.show{display:flex}
.spinner-ring{width:52px;height:52px;border:4px solid #dbeafe;border-top-color:#1977f3;border-radius:50%;animation:spin .85s linear infinite}
.loading-text{font-size:16px;font-weight:700;color:#1977f3}
@keyframes spin{to{transform:rotate(360deg)}}
