/* ==================== 通用样式 ==================== */
:root {
  --bg-deep: #21122f;
  --bg-dark: #2d1940;
  --purple: #a66fbb;
  --purple-light: #d3addf;
  --accent: #f5b85f;
  --accent-light: #ffd48d;
  --text: #f7f2fa;
  --text-soft: #c9bbd3;
  --text-muted: #94869f;
  --line: rgba(217, 190, 229, 0.13);
  --warn: #ff8a5c;
  --danger: #ff6f6f;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(700px 500px at 18% 8%, rgba(166, 111, 187, 0.22), transparent 68%),
    radial-gradient(620px 460px at 88% 92%, rgba(245, 184, 95, 0.11), transparent 68%),
    linear-gradient(145deg, var(--bg-dark), var(--bg-deep));
}

/* 背景装饰圆环 */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(10px);
}

body::before {
  top: -150px;
  right: -110px;
  width: 390px;
  height: 390px;
  border: 1px solid rgba(211, 173, 223, 0.08);
  box-shadow:
    0 0 0 45px rgba(211, 173, 223, 0.018),
    0 0 0 90px rgba(211, 173, 223, 0.012);
  animation: orbFloat 14s ease-in-out infinite;
}

body::after {
  bottom: -180px;
  left: -130px;
  width: 430px;
  height: 430px;
  background: rgba(166, 111, 187, 0.055);
  animation: orbFloat 18s ease-in-out infinite reverse;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(20px, -28px); }
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(245, 184, 95, 0.75);
  outline-offset: 2px;
}

.cd-container {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 26px 20px;
  display: flex;
  align-items: safe center;
  justify-content: center;
}

.cd-content {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  min-width: 0;
  animation: fadeUp 0.6s ease both;
}

/* 卡片背后柔光 */
.cd-content::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 20px -22px -22px 22px;
  border-radius: 32px;
  background: rgba(166, 111, 187, 0.09);
  filter: blur(18px);
}

/* 毛玻璃主卡片 */
.cd-wrap {
  overflow: hidden;
  border: 1px solid rgba(217, 190, 229, 0.16);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.045));
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 35px 90px -35px rgba(5, 0, 10, 0.75);
}

.brand-note {
  margin-top: 18px;
  color: rgba(201, 187, 211, 0.48);
  font-size: 10px;
  text-align: center;
  letter-spacing: 1.2px;
}

.brand-note span {
  color: rgba(245, 184, 95, 0.65);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
  .cd-container {
    padding: 18px 14px;
  }

  .cd-wrap {
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}



/* ==================== cd-header ==================== */
.cd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 34px 0;
}

.company-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  filter: drop-shadow(0 8px 18px rgba(245, 184, 95, 0.1));
}

.company-logo .brand-mark {
  width: 46px;
  height: 46px;
  flex: none;
}

.company-wordmark strong {
  display: block;
  font-size: 25px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 2px;
}

.company-wordmark span {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-family: Arial, sans-serif;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 1.7px;
}

.cd-label {
  padding: 8px 14px;
  flex: none;
  color: var(--accent-light);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

@media (max-width: 600px) {
  .cd-header {
    padding: 24px 20px 0;
  }

  .company-logo {
    gap: 8px;
  }

  .company-logo .brand-mark {
    width: 40px;
    height: 40px;
  }

  .company-wordmark strong {
    font-size: 22px;
  }

  .cd-label {
    padding: 7px 10px;
    font-size: 11px;
    letter-spacing: 1px;
  }
}



/* ==================== cd-stage（圆环 + 时间） ==================== */
.cd-stage {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 20px auto 4px;
  display: grid;
  place-items: center;
}

.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 14;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 10px rgba(245, 184, 95, 0.45));
  transition: stroke-dashoffset 0.18s linear, stroke 0.4s ease, filter 0.4s ease;
}

/* 圆环中心呼吸光晕 */
.ring-glow {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 184, 95, 0.16), transparent 70%);
  animation: breathe 3.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.92); opacity: 0.55; }
  50% { transform: scale(1.06); opacity: 0.95; }
}

