:root {
  --bg-a: #0b1028;
  --bg-b: #1a0f2e;
  --fg: #f5f1ea;
  --fg-dim: #b9b3c9;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
  --grad-a: #ff6b6b;
  --grad-b: #ffb15c;
  --accent: #ff6b6b;
  --accent-2: #ffb15c;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-mode="focus"] {
  --grad-a: #ff6b6b;
  --grad-b: #ffb15c;
  --accent: #ff6b6b;
  --accent-2: #ffb15c;
}
body[data-mode="short"] {
  --grad-a: #5eead4;
  --grad-b: #60a5fa;
  --accent: #5eead4;
  --accent-2: #60a5fa;
}
body[data-mode="long"] {
  --grad-a: #a78bfa;
  --grad-b: #60a5fa;
  --accent: #a78bfa;
  --accent-2: #60a5fa;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI Symbol", "Segoe UI Emoji",
    "Apple Color Emoji", sans-serif;
  color: var(--fg);
  background: radial-gradient(ellipse at 20% 10%, var(--bg-b), var(--bg-a) 60%);
  overflow-x: hidden;
  transition: background var(--transition);
}

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 24px 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 返回首页链接 */
.back-home {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg-dim);
  text-decoration: none;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--card-border);
  margin-bottom: 14px;
  backdrop-filter: blur(6px);
  transition: all 0.2s ease;
}
.back-home:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

