/* 打字通 - 在线打字 / 测速页面样式 */

:root {
  --primary: #2c3e50;
  --accent: #27ae60;
  --accent-hover: #219150;
  --error: #e74c3c;
  --correct: #27ae60;
  --text: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-card: #f1f5f9;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 导航栏（复用首页） */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--primary);
}

.logo img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.back-link {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

.back-link:hover {
  color: var(--accent);
}

/* 主内容 */
main {
  padding: 32px 0 64px;
}

.page-header {
  text-align: center;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Tab 切换 */
.tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  padding: 6px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.typing-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  transition: all 0.2s;
}

.typing-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* 设置面板 */
.settings-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.setting-item label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.setting-item select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.setting-item select:focus {
  outline: none;
  border-color: var(--accent);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* 统计条 */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-box strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-box span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 打字区域 */
.typing-area {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.target-text {
  font-family: "Menlo", "Consolas", "Monaco", "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 1.35rem;
  line-height: 2;
  color: var(--text-muted);
  min-height: 120px;
  max-height: 220px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: 10px;
  margin-bottom: 16px;
  word-break: break-all;
}

.target-char {
  display: inline-block;
  min-width: 0.5em;
  border-radius: 3px;
  transition: background 0.1s;
}

.target-char.correct {
  color: var(--correct);
  background: rgba(39, 174, 96, 0.08);
}

.target-char.error {
  color: var(--error);
  background: rgba(231, 76, 60, 0.08);
}

.input-wrapper {
  position: relative;
}

.input-box {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: "Menlo", "Consolas", "Monaco", "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 1.1rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
}

.input-box:focus {
  outline: none;
  border-color: var(--accent);
}

.input-box:disabled {
  background: var(--bg-soft);
  color: var(--text-muted);
}

.input-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* 结果面板 */
.result-panel {
  display: none;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
  text-align: center;
  margin-bottom: 20px;
}

.result-panel.open {
  display: block;
  animation: fadeIn 0.3s ease;
}

.result-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--primary);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.result-item {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 14px;
}

.result-item strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

.result-item span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 页脚 */
.footer {
  background: var(--primary);
  color: #fff;
  text-align: center;
  padding: 24px 0;
  font-size: 0.85rem;
}

.footer p {
  margin: 6px 0;
}

.footer a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: underline;
}

.footer a:hover {
  color: #fff;
}

.footer-icp {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
}

.footer-report {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
}

/* 动画 */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 响应式 */
@media (min-width: 520px) {
  .stats-bar {
    grid-template-columns: repeat(4, 1fr);
  }

  .settings-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 720px) {
  .page-header h1 {
    font-size: 2rem;
  }

  .target-text {
    font-size: 1.5rem;
    max-height: 260px;
  }
}
