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

html, body {
  width: 100%;
  height: 100%;
  background: transparent;
  font-family: "Comic Sans MS", "Microsoft YaHei", sans-serif;
  user-select: none;
  overflow: hidden;
}

.app {
  width: 100%;
  height: 100vh;
  padding: 8px;
}

/* 标题栏 */
.titlebar {
  -webkit-app-region: drag;
  height: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  color: #8b5a2b;
  font-size: 13px;
  font-weight: bold;
}
.drag-area { flex: 1; }
.window-buttons {
  -webkit-app-region: no-drag;
  display: flex;
  gap: 4px;
}
.win-btn {
  width: 22px; height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 12px;
  color: #8b5a2b;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.win-btn:hover { background: #ffd6c4; transform: scale(1.1); }
.win-btn.close:hover { background: #ff9aa2; color: white; }
.win-btn.active { background: #ff6b8a; color: white; }

/* 卡片 */
.card {
  background: linear-gradient(160deg, #ffe5d4 0%, #ffd6e0 100%);
  border-radius: 28px;
  padding: 16px 20px 20px;
  height: calc(100% - 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow:
    0 10px 30px rgba(255, 130, 150, 0.25),
    inset 0 -3px 0 rgba(255,255,255,0.5);
  position: relative;
  overflow: hidden;
}

.card.resting {
  background: linear-gradient(160deg, #d4f0ff 0%, #e0d4ff 100%);
}

.mode-label {
  font-size: 14px;
  color: #8b5a2b;
  background: rgba(255,255,255,0.7);
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
  font-weight: bold;
  letter-spacing: 1px;
}
.card.resting .mode-label { color: #5a6a8b; }

/* 猫咪舞台 */
.cat-stage {
  width: 200px;
  height: 200px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ground {
  position: absolute;
  bottom: 15px;
  width: 140px;
  height: 16px;
  background: rgba(139, 90, 43, 0.15);
  border-radius: 50%;
  filter: blur(4px);
}

.cat {
  width: 180px;
  height: 180px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
  transform-origin: center bottom;
}
.cat .head {
  transform-origin: 100px 110px;
  animation: headBob 3s ease-in-out infinite;
}
.cat .tail {
  transform-origin: 155px 140px;
  animation: tailWag 1.8s ease-in-out infinite;
}

/* 工作状态：眼睛认真 + 偶尔眨眼 */
.cat .eye {
  transform-origin: center;
  animation: blink 4.5s infinite;
}

/* 休息状态：闭眼睡觉 */
.cat.sleeping .eye {
  animation: none;
  transform: scaleY(0.08);
}
.cat.sleeping .head {
  animation: sleepBob 3.5s ease-in-out infinite;
}
.cat.sleeping .tail {
  animation: tailWag 3s ease-in-out infinite;
}

/* 庆祝：跳动 */
.cat.celebrate {
  animation: bounce 0.5s ease infinite;
}

.zzz { animation: floatZ 2.5s ease-in-out infinite; }
.zzz.hidden { opacity: 0; }

.deco-tomato {
  position: absolute;
  bottom: 10px;
  right: 18px;
  font-size: 22px;
  animation: wobble 2s ease-in-out infinite;
}

/* 计时器 */
.timer {
  font-size: 48px;
  font-weight: bold;
  color: #8b5a2b;
  text-shadow: 0 2px 0 rgba(255,255,255,0.6);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.card.resting .timer { color: #5a6a8b; }

/* 进度环 */
.progress-ring {
  width: 70px;
  height: 70px;
  position: absolute;
  top: 50px;
  right: 16px;
  opacity: 0.5;
}
.progress-ring svg { width: 100%; height: 100%; }

/* 控制按钮 */
.controls {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.btn {
  border: none;
  padding: 10px 26px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  background: white;
  color: #8b5a2b;
  box-shadow: 0 4px 0 rgba(139, 90, 43, 0.2);
  transition: all 0.1s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(139, 90, 43, 0.2); }
.btn.primary {
  background: #ff6b8a;
  color: white;
  box-shadow: 0 4px 0 #d14764;
}
.btn.primary:active { box-shadow: 0 1px 0 #d14764; }
.card.resting .btn.primary {
  background: #7aa9d6;
  box-shadow: 0 4px 0 #5688b8;
}

.stats {
  margin-top: 10px;
  font-size: 13px;
  color: #8b5a2b;
  opacity: 0.7;
}
.card.resting .stats { color: #5a6a8b; }

/* ===== 动画 ===== */
@keyframes headBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(-1.5deg); }
}
@keyframes sleepBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}
@keyframes tailWag {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-15deg); }
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
@keyframes floatZ {
  0%, 100% { transform: translateY(0); opacity: 0.9; }
  50% { transform: translateY(-6px); opacity: 0.5; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.05); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(8deg); }
}

/* ===== 设置面板 ===== */
.settings-panel {
  position: absolute;
  top: 36px;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: rgba(255, 250, 245, 0.98);
  border-radius: 22px;
  padding: 18px 22px;
  box-shadow: 0 8px 24px rgba(255, 130, 150, 0.3);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideDown 0.25s ease;
  backdrop-filter: blur(6px);
}
.settings-panel.hidden { display: none; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #8b5a2b;
  font-weight: bold;
  font-size: 15px;
  border-bottom: 2px dashed #ffd6c4;
  padding-bottom: 8px;
}
.close-settings {
  border: none;
  background: transparent;
  color: #8b5a2b;
  font-size: 20px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.close-settings:hover { background: #ffd6c4; }

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-row label {
  color: #8b5a2b;
  font-weight: bold;
  font-size: 14px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: white;
  padding: 4px 8px;
  border-radius: 14px;
  box-shadow: inset 0 2px 4px rgba(139,90,43,0.08);
}
.step-btn {
  width: 24px; height: 24px;
  border: none;
  border-radius: 50%;
  background: #ff6b8a;
  color: white;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.step-btn:hover { background: #ff8aa3; }
.step-btn:active { transform: scale(0.9); }

.stepper input {
  width: 38px;
  border: none;
  outline: none;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: #8b5a2b;
  background: transparent;
  font-family: inherit;
}
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.unit {
  font-size: 12px;
  color: #8b5a2b;
  opacity: 0.7;
}

.settings-presets {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.preset {
  flex: 1;
  border: none;
  background: white;
  color: #8b5a2b;
  padding: 6px 4px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(139, 90, 43, 0.15);
  font-family: inherit;
}
.preset:hover { background: #ffd6c4; }
.preset:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(139, 90, 43, 0.15); }

.save-btn {
  margin-top: auto;
  width: 100%;
}

/* ===== Web / PWA 模式 ===== */
body.web-mode {
  background: linear-gradient(160deg, #ffe5d4 0%, #ffd6e0 100%);
  /* Safe-area insets for iPhone notch */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.web-mode .app {
  max-width: 420px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
}
body.web-mode #pinBtn,
body.web-mode #minBtn,
body.web-mode #closeBtn {
  display: none;
}
body.web-mode .titlebar {
  -webkit-app-region: auto;
  justify-content: center;
  font-size: 15px;
}
body.web-mode .window-buttons {
  position: absolute;
  right: 16px;
}
body.web-mode .card {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
body.web-mode.resting,
body.web-mode .card.resting {
  background: linear-gradient(160deg, #d4f0ff 0%, #e0d4ff 100%);
}

/* 小屏幕缩放猫咪和计时器 */
@media (max-height: 640px) {
  body.web-mode .cat-stage { width: 160px; height: 160px; }
  body.web-mode .cat { width: 150px; height: 150px; }
  body.web-mode .timer { font-size: 40px; }
}