.timer-center {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.timer-status {
  color: var(--text-soft);
  font-size: 13px;
  letter-spacing: 2px;
}

.timer-time {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

/* 突出的剩余时间文字（金紫渐变 + 发光） */
.time-text {
  font-family: "DIN Alternate", "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 62px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff1d8 0%, var(--accent-light) 45%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(245, 184, 95, 0.45));
  animation: timePulse 2s ease-in-out infinite;
  font-variant-numeric: tabular-nums;
}

@keyframes timePulse {
  0%, 100% { filter: drop-shadow(0 4px 16px rgba(245, 184, 95, 0.38)); }
  50% { filter: drop-shadow(0 4px 26px rgba(245, 184, 95, 0.68)); }
}

.timer-hint {
  margin-top: 2px;
  padding: 3px 12px;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 8, 29, 0.2);
}

/* 警示状态：剩余 ≤ 60s */
.cd-stage.is-warning .ring-fill {
  stroke: url(#ringGradWarn);
  filter: drop-shadow(0 0 14px rgba(255, 138, 92, 0.6));
}
.cd-stage.is-warning .time-text {
  background: linear-gradient(180deg, #ffd9a8 0%, #ffae6e 50%, var(--warn) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: timePulseWarn 1.4s ease-in-out infinite;
}
@keyframes timePulseWarn {
  0%, 100% { filter: drop-shadow(0 4px 14px rgba(255, 138, 92, 0.4)); }
  50% { filter: drop-shadow(0 4px 26px rgba(255, 138, 92, 0.8)); }
}

/* 危险状态：剩余 ≤ 10s */
.cd-stage.is-danger {
  animation: stageShake 0.5s ease-in-out infinite;
}
.cd-stage.is-danger .ring-fill {
  stroke: var(--danger);
  filter: drop-shadow(0 0 16px rgba(255, 111, 111, 0.75));
}
.cd-stage.is-danger .time-text {
  background: linear-gradient(180deg, #ffd0d0 0%, #ff8a8a 50%, var(--danger) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: timePulseDanger 0.7s ease-in-out infinite;
}
@keyframes timePulseDanger {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 16px rgba(255, 111, 111, 0.5)); }
  50% { transform: scale(1.06); filter: drop-shadow(0 4px 28px rgba(255, 111, 111, 0.9)); }
}
@keyframes stageShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* 时间到：卡片红色内发光 + 数字收尾脉冲 */
body.is-finished .cd-wrap {
  animation: finishFlash 1.4s ease-out;
}
@keyframes finishFlash {
  0%   { box-shadow: 0 35px 90px -35px rgba(5, 0, 10, 0.75), inset 0 0 0 0 rgba(255, 111, 111, 0); }
  18%  { box-shadow: 0 35px 90px -35px rgba(5, 0, 10, 0.75), inset 0 0 70px 6px rgba(255, 111, 111, 0.42); }
  100% { box-shadow: 0 35px 90px -35px rgba(5, 0, 10, 0.75), inset 0 0 0 0 rgba(255, 111, 111, 0); }
}

.cd-stage.is-finished .ring-fill {
  stroke: var(--danger);
  filter: drop-shadow(0 0 18px rgba(255, 111, 111, 0.8));
}
.cd-stage.is-finished .time-text {
  background: linear-gradient(180deg, #ffd0d0 0%, #ff8a8a 50%, var(--danger) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: finishPulse 1.2s ease-in-out infinite;
}
@keyframes finishPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 16px rgba(255, 111, 111, 0.5)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 4px 30px rgba(255, 111, 111, 0.95)); }
}

@media (max-width: 600px) {
  .cd-stage {
    width: 240px;
    height: 240px;
    margin: 16px auto 2px;
  }
  .ring-track,
  .ring-fill {
    stroke-width: 13;
  }
  .time-text {
    font-size: 52px;
  }
  .timer-status {
    font-size: 12px;
  }
}

/* 短屏（按视口高度）自适应缩放，保证不溢出、不出现滚动条 */
@media (max-height: 700px) {
  .cd-container {
    padding: 16px 20px;
  }
  .cd-header {
    padding-top: 18px;
  }
  .cd-stage {
    width: 220px;
    height: 220px;
    margin: 14px auto 2px;
  }
  .time-text {
    font-size: 50px;
  }
  .cd-count {
    margin-top: 10px;
    padding: 12px 18px;
  }
  .cd-setup {
    padding: 12px 34px 2px;
  }
  .preset-row {
    margin-top: 10px;
  }
  .cd-controls {
    padding: 12px 34px 18px;
  }
}

