:root {
  /* 治愈系配色（米色、柔和淡绿、温润沙色） */
  --bg-primary: #f6f5f0;
  --bg-secondary: #fbfaf7;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(255, 255, 255, 0.96);

  --accent-sage: #5f7d6a;          /* 鼠尾草淡绿（主色） */
  --accent-sage-light: #e5ede7;    /* 淡绿衬底 */
  --accent-sage-hover: #4e6757;
  --accent-sand: #e4c5a0;          /* 温暖沙色 */
  --accent-peach: #e09477;         /* 朝霞柔和暖色 */
  --accent-blue-soft: #8ba3b0;     /* 柔和水蓝 */

  --text-main: #2d3832;            /* 深苔藓灰 */
  --text-muted: #79867f;           /* 柔和文字次色 */
  --text-light: #a3aba6;

  --border-subtle: rgba(95, 125, 106, 0.12);
  --border-focus: rgba(95, 125, 106, 0.35);

  --radius-full: 9999px;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;

  --shadow-soft: 0 10px 30px -10px rgba(95, 125, 106, 0.08);
  --shadow-float: 0 20px 40px -12px rgba(85, 117, 100, 0.14);

  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-family-serif: 'Noto Serif SC', "Songti SC", SimSun, serif;
  --font-family-timer: "Plus Jakarta Sans", -apple-system, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family-base);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(229, 237, 231, 0.8) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(244, 233, 218, 0.7) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* 核心容器：适配手机端垂直布局 */
#app {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 20px 32px;
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 600px) {
  #app {
    min-height: 820px;
    height: 92vh;
    max-height: 900px;
    background: var(--bg-card);
    border-radius: 40px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-float);
    backdrop-filter: blur(20px);
    overflow: hidden;
    padding: 30px 24px;
  }
}

/* 页面切换动画容器 */
.view-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.view-hidden {
  display: none !important;
  opacity: 0;
  transform: translateY(12px);
}

/* ================================
   通用组件：顶部 XP 经验条
   ================================ */
.xp-header {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 8px 16px 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(95, 125, 106, 0.05);
  margin-bottom: 24px;
  transition: transform 0.2s ease;
}

.xp-level-chip {
  background: var(--accent-sage);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 4px;
}

.xp-bar-wrapper {
  flex: 1;
  position: relative;
}

.xp-bar-bg {
  width: 100%;
  height: 7px;
  background: var(--accent-sage-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-sage), var(--accent-peach));
  width: 0%;
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.xp-percent-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 38px;
  text-align: right;
  font-family: var(--font-family-timer);
}

/* ================================
   页面 1：首页 (Setup View)
   ================================ */
.home-view {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.brand-section {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 30px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--accent-sage);
  background: var(--accent-sage-light);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
  font-weight: 500;
}

.brand-title {
  font-family: var(--font-family-serif);
  font-size: 42px;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.brand-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* 圆润输入框 */
.input-section {
  margin-bottom: 28px;
}

.task-input-wrapper {
  position: relative;
  width: 100%;
}

.task-input {
  width: 100%;
  height: 60px;
  background: #ffffff;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 24px;
  font-size: 16px;
  color: var(--text-main);
  box-shadow: var(--shadow-soft);
  outline: none;
  transition: all 0.25s ease;
}

.task-input:focus {
  border-color: var(--accent-sage);
  box-shadow: 0 0 0 4px rgba(95, 125, 106, 0.15);
  background: #ffffff;
}

.task-input::placeholder {
  color: var(--text-light);
  font-size: 15px;
}

/* 快捷任务标签 */
.task-presets {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 0 8px;
  flex-wrap: wrap;
}

.preset-chip {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
}

.preset-chip:active, .preset-chip:hover {
  color: var(--accent-sage);
  border-color: var(--accent-sage);
  background: var(--accent-sage-light);
}

/* 时长选择器 (15-60分钟) */
.duration-section {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 22px 20px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 30px;
}

.duration-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

.duration-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.duration-value-display {
  font-family: var(--font-family-timer);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-sage);
}

.duration-value-display small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

/* 预设时长快捷胶囊 */
.duration-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.duration-pill {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.duration-pill.active {
  background: var(--accent-sage);
  color: #ffffff;
  border-color: var(--accent-sage);
  box-shadow: 0 4px 10px rgba(95, 125, 106, 0.25);
}

/* 滑块控件 */
.slider-wrapper {
  position: relative;
  padding: 4px 0;
}

.duration-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--accent-sage-light);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.duration-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border: 3px solid var(--accent-sage);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}

.duration-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 6px;
  padding: 0 4px;
}

/* 开启专注按钮 */
.action-section {
  margin-top: auto;
  padding-bottom: 8px;
}

