/* 在线听力检测系统 - 共享样式 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #0891b2;
  --bg: #f4f7ff;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --success-bg: #d1fae5;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --shadow: 0 10px 40px rgba(30, 58, 138, .08);
  --shadow-sm: 0 2px 12px rgba(30, 58, 138, .06);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #f4f7ff 0%, #eef4ff 45%, #f8fafc 100%);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* 顶部导航 */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff;
}
.brand .logo svg { width: 22px; height: 22px; }
.topbar nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
  font-size: 13px; color: var(--muted); padding: 8px 12px; border-radius: 10px;
  transition: .2s;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); }

/* 布局容器 */
.container { max-width: 760px; margin: 0 auto; padding: 28px 18px 60px; }
.container.wide { max-width: 1180px; }

/* 视图切换 */
.view { display: none; animation: fadeUp .35s ease; }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px;
  border: 1px solid rgba(226,232,240,.7);
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 19px; font-weight: 700; margin: 0 0 6px; }
.card-sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.hero-logo { position: relative; z-index: 1; background: #fff; border-radius: 14px; padding: 10px 16px; display: inline-block; margin-bottom: 16px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.hero-logo img { display: block; height: 50px; width: auto; }

/* Hero */
.hero {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 45%, #0891b2 100%);
  color: #fff; border-radius: 24px; padding: 40px 32px;
  box-shadow: 0 20px 50px rgba(37,99,235,.25);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -70px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(255,255,255,.09);
}
.hero::before {
  content: ""; position: absolute; right: 60px; bottom: -90px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.hero .tag {
  display: inline-block; font-size: 12px; letter-spacing: 1px;
  background: rgba(255,255,255,.18); padding: 5px 12px; border-radius: 999px;
  margin-bottom: 14px;
}
.hero h1 { font-size: 32px; margin: 0 0 10px; line-height: 1.3; }
.hero p { margin: 0 0 24px; opacity: .9; font-size: 15px; max-width: 480px; position: relative; z-index: 1; }
.hero-features { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; position: relative; z-index: 1; }
.hero-features span {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2);
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
}

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 24px;
  font-size: 15px; font-weight: 600; cursor: pointer; transition: .2s;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.light { background: #fff; color: var(--primary); }
.btn.light:hover { background: #f0f6ff; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f8fafc; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* 步骤指示 */
.steps { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 26px 0 22px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.step .num {
  width: 26px; height: 26px; border-radius: 50%; background: #e2e8f0; color: var(--muted);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.step.done .num { background: var(--success); color: #fff; }
.step.current .num { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-light); }
.step.current { color: var(--primary); font-weight: 600; }
.step-line { width: 26px; height: 2px; background: var(--border); margin: 0 4px; }
.step-line.done { background: var(--success); }

/* 表单 */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.field label .req { color: var(--danger); margin-left: 2px; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 11px; font-size: 15px; background: #fff; color: var(--text);
  transition: .2s; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.field .err { color: var(--danger); font-size: 12px; margin-top: 5px; display: none; }
.field.invalid .err { display: block; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* 提示框 */
.notice {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px;
  font-size: 13px; line-height: 1.65; margin-bottom: 18px;
  background: #eff6ff; color: #1e40af; border: 1px solid #dbeafe;
}
.notice.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.notice.success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.notice.danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.notice svg { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; }
.notice strong { display: block; margin-bottom: 2px; }

/* 检查清单 */
.checklist { list-style: none; padding: 0; margin: 0 0 22px; }
.checklist li {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 0;
  border-bottom: 1px dashed var(--border); font-size: 14px;
}
.checklist li:last-child { border-bottom: 0; }
.checklist .ico {
  width: 30px; height: 30px; border-radius: 9px; background: var(--primary-light);
  color: var(--primary); display: grid; place-items: center; flex: 0 0 auto; font-size: 15px;
}

/* 校准 */
.calib-box { text-align: center; padding: 20px 0; }
.calib-wave {
  width: 120px; height: 120px; margin: 0 auto 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 0 0 12px var(--primary-light);
  animation: pulse 1.6s ease-in-out infinite;
}
.calib-wave.playing { animation: pulse .7s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.calib-wave svg { width: 52px; height: 52px; }
.calib-box h3 { margin: 0 0 6px; font-size: 18px; }
.calib-box p { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

/* 测试界面 */
.test-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.ear-badge {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px;
  background: var(--primary-light); color: var(--primary); padding: 8px 14px; border-radius: 999px;
}
.ear-badge.right { background: #fce7f3; color: #be185d; }
.progress-text { font-size: 13px; color: var(--muted); }
.progress-bar { height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-bottom: 26px; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s; border-radius: 99px; }

.tone-stage {
  min-height: 300px; border-radius: 18px; background: linear-gradient(160deg, #f8fbff, #eef4ff);
  border: 1px solid #dbeafe; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
}
.tone-ring {
  width: 150px; height: 150px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 20px;
  background: #fff; border: 3px solid var(--primary-light);
  box-shadow: 0 0 0 14px rgba(219,234,254,.5);
  transition: .2s;
}
.tone-ring.listening { border-color: var(--primary); box-shadow: 0 0 0 14px rgba(37,99,235,.12); animation: pulse 1s ease-in-out infinite; }
.tone-ring.sounding { border-color: var(--accent); box-shadow: 0 0 0 18px rgba(8,145,178,.15); animation: pulse .5s ease-in-out infinite; }
.tone-ring svg { width: 64px; height: 64px; color: var(--primary); }
.tone-info { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.tone-level { font-size: 30px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.tone-hint { font-size: 14px; color: var(--muted); min-height: 24px; }
.answer-row { display: flex; gap: 14px; margin-top: 24px; width: 100%; max-width: 440px; }
.answer-row .btn { flex: 1; padding: 16px; font-size: 16px; }
.btn-heard { background: var(--success); }
.btn-heard:hover { background: #047857; }
.btn-silent { background: #fff; color: var(--muted); border: 1px solid var(--border); }
.btn-silent:hover { background: #f8fafc; color: var(--text); }
.timer-line { height: 4px; background: #e2e8f0; border-radius: 99px; margin-top: 16px; width: 100%; max-width: 440px; overflow: hidden; }
.timer-line > div { height: 100%; background: var(--accent); width: 100%; transition: width 3s linear; }
.test-foot { text-align: center; margin-top: 18px; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--danger); }

/* 耳朵与频率选择器 */
.selector-panel { border: 1px solid var(--border); border-radius: 16px; padding: 18px; margin-bottom: 18px; background: #fff; }
.selector-label { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 10px; }
.selector-label:not(:first-child) { margin-top: 18px; }
.ear-select { display: flex; gap: 12px; }
.ear-choice {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: 12px; border: 2px solid var(--border); background: #fff;
  color: var(--muted); font-size: 15px; font-weight: 700; cursor: pointer; transition: .2s;
}
.ear-choice svg { width: 20px; height: 20px; }
.ear-choice small { font-size: 11px; opacity: .6; }
.ear-choice:hover { border-color: var(--accent); }
.ear-choice.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.ear-choice.done::after { content: "✓"; margin-left: 4px; color: var(--success); font-weight: 800; }
.freq-select { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.freq-choice {
  position: relative; padding: 12px 4px; border-radius: 10px; border: 2px solid var(--border);
  background: #fff; color: var(--text); font-size: 14px; font-weight: 700; cursor: pointer; transition: .2s;
}
.freq-choice small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.freq-choice:hover { border-color: var(--accent); }
.freq-choice.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.freq-choice.done { border-color: var(--success); }
.freq-choice .freq-mark { position: absolute; top: -8px; right: -6px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 999px; background: var(--success); color: #fff; font-size: 10px; font-weight: 700; line-height: 20px; }
.freq-choice .freq-mark.unheard { background: var(--accent); }
@media (max-width: 520px) { .freq-select { gap: 5px; } .freq-choice { font-size: 12px; padding: 10px 2px; } }

/* 手动选择分贝的测试界面 */
.manual-test {
  border-radius: 18px; background: linear-gradient(160deg, #f8fbff, #eef4ff);
  border: 1px solid #dbeafe; padding: 28px 24px; text-align: center;
}
.current-target { display: inline-block; font-size: 13px; font-weight: 700; color: var(--primary); background: var(--primary-light); padding: 5px 14px; border-radius: 999px; margin-bottom: 12px; }
.freq-display { font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: 1px; }
.db-display { margin: 4px 0 2px; font-size: 56px; font-weight: 800; line-height: 1.1; color: var(--primary); }
.db-display small { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.db-hint { font-size: 13px; color: var(--muted); min-height: 20px; margin-bottom: 18px; }
.db-hint.hearing { color: var(--accent); font-weight: 600; }
.slider-wrap { max-width: 480px; margin: 0 auto 14px; }
.slider-wrap input[type=range] {
  width: 100%; height: 10px; border-radius: 99px; outline: none;
  -webkit-appearance: none; appearance: none;
  background: linear-gradient(90deg, var(--success) 0%, #fbbf24 50%, var(--danger) 100%);
}
.slider-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary); cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.slider-wrap input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary); cursor: pointer;
}
.slider-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; }
.quick-db { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.quick-db .btn { min-width: 62px; background: #fff; }
.listen-btn { min-width: 240px; background: linear-gradient(135deg, var(--accent), var(--primary)); margin-bottom: 20px; }
.listen-btn.playing { animation: pulse .6s ease-in-out infinite; }
.confirm-area { border-top: 1px dashed var(--border); padding-top: 18px; }
.confirm-area .tip { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.confirm-area .tip strong { color: var(--primary); }
.confirm-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.confirm-buttons .btn { flex: 1 1 200px; max-width: 250px; padding: 14px 10px; font-size: 15px; }
.btn-unheard { background: #fff; color: var(--muted); border: 1px solid var(--border); }
.btn-unheard:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

/* 结果 */
.grade-hero {
  border-radius: 20px; padding: 28px; color: #fff; text-align: center;
  background: linear-gradient(135deg, #059669, #10b981); margin-bottom: 20px;
}
.grade-hero.mild { background: linear-gradient(135deg, #d97706, #f59e0b); }
.grade-hero.moderate { background: linear-gradient(135deg, #ea580c, #f97316); }
.grade-hero.severe { background: linear-gradient(135deg, #dc2626, #ef4444); }
.grade-hero.profound { background: linear-gradient(135deg, #991b1b, #b91c1c); }
.grade-hero .badge { font-size: 13px; opacity: .9; }
.grade-hero h2 { font-size: 30px; margin: 6px 0; }
.grade-hero p { margin: 0; opacity: .92; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; text-align: center;
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 800; margin: 4px 0; }
.stat .u { font-size: 11px; color: var(--muted); }
.section-title { font-size: 16px; font-weight: 700; margin: 24px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 17px; border-radius: 4px; background: var(--primary); }
.chart-wrap { background: #fbfdff; border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 18px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 8px; text-align: center; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; }
th:first-child, td:first-child { text-align: left; padding-left: 14px; }
.guidance-card { border-left: 4px solid var(--primary); background: #f8fbff; border-radius: 0 12px 12px 0; padding: 16px 18px; margin-bottom: 12px; }
.guidance-card h4 { margin: 0 0 8px; font-size: 14px; color: var(--primary); }
.guidance-card p, .guidance-card ul { margin: 0; font-size: 13px; color: #475569; }
.guidance-card ul { padding-left: 18px; }

/* 后台 */
.login-wrap { max-width: 400px; margin: 70px auto; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.admin-header h1 { font-size: 24px; margin: 0; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 800px) { .admin-stats { grid-template-columns: 1fr 1fr; } }
.admin-stat { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow-sm); }
.admin-stat .k { font-size: 12px; color: var(--muted); }
.admin-stat .v { font-size: 28px; font-weight: 800; color: var(--primary); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.table-wrap table { min-width: 820px; }
.table-wrap tbody tr:hover { background: #f8fbff; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.normal { background: var(--success-bg); color: var(--success); }
.pill.mild { background: var(--warn-bg); color: var(--warn); }
.pill.moderate { background: #ffedd5; color: #c2410c; }
.pill.severe { background: var(--danger-bg); color: var(--danger); }
.pill.profound { background: #fee2e2; color: #991b1b; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 54px; height: 54px; opacity: .4; margin-bottom: 12px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 20px; width: 100%; max-width: 680px;
  max-height: 88vh; overflow-y: auto; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.2);
}
.modal h3 { margin: 0 0 4px; font-size: 20px; }
.modal .meta { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.modal .close { float: right; background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }

/* 页脚 */
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 30px 20px 10px; line-height: 1.8; }
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; z-index: 200; opacity: 0; pointer-events: none; transition: .25s;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
