* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5; color: #333; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  background: linear-gradient(135deg, #4a90d9, #357abd);
  color: #fff; padding: 12px 16px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: space-between;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header-right { display: flex; gap: 8px; align-items: center; }
.btn-help {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2); color: #fff; font-size: 13px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-help:hover { background: rgba(255,255,255,0.35); }
.btn-import {
  padding: 4px 10px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2); color: #fff; font-size: 12px; cursor: pointer;
}
.btn-import:hover { background: rgba(255,255,255,0.35); }
.btn-del {
  padding: 4px 8px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,80,80,0.3); color: #fff; font-size: 12px; cursor: pointer;
}
.btn-del:hover { background: rgba(255,80,80,0.5); }
.sub-info { font-size: 12px; opacity: 0.85; margin-top: 2px; }

/* Menu button */
.menu-btn {
  background: none; border: none; color: #fff; font-size: 20px;
  cursor: pointer; padding: 2px 4px; line-height: 1;
}
.menu-btn:hover { opacity: 0.8; }

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3); z-index: 150;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: -300px; bottom: 0;
  width: 280px; max-width: 85vw;
  background: #fff; z-index: 160;
  box-shadow: 0 0 24px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  transition: left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.open { left: 0; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid #eaeef3;
}
.sidebar-header h3 {
  font-size: 17px; font-weight: 700; color: #1a1a2e;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-header h3 svg { color: #4a90d9; }
.sidebar-close {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border: none; background: #f5f7fa; border-radius: 6px;
  cursor: pointer; font-size: 15px; color: #666;
  transition: all 0.15s;
}
.sidebar-close:hover { background: #e8ecf1; color: #333; }
.sidebar-body {
  flex: 1; overflow-y: auto; padding: 12px 12px;
}
.sidebar-section-label {
  font-size: 11px; font-weight: 600; color: #8e99a6;
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 8px 8px 6px;
}
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid #eaeef3;
  background: #fafbfc;
}
.sidebar-stats {
  font-size: 12px; color: #8e99a6; text-align: center;
}

/* Sidebar bank items */
.sidebar-banks { margin-bottom: 12px; }
.sidebar-bank-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  transition: all 0.12s; position: relative;
}
.sidebar-bank-item:hover { background: #f0f4f9; }
.sidebar-bank-item.active {
  background: #e8f3ff; color: #1a73e8; font-weight: 600;
}
.sidebar-bank-item .bank-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
  background: #e8ecf1; color: #555;
}
.sidebar-bank-item.active .bank-icon { background: #d0e4ff; color: #1a73e8; }
.sidebar-bank-item .bank-info { flex: 1; min-width: 0; }
.sidebar-bank-item .bank-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-bank-item .bank-count { font-size: 11px; color: #8e99a6; margin-top: 1px; }
.sidebar-bank-item.active .bank-count { color: #7ba7e0; }
.sidebar-bank-item .bank-del {
  width: 24px; height: 24px; display: none; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 4px; cursor: pointer;
  font-size: 13px; color: #bbb; flex-shrink: 0;
}
.sidebar-bank-item:hover .bank-del { display: flex; }
.sidebar-bank-item .bank-del:hover { background: #fee2e2; color: #ef4444; }
.sidebar-bank-item .bank-rename {
  width: 24px; height: 24px; display: none; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 4px; cursor: pointer;
  font-size: 12px; color: #bbb; flex-shrink: 0;
}
.sidebar-bank-item:hover .bank-rename { display: flex; }
.sidebar-bank-item .bank-rename:hover { background: #e8f3ff; color: #1a73e8; }
.sidebar-bank-item .bank-append {
  width: 24px; height: 24px; display: none; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 4px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: #bbb; flex-shrink: 0;
}
.sidebar-bank-item:hover .bank-append { display: flex; }
.sidebar-bank-item .bank-append:hover { background: #e8ffe8; color: #52c41a; }

/* Sidebar import button */
.sidebar-import {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px; margin-top: 4px;
  border: 2px dashed #dce3eb; border-radius: 8px;
  background: #fafbfc; cursor: pointer;
  font-size: 13px; color: #5f6b7a; transition: all 0.15s;
}
.sidebar-import:hover { border-color: #4a90d9; color: #4a90d9; background: #f0f6ff; }
.sidebar-import svg { transition: all 0.15s; }
.sidebar-import:hover svg { stroke: #4a90d9; }

.container { max-width: 800px; margin: 0 auto; padding: 12px; }

/* Stats */
.stats-row { display: flex; gap: 8px; margin-bottom: 12px; }
.stat-card {
  flex: 1; background: #fff; border-radius: 8px; padding: 10px;
  text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-card .num { font-size: 20px; font-weight: 700; }
.stat-card .lbl { font-size: 11px; color: #999; margin-top: 2px; }
.stat-card.right .num { color: #52c41a; }
.stat-card.wrong .num { color: #f5222d; }
.stat-card.total .num { color: #4a90d9; }

/* Mode tabs */
.mode-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.mode-tab {
  flex: 1; padding: 8px; text-align: center; background: #fff;
  border: 1px solid #e0e0e0; border-radius: 6px; cursor: pointer; font-size: 13px;
  transition: all 0.2s;
}
.mode-tab.active { background: #4a90d9; color: #fff; border-color: #4a90d9; }

/* Type tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  flex: 1; min-width: 80px; padding: 10px 6px;
  background: #fff; border: 2px solid #e0e0e0; border-radius: 8px;
  text-align: center; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.2s; color: #555;
}
.tab.active { border-color: #4a90d9; color: #4a90d9; background: #ebf3fc; }
.tab .count { display: block; font-size: 11px; color: #999; font-weight: 400; margin-top: 2px; }
.tab.active .count { color: #4a90d9; }

/* Card */
.card {
  background: #fff; border-radius: 10px; padding: 16px;
  margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.q-tag {
  display: inline-block; background: #e8f0fe; color: #4a90d9;
  padding: 2px 8px; border-radius: 4px; font-size: 11px; margin-bottom: 8px;
}
.q-stem { font-size: 15px; margin-bottom: 14px; font-weight: 500; line-height: 1.7; }

/* Passage */
.passage-box {
  background: #f9f9f7; border-left: 3px solid #d0c8a0;
  padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
  max-height: 300px; overflow-y: auto; line-height: 1.8;
}
.passage-box.collapsed { max-height: 80px; }
.passage-toggle {
  display: inline-block; color: #4a90d9; cursor: pointer;
  font-size: 12px; margin-bottom: 8px;
}

/* Options */
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 2px solid #e8e8e8; border-radius: 8px;
  cursor: pointer; transition: all 0.15s; font-size: 14px;
}
.option:hover { border-color: #b0d0f0; background: #f8fbff; }
.option.selected { border-color: #4a90d9; background: #ebf3fc; }
.option.correct { border-color: #52c41a; background: #f0fae8; }
.option.wrong { border-color: #f5222d; background: #fff1f0; }
.option .letter {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: #f0f0f0; color: #666; display: flex;
  align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.option.selected .letter { background: #4a90d9; color: #fff; }
.option.correct .letter { background: #52c41a; color: #fff; }
.option.wrong .letter { background: #f5222d; color: #fff; }
.option .opt-text { flex: 1; padding-top: 2px; }

/* Answer box */
.answer-box {
  margin-top: 12px; padding: 10px 12px; border-radius: 6px;
  font-size: 13px; display: none;
}
.answer-box.show { display: block; }
.answer-box.correct { background: #f0fae8; color: #389e0d; }
.answer-box.wrong { background: #fff1f0; color: #cf1322; }
.answer-box .label { font-weight: 600; }

/* Actions */
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions button {
  flex: 1; padding: 9px; border: none; border-radius: 6px;
  font-size: 13px; cursor: pointer; font-weight: 500;
}
.btn-next { background: #52c41a; color: #fff; }
.btn-fav { background: #fff7e6; color: #fa8c16; border: 1px solid #ffd591 !important; }
.btn-edit { background: #e8f0fe; color: #4a90d9; border: 1px solid #b0d0f0 !important; }
.actions button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Navigation */
.nav-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; padding: 8px 0;
}
.nav-bar button {
  padding: 8px 16px; border: 1px solid #d0d0d0; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 13px;
}
.nav-bar button:disabled { opacity: 0.4; cursor: not-allowed; }
.nav-pos { font-size: 13px; color: #666; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.nav-pos:hover { color: #4a90d9; }

/* Question map overlay */
.qmap-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 200;
  display: none; align-items: center; justify-content: center;
}
.qmap-overlay.show { display: flex; }
.qmap-panel {
  background: #fff; border-radius: 12px; padding: 16px;
  max-width: 420px; width: 90%; max-height: 70vh; overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.qmap-panel h3 { font-size: 15px; margin-bottom: 10px; text-align: center; }
.qmap-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}
.qmap-item {
  padding: 8px 4px; text-align: center; border-radius: 6px;
  font-size: 13px; cursor: pointer; border: 1px solid #e8e8e8;
  transition: all 0.15s;
}
.qmap-item:hover { border-color: #4a90d9; color: #4a90d9; }
.qmap-item.current { background: #4a90d9; color: #fff; border-color: #4a90d9; font-weight: 600; }
.qmap-item.done-right { background: #f0fae8; color: #389e0d; border-color: #b7eb8f; }
.qmap-item.done-wrong { background: #fff1f0; color: #cf1322; border-color: #ffa39e; }
.qmap-close {
  display: block; margin: 12px auto 0; padding: 6px 20px;
  border: 1px solid #d0d0d0; border-radius: 6px; background: #fff;
  cursor: pointer; font-size: 13px;
}

/* Fill blank specific */
.fill-passage { font-size: 14px; line-height: 2; margin-bottom: 14px; }
.fill-passage .blank {
  display: inline-block; min-width: 60px; padding: 1px 8px;
  margin: 0 2px; border-bottom: 2px solid #4a90d9;
  background: #f8fbff; border-radius: 3px; font-weight: 600; color: #4a90d9;
  cursor: pointer;
}
.fill-passage .blank.filled { background: #f0fae8; color: #389e0d; border-color: #52c41a; }
.fill-passage .blank.wrong { background: #fff1f0; color: #cf1322; border-color: #f5222d; }

.word-bank {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px;
  padding: 10px; background: #f9f9f7; border-radius: 6px;
}
.word-chip {
  padding: 4px 10px; background: #fff; border: 1px solid #d9d9d9;
  border-radius: 14px; font-size: 12px; cursor: pointer;
  transition: all 0.15s;
}
.word-chip:hover { border-color: #4a90d9; color: #4a90d9; }
.word-chip.used { opacity: 0.3; pointer-events: none; text-decoration: line-through; }

/* Matching options */
.match-options {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 6px; margin-bottom: 14px;
}
.match-opt {
  padding: 8px; text-align: center; border: 2px solid #e8e8e8;
  border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 14px;
  transition: all 0.15s;
}
.match-opt:hover { border-color: #b0d0f0; }
.match-opt.selected { border-color: #4a90d9; background: #ebf3fc; color: #4a90d9; }
.match-opt.correct { border-color: #52c41a; background: #f0fae8; color: #389e0d; }
.match-opt.wrong { border-color: #f5222d; background: #fff1f0; color: #cf1322; }

/* Import modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 200;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-panel {
  background: #fff; border-radius: 12px; padding: 20px;
  max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.modal-panel h3 { font-size: 16px; margin-bottom: 14px; }
.modal-close {
  display: block; margin: 14px auto 0; padding: 8px 24px;
  border: 1px solid #d0d0d0; border-radius: 6px; background: #fff;
  cursor: pointer; font-size: 13px;
}

.empty { text-align: center; padding: 40px; color: #999; font-size: 14px; }

/* Responsive */
@media (max-width: 480px) {
  .header h1 { font-size: 16px; }
  .container { padding: 8px; }
  .tab { min-width: 70px; padding: 8px 4px; font-size: 12px; }
  .mode-tab { font-size: 12px; padding: 6px; }
  .actions button { padding: 10px 6px; font-size: 14px; min-height: 44px; }
  .nav-bar button { padding: 10px 14px; min-height: 44px; }
  .option { padding: 12px 10px; }
  .word-chip { padding: 6px 12px; font-size: 13px; }
}

/* Help modal */
.help-content { max-height: 60vh; overflow-y: auto; font-size: 13px; line-height: 1.7; }
.help-section { margin-bottom: 16px; }
.help-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #1a73e8; }
.help-section ul, .help-section ol { padding-left: 20px; margin: 0; }
.help-section li { margin-bottom: 4px; }
.help-keys { border-collapse: collapse; }
.help-keys td { padding: 3px 10px 3px 0; }
.help-keys kbd { background: #f0f0f0; border: 1px solid #d0d0d0; border-radius: 3px; padding: 1px 6px; font-size: 12px; font-family: inherit; }

/* User area */
#userArea { display: flex; align-items: center; gap: 6px; }
.user-name {
  font-size: 12px; color: rgba(255,255,255,0.9);
  max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-login {
  padding: 4px 12px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2); color: #fff; font-size: 12px; cursor: pointer;
  transition: background 0.15s;
}
.btn-login:hover { background: rgba(255,255,255,0.35); }
.btn-logout {
  padding: 2px 8px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,80,80,0.2); color: #fff; font-size: 11px; cursor: pointer;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(255,80,80,0.4); }

/* Auth modal */
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 16px;
  border-bottom: 2px solid #e8e8e8;
}
.auth-tab {
  flex: 1; text-align: center; padding: 10px 0; font-size: 14px;
  font-weight: 600; cursor: pointer; color: #999;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.15s;
}
.auth-tab.active { color: #4a90d9; border-bottom-color: #4a90d9; }
.auth-error {
  background: #fff2f0; color: #cf1322; padding: 8px 12px;
  border-radius: 6px; font-size: 13px; margin-bottom: 12px;
}
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block; font-size: 13px; font-weight: 500;
  color: #555; margin-bottom: 4px;
}
.auth-field input {
  width: 100%; padding: 10px 12px; border: 1px solid #d9d9d9;
  border-radius: 6px; font-size: 14px; transition: border-color 0.15s;
  font-family: inherit;
}
.auth-field input:focus { outline: none; border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74,144,217,0.15); }
.auth-submit {
  width: 100%; padding: 12px; background: #4a90d9; color: #fff;
  border: none; border-radius: 6px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.auth-submit:hover { background: #357abd; }

/* Header buttons (friends/admin) */
.btn-friends, .btn-admin {
  width: 26px; height: 26px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2); color: #fff; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.btn-friends:hover, .btn-admin:hover { background: rgba(255,255,255,0.35); }

/* Friends modal */
.friend-search { margin-bottom: 8px; }
.friend-search input {
  width: 100%; padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
  font-size: 13px; font-family: inherit;
}
.friend-search input:focus { outline: none; border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74,144,217,0.15); }
.friend-search-result { margin-bottom: 12px; }
.friends-section-label {
  font-size: 11px; font-weight: 600; color: #8e99a6;
  text-transform: uppercase; letter-spacing: 0.8px; margin: 12px 0 6px;
}
.friend-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; transition: background 0.12s;
}
.friend-item:hover { background: #f0f4f9; }
.friend-item.pending-item { background: #fffbe6; }
.friend-item.search-result-item { background: #f6ffed; margin-bottom: 4px; }
.friend-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #4a90d9; color: #fff; font-weight: 600; font-size: 15px;
}
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-size: 14px; font-weight: 500; }
.friend-email { font-size: 12px; color: #8e99a6; }
.friend-actions { display: flex; gap: 6px; }
.btn-accept {
  padding: 4px 12px; border: none; border-radius: 4px;
  background: #52c41a; color: #fff; font-size: 12px; cursor: pointer;
}
.btn-accept:hover { background: #389e0d; }
.btn-reject {
  padding: 4px 12px; border: 1px solid #ffccc7; border-radius: 4px;
  background: #fff; color: #cf1322; font-size: 12px; cursor: pointer;
}
.btn-reject:hover { background: #fff2f0; }
.btn-add-friend {
  padding: 4px 12px; border: none; border-radius: 4px;
  background: #4a90d9; color: #fff; font-size: 12px; cursor: pointer; flex-shrink: 0;
}
.btn-add-friend:hover { background: #357abd; }

/* Admin panel */
.admin-section { margin-bottom: 20px; }
.admin-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: #1a1a2e; }
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-table th {
  background: #fafbfc; padding: 8px 6px; text-align: left;
  font-weight: 600; color: #8e99a6; border-bottom: 2px solid #eaeef3;
}
.admin-table td {
  padding: 8px 6px; border-bottom: 1px solid #f0f0f0; vertical-align: middle;
}
.admin-table td:first-child { color: #999; }
.admin-badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.badge-admin { background: #fff2f0; color: #cf1322; }
.badge-user { background: #e8f0fe; color: #4a90d9; }
.btn-admin-del {
  padding: 3px 10px; border: 1px solid #ffccc7; border-radius: 4px;
  background: #fff; color: #cf1322; font-size: 12px; cursor: pointer;
}
.btn-admin-del:hover { background: #fff2f0; }
