/* ===== 计时器模块 - 公考通 iOS 风格 ===== */

/* 页面容器 */
.timer-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--page);
}

/* 顶部栏 */
.timer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(var(--safe-top, 12px) + 8px);
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(24px) saturate(1.25);
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
  border-bottom: 1px solid rgba(219,226,236,0.8);
  flex-shrink: 0;
}

.timer-back-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.15s;
}

.timer-back-btn:active {
  background: var(--surface-soft);
}

.timer-topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.timer-traj-link {
  border: none;
  background: var(--surface-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.timer-traj-link:active {
  background: var(--primary-soft);
  transform: scale(0.95);
}

.timer-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.timer-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.timer-status-pill.running .timer-status-dot {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52,199,89,0.5);
  animation: timerPulse 1.5s ease-in-out infinite;
}

.timer-status-pill.running {
  color: var(--success);
  background: var(--success-soft);
}

.timer-status-pill.paused .timer-status-dot {
  background: var(--warning);
}

.timer-status-pill.paused {
  color: var(--warning);
  background: var(--warning-soft);
}

.timer-status-pill.finished .timer-status-dot {
  background: var(--primary);
}

.timer-status-pill.finished {
  color: var(--primary);
  background: var(--primary-soft);
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 内容区 */
.timer-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: 100px;
}

/* 计时器面板卡片 */
.timer-plate-card {
  background: linear-gradient(135deg, #007aff, #5ac8fa);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(0,122,255,0.25);
}

.timer-plate-card::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.timer-plate-label {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 8px;
  font-weight: 500;
}

.timer-plate-total {
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.timer-plate-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  opacity: 0.9;
}

.timer-plate-segment output {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 16px;
}

/* 统计卡片 */
.timer-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.timer-stat-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  border: 1px solid var(--line);
  animation: liftIn 0.35s ease backwards;
}

.timer-stat-card:nth-child(1) { animation-delay: 0.05s; }
.timer-stat-card:nth-child(2) { animation-delay: 0.1s; }
.timer-stat-card:nth-child(3) { animation-delay: 0.15s; }

.timer-stat-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.timer-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* 控制按钮组 */
.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.timer-btn {
  border: none;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.timer-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.timer-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.timer-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* 主按钮 - 开始/继续 */
.timer-btn-primary {
  height: 52px;
  padding: 0 32px;
  background: linear-gradient(135deg, #007aff, #4da3ff);
  color: white;
  box-shadow: 0 4px 16px rgba(0,122,255,0.3);
  font-size: 16px;
}

.timer-btn-primary:active:not(:disabled) {
  box-shadow: 0 2px 8px rgba(0,122,255,0.2);
}

/* 暂停按钮 */
.timer-btn-warning {
  height: 44px;
  padding: 0 20px;
  background: linear-gradient(135deg, #ff9f0a, #ffd166);
  color: white;
  box-shadow: 0 4px 12px rgba(255,159,10,0.3);
}

/* 分段按钮 */
.timer-btn-accent {
  height: 44px;
  padding: 0 20px;
  background: linear-gradient(135deg, #34c759, #5ac8fa);
  color: white;
  box-shadow: 0 4px 12px rgba(52,199,89,0.3);
}

/* 结束按钮 */
.timer-btn-danger {
  height: 44px;
  padding: 0 20px;
  background: linear-gradient(135deg, #ff3b30, #ff6961);
  color: white;
  box-shadow: 0 4px 12px rgba(255,59,48,0.3);
}

/* 重置按钮 */
.timer-btn-ghost {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface-soft);
  color: var(--muted);
  border-radius: 12px;
}

/* 上传按钮 */
.timer-upload-btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #007aff, #5ac8fa);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(0,122,255,0.25);
  transition: all 0.2s;
}

.timer-upload-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.timer-upload-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.timer-upload-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.timer-upload-status {
  text-align: center;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
  animation: liftIn 0.3s ease;
}

.timer-upload-status[data-tone="pending"] {
  background: var(--primary-soft);
  color: var(--primary);
}

.timer-upload-status[data-tone="success"] {
  background: var(--success-soft);
  color: var(--success);
}

.timer-upload-status[data-tone="error"] {
  background: var(--danger-soft);
  color: var(--danger);
}

/* 分段记录 */
.timer-records-section {
  margin-top: 4px;
}

.timer-records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.timer-records-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.timer-records-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.timer-record-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timer-record-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  animation: liftIn 0.35s ease backwards;
}

.timer-record-badge {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #007aff, #5ac8fa);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.timer-record-main {
  flex: 1;
  min-width: 0;
}

.timer-record-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.timer-record-meta {
  font-size: 11px;
  color: var(--muted);
}

.timer-record-duration {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* 记录名称选择 */
.timer-name-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  margin-top: 4px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='m7 10 5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.timer-name-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

/* 空状态 */
.timer-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.timer-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.timer-empty-text {
  font-size: 14px;
}

/* 练习统计 */
.timer-practice-section {
  margin-top: 20px;
}

.timer-practice-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}

.timer-practice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.timer-practice-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  animation: liftIn 0.35s ease backwards;
}

.timer-practice-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--practice-a, #007aff), var(--practice-b, #5ac8fa));
}

.timer-practice-name {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.timer-practice-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.timer-practice-unit {
  font-size: 11px;
  color: var(--muted);
}

/* 轨迹页面 */
.timer-traj-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--page);
}

