/* ===== 基础重置与排版 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8f6f1;
  --card: #ffffff;
  --text: #333;
  --text-light: #888;
  --accent: #5b7e91;
  --accent-hover: #4a6a7b;
  --danger: #c0392b;
  --success: #27ae60;
  --border: #e0ddd6;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
  --radius: 8px;
  --sidebar-w: 280px;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-poem: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, .btn {
  font-family: inherit;
  font-size: .9rem;
  padding: .55rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, transform .1s;
}
button:active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-sm { font-size: .8rem; padding: .35rem .8rem; }
.btn-lg { font-size: 1.05rem; padding: .7rem 2rem; }

/* ===== 登录/注册页 ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: .3rem;
  text-align: center;
}
.auth-card .subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 1.5rem;
  font-size: .9rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: .3rem;
  color: #555;
}
.form-group input {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .2s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-card .btn { width: 100%; margin-top: .5rem; }
.auth-card .links {
  text-align: center;
  margin-top: 1rem;
  font-size: .85rem;
  color: var(--text-light);
}
.error-msg {
  background: #fdecea;
  color: var(--danger);
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}

/* ===== 主布局 ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 100;
}
.hamburger {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: .3rem;
  color: var(--text);
  line-height: 1;
}
.app-header .title {
  margin-left: .75rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
}

/* ===== 侧边栏 ===== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--card);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 16px rgba(0,0,0,.08);
}
.sidebar.active { transform: translateX(0); }

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h2 { font-size: 1rem; font-weight: 600; }
.sidebar-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-light);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}
.sidebar-body .poem-item {
  display: flex;
  align-items: center;
  padding: .6rem 1rem;
  gap: .5rem;
  border-bottom: 1px solid #f0ede8;
  font-size: .9rem;
}
.sidebar-body .poem-item:hover { background: #faf8f4; }
.sidebar-body .poem-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.sidebar-body .poem-item .poem-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text);
}
.sidebar-body .poem-item .poem-name:hover { color: var(--accent); }
.sidebar-body .poem-item .del-btn {
  font-size: .75rem;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s;
  padding: .2rem .4rem;
}
.sidebar-body .poem-item:hover .del-btn { opacity: 1; }

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
}
.sidebar-footer .btn { width: 100%; }

.sidebar-empty {
  text-align: center;
  color: var(--text-light);
  padding: 2rem 1rem;
  font-size: .85rem;
}

/* ===== 主内容区 ===== */
.main-content {
  padding-top: 56px;
  min-height: 100vh;
}
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ===== 首页 ===== */
.welcome-section {
  text-align: center;
  margin-bottom: 2rem;
}
.welcome-section h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: .3rem;
}
.welcome-section p { color: var(--text-light); font-size: .9rem; }

.mode-select {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.mode-card {
  flex: 1;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.mode-card:hover, .mode-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,126,145,.12);
}
.mode-card .mode-icon { font-size: 1.8rem; margin-bottom: .3rem; }
.mode-card .mode-name { font-weight: 600; font-size: .95rem; }
.mode-card .mode-desc { font-size: .78rem; color: var(--text-light); margin-top: .2rem; }

.queue-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.queue-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.queue-section h3 .badge {
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  padding: .1rem .5rem;
  border-radius: 10px;
}
.queue-list { list-style: none; }
.queue-list li {
  padding: .5rem 0;
  border-bottom: 1px solid #f0ede8;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.queue-list li:last-child { border-bottom: none; }

.start-btn-wrap {
  text-align: center;
  margin-top: 1.5rem;
}

.empty-hint {
  text-align: center;
  color: var(--text-light);
  font-size: .85rem;
  padding: 1.5rem 0;
}

/* ===== 导入页面 ===== */
.import-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.import-section textarea {
  width: 100%;
  min-height: 200px;
  padding: .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-poem);
  font-size: 1rem;
  line-height: 1.8;
  resize: vertical;
  transition: border-color .2s;
}
.import-section textarea:focus { outline: none; border-color: var(--accent); }
.import-section input[type="text"] {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1rem;
}
.import-section input[type="text"]:focus { outline: none; border-color: var(--accent); }
.import-section label { font-weight: 500; font-size: .9rem; display: block; margin-bottom: .3rem; }

