/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif; background: #f0f2f5; color: #333; line-height: 1.7; }

/* ===== Header & Nav ===== */
.header { background: linear-gradient(135deg, #6a1b9a 0%, #4a148c 50%, #1a73e8 100%); color: #fff; text-align: center; padding: 24px 20px 28px; }
.header h1 { font-size: 26px; margin-bottom: 6px; }
.header p { font-size: 14px; opacity: 0.9; }
.nav-bar { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.nav-link { color: rgba(255,255,255,0.7); text-decoration: none; padding: 6px 16px; border-radius: 16px; font-size: 14px; transition: 0.2s; }
.nav-link:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.2); color: #fff; font-weight: 600; }
.nav-user { color: rgba(255,255,255,0.85); font-size: 13px; padding: 6px 8px; margin-left: 6px; }
.nav-logout { font-size: 12px; opacity: 0.6; }
.nav-logout:hover { opacity: 1; }
.legend { display: flex; justify-content: center; gap: 20px; margin-top: 10px; flex-wrap: wrap; }
.legend span { background: rgba(255,255,255,0.12); padding: 4px 14px; border-radius: 12px; font-size: 13px; }

/* ===== Container ===== */
.container { max-width: 860px; margin: 20px auto; padding: 0 16px 40px; }

/* ===== Buttons ===== */
.button-bar { text-align: center; margin: 20px 0 10px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; align-items: center; }
.btn { padding: 10px 24px; border-radius: 8px; border: none; cursor: pointer; font-size: 14px; font-weight: 600; transition: 0.2s; font-family: inherit; text-decoration: none; display: inline-block; }
.btn-start { background: #6a1b9a; color: #fff; }
.btn-start:hover { background: #4a148c; }
.btn-clear { background: #f5f5f5; color: #666; }
.btn-clear:hover { background: #e0e0e0; }
.btn-check { background: #6a1b9a; color: #fff; }
.btn-check:hover { background: #4a148c; }
.btn-history { background: #1a73e8; color: #fff; }
.btn-history:hover { background: #1557b0; }
.btn-abandon { background: #ffebee; color: #c62828; }
.btn-abandon:hover { background: #ffcdd2; }

/* ===== Config Inline（融入页头） ===== */
.config-inline { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }
.config-inline label { font-size: 13px; opacity: 0.8; }
.config-inline select { padding: 4px 10px; border: 1px solid rgba(255,255,255,0.3); border-radius: 12px; font-size: 13px; color: #fff; background: rgba(255,255,255,0.1); outline: none; cursor: pointer; font-family: inherit; -webkit-appearance: none; appearance: none; text-align: center; }
.config-inline select:focus { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.5); }
.config-inline select option { color: #333; background: #fff; }
.config-inline-conn { color: rgba(255,255,255,0.5); font-size: 13px; }

/* ===== Password Panel ===== */
.pwd-panel { margin-bottom: 16px; }
.pwd-card { background: #fff; border-radius: 10px; padding: 20px 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); max-width: 400px; margin: 0 auto; }
.pwd-card h3 { font-size: 16px; color: #333; margin-bottom: 16px; text-align: center; }
.pwd-btns { display: flex; gap: 10px; margin-top: 8px; }
.pwd-btns .btn { flex: 1; }
.nav-settings { font-size: 12px; opacity: 0.7; }
.nav-settings:hover { opacity: 1; }
.form-success { color: #2e7d32; font-size: 13px; text-align: center; min-height: 18px; }

/* ===== Question Cards ===== */
.question { background: #fff; border-radius: 10px; padding: 20px 24px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); border-left: 4px solid #1a73e8; transition: 0.2s; position: relative; }
.question.type-fill-choice { border-left-color: #0277bd; }
.question.type-fill-letter { border-left-color: #6a1b9a; }
.question.type-context { border-left-color: #0d904f; }

.q-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.q-num { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; color: #fff; }
.type-fill-choice .q-num { background: #0277bd; }
.type-fill-letter .q-num { background: #6a1b9a; }
.type-context .q-num { background: #0d904f; }

.q-type-badge { font-size: 11px; padding: 2px 8px; border-radius: 8px; color: #fff; white-space: nowrap; }
.type-fill-choice .q-type-badge { background: #0277bd; }
.type-fill-letter .q-type-badge { background: #6a1b9a; }
.type-context .q-type-badge { background: #0d904f; }

.q-stem-label { font-size: 13px; color: #999; margin-bottom: 4px; display: block; }
.q-stem { font-size: 15px; margin-bottom: 8px; color: #444; line-height: 1.9; word-break: break-word; }
.q-stem b { color: #0d904f; background: #e8f5e9; padding: 1px 4px; border-radius: 3px; font-weight: 700; }
.q-stem .blank { display: inline-block; min-width: 4.5em; height: 1.1em; border-bottom: 2px solid #6a1b9a; vertical-align: middle; margin: 0 2px; }

.q-meaning-hint { font-size: 13px; color: #888; margin-bottom: 8px; padding: 4px 10px; background: #f9f9f9; border-radius: 6px; display: inline-block; }
.q-list { font-size: 11px; color: #bbb; margin-left: auto; }

/* ===== Choice Options ===== */
.options { display: flex; flex-direction: column; gap: 5px; }
.opt-radio { display: none; }
.opt-label { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: 8px; cursor: pointer; border: 2px solid #e8e8e8; transition: all 0.15s; font-size: 14px; user-select: none; }
.opt-label:hover { background: #f5f7fa; border-color: #c0c0c0; }
.opt-label:active { transform: scale(0.99); }
.opt-letter { font-weight: 700; min-width: 22px; color: #999; }
.opt-label.selected { background: #e8f0fe !important; border-color: #1a73e8 !important; box-shadow: 0 0 0 1px #1a73e8; }
.opt-label.selected .opt-letter { color: #1a73e8; }

/* ===== Fill Input ===== */
.fill-input-area { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.fill-input { padding: 10px 14px; border: 2px solid #d0d0d0; border-radius: 8px; font-size: 16px; font-family: "Consolas", "Courier New", monospace; width: 220px; outline: none; transition: border-color 0.2s; letter-spacing: 1px; }
.fill-input:focus { border-color: #6a1b9a; box-shadow: 0 0 0 2px rgba(106,27,154,0.1); }
.fill-input.filled { border-color: #6a1b9a; background: #f3e5f5; }
.fill-hint { font-size: 14px; color: #666; }
.fill-hint b { color: #6a1b9a; font-size: 18px; }
.fill-correct-answer { font-size: 12px; color: #d32f2f; margin-top: 4px; }

/* ===== Correct/Wrong ===== */
.question.correct { box-shadow: 0 0 0 3px #4caf50 !important; }
.question.wrong { box-shadow: 0 0 0 3px #f44336 !important; }
.question.correct::after { content: '\2713'; position: absolute; top: 12px; right: 16px; font-size: 24px; color: #4caf50; font-weight: bold; }
.question.wrong::after { content: '\2717'; position: absolute; top: 12px; right: 16px; font-size: 24px; color: #f44336; font-weight: bold; }

/* ===== Score ===== */
.score-area { text-align: center; font-size: 18px; margin: 20px 0; display: none; padding: 16px 20px; border-radius: 10px; }
.score-area.show { display: block; }
.score-perfect { background: #e8f5e9; color: #2e7d32; }
.score-good { background: #e8f0fe; color: #1a73e8; }
.score-ok { background: #fff3e0; color: #e65100; }
.score-low { background: #ffebee; color: #c62828; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 60px 20px; color: #999; }

/* ===== History Actions ===== */
.action-link { padding: 3px 10px; border-radius: 10px; font-size: 12px; text-decoration: none; display: inline-block; margin: 0 2px; cursor: pointer; }
.action-resume { background: #e8f5e9; color: #2e7d32; }
.action-resume:hover { background: #c8e6c9; }
.action-delete { background: #ffebee; color: #c62828; }
.action-delete:hover { background: #ffcdd2; }

/* ===== Footer ===== */
.footer { text-align: center; padding: 30px; color: #bbb; font-size: 12px; }

/* ===== Login Page ===== */
.login-container { max-width: 420px; margin-top: 40px; }
.login-card { background: #fff; border-radius: 14px; padding: 32px 28px 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.login-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid #eee; }
.login-tab { flex: 1; padding: 10px 0; text-align: center; border: none; background: none; font-size: 16px; font-weight: 600; color: #999; cursor: pointer; transition: 0.2s; font-family: inherit; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.login-tab.active { color: #6a1b9a; border-bottom-color: #6a1b9a; }
.login-tab:hover { color: #6a1b9a; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; color: #666; font-weight: 500; }
.form-group input { padding: 11px 14px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 15px; outline: none; transition: border-color 0.2s; font-family: inherit; }
.form-group input:focus { border-color: #6a1b9a; box-shadow: 0 0 0 2px rgba(106,27,154,0.08); }
.form-error { color: #d32f2f; font-size: 13px; text-align: center; min-height: 18px; }
.btn-login { background: linear-gradient(135deg, #6a1b9a, #4a148c); color: #fff; padding: 12px 24px; border-radius: 10px; font-size: 16px; width: 100%; margin-top: 4px; }
.btn-login:hover { background: linear-gradient(135deg, #4a148c, #3a0a6e); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== Print ===== */
@media print {
  body { background: #fff; }
  .header { background: #6a1b9a !important; }
  .container { max-width: 100%; }
  .question { break-inside: avoid; box-shadow: none !important; border: 1px solid #ddd; }
  .question.correct, .question.wrong { box-shadow: none !important; }
  .question.correct::after, .question.wrong::after { display: none !important; }
  .btn, .button-bar, .nav-bar { display: none; }
  .opt-label.selected { background: none !important; }
}