.timer-traj-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: 100px;
}

/* 统计条 */
.traj-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.traj-summary-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid var(--line);
  animation: liftIn 0.3s ease backwards;
}

.traj-summary-card span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.traj-summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* 图表网格 */
.traj-chart-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 图表卡片 */
.traj-chart-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  animation: liftIn 0.35s ease backwards;
}

.traj-chart-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c, #007aff), color-mix(in srgb, var(--c, #007aff), #fff 40%));
}

.traj-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.traj-chart-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.traj-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, #007aff);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, #007aff), transparent 80%);
}

.traj-chart-title h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.traj-target-band {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  white-space: nowrap;
}

/* 图表元数据 */
.traj-chart-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.traj-chart-meta div {
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-soft);
  text-align: center;
}

.traj-chart-meta span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.traj-chart-meta strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* 图表框架 */
.traj-chart-frame {
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 4px 0;
  overflow: hidden;
}

.traj-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.traj-axis-text {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.traj-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.traj-range-fill {
  fill: color-mix(in srgb, var(--c, #007aff), transparent 90%);
}

.traj-range-line {
  stroke: color-mix(in srgb, var(--c, #007aff), transparent 50%);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.traj-trend-line {
  fill: none;
  stroke: var(--c, #007aff);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.traj-trend-area {
  fill: color-mix(in srgb, var(--c, #007aff), transparent 88%);
}

.traj-point {
  fill: #fff;
  stroke: var(--c, #007aff);
  stroke-width: 2;
  cursor: pointer;
  transition: r 0.15s ease, filter 0.15s ease;
}

.traj-point:hover,
.traj-point:focus-visible {
  r: 6.5;
  filter: drop-shadow(0 3px 6px color-mix(in srgb, var(--c, #007aff), transparent 50%));
  outline: none;
  stroke-width: 2.5;
}

.traj-point-label {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 700;
}

/* Tooltip */
.traj-tooltip {
  position: fixed;
  z-index: 100;
  min-width: 130px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid rgba(255,255,255,0.8);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  text-align: center;
}

.traj-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: rgba(255,255,255,0.95);
  border-right: 1px solid rgba(255,255,255,0.8);
  border-bottom: 1px solid rgba(255,255,255,0.8);
  transform: translateX(-50%) rotate(45deg);
}

.traj-tooltip-title {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.traj-tooltip-time {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.traj-tooltip-session {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

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