/* style.css – FocusFlow（侧边栏多视图版） */
:root {
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --radius: 24px;
  --radius-sm: 16px;
  --gap: 24px;
  --transition: 240ms cubic-bezier(0.4, 0, 0.2, 1);

  /* 浅色主题（默认） */
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --text: #111827;
  --text-muted: #6b7280;
  --border: rgba(0, 0, 0, 0.08);
  --accent: #6366f1;
  /* Indigo */
  --accent-light: #eef2ff;
  --focus: #10b981;
  /* Emerald */
  --break: #f59e0b;
  /* Amber */
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);

  /* 进度环更直观的颜色 */
  --progress-focus: #10b981;
  --progress-break: #f59e0b;
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #818cf8;
  --accent-light: rgba(129, 140, 248, 0.15);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* 可访问性：跳转链接 */
.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--surface);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 1000;
}

/* 通用按钮 */
.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.icon {
  width: 48px;
  height: 48px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn.primary {
  background: var(--accent);
  color: white;
  padding: 14px 28px;
  font-size: 17px;
}

.btn.primary.large {
  padding: 18px 36px;
  font-size: 20px;
  min-width: 220px;
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 20px;
}

/* 文件按钮：隐藏原生文字，只展示自定义按钮 */
.file-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 120px;
}

.file-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.file-btn::-webkit-file-upload-button {
  visibility: hidden;
}

.file-btn::file-selector-button {
  visibility: hidden;
}

/* Logo / brand */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--focus));
  color: white;
  font-weight: 900;
  font-size: 20px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ====== 布局：侧边栏 + 主内容 ====== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  width: 100%;
  padding: 14px 18px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.nav-item.active .nav-icon {
  transform: scale(1.08);
}

.nav-icon {
  font-size: 20px;
  transition: transform var(--transition);
}

/* 移动端遮罩 */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 90;
}

.sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* 主内容区 */
.main-wrapper {
  min-height: 100vh;
  margin-left: 280px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

html[data-theme="dark"] .topbar {
  background: rgba(30, 41, 59, 0.8);
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.menu-btn {
  display: none;
}

.mobile-brand {
  display: none;
}

/* Container */
.container {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* 视图 */
.view {
  display: none;
  flex-direction: column;
  gap: var(--gap);
}

.view.active {
  display: flex;
}

.view-slot {
  min-height: 200px;
}

/* ====== 卡片通用 ====== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.card-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 18px;
  font-weight: 800;
}

.count,
.streak {
  font-weight: 700;
  color: var(--accent);
}

/* ====== 计时器 ====== */
.timer-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* 运行时卡片脉动阴影 */
.timer-card.running {
  animation: pulseShadow 4s infinite ease-in-out;
  border-color: var(--accent);
}

@keyframes pulseShadow {

  0%,
  100% {
    box-shadow: var(--shadow);
  }

  50% {
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
  }
}

html[data-theme="dark"] .timer-card.running {
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.timer-header {
  padding: 24px 28px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.timer-header h2 {
  font-size: 20px;
  font-weight: 800;
}

.segmented {
  display: flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 6px;
  gap: 6px;
}

.seg-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.seg-btn[aria-selected="true"] {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.timer-body {
  padding: 32px 28px;
  text-align: center;
}

.timer-display {
  position: relative;
  margin-bottom: 28px;
}

.clock-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 24px;
}

.clock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 1px;
  z-index: 2;
}

/* 时钟呼吸动画 */
.clock.running {
  animation: breathe 3s infinite ease-in-out;
}

@keyframes breathe {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring__bg {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 12;
}

/* 进度环颜色随模式变化 */
.progress-ring__fg {
  fill: none;
  stroke: var(--progress-focus);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 565;
  stroke-dashoffset: 565;
  transition: stroke 0.4s ease, stroke-dashoffset 0.4s ease;
}

.timer-section.short .progress-ring__fg,
.timer-section.long .progress-ring__fg {
  stroke: var(--progress-break);
}

.timer-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 15px;
}

.pill {
  padding: 8px 16px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 700;
}

.current-task {
  color: var(--text-muted);
}

.current-task span {
  font-weight: 800;
  color: var(--text);
}

.timer-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ====== 底部并排区域（timer 视图） ====== */
.bottom-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

/* ====== 任务 ====== */
.task-add {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
}

.task-add input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 16px;
  color: var(--text);
}

.task-list {
  flex: 1;
  padding: 0 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.task-item.active {
  background: var(--accent-light);
  border: 2px solid var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.task-item.done {
  opacity: 0.6;
  filter: grayscale(30%);
}

.task-title {
  flex: 1;
  font-size: 16px;
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  color: inherit;
}

.task-title.done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-actions {
  display: flex;
  gap: 10px;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  padding: 8px 10px;
  border-radius: 12px;
  transition: var(--transition);
  color: var(--text);
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.14);
}

.hint {
  padding: 0 24px 20px;
  font-size: 13px;
  color: var(--text-muted);
}

/* 添加任务时淡入 */
.fade-in {
  animation: taskFadeIn 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes taskFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ====== 统计 ====== */
.stats-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px 24px;
}

.stat-big {
  text-align: center;
  padding: 20px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.stat-big .label {
  font-size: 14px;
  color: var(--text-muted);
}

.stat-big .value {
  font-size: 36px;
  font-weight: 900;
  margin: 8px 0 4px;
}

.stat-big .unit {
  font-size: 14px;
  color: var(--text-muted);
}

.chart-container {
  padding: 0 24px 16px;
}

.chart-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  height: 140px;
  align-items: end;
}

.bar {
  background: linear-gradient(to top, var(--accent), var(--accent-light));
  border-radius: 12px;
  position: relative;
  min-height: 12px;
  transition: transform 0.3s ease;
}

.bar:hover {
  transform: scaleY(1.15) scaleX(1.08);
  z-index: 1;
}

.bar::after {
  content: attr(data-min) "分";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

.bar:hover::after {
  opacity: 1;
  margin-bottom: 8px;
}

/* 历史表格 */
.history {
  padding: 0 24px 20px;
}

.history summary {
  padding: 12px 0;
  cursor: pointer;
  font-weight: 700;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  color: var(--text-muted);
  padding: 10px 0;
}

.table td {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

/* ====== 设置页 ====== */
.settings-card {
  padding-bottom: 10px;
}

.settings-content {
  padding: 20px 24px;
  display: grid;
  gap: 16px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.settings-panel {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 20px;
}

.settings-panel-standalone .settings-title {
  font-weight: 800;
  margin-bottom: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

.toggles {
  display: flex;
  gap: 24px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.settings-note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

/* 状态栏 */
.status-bar {
  position: sticky;
  bottom: 0;
  padding: 16px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* 焦点环更柔和 */
:where(button, input):focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-light);
}

/* stash（隐藏） */
.stash {
  display: none;
}

/* ====== 响应式 ====== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .menu-btn {
    display: inline-flex;
  }

  .mobile-brand {
    display: flex;
  }

  .topbar {
    justify-content: space-between;
  }

  .bottom-sections {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 14px;
  }

  .brand-subtitle {
    display: none;
  }

  .btn.primary.large {
    padding: 20px 40px;
    font-size: 22px;
    min-height: 64px;
    min-width: unset;
    width: 100%;
  }

  .timer-actions {
    flex-direction: row;
    gap: 12px;
  }

  .timer-actions .btn.secondary {
    flex: 1;
    padding: 14px 12px;
    font-size: 15px;
  }

  .clock-wrapper {
    width: 180px;
    height: 180px;
  }

  .clock {
    font-size: 42px;
  }

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

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

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