:root {
  --bg: #071018;
  --text: #eef4fb;
  --text-soft: rgba(238, 244, 251, 0.74);
  --text-faint: rgba(238, 244, 251, 0.46);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --track: rgba(255, 255, 255, 0.08);
  --ring: #9ed6ff;
  --glow: rgba(158, 214, 255, 0.22);
  --warn: #f1c790;
  --end: #ffd3a8;
  --finish: #f0ddd0;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
  --stage-size: min(58vh, 520px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  letter-spacing: 0.02em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 16%, rgba(255, 247, 226, 0.14), transparent 24%),
    radial-gradient(circle at 82% 12%, rgba(113, 184, 255, 0.1), transparent 20%),
    linear-gradient(180deg, rgba(6, 11, 18, 0.12), rgba(6, 11, 18, 0.56) 56%, rgba(6, 11, 18, 0.82));
  z-index: 1;
}

.scene {
  position: fixed;
  inset: -8vmax;
  overflow: hidden;
  transform: scale(1.05);
  z-index: 0;
  background: linear-gradient(180deg, #112131 0%, #0d1927 48%, #132435 60%, #31251c 61%, #18120e 100%);
}

.scene span,
.scene::before,
.scene::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.scene::before {
  inset: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 244, 216, 0.24), transparent 30%),
    radial-gradient(circle at 86% 10%, rgba(118, 186, 255, 0.12), transparent 22%);
}

.scene::after {
  inset: 0;
  background: radial-gradient(circle at center, transparent 36%, rgba(0, 0, 0, 0.38) 100%);
}

.glow-warm {
  left: -4%;
  top: -14%;
  width: 56vw;
  height: 56vw;
  min-width: 680px;
  min-height: 680px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 243, 211, 0.24), rgba(255, 243, 211, 0.08) 32%, transparent 68%);
  filter: blur(18px);
  animation: driftWarm 24s ease-in-out infinite;
}

.glow-cool {
  right: -8%;
  top: -10%;
  width: 40vw;
  height: 40vw;
  min-width: 460px;
  min-height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(122, 186, 255, 0.16), rgba(122, 186, 255, 0.06) 40%, transparent 72%);
  filter: blur(34px);
  animation: driftCool 32s ease-in-out infinite;
}

.light {
  left: 4%;
  top: 10%;
  width: 60vw;
  height: 54vh;
  background: linear-gradient(108deg, rgba(255, 246, 220, 0.24), rgba(255, 244, 216, 0.08) 24%, transparent 62%);
  filter: blur(28px);
  transform: skewX(-12deg) rotate(-8deg);
  opacity: 0.8;
  animation: breathe 18s ease-in-out infinite;
}

.plant {
  right: 5%;
  top: 6%;
  width: 300px;
  height: 400px;
  opacity: 0.16;
  filter: blur(2px);
  background:
    radial-gradient(circle at 28% 24%, rgba(122, 165, 126, 0.68) 0 18%, transparent 19%),
    radial-gradient(circle at 46% 18%, rgba(106, 146, 113, 0.56) 0 16%, transparent 17%),
    radial-gradient(circle at 56% 34%, rgba(112, 155, 119, 0.58) 0 18%, transparent 19%),
    radial-gradient(circle at 34% 44%, rgba(97, 140, 107, 0.52) 0 16%, transparent 17%),
    radial-gradient(circle at 60% 58%, rgba(104, 141, 104, 0.48) 0 18%, transparent 19%);
}

.grain {
  inset: 0;
  opacity: 0.12;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.82'/%3E%3C/svg%3E");
}

.vignette {
  inset: 0;
  background: radial-gradient(circle at center, transparent 36%, rgba(0, 0, 0, 0.38) 100%);
  opacity: 0.78;
}

.shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: 28px 30px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.brand small {
  display: block;
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.brand h1 {
  margin: 10px 0 0;
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 650;
  letter-spacing: 0.1em;
}

.brand p {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-soft);
}

.topbar__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.topbar__buttons {
  display: flex;
  gap: 10px;
}

.now {
  text-align: right;
}

.now span {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-faint);
}

.now strong {
  display: block;
  font-size: clamp(30px, 2.5vw, 40px);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.ctrl-btn {
  appearance: none;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
  backdrop-filter: blur(20px);
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.ctrl-btn__icon {
  font-size: 16px;
  opacity: 0.8;
}

.ctrl-btn__label {
  white-space: nowrap;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  color: var(--text);
  transform: translateY(-1px);
}

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

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

.ctrl-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(158, 214, 255, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.button,
.preset,
.fullscreen {
  appearance: none;
  border: none;
  outline: none;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease, opacity 180ms ease, color 180ms ease;
}

.button:focus-visible,
.preset:focus-visible,
.custom input:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16), 0 0 0 5px rgba(158, 214, 255, 0.18);
}

.button,
.preset,
.custom {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: var(--text);
  backdrop-filter: blur(14px);
}

.button:hover:not(:disabled),
.preset:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.09);
}

.button:disabled,
.preset:disabled,
.custom input:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.screen {
  flex: 1;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 0 0 6px;
}

.timer-stage {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
}

.timer-frame {
  position: relative;
  width: var(--stage-size);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.timer-frame::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.12), transparent 36%), linear-gradient(180deg, rgba(13, 24, 36, 0.9), rgba(7, 13, 22, 0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 28px 44px rgba(255, 255, 255, 0.03), inset 0 -28px 36px rgba(0, 0, 0, 0.26), var(--shadow);
}

.timer-frame::after {
  content: "";
  position: absolute;
  inset: -1.6%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.04);
  opacity: 0.7;
}