/* 顶栏 */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.5px;
}
.logo {
  font-size: 22px;
  filter: drop-shadow(0 0 8px var(--accent));
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  50% { transform: scale(1.08); }
}
.modes {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}
.mode-btn {
  border: none;
  background: transparent;
  color: var(--fg-dim);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.25s ease;
}
.mode-btn:hover { color: var(--fg); }
.mode-btn.active {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: white;
  box-shadow: 0 4px 14px -4px var(--accent);
}
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--fg);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.orbit-wrap {
  position: relative;
  width: min(440px, 92vw);
  height: min(440px, 92vw);
  display: flex;
  align-items: center;
  justify-content: center;
}
.orbit {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  animation: spin linear infinite;
}
.orbit-1 { width: 84%; height: 84%; animation-duration: 80s; }
.orbit-2 { width: 96%; height: 96%; animation-duration: 120s; animation-direction: reverse; }
.orbit-3 { width: 108%; height: 108%; animation-duration: 160s; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

.harvest {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.planet {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffb4a8, #e53935 60%, #7a1212);
  box-shadow: 0 0 12px rgba(229, 57, 53, 0.6);
  transform-origin: center;
  animation: orbit var(--dur, 60s) linear infinite;
}
@keyframes orbit {
  from { transform: rotate(var(--start, 0deg)) translateX(var(--r, 180px)) rotate(calc(-1 * var(--start, 0deg))); }
  to   { transform: rotate(calc(var(--start, 0deg) + 360deg)) translateX(var(--r, 180px)) rotate(calc(-1 * var(--start, 0deg) - 360deg)); }
}

.timer-wrap {
  position: relative;
  width: 74%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 6;
}
.ring-progress {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 628.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              stroke var(--transition);
}

.tomato {
  position: absolute;
  width: 56%;
  aspect-ratio: 1;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.4));
  transition: transform 0.5s ease;
}
.tomato.breathing {
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.tomato-body {
  position: absolute;
  inset: 12% 8% 0 8%;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%,
    color-mix(in srgb, var(--grad-a) 80%, white 20%),
    var(--grad-a) 45%,
    color-mix(in srgb, var(--grad-a) 70%, black 30%) 100%);
  box-shadow: inset -8px -14px 30px rgba(0, 0, 0, 0.25),
              0 0 40px color-mix(in srgb, var(--grad-a) 40%, transparent);
  transition: background var(--transition);
}
.tomato-shine {
  position: absolute;
  top: 22%;
  left: 22%;
  width: 20%;
  height: 15%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.7), transparent 70%);
  border-radius: 50%;
  filter: blur(2px);
}
.tomato-leaf {
  position: absolute;
  top: 6%;
  left: 50%;
  width: 40%;
  height: 22%;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 30% 60%, #4ade80 20%, transparent 22%),
    radial-gradient(circle at 70% 60%, #4ade80 20%, transparent 22%),
    radial-gradient(circle at 50% 40%, #22c55e 25%, transparent 27%),
    radial-gradient(circle at 15% 70%, #22c55e 18%, transparent 20%),
    radial-gradient(circle at 85% 70%, #22c55e 18%, transparent 20%);
}
.tomato-stem {
  position: absolute;
  top: 0;
  left: 50%;
  width: 6%;
  height: 16%;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, #16a34a, #15803d);
  border-radius: 4px;
}

.display {
  position: relative;
  z-index: 2;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.time {
  font-size: clamp(48px, 11vw, 80px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
}
.phase {
  margin-top: 8px;
  font-size: 13px;
  color: var(--fg-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.btn {
  border: none;
  border-radius: 999px;
  padding: 14px 36px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  font-family: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-ghost {
  font-family: "Segoe UI Symbol", "Apple Symbols", system-ui, sans-serif;
  width: 52px;
  height: 52px;
  padding: 0;
  font-size: 20px;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  border: none;
  min-width: 140px;
  box-shadow: 0 10px 30px -10px var(--accent);
}
.btn-primary:hover {
  box-shadow: 0 16px 40px -10px var(--accent);
}
.btn-small {
  padding: 10px 16px;
  font-size: 14px;
  min-width: auto;
}

.tasks {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
}
.tasks-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.tasks-head h3 { margin: 0; font-size: 15px; }
.hint { color: var(--fg-dim); font-size: 12px; }
.task-input {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.task-input input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  color: var(--fg);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s ease;
}
.task-input input:focus {
  border-color: var(--accent);
}
.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
}
.task-list::-webkit-scrollbar { width: 6px; }
.task-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}
.task-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.task-item.active {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--grad-a) 15%, transparent),
    color-mix(in srgb, var(--grad-b) 15%, transparent));
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.task-item.done .task-name {
  text-decoration: line-through;
  opacity: 0.5;
}
.task-check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--fg-dim);
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.2s ease;
}
.task-item.done .task-check {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.task-name { flex: 1; font-size: 14px; }
.task-count {
  font-size: 12px;
  color: var(--fg-dim);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 999px;
}
.task-del {
  background: none;
  border: none;
  color: var(--fg-dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 16px;
}
.task-item:hover .task-del { opacity: 1; }
.task-del:hover { color: #ef4444; }

.foot {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  color: var(--fg-dim);
  font-size: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.foot b { color: var(--fg); font-weight: 600; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}
.modal[hidden] { display: none; }
@keyframes fadeIn {
  from { opacity: 0; }
}
.modal-card {
  background: linear-gradient(145deg, #1c1738, #14102a);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  animation: pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  from { transform: scale(0.9); opacity: 0; }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--card-border);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body {
  padding: 20px 22px;
  max-height: 60vh;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--card-border);
}
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 14px;
}
.row input[type="number"] {
  width: 80px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  color: var(--fg);
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  outline: none;
}
.row.toggle input { width: 40px; height: 22px; accent-color: var(--accent); }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 4px;
}
.sub {
  margin: 16px 0 10px;
  font-size: 13px;
  color: var(--fg-dim);
  font-weight: 500;
}
.chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 100px;
  gap: 6px;
  padding: 8px 0;
}
.bar {
  flex: 1;
  background: linear-gradient(to top, var(--grad-a), var(--grad-b));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  position: relative;
  transition: height 0.5s ease;
}
.bar-label {
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--fg-dim);
}
.bar-val {
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--fg);
}
.danger-row {
  margin-top: 28px;
  text-align: center;
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(20, 14, 40, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  color: var(--fg);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}

body.running .tomato { animation: breathe 4s ease-in-out infinite; }
body.running .orbit { animation-play-state: running; }
body.paused .orbit { animation-play-state: paused; }

@media (max-width: 600px) {
  .app { padding: 16px 16px 40px; }
  .top-bar { gap: 10px; }
  .modes { order: 3; width: 100%; justify-content: center; }
  .mode-btn { font-size: 12px; padding: 6px 10px; }
  .btn-primary { min-width: 110px; padding: 12px 24px; }
  .foot { font-size: 11px; }
}
