:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #66736c;
  --line: #dce3df;
  --soft: #f3f6f4;
  --paper: #ffffff;
  --green: #176c52;
  --green-dark: #12372a;
  --green-soft: #e6f2ed;
  --gold: #b4771d;
  --gold-soft: #f8efdc;
  --red: #b23a3a;
  --red-soft: #faeaea;
  --blue: #32679a;
  --radius: 6px;
  --shadow: 0 12px 32px rgba(18, 55, 42, 0.09);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: #f6f8f7; color: var(--ink); font-size: 15px; letter-spacing: 0; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(320px, 440px);
  justify-content: center;
  align-items: center;
  gap: 72px;
  padding: 40px;
  background: #f2f6f3;
}
.auth-brand { display: flex; align-items: center; gap: 20px; }
.auth-brand h1 { margin: 0 0 8px; font-size: 34px; line-height: 1.2; }
.auth-brand p { margin: 0; color: var(--muted); }
.brand-mark { width: 68px; height: 68px; display: grid; place-items: center; border-radius: var(--radius); background: var(--green-dark); color: white; font-size: 30px; font-weight: 750; }
.brand-mark.small { width: 38px; height: 38px; font-size: 18px; }
.auth-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 30px; box-shadow: var(--shadow); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); padding: 4px; border-radius: var(--radius); margin-bottom: 26px; }
.segment { height: 38px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.segment.active { background: white; color: var(--ink); font-weight: 650; box-shadow: 0 1px 4px rgba(23, 33, 28, .1); }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field span { color: #3d4a43; font-size: 13px; font-weight: 600; }
.field input, .field textarea, .text-answer { width: 100%; min-height: 44px; border: 1px solid #cbd5cf; border-radius: var(--radius); background: white; padding: 10px 12px; color: var(--ink); outline: none; }
.field input:focus, .field textarea:focus, .text-answer:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,108,82,.12); }
.primary, .secondary, .quiet-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--radius); padding: 0 16px; font-weight: 650; }
.primary { border: 1px solid var(--green); background: var(--green); color: white; }
.primary:hover { background: #115d46; }
.secondary { border: 1px solid #cbd5cf; background: white; color: var(--ink); }
.secondary:hover { border-color: #95a59c; background: var(--soft); }
.quiet-button { border: 0; background: var(--soft); color: var(--ink); }
.wide { width: 100%; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 13px; }
.form-note { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.panel-heading { margin-bottom: 22px; }
.panel-heading h2 { margin: 5px 0 7px; font-size: 21px; line-height: 1.35; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 750; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code-block { margin: 20px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); padding: 12px; }
.code-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 12px; }
.copy-button, .text-button { border: 0; background: transparent; color: var(--green); font-weight: 700; padding: 4px; }
.code-block textarea, .license-input { width: 100%; min-height: 78px; resize: vertical; border: 1px solid #cbd5cf; border-radius: var(--radius); padding: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.activation-form { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.compact-panel { max-width: 440px; width: 100%; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--green-dark); color: white; padding: 22px 16px; }
.app-brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 22px; border-bottom: 1px solid rgba(255,255,255,.14); }
.side-nav { display: grid; gap: 6px; margin-top: 22px; }
.nav-item { height: 44px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: var(--radius); padding: 0 12px; background: transparent; color: #d7e5de; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: #f1f7f4; color: var(--green-dark); font-weight: 700; }
.nav-item svg, .icon-button svg, button svg { width: 18px; height: 18px; flex: 0 0 auto; }
.user-box { margin-top: auto; display: grid; grid-template-columns: 38px 1fr 34px; align-items: center; gap: 9px; border-top: 1px solid rgba(255,255,255,.14); padding: 18px 2px 0; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: #201503; font-weight: 750; }
.user-meta { min-width: 0; display: grid; gap: 2px; }
.user-meta strong, .user-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { color: #afc3b9; font-size: 11px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: var(--radius); background: transparent; color: inherit; padding: 0; }
.icon-button:hover { background: rgba(255,255,255,.1); }
.workspace { min-width: 0; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 34px; background: white; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 3px 0 0; font-size: 22px; line-height: 1.25; }
.breadcrumb { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; min-width: 0; }
.license-badge { min-height: 30px; display: inline-flex; align-items: center; border-radius: 4px; padding: 0 9px; background: var(--gold-soft); color: #71490d; font-size: 11px; font-weight: 700; white-space: nowrap; }
.offline-button { min-height: 34px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: var(--radius); background: white; color: var(--ink); padding: 0 10px; font-size: 11px; white-space: nowrap; }
.offline-button:hover { background: var(--soft); }
.offline-button:disabled { cursor: default; opacity: .78; }
#offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.offline-button.ready #offline-dot { background: var(--green); }
.offline-button.error #offline-dot { background: var(--red); }
.content { width: min(1180px, 100%); margin: 0 auto; padding: 28px 34px 48px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat-card { min-height: 98px; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 10px; font-size: 24px; line-height: 1; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 12px; }
.section-title h3 { margin: 0; font-size: 17px; }
.section-title span { color: var(--muted); font-size: 12px; }
.course-list, .chapter-list, .review-list { display: grid; gap: 10px; }
.course-row, .chapter-row, .review-row { display: grid; align-items: center; gap: 16px; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.course-row { grid-template-columns: 8px minmax(180px, 1.2fr) minmax(180px, 2fr) auto; }
.course-accent { width: 8px; height: 48px; border-radius: 3px; background: var(--green); }
.course-row[data-course="行测"] .course-accent { background: var(--gold); }
.course-row[data-course="企业文化"] .course-accent { background: var(--blue); }
.course-name strong, .chapter-main strong { display: block; font-size: 16px; }
.course-name span, .chapter-main span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.progress-track { height: 7px; overflow: hidden; border-radius: 4px; background: #e9eeeb; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--green); }
.progress-meta { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 11px; }
.chapter-row { grid-template-columns: minmax(0, 1fr) 170px auto; }
.chapter-actions { display: flex; gap: 8px; }
.chapter-actions button { min-width: 64px; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); border: 1px dashed #cbd5cf; border-radius: var(--radius); background: rgba(255,255,255,.55); }

.practice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.question-surface, .question-index { background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.question-surface { min-height: 620px; display: flex; flex-direction: column; }
.question-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.question-position { color: var(--muted); font-size: 12px; }
.favorite-button.active { color: var(--gold); background: var(--gold-soft); }
.question-body { flex: 1; padding: 24px 28px; }
.question-type { display: inline-flex; align-items: center; min-height: 26px; border-radius: 4px; padding: 0 8px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700; }
.question-text { margin: 16px 0 22px; font-size: 17px; font-weight: 650; line-height: 1.8; overflow-wrap: anywhere; }
.question-text img, .option-content img, .explanation img { display: block; max-width: 100%; height: auto; margin: 12px 0; object-fit: contain; }
.options { display: grid; gap: 10px; }
.option { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: start; gap: 10px; min-height: 52px; border: 1px solid #d5ddd8; border-radius: var(--radius); padding: 13px 14px; background: white; cursor: pointer; }
.option:hover { border-color: #8ca59a; background: #fbfdfc; }
.option.selected { border-color: var(--green); background: var(--green-soft); }
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option-key { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #bfcac4; border-radius: 50%; color: #425149; font-size: 12px; font-weight: 700; }
.selected .option-key { border-color: var(--green); background: var(--green); color: white; }
.option-content { min-width: 0; line-height: 1.65; overflow-wrap: anywhere; }
.text-answer { min-height: 100px; resize: vertical; line-height: 1.6; }
.answer-panel { margin-top: 22px; border-left: 4px solid var(--green); background: var(--soft); padding: 16px 18px; }
.answer-panel.wrong { border-left-color: var(--red); }
.answer-line { display: flex; gap: 8px; align-items: baseline; margin-bottom: 10px; }
.answer-line strong { color: var(--green); }
.answer-panel.wrong .answer-line strong { color: var(--red); }
.explanation { color: #3b4841; line-height: 1.75; overflow-wrap: anywhere; }
.question-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 14px 22px; }
.footer-actions { display: flex; gap: 8px; }
.question-index { position: sticky; top: 112px; max-height: calc(100vh - 136px); overflow-y: auto; padding: 16px; }
.question-index h3 { margin: 0 0 12px; font-size: 14px; }
.index-grid { display: grid; grid-template-columns: repeat(5, 34px); gap: 7px; }
.index-item { width: 34px; height: 34px; border: 1px solid #d4ddd8; border-radius: 4px; background: white; color: var(--muted); font-size: 11px; padding: 0; }
.index-item.current { border-color: var(--green); background: var(--green); color: white; }
.index-item.answered { box-shadow: inset 0 -3px var(--green); }
.index-item.wrong { box-shadow: inset 0 -3px var(--red); }
.review-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.review-type { align-self: start; min-width: 54px; text-align: center; background: var(--soft); color: var(--muted); border-radius: 4px; padding: 5px 7px; font-size: 11px; }
.review-text { min-width: 0; line-height: 1.6; }
.review-text img { display: none; }
.review-meta { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.admin-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.admin-summary strong { font-size: 18px; }
.account-list { display: grid; gap: 8px; }
.account-row { display: grid; grid-template-columns: minmax(150px, 1.2fr) minmax(130px, 1fr) 100px auto; align-items: center; gap: 14px; min-height: 68px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.account-identity { min-width: 0; }
.account-identity strong, .account-identity span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity span, .account-date { margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-badge { justify-self: start; min-height: 26px; display: inline-flex; align-items: center; border-radius: 4px; padding: 0 8px; font-size: 11px; font-weight: 700; }
.status-badge.pending { background: var(--gold-soft); color: #80520f; }
.status-badge.approved { background: var(--green-soft); color: var(--green); }
.account-actions { display: flex; justify-content: flex-end; gap: 8px; }
.danger { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #e2bcbc; border-radius: var(--radius); background: white; color: var(--red); padding: 0 14px; font-weight: 650; }
.danger:hover { background: var(--red-soft); }
.toast { position: fixed; z-index: 100; left: 50%; top: 18px; transform: translate(-50%, -18px); opacity: 0; pointer-events: none; border-radius: var(--radius); background: var(--green-dark); color: white; padding: 10px 16px; box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.loading { display: grid; place-items: center; min-height: 300px; color: var(--muted); }
.dialog-layer { position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; padding: 18px; }
.dialog-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(17, 27, 22, .52); padding: 0; }
.dialog-panel { position: relative; width: min(430px, 100%); border: 1px solid var(--line); border-radius: 8px; background: white; padding: 22px; box-shadow: 0 18px 52px rgba(18, 55, 42, .2); }
.dialog-eyebrow { color: var(--green); font-size: 11px; font-weight: 750; }
.dialog-panel h2 { margin: 5px 0 8px; font-size: 20px; }
.dialog-panel p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dialog-actions button { min-height: 46px; padding-inline: 10px; }
.dialog-panel .text-button { min-height: 38px; margin-top: 7px; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: minmax(300px, 480px); gap: 30px; background: #f5f8f6; }
  .auth-brand { justify-content: center; }
  .app-layout { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px; }
  .app-brand { justify-content: center; padding-inline: 0; }
  .app-brand strong, .nav-item span:last-child, .user-meta, #logout { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .user-box { display: flex; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .course-row { grid-template-columns: 8px minmax(0, 1fr) auto; }
  .course-progress { grid-column: 2 / -1; }
  .practice-layout { grid-template-columns: minmax(0, 1fr); }
  .question-index { position: static; max-height: 360px; }
  .index-grid { grid-template-columns: repeat(auto-fill, 34px); }
}

@media (max-width: 620px) {
  .auth-layout { min-height: 100dvh; padding: 24px 16px; align-content: center; }
  .auth-brand { justify-content: flex-start; }
  .brand-mark { width: 50px; height: 50px; font-size: 23px; }
  .auth-brand h1 { font-size: 26px; }
  .auth-panel { padding: 22px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .app-layout { display: block; padding-bottom: 68px; }
  .sidebar { position: fixed; z-index: 20; top: auto; bottom: 0; width: 100%; height: 64px; display: block; padding: 7px 12px; border-top: 1px solid rgba(255,255,255,.18); }
  .app-brand, .user-box { display: none; }
  .side-nav { height: 50px; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); margin: 0; gap: 6px; }
  .nav-item { height: 50px; flex-direction: column; gap: 2px; font-size: 10px; }
  .nav-item span:last-child { display: inline; }
  .topbar { min-height: 78px; height: auto; padding: 12px 16px; }
  .topbar h2 { font-size: 19px; }
  .topbar-actions { gap: 6px; }
  .license-badge { display: none; }
  #offline-label { display: none; }
  .offline-button { width: 34px; padding: 0; justify-content: center; }
  .content { padding: 18px 14px 34px; }
  .stats-grid { gap: 8px; }
  .stat-card { min-height: 82px; padding: 13px; }
  .stat-card strong { font-size: 20px; }
  .course-row, .chapter-row { grid-template-columns: 7px minmax(0, 1fr); gap: 11px; padding: 14px; }
  .course-row > button, .course-progress, .chapter-progress, .chapter-actions { grid-column: 2; }
  .chapter-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .question-surface { min-height: calc(100dvh - 180px); }
  .question-body { padding: 20px 16px; }
  .question-head, .question-footer { padding: 13px 14px; }
  .question-footer { align-items: stretch; flex-direction: column; }
  .footer-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .footer-actions .primary { grid-column: auto; }
  .dialog-layer { align-items: end; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .dialog-panel { padding: 20px 18px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .question-text { font-size: 16px; }
  .option { padding: 12px; }
  .review-row { grid-template-columns: auto minmax(0, 1fr); }
  .review-row button { grid-column: 2; justify-self: start; }
  .account-row { grid-template-columns: minmax(0, 1fr) auto; }
  .account-date { grid-column: 1; }
  .account-actions { grid-column: 1 / -1; justify-content: stretch; }
  .account-actions button { flex: 1; }
}
