/* 训练倒计时样式：移动优先、单列卡片布局、清新薄荷运动主题 */
:root {
	--primary: #14b8a6;
	--primary-strong: #0d9488;
	--accent-blue: #38bdf8;
	--accent-orange: #fb923c;
	--bg: #f3f9f7;
	--bg-top: #e5f4f0;
	--card: rgba(255, 255, 255, 0.92);
	--text: #14303f;
	--muted: #7d98a5;
	--border: #e0edef;
	--danger: #f87171;
	--warning-bg: #fff6e8;
	--warning-border: #f8d9a8;
	--warning-text: #9a6b1f;
	--radius: 16px;
}

* {
	box-sizing: border-box;
}

/* hidden 属性统一生效（防止被 display 规则覆盖） */
[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	/* 清新浅色运动主题：柔和薄荷与天空蓝光斑 */
	background:
		radial-gradient(1000px 520px at 88% -140px, rgba(56, 189, 248, 0.16), transparent 60%),
		radial-gradient(820px 480px at 8% 24%, rgba(45, 212, 191, 0.13), transparent 56%),
		linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 460px);
	background-attachment: fixed;
	color: var(--text);
	/* 系统字体栈 */
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
	font-size: 16px;
	line-height: 1.5;
	overscroll-behavior: none;
	touch-action: manipulation;
	/* 禁用双击缩放 */
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}

/* iOS 独立模式：底部为 Home 指示条留白 */
body.standalone {
	padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
	background: linear-gradient(180deg, rgba(45, 212, 191, 0.16), rgba(45, 212, 191, 0.02));
	color: var(--text);
	text-align: center;
	padding: calc(env(safe-area-inset-top) + 12px) 16px 14px;
	border-bottom: 1px solid var(--border);
}

.app-header h1 {
	margin: 0;
	font-size: 20px;
	font-weight: 800;
	letter-spacing: 2px;
	background: linear-gradient(135deg, #0d9488, #0ea5e9);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	-webkit-text-fill-color: transparent;
}

.container {
	max-width: 520px;
	margin: 0 auto;
	padding: 12px 12px 24px;
}

.card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: 0 10px 28px rgba(20, 48, 63, 0.07);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	padding: 16px;
	margin-bottom: 12px;
}

.card-title {
	margin: 0 0 12px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 2px;
	color: var(--muted);
}

/* 运行中禁用编辑：CSS pointer-events + disabled 双保险 */
.disabled {
	pointer-events: none;
	opacity: 0.6;
}

/* ---------- 设置卡片 ---------- */

.settings-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.field-label {
	font-size: 13px;
	color: var(--muted);
}

.field input {
	font-size: 18px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: 10px;
	min-height: 44px;
	width: 100%;
	background: #ffffff;
	color: var(--text);
	font-variant-numeric: tabular-nums;
}

.field input:focus {
	outline: 2px solid rgba(20, 184, 166, 0.4);
	outline-offset: -1px;
	border-color: var(--primary);
}

.settings-error {
	margin: 10px 0 0;
	color: var(--danger);
	font-size: 13px;
}

.settings-note {
	margin: 10px 0 0;
	color: var(--muted);
	font-size: 12px;
}

/* ---------- 列表卡片 ---------- */

.segment-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	position: relative; /* 保证子行 offsetTop 相对本容器计算 */
}

/* 运行中：固定高度滚动容器，允许滑动查看全部训练 */
.segment-list.scroll-locked {
	max-height: 240px; /* 4 行 × 54px + 3 × 8px 间隙 */
	overflow-y: auto;
	-webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
	overscroll-behavior: contain; /* 滚动到边界时不带动页面 */
	padding-right: 2px; /* 预留滚动条空间，避免布局抖动 */
}

/* 运行中列表保持可触摸滚动，行内控件已单独禁用 */
.segment-list.disabled {
	pointer-events: auto;
	opacity: 1;
}

/* 深色细滚动条 */
.segment-list.scroll-locked::-webkit-scrollbar {
	width: 3px;
}

.segment-list.scroll-locked::-webkit-scrollbar-thumb {
	background: rgba(20, 48, 63, 0.22);
	border-radius: 3px;
}

.segment-list.scroll-locked::-webkit-scrollbar-track {
	background: transparent;
}

.segment-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: #ffffff;
	min-height: 54px; /* 运行中窗口固定显示 4 行，保持高度稳定 */
	transition: background-color 0.35s ease, border-color 0.35s ease; /* 高亮平滑过渡 */
}

.drag-handle {
	color: var(--muted);
	font-size: 18px;
	cursor: grab;
	padding: 4px;
	user-select: none;
	touch-action: none;
	/* 拖拽手柄上禁用触摸滚动 */
}

/* 运行中拖拽已禁用：手柄恢复触摸滚动，便于滑动查看列表 */
body.running .drag-handle {
	touch-action: pan-y;
	cursor: default;
}