@media (max-height: 560px) {
  .cd-stage {
    width: 180px;
    height: 180px;
  }
  .time-text {
    font-size: 42px;
  }
  .company-logo .brand-mark {
    width: 38px;
    height: 38px;
  }
  .company-wordmark strong {
    font-size: 21px;
  }
  .timer-status {
    font-size: 11px;
  }
  .timer-hint {
    font-size: 10px;
  }
}



/* ==================== cd-count（进度统计） ==================== */
.cd-count {
  margin: 12px 34px 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(20, 8, 29, 0.2);
}

.progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.progress-info p {
  color: var(--text-soft);
  font-size: 14px;
}

.progress-info p strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-info p span {
  font-variant-numeric: tabular-nums;
}

.progress-percent {
  color: var(--accent-light);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.065);
}

.progress-bar {
  position: relative;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), var(--accent));
  box-shadow: 0 0 18px rgba(245, 184, 95, 0.2);
  transition: width 0.35s ease;
}

.progress-bar::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff5df;
  box-shadow: 0 0 6px #fff5df;
}

@media (max-width: 600px) {
  .cd-count {
    margin: 12px 20px 0;
  }
}



/* ==================== cd-setup（输入 + 预设） ==================== */
.cd-setup {
  padding: 16px 34px 2px;
}

.setup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 10px;
}

.minute-field {
  position: relative;
  display: flex;
  align-items: center;
}

.minute-input {
  width: 100%;
  height: 47px;
  padding: 0 56px 0 16px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(17, 6, 26, 0.28);
  -moz-appearance: textfield;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.minute-input::-webkit-outer-spin-button,
.minute-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.minute-input::placeholder {
  color: #a093aa;
  font-weight: 500;
}

.minute-input:focus {
  border-color: rgba(211, 173, 223, 0.38);
  box-shadow: 0 0 0 3px rgba(166, 111, 187, 0.08);
}

.minute-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.minute-unit {
  position: absolute;
  right: 14px;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.minute-field.locked .minute-unit {
  color: var(--accent-light);
}

.start-btn {
  width: 116px;
  flex: none;
  color: #422200;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  box-shadow: 0 12px 24px -13px rgba(245, 184, 95, 0.7);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.start-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 16px 30px -13px rgba(245, 184, 95, 0.8);
}

.start-btn:active:not(:disabled) {
  transform: translateY(0);
}

.start-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  filter: grayscale(0.25);
}

/* 预设快捷选择 */
.preset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.preset-label {
  color: var(--text-muted);
  font-size: 12px;
  flex: none;
}

.preset-chips {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.preset-chip {
  flex: 1;
  min-width: 0;
  height: 36px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  transition: all 0.18s ease;
  font-variant-numeric: tabular-nums;
}

.preset-chip:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(211, 173, 223, 0.28);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.preset-chip.active {
  color: #422200;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  box-shadow: 0 8px 18px -10px rgba(245, 184, 95, 0.7);
}

.preset-chip:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

@media (max-width: 600px) {
  .cd-setup {
    padding: 18px 20px 2px;
  }

  .setup-row {
    grid-template-columns: minmax(0, 1fr) 100px;
    gap: 8px;
  }

  .start-btn {
    width: 100px;
  }

  .preset-chip {
    height: 34px;
    font-size: 13px;
  }
}



/* ==================== cd-controls（暂停 / 重置） ==================== */
.cd-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  padding: 14px 34px 22px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  transition: all 0.18s ease;
}

.ctrl-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
}

.ctrl-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(211, 173, 223, 0.28);
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}

.ctrl-btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.ctrl-pause:hover:not(:disabled) {
  color: var(--accent-light);
  border-color: rgba(245, 184, 95, 0.32);
}

.ctrl-reset:hover:not(:disabled) {
  color: var(--purple-light);
  border-color: rgba(211, 173, 223, 0.32);
}

@media (max-width: 600px) {
  .cd-controls {
    padding: 16px 20px 24px;
  }
}
