/* ============ 打字练习软件 样式 ============ */
:root {
  --bg: #f2f5f9;
  --card: #ffffff;
  --ink: #243044;
  --muted: #7a8699;
  --line: #e3e9f1;
  --brand: #2f6fed;
  --brand-dark: #1e56c8;
  --green: #22a06b;
  --red: #e5484d;
  --amber: #e8930c;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(30, 50, 90, .07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 15px; }
a { color: var(--brand); }

/* ---------- 通用 ---------- */
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 9px 18px;
  background: var(--brand); color: #fff; font-size: 15px; transition: .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:hover { background: #eef3fe; }
.btn.gray { background: #eef1f6; color: var(--ink); }
.btn.gray:hover { background: #e2e7ef; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #c93a3f; }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.muted { color: var(--muted); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; background: #eef3fe; color: var(--brand); }
.tag.green { background: #e6f6ef; color: var(--green); }
.tag.red { background: #fdecec; color: var(--red); }
.tag.amber { background: #fdf3e2; color: var(--amber); }
.tag.gray { background: #eef1f6; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #2f6fed 0%, #6a9bff 55%, #9cc0ff 100%); }
.login-card { width: 420px; max-width: 94vw; background: #fff; border-radius: 16px; padding: 36px 34px; box-shadow: 0 18px 50px rgba(10,30,80,.25); }
.login-card h1 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,237,.15); }
.login-card .btn { width: 100%; padding: 12px; font-size: 16px; }
.err-msg { color: var(--red); font-size: 13px; min-height: 20px; margin: 8px 0; }
.login-foot { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------- 主框架 ---------- */
.topbar {
  background: #fff; box-shadow: var(--shadow); padding: 0 26px; height: 58px;
  display: flex; align-items: center; gap: 18px; position: sticky; top: 0; z-index: 20;
}
.topbar .logo { font-size: 18px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .user-chip { font-size: 14px; color: var(--muted); }
.tabs { display: flex; gap: 4px; }
.tabs button {
  border: none; background: transparent; padding: 8px 16px; font-size: 15px; color: var(--muted);
  border-radius: 8px; position: relative;
}
.tabs button:hover { background: #f0f4fa; color: var(--ink); }
.tabs button.active { color: var(--brand); font-weight: 600; background: #eef3fe; }
.tabs button .lock-ico { font-size: 12px; margin-left: 3px; }
.main { max-width: 1080px; margin: 22px auto 60px; padding: 0 18px; }

/* ---------- 指法课程 ---------- */
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.lesson-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; border: 2px solid transparent; cursor: pointer; transition: .15s; }
.lesson-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.lesson-card.locked { opacity: .55; cursor: not-allowed; }
.lesson-card.locked:hover { border-color: transparent; transform: none; }
.lesson-card h3 { font-size: 16px; margin-bottom: 6px; }
.lesson-card .keys-line { font-family: Consolas, monospace; letter-spacing: 3px; color: var(--brand); font-size: 15px; margin: 6px 0; text-transform: uppercase; }
.lesson-card .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.lesson-card .state { float: right; }
.section-title { font-size: 18px; font-weight: 700; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }
.intro-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; line-height: 1.9; font-size: 14.5px; }
.intro-box ul { padding-left: 22px; }

/* ---------- 键盘图 ---------- */
.keyboard { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; user-select: none; }
.kb-row { display: flex; gap: 6px; margin-bottom: 6px; justify-content: center; }
.kb-key {
  --fc: #95a5a6;
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 8px; background: #f7f9fc;
  border: 1px solid var(--line); border-bottom: 4px solid var(--fc);
  display: flex; align-items: center; justify-content: center;
  font-family: Consolas, monospace; font-size: 15px; color: #4a5568; position: relative; transition: background .1s;
}
.kb-key.w15 { width: 72px; } .kb-key.w18 { width: 86px; } .kb-key.w2 { width: 96px; }
.kb-key.w22 { width: 106px; } .kb-key.w23 { width: 110px; } .kb-key.w27 { width: 130px; }
.kb-key.space { width: 420px; }
.kb-key.home::after { content: ''; position: absolute; bottom: 7px; width: 14px; height: 3px; border-radius: 2px; background: #b6c2d4; }
.kb-key.next { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,237,.25); }
.kb-key.next-shift { background: #ffd166; border-color: #e8b93c; color: #6b4e00; }
.kb-key.hit { background: #d9f2e5; }
.kb-key.miss { background: #fde0e0; }
.finger-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.finger-legend span { display: inline-flex; align-items: center; gap: 6px; }
.finger-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* ---------- 打字练习区 ---------- */
.player-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.player-head h2 { font-size: 18px; }
.player-head .spacer { flex: 1; }
.statbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat-pill { background: #fff; border-radius: 10px; box-shadow: var(--shadow); padding: 10px 18px; min-width: 108px; text-align: center; }
.stat-pill .v { font-size: 22px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.stat-pill .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.type-text {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; font-family: Consolas, "Courier New", monospace;
  font-size: 24px; line-height: 1.9; letter-spacing: 1px; word-break: break-all;
  min-height: 90px; margin-bottom: 14px;
}
.type-text.zh { font-family: "Microsoft YaHei", sans-serif; font-size: 22px; letter-spacing: 2px; }
.type-text .ch { border-radius: 3px; padding: 0 1px; }
.type-text .ch.ok { color: var(--green); }
.type-text .ch.bad { color: #fff; background: var(--red); }
.type-text .ch.cur { background: #dbe7ff; border-bottom: 3px solid var(--brand); animation: blink 1s infinite; }
.type-text .ch.flash-bad { animation: shake .18s; background: #fde0e0; }
@keyframes blink { 50% { background: #b9d0ff; } }
@keyframes shake { 25% { transform: translateX(-2px);} 75% { transform: translateX(2px);} }
.zh-input { width: 100%; min-height: 110px; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 20px; outline: none; resize: vertical; background: #fff; }
.zh-input:focus { border-color: var(--brand); }
.player-tip { font-size: 13px; color: var(--muted); margin: 10px 2px; }
.progress-track { height: 8px; background: #e6ebf3; border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.progress-track i { display: block; height: 100%; background: linear-gradient(90deg, #2f6fed, #6a9bff); width: 0; transition: width .15s; }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,30,50,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 30px 32px; width: 460px; max-width: 94vw; text-align: center; }
.modal h2 { font-size: 22px; margin-bottom: 6px; }
.modal .big-ico { font-size: 46px; margin-bottom: 8px; }
.modal .result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.modal .result-grid .cell { background: #f5f8fc; border-radius: 10px; padding: 12px 6px; }
.modal .result-grid .v { font-size: 21px; font-weight: 700; color: var(--brand); }
.modal .result-grid .l { font-size: 12px; color: var(--muted); margin-top: 3px; }
.modal .actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.modal .req { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- 素材浏览 ---------- */
.mat-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.mat-filters button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 16px; font-size: 13.5px; color: var(--muted); }
.mat-filters button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.mat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; cursor: pointer; border: 2px solid transparent; transition: .15s; }
.mat-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.mat-card h4 { font-size: 15px; margin-bottom: 6px; }
.mat-card .preview { font-size: 12.5px; color: var(--muted); line-height: 1.6; height: 40px; overflow: hidden; }
.mat-card .meta { margin-top: 8px; display: flex; gap: 8px; }
.lock-panel { text-align: center; padding: 60px 20px; }
.lock-panel .ico { font-size: 52px; }
.lock-panel h3 { margin: 12px 0 8px; }
.lock-panel p { color: var(--muted); margin-bottom: 18px; }

/* ---------- 统计 ---------- */
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.sum-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.sum-card .t { font-size: 13px; color: var(--muted); }
.sum-card .v { font-size: 26px; font-weight: 700; margin-top: 4px; }
.sum-card .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
table.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.tbl th, table.tbl td { padding: 10px 14px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--line); }
table.tbl th { background: #f5f8fc; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.num { font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); }

/* ---------- 管理后台 ---------- */
.admin-main { max-width: 1180px; margin: 22px auto 60px; padding: 0 18px; }
.gen-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.gen-form .field { margin-bottom: 0; }
.gen-form input { width: 130px; }
.gen-form input.note { width: 220px; }
.code-cell { font-family: Consolas, monospace; font-size: 13.5px; letter-spacing: .5px; }
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 99;
  background: #243044; color: #fff; padding: 10px 22px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }
.empty-tip { text-align: center; color: var(--muted); padding: 36px 0; }

@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .tabs button { padding: 8px 10px; font-size: 14px; }
  .kb-key { width: 30px; height: 36px; font-size: 12px; }
  .kb-key.w15, .kb-key.w18, .kb-key.w2, .kb-key.w22, .kb-key.w23, .kb-key.w27 { width: 46px; }
  .kb-key.space { width: 220px; }
  .type-text { font-size: 19px; }
}