.segment-index {
	min-width: 22px;
	height: 22px;
	border-radius: 50%;
	background: linear-gradient(135deg, #2dd4bf, #0ea5e9);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.segment-name {
	flex: 1;
	min-width: 0;
	font-size: 16px;
	border: none;
	outline: none;
	background: transparent;
	padding: 6px 4px;
	color: var(--text);
}

.segment-name:focus {
	background: rgba(20, 184, 166, 0.08);
	border-radius: 6px;
}

.start-label {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 13px;
	color: var(--muted);
	white-space: nowrap;
}

.btn-delete {
	border: none;
	background: transparent;
	color: var(--danger);
	font-size: 20px;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	cursor: pointer;
}

.btn-delete:active {
	background: rgba(229, 72, 77, 0.1);
}

.list-empty {
	color: var(--muted);
	font-size: 14px;
	text-align: center;
	margin: 4px 0;
}

/* 计划导入导出工具栏 */
.plan-tools {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}

.plan-tools .btn {
	flex: 1;
	min-height: 38px;
	font-size: 14px;
}

/* 运行中训练高亮：训练中当前段、休息中下一段、准备中起始段 */
.segment-row.seg-active {
	background: rgba(20, 184, 166, 0.1);
	border-color: var(--primary);
	box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.25), 0 4px 14px rgba(20, 184, 166, 0.14);
}

.segment-row.seg-next {
	background: rgba(251, 146, 60, 0.1);
	border-color: var(--accent-orange);
}

.sortable-ghost {
	opacity: 0.4;
}

/* 训练计划总时长汇总 */
.plan-summary {
	margin: 10px 0 0;
	color: var(--muted);
	font-size: 13px;
	text-align: center;
}

/* ---------- 按钮 ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 18px;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: #ffffff;
	color: var(--text);
	font-size: 16px;
	font-weight: 500;
	cursor: pointer;
}

.btn:active {
	background: #eef6f4;
}

.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.btn-primary {
	background: linear-gradient(135deg, #2dd4bf 0%, #0ea5e9 100%);
	border-color: transparent;
	color: #fff;
	font-weight: 700;
	box-shadow: 0 6px 18px rgba(14, 165, 233, 0.3);
}

.btn-primary:active {
	background: linear-gradient(135deg, #2dd4bf 0%, #0ea5e9 100%);
	filter: brightness(0.94);
}

.btn-block {
	width: 100%;
	margin-top: 12px;
	border-style: dashed;
	color: var(--primary);
	border-color: rgba(20, 184, 166, 0.55);
	background: rgba(20, 184, 166, 0.05);
}

/* ---------- 运行面板 ---------- */

.run-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
}

.phase-label {
	font-size: 13px;
	font-weight: 700;
	color: #fff;
	background: linear-gradient(135deg, #14b8a6, #0ea5e9);
	border-radius: 999px;
	padding: 3px 12px;
	white-space: nowrap;
	letter-spacing: 1px;
}

.run-segment-name {
	font-size: 15px;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 大号倒计时：清晰醒目 */
.run-time {
	font-size: 64px;
	font-weight: 700;
	text-align: center;
	font-variant-numeric: tabular-nums;
	letter-spacing: 2px;
	margin: 12px 0 6px;
	/* 薄荷到天空蓝渐变数字 */
	background: linear-gradient(180deg, #0d9488 0%, #0ea5e9 100%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	-webkit-text-fill-color: transparent;
}

/* 运行进度标注 */
.run-progress {
	text-align: center;
	color: var(--muted);
	font-size: 13px;
	margin-bottom: 8px;
	min-height: 20px;
}

.progress {
	height: 8px;
	border-radius: 999px;
	background: #e7f0f2;
	overflow: hidden;
	margin-bottom: 14px;
}

.progress-fill {
	height: 100%;
	width: 0;
	background: linear-gradient(90deg, #14b8a6, #38bdf8);
	border-radius: 999px;
	transition: width 0.15s linear;
}

.controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.controls .btn {
	flex: 1 1 30%;
}

.done-panel {
	text-align: center;
	padding: 8px 0 4px;
}

.done-title {
	font-size: 22px;
	font-weight: 800;
	background: linear-gradient(135deg, #14b8a6, #0ea5e9);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	-webkit-text-fill-color: transparent;
	margin: 0 0 12px;
}

/* ---------- 静音拨片提示条 ---------- */

.hint-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--warning-bg);
	border-bottom: 1px solid var(--warning-border);
	padding: 10px 14px;
	font-size: 13px;
	color: var(--warning-text);
}

.hint-text {
	flex: 1;
}

.hint-close {
	border: none;
	background: transparent;
	color: inherit;
	font-size: 18px;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	cursor: pointer;
}

/* ---------- 轻提示 ---------- */

.toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	transform: translateX(-50%);
	background: rgba(20, 48, 63, 0.95);
	color: #fff;
	padding: 10px 18px;
	border-radius: 999px;
	font-size: 14px;
	max-width: 86vw;
	z-index: 10;
}

/* ---------- 语音加载遮罩 ---------- */

.loading-overlay {
	position: fixed;
	inset: 0;
	background: rgba(243, 249, 247, 0.88);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 50;
}

.loading-box { text-align: center; }

.spinner {
	width: 44px;
	height: 44px;
	margin: 0 auto 14px;
	border: 4px solid rgba(20, 184, 166, 0.18);
	border-top-color: var(--primary);
	border-radius: 50%;
	animation: spin 0.9s linear infinite;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

.loading-text { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- 页脚 ---------- */

.app-footer {
  text-align: center;
  padding: 14px 12px calc(16px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
}

.app-footer p { margin: 0; }