/* ===== 诗词详情页 ===== */
.poem-header {
  margin-bottom: 1.5rem;
}
.poem-header h2 {
  font-family: var(--font-poem);
  font-size: 1.4rem;
  margin-bottom: .3rem;
}
.poem-header .meta { color: var(--text-light); font-size: .85rem; }

.sentence-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.5rem;
}
.sentence-item {
  display: flex;
  align-items: center;
  padding: .65rem 0;
  border-bottom: 1px solid #f0ede8;
  gap: .75rem;
}
.sentence-item:last-child { border-bottom: none; }
.sentence-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.sentence-item .sentence-text {
  font-family: var(--font-poem);
  font-size: 1.05rem;
  flex: 1;
}
.sentence-item .sentence-pos {
  color: var(--text-light);
  font-size: .78rem;
  flex-shrink: 0;
}

/* ===== 背诵卡片 ===== */
.quiz-page { padding-top: 70px; }

.quiz-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}
.quiz-card .quiz-hint {
  color: var(--text-light);
  font-size: .85rem;
  margin-bottom: 1rem;
}
.quiz-card .quiz-title {
  font-family: var(--font-poem);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: .8rem;
}
.quiz-card .quiz-prompt {
  font-family: var(--font-poem);
  font-size: 1.15rem;
  line-height: 2;
  margin-bottom: 1.5rem;
  color: #444;
}
.quiz-card .quiz-answer {
  font-family: var(--font-poem);
  font-size: 1.1rem;
  line-height: 2;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #faf8f4;
  border-radius: var(--radius);
  text-align: left;
  white-space: pre-wrap;
}
.quiz-card .quiz-answer .highlight {
  color: var(--accent);
  font-weight: 600;
}
.quiz-btns {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}
.quiz-btns .btn { min-width: 120px; }

.quiz-progress {
  text-align: center;
  color: var(--text-light);
  font-size: .8rem;
  margin-bottom: 1rem;
}

.quiz-done {
  text-align: center;
  padding: 2rem;
}
.quiz-done .done-icon { font-size: 3rem; margin-bottom: 1rem; }
.quiz-done h2 { font-size: 1.3rem; margin-bottom: .5rem; }
.quiz-done p { color: var(--text-light); font-size: .9rem; margin-bottom: 1.5rem; }

.quiz-stats {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.quiz-stats .stat-box {
  background: #faf8f4;
  padding: .8rem 1.2rem;
  border-radius: var(--radius);
  text-align: center;
}
.quiz-stats .stat-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
.quiz-stats .stat-label {
  font-size: .78rem;
  color: var(--text-light);
}

/* ===== 管理后台 ===== */
.admin-page { padding-top: 56px; }
.admin-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #2c3e50;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 100;
}
.admin-header .title { color: #fff; font-size: 1.05rem; font-weight: 600; }
.admin-header .links { margin-left: auto; display: flex; gap: 1rem; }
.admin-header .links a { color: #bdc3c7; font-size: .85rem; }
.admin-header .links a:hover { color: #fff; text-decoration: none; }
.admin-header .links a.active { color: #fff; font-weight: 600; }

.admin-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  text-align: center;
}
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: .8rem; color: var(--text-light); margin-top: .2rem; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: .88rem;
}
.admin-table th {
  background: #f5f3ee;
  font-weight: 600;
  text-align: left;
  padding: .7rem 1rem;
  border-bottom: 2px solid var(--border);
}
.admin-table td {
  padding: .6rem 1rem;
  border-bottom: 1px solid #f0ede8;
}
.admin-table tr:hover td { background: #faf8f4; }

.admin-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.admin-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.tag { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 10px; }
.tag-active { background: #d5f5e3; color: #1e8449; }
.tag-banned { background: #fadbd8; color: #c0392b; }
.tag-admin { background: #d6eaf8; color: #2471a3; }
.tag-inactive { background: #eee; color: #999; }

.inline-form { display: inline; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ===== 提示消息 ===== */
.alert {
  padding: .6rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .85rem;
}
.alert-success { background: #d5f5e3; color: #1e8449; }
.alert-error { background: #fdecea; color: var(--danger); }

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .mode-select { flex-direction: column; }
  .quiz-card { padding: 1.2rem; }
  .quiz-btns .btn { min-width: 100px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
