/* ============================================================
   FocusFlow · 专注工作台
   Design tokens: 纸感冷白 + 松绿主色 + 黛青辅色；深色模式同族。
   字体：Space Grotesk（数字/拉丁）+ 系统中文栈。
   ============================================================ */

:root {
  --paper: #F7F8F7;
  --surface: #FFFFFF;
  --ink: #1F2421;
  --ink-soft: #5A6660;
  --line: #E3E8E4;
  --accent: #2E6B4F;
  --accent-strong: #245540;
  --accent-tint: #DCE9E2;
  --break: #3D7A8C;
  --break-tint: #DCE9ED;
  --danger: #B3402E;
  --heat-0: #E7ECE8;
  --heat-1: #C9E2D4;
  --heat-2: #8FC7A8;
  --heat-3: #4E9B74;
  --heat-4: #2E6B4F;
  --font-body: "Space Grotesk", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-num: "Space Grotesk", ui-monospace, monospace;
  --radius: 6px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --paper: #141816;
  --surface: #1C211E;
  --ink: #E8EDE9;
  --ink-soft: #9AA8A0;
  --line: #2A322D;
  --accent: #7FBF9E;
  --accent-strong: #93CFB0;
  --accent-tint: #22362C;
  --break: #6FA8B8;
  --break-tint: #22343A;
  --danger: #E07A5F;
  --heat-0: #232B26;
  --heat-1: #2C4A3A;
  --heat-2: #3E7355;
  --heat-3: #5DA87E;
  --heat-4: #8FD4AD;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h2, h3 { margin: 0; font-weight: 700; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 头部 ---------- */
.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 28px; height: 28px; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.header-right { display: flex; align-items: center; gap: 10px; }
.chip {
  background: var(--accent-tint);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 13px;
  font-weight: 500;
}
.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  font-size: 16px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 布局 ---------- */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(380px, 1fr) minmax(300px, 400px);
  gap: 24px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.panel-focus {
  background: transparent;
  border: none;
  padding: 12px 8px;
  text-align: center;
}
.panel-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 16px;
}
.section-subtitle {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin: 24px 0 10px;
}

/* ---------- 今日面板 ---------- */
.daily-focus label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.daily-focus input {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: transparent;
  padding: 6px 2px;
  font-size: 15px;
}
.daily-focus input:focus { outline: none; border-bottom-color: var(--accent-strong); }