.ring-svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  overflow: visible;
  filter: drop-shadow(0 0 20px var(--glow));
}

.ring-track {
  fill: none;
  stroke: var(--track);
  stroke-width: 4.8;
}

.ring-progress-glow {
  fill: none;
  stroke: var(--ring);
  stroke-width: 4.8;
  stroke-linecap: round;
  opacity: 0.26;
  filter: blur(6px);
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}

.ring-progress {
  fill: none;
  stroke: var(--ring);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}

.ring-highlight {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-dasharray: 12 88;
}

.timer-core {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 19% 16%;
}

.status {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(238, 244, 251, 0.66);
}

.time {
  margin: 0;
  font-family: "Inter", "Segoe UI", "PingFang SC", sans-serif;
  font-size: clamp(56px, 8vw, 102px);
  line-height: 0.92;
  font-weight: 700;
  letter-spacing: -0.08em;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  white-space: nowrap;
  text-align: center;
  text-shadow: 0 12px 38px rgba(0, 0, 0, 0.3);
}

.subtitle {
  margin: 12px auto 0;
  max-width: 280px;
  font-size: 14px;
  line-height: 1.72;
  color: var(--text-soft);
}

.meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.meta-pill {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: var(--text-soft);
}

.controls {
  width: min(1040px, calc(100vw - 48px));
  display: grid;
  gap: 12px;
  justify-items: center;
  transition: all 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.controls.minimal #presetRow,
.controls.minimal .custom,
.controls.minimal #startButton,
.controls.minimal #resumeButton,
.controls.minimal #restartButton,
.controls.minimal .hint {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.controls.minimal #pauseButton,
.controls.minimal #resetButton {
  opacity: 1;
  pointer-events: auto;
}

.controls > * {
  transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1), 
              transform 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.preset {
  min-width: 104px;
  padding: 14px 18px;
  color: var(--text-soft);
}

.preset.active {
  background: linear-gradient(135deg, rgba(158, 214, 255, 0.18), rgba(212, 236, 255, 0.08));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(158, 214, 255, 0.28), 0 10px 22px rgba(158, 214, 255, 0.12);
}

.custom {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 16px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-soft);
}

.custom input {
  width: 112px;
  border: none;
  outline: none;
  padding: 12px 14px;
  border-radius: 999px;
  font: inherit;
  color: var(--text);
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.button {
  min-width: 112px;
  padding: 14px 20px;
}

.button.primary {
  background: linear-gradient(135deg, rgba(158, 214, 255, 0.96), rgba(212, 236, 255, 0.92));
  color: #07111b;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28), 0 18px 34px rgba(109, 187, 247, 0.26);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.03);
}

.hint {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 8, 14, 0.46);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay__panel {
  width: min(560px, 100%);
  padding: 40px 34px 32px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(14, 25, 37, 0.88), rgba(8, 14, 22, 0.96));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  text-align: center;
}

.overlay__panel small {
  display: block;
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.overlay__panel h2 {
  margin: 16px 0 12px;
  font-size: clamp(42px, 7vw, 74px);
  line-height: 1;
  letter-spacing: 0.06em;
}

.overlay__panel p {
  margin: 0;
  line-height: 1.8;
  color: var(--text-soft);
}

body.idle {
  --ring: #9ed6ff;
  --glow: rgba(158, 214, 255, 0.18);
}

body.run {
  --ring: #9ed6ff;
  --glow: rgba(158, 214, 255, 0.24);
}

body.pause {
  --ring: #bfcfdd;
  --glow: rgba(191, 207, 221, 0.14);
}

body.warn {
  --ring: var(--warn);
  --glow: rgba(241, 199, 144, 0.2);
}

body.end {
  --ring: var(--end);
  --glow: rgba(255, 211, 168, 0.22);
}

body.end .timer-frame {
  animation: pulse 2.6s ease-in-out infinite;
}

body.fin {
  --ring: var(--finish);
  --glow: rgba(240, 221, 208, 0.14);
}

@keyframes driftWarm {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(2%, -2%, 0) scale(1.03); }
}

@keyframes driftCool {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-2%, 1.5%, 0) scale(1.04); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 0.92; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.014); }
}

.wallpaper {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: transparent;
  opacity: 0;
  transition: opacity 1.2s ease;
  z-index: 0;
  pointer-events: none;
}

.scene.has-wallpaper {
  background: #000;
}

.scene.has-wallpaper .wallpaper {
  opacity: 0.7;
}

.scene span {
  z-index: 1;
}

@media (max-width: 920px) {
  html, body { overflow: auto; }
  .shell { padding: 24px 16px 18px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar__side { justify-content: space-between; align-items: center; }
  .now { text-align: left; }
  .timer-frame { width: min(84vw, 500px); }
  .timer-core { padding: 18% 10%; }
  .time { font-size: clamp(52px, 11vw, 92px); }
  .subtitle { max-width: 280px; }
  .plant { right: -8%; top: 1%; }
}

@media (max-height: 860px) {
  .screen { gap: 12px; }
  .timer-frame { width: min(56vh, 470px); }
  .time { font-size: clamp(52px, 7vw, 88px); }
  .timer-core { padding: 17% 11%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
