/* ===== 基础重置 ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  color: #fff;
  transition: background-color 0.5s ease;
  position: relative;
}

/* 模式主题色 */
body[data-mode="pomodoro"] { --theme-color: #d95550; --theme-dark: #c34a4a; --theme-light: #e87e7a; }
body[data-mode="shortBreak"] { --theme-color: #4c9195; --theme-dark: #3d7a7e; --theme-light: #6babad; }
body[data-mode="longBreak"] { --theme-color: #457ca3; --theme-dark: #37658a; --theme-light: #6a99b8; }

.app-background {
  position: fixed;
  inset: 0;
  background-color: var(--theme-color);
  z-index: -1;
  transition: background-color 0.5s ease;
}

.container {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 0 12px;
}

/* ===== 头部 ===== */
.header {
  padding: 14px 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
}

.logo-icon {
  font-size: 24px;
  line-height: 1;
}

.logo-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.btn-header:hover {
  background: rgba(255,255,255,0.25);
}

.btn-header svg {
  opacity: 0.9;
}

.btn-user .user-text {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 主内容区 ===== */
.main {
  flex: 1;
  padding: 20px 0 40px;
}

.timer-card {
  background: rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 28px 20px 32px;
  text-align: center;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 24px;
}

.mode-tabs {
  display: inline-flex;
  background: rgba(0,0,0,0.12);
  border-radius: 50px;
  padding: 4px;
  margin-bottom: 24px;
}

.mode-tab {
  padding: 10px 18px;
  border-radius: 50px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab:hover {
  color: #fff;
}

.mode-tab.active {
  background: var(--theme-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.timer-display {
  font-size: 96px;
  font-weight: 700;
  line-height: 1;
  margin: 24px 0 32px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  text-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.timer-btn {
  min-width: 180px;
  padding: 16px 48px;
  border-radius: 12px;
  border: none;
  background: #fff;
  color: var(--theme-color);
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.timer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

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

/* ===== 当前任务 ===== */
.current-task {
  text-align: center;
  margin-bottom: 32px;
  opacity: 0.95;
}

.current-task-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
  margin-bottom: 6px;
  display: block;
}

.current-task-title {
  font-size: 20px;
  font-weight: 600;
}

/* ===== 任务区域 ===== */
.tasks-section {
  margin-bottom: 24px;
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px 12px;
  border-bottom: 2px solid rgba(255,255,255,0.4);
  margin-bottom: 12px;
}

.tasks-title {
  font-size: 18px;
  font-weight: 700;
}

.btn-icon {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-icon:hover {
  opacity: 1;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #333;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.task-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.task-item.active {
  border-left: 6px solid var(--theme-color);
}

.task-item.done {
  opacity: 0.6;
}

.task-item.done .task-title {
  text-decoration: line-through;
}

.task-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid #ddd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s;
}

.task-item.done .task-checkbox {
  background: var(--theme-color);
  border-color: var(--theme-color);
  color: #fff;
}

.task-checkbox svg {
  width: 12px;
  height: 12px;
  opacity: 0;
}

.task-item.done .task-checkbox svg {
  opacity: 1;
}

.task-content {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  font-size: 13px;
  color: #888;
}

.task-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.task-item:hover .task-actions {
  opacity: 1;
}

.task-action-btn {
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.task-action-btn:hover {
  color: var(--theme-color);
  background: rgba(0,0,0,0.05);
}

.btn-add-task {
  width: 100%;
  padding: 16px;
  border: 2px dashed rgba(255,255,255,0.4);
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-add-task:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.6);
}

/* ===== 信息卡片 ===== */
.info-section {
  margin-bottom: 40px;
}

.info-card {
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  gap: 16px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
}

.info-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.info-content h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.info-content p {
  margin: 0;
  opacity: 0.85;
  font-size: 15px;
  line-height: 1.5;
}

/* ===== 页脚 ===== */
.footer {
  padding: 20px 0;
  text-align: center;
  opacity: 0.7;
  font-size: 13px;
}

.footer .beian {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer .beian:hover {
  color: rgba(255,255,255,0.9);
  text-decoration: underline;
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 16px;
}

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

.modal {
  background: #fff;
  color: #333;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.2s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  color: #333;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(0,0,0,0.05);
  color: #333;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #eee;
}

/* ===== 表单元素 ===== */
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  border-color: var(--theme-color);
  box-shadow: 0 0 0 3px rgba(217, 85, 80, 0.1);
}

.input--small {
  max-width: 100px;
  text-align: center;
}

.btn {
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn--primary {
  background: var(--theme-color);
  color: #fff;
}

.btn--primary:hover {
  background: var(--theme-dark);
}

.btn--secondary {
  background: #f0f0f0;
  color: #555;
}

.btn--secondary:hover {
  background: #e0e0e0;
}

.btn--block {
  width: 100%;
  margin-top: 12px;
}

/* ===== 设置弹窗 ===== */
.settings-section {
  margin-bottom: 24px;
}

.settings-title {
  font-size: 15px;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.settings-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.settings-field {
  flex: 1;
  min-width: 100px;
}

.settings-field label {
  display: block;
  font-size: 13px;
  color: #777;
  margin-bottom: 6px;
}

.settings-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 15px;
  color: #444;
}

/* 开关 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}

.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .slider {
  background-color: var(--theme-color);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* 任务估算 */
.task-estimate {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.estimate-label {
  font-size: 14px;
  color: #666;
}

.estimate-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.estimate-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #f5f5f5;
  color: #555;
  font-size: 18px;
  cursor: pointer;
}

.estimate-value {
  font-size: 18px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

/* 主题色 */
.theme-colors {
  display: flex;
  gap: 10px;
}

.theme-color {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s;
}

.theme-color:hover {
  transform: scale(1.1);
}

.theme-color.active {
  border-color: #333;
  transform: scale(1.1);
}

/* 音量滑块 */
.range {
  width: 120px;
  accent-color: var(--theme-color);
}

/* ===== 报告弹窗 ===== */
.report-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: #f5f5f5;
  padding: 4px;
  border-radius: 8px;
}

.report-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: #666;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.report-tab.active {
  background: #fff;
  color: #333;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.report-stat {
  text-align: center;
  padding: 16px;
  background: #f9f9f9;
  border-radius: 10px;
}

.report-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--theme-color);
  margin-bottom: 4px;
}

.report-stat-label {
  font-size: 13px;
  color: #888;
}

.report-chart {
  min-height: 160px;
  background: #f9f9f9;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}

/* ===== 登录弹窗 ===== */
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: #f5f5f5;
  border-radius: 8px;
  color: #666;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--theme-color);
  color: #fff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-error {
  color: #e74c3c;
  font-size: 13px;
  min-height: 18px;
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .timer-display {
    font-size: 72px;
  }

  .timer-btn {
    min-width: 160px;
    padding: 14px 36px;
    font-size: 20px;
  }

  .mode-tab {
    padding: 8px 12px;
    font-size: 13px;
  }

  .header-actions span {
    display: none;
  }

  .btn-header {
    padding: 8px;
  }

  .logo-text {
    font-size: 18px;
  }

  .report-stats {
    grid-template-columns: 1fr;
  }

  .tasks-header {
    padding: 0 4px 12px;
  }

  .task-actions {
    opacity: 1;
  }

  .task-action-btn {
    padding: 6px;
  }
}

@media (max-width: 360px) {
  .timer-display {
    font-size: 56px;
  }

  .mode-tab {
    padding: 8px 10px;
    font-size: 12px;
  }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.task-item {
  animation: fadeIn 0.2s ease;
}

.tasks-actions {
  display: flex;
  gap: 8px;
}

.current-task-project {
  font-size: 13px;
  opacity: 0.75;
  margin-top: 4px;
}

.task-form-row {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.task-form-field {
  flex: 1;
}

.task-form-field label {
  display: block;
  font-size: 13px;
  color: #777;
  margin-bottom: 6px;
}

.task-form-field textarea {
  resize: none;
  margin-top: 8px;
}

.settings-field--wide {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-field--wide label {
  min-width: 80px;
  margin-bottom: 0;
}

.range-value {
  font-size: 13px;
  color: #666;
  min-width: 40px;
  text-align: right;
}

/* Project Manager */
.project-manager {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 160px;
  overflow-y: auto;
}

.project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f9f9f9;
  border-radius: 6px;
  font-size: 14px;
}

.project-item-empty {
  color: #999;
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

.project-delete {
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.project-delete:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
}

.project-add {
  display: flex;
  gap: 8px;
}

.project-add input {
  flex: 1;
}

.project-add button {
  white-space: nowrap;
}

/* Templates */
.modal--template {
  max-width: 420px;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  max-height: 240px;
  overflow-y: auto;
}

.template-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.template-item:hover {
  background: #f0f0f0;
}

.template-info {
  flex: 1;
}

.template-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.template-meta {
  font-size: 12px;
  color: #888;
}

.template-actions {
  display: flex;
  gap: 6px;
}

.template-actions button {
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}

.template-actions button:hover {
  background: rgba(0,0,0,0.05);
  color: #666;
}

.template-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Report */
.report-summary {
  margin-bottom: 16px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  font-size: 14px;
  color: #555;
}

.report-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.report-bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 160px;
  padding: 12px 4px 28px;
  position: relative;
}

.report-bar {
  flex: 1;
  background: var(--theme-color);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  position: relative;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.report-bar:hover {
  opacity: 1;
}

.report-bar-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #888;
  white-space: nowrap;
}

.report-bar-value {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #666;
  font-weight: 600;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #fff;
  color: #333;
  padding: 14px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: 360px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease;
  border-left: 4px solid var(--theme-color);
}

.toast.toast-exit {
  animation: toastSlideOut 0.3s ease forwards;
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 13px;
  color: #666;
}

.toast-close {
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: #333;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* Task project tag */
.task-project {
  display: inline-block;
  font-size: 11px;
  color: var(--theme-color);
  background: rgba(217, 85, 80, 0.1);
  padding: 2px 8px;
  border-radius: 50px;
  margin-top: 4px;
  font-weight: 500;
}

/* Project filter */
.project-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 4px 12px;
  margin-top: -4px;
}

.project-filter-btn {
  padding: 6px 12px;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.project-filter-btn.active,
.project-filter-btn:hover {
  background: rgba(255,255,255,0.25);
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}

::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.3);
}