.task-form {
  display: grid;
  grid-template-columns: 1fr 56px auto;
  gap: 8px;
  margin: 18px 0 12px;
}
.task-form input[type="text"] {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--paper);
}
.task-form input[type="number"] {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 6px;
  background: var(--paper);
  text-align: center;
  font-family: var(--font-num);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
[data-theme="dark"] .btn-primary { color: #14201A; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-lg { padding: 12px 36px; font-size: 16px; border-radius: 8px; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
}
.task-item:last-child { border-bottom: none; }
.task-item.active { border-left-color: var(--accent); background: var(--accent-tint); }
.task-item.dragging { opacity: 0.4; }
.task-check {
  width: 20px; height: 20px;
  border: 2px solid var(--ink-soft);
  border-radius: 50%;
  background: transparent;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #fff;
  font-size: 12px;
}
.task-check:hover { border-color: var(--accent); }
.task-item.completed .task-check { background: var(--accent); border-color: var(--accent); }
.task-title { flex: 1; word-break: break-word; }
.task-item.completed .task-title { text-decoration: line-through; color: var(--ink-soft); }
.task-est { font-family: var(--font-num); font-size: 12px; color: var(--ink-soft); flex: none; }
.task-del {
  border: none; background: none; color: var(--ink-soft);
  font-size: 14px; padding: 2px 6px; border-radius: 4px; flex: none;
}
.task-del:hover { color: var(--danger); }
.task-drag { cursor: grab; color: var(--ink-soft); flex: none; font-size: 13px; user-select: none; }

.empty-state { text-align: center; padding: 28px 12px; color: var(--ink-soft); }
.empty-illustration { width: 140px; height: auto; margin-bottom: 10px; }

/* ---------- 专注面板 ---------- */
.timer-stage {
  position: relative;
  width: min(320px, 72vw);
  margin: 8px auto 0;
  aspect-ratio: 1;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-track { stroke: var(--line); }
.ring-progress {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s;
}
.timer-stage.on-break .ring-progress { stroke: var(--break); }
.timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}
.phase-label { font-size: 14px; color: var(--ink-soft); }
.time-display {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 8vw, 4.2rem);
  font-weight: 500;
  line-height: 1.1;
}
.active-task {
  font-size: 13px;
  color: var(--accent-strong);
  background: var(--accent-tint);
  border-radius: 999px;
  padding: 2px 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timer-stage.on-break .active-task { visibility: hidden; }

.cycle-dots { display: flex; justify-content: center; gap: 8px; margin: 18px 0 4px; min-height: 10px; }
.cycle-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.cycle-dot.done { background: var(--accent); }

.timer-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.timer-extras {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 20px;
  color: var(--ink-soft);
  font-size: 14px;
}
.switch-row { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------- 数据面板 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card { border-top: 2px solid var(--accent); padding-top: 8px; }
.stat-num { font-family: var(--font-num); font-size: 26px; font-weight: 500; }
.stat-label { font-size: 12px; color: var(--ink-soft); }

.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  grid-auto-columns: 12px;
  gap: 3px;
  overflow-x: auto;
  padding: 4px 0 8px;
}
.heat-cell { width: 12px; height: 12px; border-radius: 2px; }
.heat-cell.lv0 { background: var(--heat-0); }
.heat-cell.lv1 { background: var(--heat-1); }
.heat-cell.lv2 { background: var(--heat-2); }
.heat-cell.lv3 { background: var(--heat-3); }
.heat-cell.lv4 { background: var(--heat-4); }
.heatmap-legend {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--ink-soft); justify-content: flex-end;
}
.legend-cell { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend-cell.lv0 { background: var(--heat-0); }
.legend-cell.lv1 { background: var(--heat-1); }
.legend-cell.lv2 { background: var(--heat-2); }
.legend-cell.lv3 { background: var(--heat-3); }
.legend-cell.lv4 { background: var(--heat-4); }

.journal-form { display: flex; flex-direction: column; gap: 6px; }
.journal-form label { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.journal-form textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 8px 10px;
  resize: vertical;
}
.journal-form button { margin-top: 12px; align-self: flex-start; }

.journal-list { list-style: none; margin: 16px 0 0; padding: 0; }
.journal-entry { border-top: 1px solid var(--line); padding: 12px 0; }
.journal-entry-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px;
}
.journal-date { font-family: var(--font-num); font-weight: 700; font-size: 13px; }
.journal-del { border: none; background: none; color: var(--ink-soft); font-size: 13px; padding: 0 4px; }
.journal-del:hover { color: var(--danger); }
.journal-field { font-size: 13px; margin: 2px 0; }
.journal-field b { font-weight: 500; color: var(--ink-soft); }

/* ---------- 移动端 Tabs ---------- */
.mobile-tabs { display: none; }

/* ---------- 设置弹窗 ---------- */
.settings-dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
  width: min(420px, 92vw);
}
.settings-dialog::backdrop { background: rgba(20, 24, 21, 0.4); }
.settings-form h3 { margin-bottom: 16px; font-size: 16px; }
.settings-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 16px;
  align-items: center;
}
.settings-grid input[type="number"] {
  width: 72px; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 8px; background: var(--paper); font-family: var(--font-num); text-align: center;
}
.settings-grid select {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 8px; background: var(--paper);
}
.settings-data { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.settings-actions { display: flex; justify-content: flex-end; margin: 20px 0 0; padding: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(260px, 320px) 1fr; }
  #panel-stats { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  body { padding-bottom: 64px; }
  .layout { display: block; padding: 16px; }
  .panel { display: none; margin-bottom: 0; }
  body[data-tab="today"] #panel-today,
  body[data-tab="focus"] #panel-focus,
  body[data-tab="stats"] #panel-stats { display: block; }
  .mobile-tabs {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 30;
  }
  .tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 14px 0;
    font-size: 14px;
    color: var(--ink-soft);
  }
  .tab-btn[aria-selected="true"] { color: var(--accent); font-weight: 700; }
}

/* ---------- 动效克制 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