.btn-start {
  width: 100%;
  height: 60px;
  background: var(--accent-sage);
  border: none;
  border-radius: var(--radius-full);
  color: #ffffff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(95, 125, 106, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s ease;
}

.btn-start:hover {
  background: var(--accent-sage-hover);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(95, 125, 106, 0.35);
}

.btn-start:active {
  transform: scale(0.98);
}

/* ================================
   页面 2：执行页 (Execution View)
   ================================ */
.focus-view {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding-top: 4px;
}

/* 当前任务指示 */
.focus-task-info {
  text-align: center;
  margin-bottom: 12px;
}

.focus-task-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: var(--shadow-soft);
  max-width: 85%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 倒计时中间主区域 */
.timer-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 250px;
}

/* 圆环进度与倒计时 */
.timer-ring-container {
  position: relative;
  width: 250px;
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-circle-bg {
  fill: none;
  stroke: var(--accent-sage-light);
  stroke-width: 6;
}

.timer-circle-progress {
  fill: none;
  stroke: var(--accent-sage);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s linear, stroke 0.4s ease;
}

.timer-digits-wrapper {
  position: relative;
  text-align: center;
  z-index: 2;
}

.timer-digits {
  font-family: var(--font-family-timer);
  font-size: 64px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -1px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.3s ease;
}

.timer-status-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 1px;
}

/* 呼吸微动效 */
.pulse-breath {
  animation: gentleBreath 4s ease-in-out infinite;
}

@keyframes gentleBreath {
  0%, 100% { transform: scale(1); opacity: 0.96; }
  50% { transform: scale(1.025); opacity: 1; }
}

/* 控制按钮组（暂停/放弃） */
.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
  margin-bottom: 20px;
}

.btn-icon-text {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 9px 18px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.btn-icon-text:hover {
  background: #ffffff;
  color: var(--text-main);
  border-color: rgba(95, 125, 106, 0.3);
}

.btn-icon-text:active {
  transform: scale(0.96);
}

.btn-icon-text.danger {
  color: #a2655b;
}

.btn-icon-text.danger:hover {
  background: #fdf5f4;
  border-color: #e5b3ac;
}

/* ================================
   底部对话框区域：AI 鼓励语
   ================================ */
.motivation-dialog-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  position: relative;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s ease;
}

.motivation-dialog-card.glow-update {
  animation: cardHighlight 1.2s ease;
}

@keyframes cardHighlight {
  0% { transform: scale(0.98); box-shadow: 0 0 0 0 rgba(95, 125, 106, 0.4); }
  50% { transform: scale(1.01); box-shadow: 0 0 20px 4px rgba(95, 125, 106, 0.25); }
  100% { transform: scale(1); box-shadow: var(--shadow-soft); }
}

.motivation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.motivation-sender {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-sage-light);
  color: var(--accent-sage);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.sender-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.stage-badge {
  font-size: 11px;
  color: var(--accent-sage);
  background: var(--accent-sage-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  transition: all 0.2s;
}

.stage-badge.middle {
  background: #fdf2e3;
  color: #bb742f;
}

.stage-badge.finish {
  background: #e6f4ea;
  color: #2e7d32;
}

.stage-badge.fail {
  background: #fce8e6;
  color: #c53929;
}

.motivation-content {
  font-family: var(--font-family-serif);
  font-size: 14.5px;
  line-height: 1.65;
  color: #3b4740;
  letter-spacing: 0.2px;
  min-height: 48px;
  display: flex;
  align-items: center;
  transition: opacity 0.25s ease;
}

.motivation-loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.motivation-loading-dots span {
  width: 5px;
  height: 5px;
  background: var(--accent-sage);
  border-radius: 50%;
  animation: dotBounce 1.2s infinite ease-in-out;
}

.motivation-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.motivation-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ================================
   结算与完成模态弹窗 (Modal)
   ================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(45, 56, 50, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  max-width: 380px;
  width: 100%;
  padding: 30px 24px 24px;
  text-align: center;
  box-shadow: var(--shadow-float);
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-icon {
  font-size: 46px;
  margin-bottom: 12px;
}

.modal-title {
  font-family: var(--font-family-serif);
  font-size: 22px;
  color: var(--text-main);
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-xp-gained {
  background: var(--accent-sage-light);
  color: var(--accent-sage);
  display: inline-block;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 24px;
}

.modal-xp-gained.fail {
  background: #fdf0ec;
  color: var(--accent-peach);
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.btn-modal {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-full);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-primary {
  background: var(--accent-sage);
  color: #ffffff;
}

.btn-modal-primary:hover {
  background: var(--accent-sage-hover);
}

.btn-modal-secondary {
  background: #edf2ee;
  color: var(--text-muted);
}

.btn-modal-secondary:hover {
  background: #e2e8e3;
  color: var(--text-main);
}
