/* ==========================================================================
   工作留痕 WorkTrace — 设计系统
   浅色 / 深色双主题，纯 CSS，无外部依赖
   ========================================================================== */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eceff8;
  --text: #1a2133;
  --text-2: #46506a;
  --muted: #7d86a0;
  --line: #e6e9f2;
  --line-strong: #d5dbeb;
  --accent: #5b5bd6;
  --accent-2: #a855f7;
  --accent-soft: #eceefe;
  --accent-text: #4338ca;
  --green: #0d9b6c;
  --green-soft: #e4f7ef;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #0369a1;
  --blue-soft: #e0f2fe;
  --shadow: 0 1px 2px rgba(20, 25, 45, 0.04), 0 12px 32px -14px rgba(20, 25, 45, 0.14);
  --shadow-lift: 0 3px 10px rgba(20, 25, 45, 0.08), 0 24px 50px -20px rgba(20, 25, 45, 0.22);
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ring-track: #e9ecf6;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1119;
  --surface: #161c27;
  --surface-2: #1c2331;
  --surface-3: #232c3d;
  --text: #e9edf7;
  --text-2: #b3bdd2;
  --muted: #8b96ae;
  --line: #273042;
  --line-strong: #354158;
  --accent: #8b8cf8;
  --accent-2: #c084fc;
  --accent-soft: #232a44;
  --accent-text: #b9baff;
  --green: #34d399;
  --green-soft: #10352a;
  --amber: #fbbf24;
  --amber-soft: #3a2b08;
  --red: #f87171;
  --red-soft: #3b1717;
  --blue: #60a5fa;
  --blue-soft: #122a44;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -18px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 4px 14px rgba(0, 0, 0, 0.4), 0 30px 60px -24px rgba(0, 0, 0, 0.7);
  --ring-track: #232c3d;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 8% -10%, rgba(99, 102, 241, 0.12), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, rgba(168, 85, 247, 0.1), transparent 55%);
  background-attachment: fixed;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(900px 500px at 8% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, rgba(168, 85, 247, 0.12), transparent 55%);
}

h1, h2, h3, h4, p {
  margin: 0;
}

button {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ------------------------------ 布局 ------------------------------ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 22px;
  height: 68px;
  padding: 0 max(18px, calc((100vw - 1200px) / 2));
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px -8px rgba(91, 91, 214, 0.7);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 17px;
  letter-spacing: 0.02em;
}

.brand-text small {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.main-nav a {
  padding: 8px 15px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}

.main-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.main-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.view-root {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px -8px rgba(91, 91, 214, 0.75);
}

.btn-primary:hover {
  box-shadow: 0 10px 24px -8px rgba(91, 91, 214, 0.85);
  transform: translateY(-1px);
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.btn-soft:hover {
  background: color-mix(in srgb, var(--accent-soft) 80%, var(--accent) 20%);
}

.btn-outline {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn-danger {
  color: #fff;
  background: var(--red);
}

.btn-danger:hover {
  filter: brightness(1.05);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 16px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.icon-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.btn .plus {
  font-size: 16px;
  line-height: 1;
  margin-top: -1px;
}

/* ------------------------------ 通用 ------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.accent {
  color: var(--accent-text);
}

.nowrap {
  white-space: nowrap;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.view-head h1 {
  font-size: clamp(22px, 3vw, 27px);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.view-head .subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13.5px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}

.chip-soft {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.chip-muted {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
}

.chip-green {
  background: var(--green-soft);
  color: var(--green);
}

.chip-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.dot-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}

.dot-label .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot-color, var(--muted));
  flex: none;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.status-done {
  color: var(--green);
  background: var(--green-soft);
}

.status-doing {
  color: var(--blue);
  background: var(--blue-soft);
}

.status-blocked {
  color: var(--red);
  background: var(--red-soft);
}

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}

.empty .empty-icon {
  font-size: 38px;
  line-height: 1;
  margin-bottom: 12px;
  opacity: 0.85;
}

.empty strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 4px;
}

.empty p {
  font-size: 13px;
}

.loading-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 90px 20px;
  color: var(--muted);
  font-size: 13.5px;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-block {
  max-width: 560px;
  margin: 70px auto;
  padding: 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.error-block h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.error-block p {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 18px;
  word-break: break-word;
}

/* ------------------------------ 今日 ------------------------------ */
.date-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius);
}

.date-toolbar input[type="date"],
.date-toolbar input[type="month"] {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 7px 10px;
  outline: none;
}

.date-toolbar input[type="date"]:focus,
.date-toolbar input[type="month"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toolbar-spacer {
  flex: 1;
}

.daily-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.daily-main,
.daily-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px;
  flex-wrap: wrap;
}

.ring {
  --pct: 0;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--ring-track) 0);
  transition: background 0.5s ease;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--surface);
}

.ring-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.1;
}

.ring-inner strong {
  display: block;
  font-size: 30px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.ring-inner span {
  font-size: 11.5px;
  color: var(--muted);
}

.summary-info {
  flex: 1;
  min-width: 220px;
}

.summary-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-title-row h2 {
  font-size: 19px;
}

.summary-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.progress {
  height: 9px;
  border-radius: 999px;
  background: var(--ring-track);
  overflow: hidden;
  margin: 14px 0 14px;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.5s ease;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-metrics div {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 10px;
}

.summary-metrics strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.summary-metrics span {
  font-size: 11.5px;
  color: var(--muted);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.card-head h2 {
  font-size: 16px;
}

.card-head .muted {
  font-size: 12.5px;
}

.entry-card {
  padding: 18px 18px 10px;
}

.entry-list {
  display: flex;
  flex-direction: column;
}

.entry-item {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 15px 12px 15px 18px;
  border-radius: 12px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}

.entry-item:last-child {
  border-bottom: 0;
}

.entry-item::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 17px;
  bottom: 17px;
  width: 4px;
  border-radius: 4px;
  background: var(--entry-color, var(--muted));
}

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

.entry-body {
  flex: 1;
  min-width: 0;
}

.entry-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.entry-title-row h3 {
  font-size: 14.5px;
  font-weight: 600;
  word-break: break-word;
}

.hours-badge {
  margin-left: auto;
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.entry-detail {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
}

.entry-actions {
  display: flex;
  gap: 2px;
  align-self: flex-start;
  opacity: 0;
  transition: opacity 0.15s;
}

.entry-item:hover .entry-actions,
.entry-actions:focus-within {
  opacity: 1;
}

@media (hover: none) {
  .entry-actions {
    opacity: 1;
  }
}

.side-card {
  padding: 18px 20px;
}

.side-card h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

.side-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  color: var(--text-2);
}

.side-metric:last-child {
  border-bottom: 0;
}

.side-metric strong {
  font-size: 16px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.streak-flame {
  font-size: 20px;
}

/* ------------------------------ 日历 ------------------------------ */
.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.calendar-card {
  padding: 20px;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.calendar-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.calendar-title h2 {
  font-size: 20px;
  letter-spacing: -0.01em;
}

.calendar-title span {
  font-size: 12.5px;
  color: var(--muted);
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.cal-weekday {
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 2px;
}

.cal-cell {
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
  overflow: hidden;
}

.cal-cell:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.cal-cell.blank {
  border-color: transparent;
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.cal-day-num {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.cal-cell.today .cal-day-num {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 6px;
  padding: 0 5px;
}

.cal-cell.selected {
  box-shadow: inset 0 0 0 2px var(--accent);
  border-color: transparent;
}

.cal-cell.weekend .cal-day-num {
  color: var(--muted);
}

.cal-hours {
  margin-top: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

.cal-entries {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.2;
}

.cal-cell[data-level="1"] {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.cal-cell[data-level="2"] {
  background: color-mix(in srgb, var(--accent) 17%, var(--surface));
}

.cal-cell[data-level="3"] {
  background: color-mix(in srgb, var(--accent) 27%, var(--surface));
}

.cal-cell[data-level="4"] {
  background: color-mix(in srgb, var(--accent) 38%, var(--surface));
}

.cal-cell[data-level="5"] {
  background: color-mix(in srgb, var(--accent) 52%, var(--surface));
}

.cal-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
}

.cal-legend i {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-block;
}

.cal-legend i[data-level="1"] { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.cal-legend i[data-level="2"] { background: color-mix(in srgb, var(--accent) 17%, var(--surface)); }
.cal-legend i[data-level="3"] { background: color-mix(in srgb, var(--accent) 27%, var(--surface)); }
.cal-legend i[data-level="4"] { background: color-mix(in srgb, var(--accent) 38%, var(--surface)); }
.cal-legend i[data-level="5"] { background: color-mix(in srgb, var(--accent) 52%, var(--surface)); }

.calendar-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.day-panel {
  padding: 20px;
}

.day-panel .card-head {
  margin-bottom: 10px;
}

.day-panel .entry-item {
  padding-left: 14px;
  padding-right: 4px;
}

/* ------------------------------ 统计 ------------------------------ */
.range-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.range-tabs button {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.range-tabs button:hover {
  background: var(--surface-2);
}

.range-tabs button.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.custom-range input[type="date"] {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 8px;
  outline: none;
}

.stats-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.stats-toolbar .range-label {
  font-size: 12.5px;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.kpi strong {
  font-size: clamp(22px, 2.4vw, 28px);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.kpi strong em {
  font-style: normal;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.kpi-sub.good {
  color: var(--green);
}

.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
  align-items: start;
}

.chart-card {
  padding: 20px;
}

.chart-card h2 {
  font-size: 15px;
  margin-bottom: 2px;
}

.chart-card .muted {
  font-size: 12px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chart-col {
  flex: 1 1 0;
  min-width: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bar-wrap {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  width: 100%;
  max-width: 36px;
  min-height: 3px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent-2) 75%, var(--accent)));
  opacity: 0.88;
  transition: opacity 0.15s, height 0.35s ease;
}

.chart-bar.zero {
  background: var(--surface-3);
  opacity: 1;
}

.chart-col:hover .chart-bar {
  opacity: 1;
}

.chart-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  height: 14px;
  overflow: hidden;
}

.donut-card {
  padding: 20px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.donut {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  flex: none;
  background: conic-gradient(var(--surface-3) 0 100%);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  background: var(--surface);
}

.donut-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
}

.donut-center strong {
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.donut-center span {
  font-size: 10.5px;
  color: var(--muted);
}

.legend-list {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}

.legend-row .swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.legend-row .value {
  margin-left: auto;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.project-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.project-bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.project-bar-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}

.project-bar-head strong {
  font-weight: 600;
}

.project-bar-head .value {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.project-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.project-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color, var(--accent));
  transition: width 0.4s ease;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.status-card {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-card strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.status-card span {
  font-size: 11.5px;
  color: var(--muted);
}

/* ------------------------------ 记录 ------------------------------ */
.filters-card {
  padding: 16px;
  margin-bottom: 16px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}

.filters-grid .field {
  gap: 4px;
}

.filters-grid .field > span {
  font-size: 11.5px;
}

.filters-grid input,
.filters-grid select {
  padding: 8px 10px;
  font-size: 13px;
}

.filters-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.records-card {
  padding: 6px 18px 18px;
}

.records-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.records-summary strong {
  color: var(--text);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

table.records th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.records td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.records tr:last-child td {
  border-bottom: 0;
}

table.records tbody tr:hover td {
  background: var(--surface-2);
}

.record-title {
  font-weight: 600;
  min-width: 180px;
  max-width: 380px;
  word-break: break-word;
}

.record-title .record-detail {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.record-date {
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}

.record-hours {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--accent-text);
}

.record-actions {
  white-space: nowrap;
  text-align: right;
}

.tag-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.pager-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ------------------------------ 设置 ------------------------------ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.settings-card {
  padding: 22px;
}

.settings-card h2 {
  font-size: 16px;
  margin-bottom: 2px;
}

.settings-card .card-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 16px;
}

.settings-card .field {
  margin-bottom: 14px;
}

.workday-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.workday-toggle {
  position: relative;
}

.workday-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.workday-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.workday-toggle input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

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

.project-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  flex-wrap: wrap;
}

.project-row.archived {
  opacity: 0.62;
}

.project-color {
  width: 30px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  flex: none;
}

.project-name-input {
  flex: 1;
  min-width: 120px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 8px;
  outline: none;
}

.project-name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.project-meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.project-row .icon-btn {
  flex: none;
}

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

.add-project input[type="text"] {
  flex: 1;
  min-width: 130px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 10px;
  outline: none;
}

.add-project input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.data-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.backup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  max-height: 170px;
  overflow: auto;
}

.backup-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}

.backup-list div:last-child {
  border-bottom: 0;
}

.kv-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  font-size: 12.5px;
  color: var(--text-2);
}

.kv-list dt {
  color: var(--muted);
}

.kv-list dd {
  margin: 0;
  word-break: break-all;
  font-family: var(--mono);
  font-size: 11.5px;
}

.hint-box {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-size: 12px;
  color: var(--accent-text);
  line-height: 1.6;
}

/* ------------------------------ 弹窗 / 提示 ------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 18, 32, 0.52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in 0.16s ease;
}

.modal {
  width: min(660px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lift);
  border: 1px solid var(--line);
  animation: pop-in 0.18s ease;
}

.modal.narrow {
  width: min(440px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 0;
}

.modal-head h2 {
  font-size: 18px;
}

.entry-form {
  padding: 18px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 0;
}

.field > span em {
  color: var(--red);
  font-style: normal;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

.hours-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.hours-row input {
  width: 110px;
  font-variant-numeric: tabular-nums;
}

.quick-hours {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.quick-hours button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-hours button:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.confirm-body {
  padding: 10px 24px 22px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.65;
}

.confirm-body p + p {
  margin-top: 8px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 24px;
}

.toast-root {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 200px;
  max-width: 360px;
  padding: 10px 15px;
  border-radius: 11px;
  background: var(--text);
  color: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  animation: toast-in 0.2s ease;
  pointer-events: auto;
  word-break: break-word;
}

.toast.success {
  background: #047857;
  color: #fff;
}

.toast.error {
  background: #b91c1c;
  color: #fff;
}

.toast.leaving {
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.2s, transform 0.2s;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1080px) {
  .daily-grid,
  .calendar-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .daily-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .calendar-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 10px 14px;
  }

  .main-nav {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .main-nav::-webkit-scrollbar {
    display: none;
  }

  .main-nav {
    gap: 0;
  }

  .main-nav a {
    padding: 7px 8px;
    font-size: 13px;
  }

  .top-actions {
    margin-left: auto;
  }

  .view-root {
    padding: 20px 16px 50px;
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .daily-side {
    grid-template-columns: minmax(0, 1fr);
  }

  .toast-root {
    left: 16px;
    right: 16px;
    top: 126px;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .brand-text small {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .btn-label {
    display: none;
  }

  .btn-primary {
    padding: 9px 13px;
  }

  .view-head {
    align-items: flex-start;
  }

  .summary-card {
    padding: 18px;
    gap: 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .ring {
    width: 104px;
    height: 104px;
    align-self: center;
  }

  .summary-info {
    min-width: 0;
    width: 100%;
  }

  .ring::before {
    inset: 9px;
  }

  .ring-inner strong {
    font-size: 24px;
  }

  .summary-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .summary-metrics div {
    padding: 7px 8px;
  }

  .summary-metrics strong {
    font-size: 15px;
  }

  .cal-cell {
    min-height: 58px;
    padding: 5px;
    border-radius: 9px;
    gap: 1px;
  }

  .cal-day-num {
    font-size: 11px;
  }

  .cal-hours {
    font-size: 10.5px;
  }

  .cal-entries {
    display: none;
  }

  .cal-grid {
    gap: 4px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi {
    padding: 13px 14px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .entry-item {
    padding-left: 16px;
  }

  .record-title {
    min-width: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 视图切换时的轻量加载态（保留旧内容，避免白屏闪烁） */
.view-root.is-loading {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* ------------------------------ 工作产出 / 文档附件 ------------------------------ */
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
  text-decoration: none;
  line-height: 1.5;
}

a.attachment:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.attachment .attachment-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment .size {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.attachment .icon-btn {
  width: 20px;
  height: 20px;
  font-size: 13px;
  flex: none;
}

.attachment.pending {
  border-style: dashed;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.attachment-box {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
}

.attachment-box .attachment-list {
  margin-top: 0;
}

.attachment-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.attachment-pick .muted {
  font-size: 11.5px;
  line-height: 1.5;
}

.doc-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
  white-space: nowrap;
}

/* ------------------------------ v2：程序员工作日志 ------------------------------ */
.day-hero {
  padding: 22px 24px;
}

.hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.day-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.day-metrics div {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
}

.day-metrics strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.day-metrics span {
  font-size: 11.5px;
  color: var(--muted);
}

.chip-mono {
  font-family: var(--mono);
  font-size: 11px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: bottom;
}

.entry-links {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
}

.entry-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 12px;
  color: var(--accent-text);
  text-decoration: none;
  overflow: hidden;
}

.entry-link span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.entry-link:hover {
  text-decoration: underline;
}

.summary-panel {
  padding: 20px 22px;
}

.summary-head {
  margin-bottom: 10px;
}

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

.markdown-preview {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
}

.cal-entries-count {
  margin-top: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

.record-subline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.record-output {
  white-space: nowrap;
}

.record-output .doc-count + .doc-count {
  margin-left: 6px;
}

.code-inline {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: 6px;
  padding: 1px 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
}

.tag-chip em {
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .day-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-actions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .day-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-metrics div:last-child {
    grid-column: 1 / -1;
  }

  .summary-actions .btn {
    flex: 1;
  }

  .markdown-preview {
    max-height: 320px;
    font-size: 11.5px;
  }
}

/* 长 URL 在 Markdown 预览里强制换行（移动端尤其需要） */
.markdown-preview {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.entry-link span:last-child {
  overflow-wrap: anywhere;
}

/* ------------------------------ v2.1：工作项结论与快捷模板 ------------------------------ */
.template-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
}

.template-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.template-chip:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.modal-sub {
  margin: -4px 0 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
}

.entry-outcome {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 9px;
  padding: 8px 11px;
  border-left: 3px solid var(--green);
  border-radius: 0 8px 8px 0;
  background: var(--green-soft);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.entry-outcome strong {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.01em;
}

.record-outcome {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--green);
  overflow-wrap: anywhere;
}

.record-outcome b {
  font-weight: 700;
}

@media (max-width: 640px) {
  .template-bar {
    gap: 6px;
    padding: 9px 10px;
  }

  .template-chip {
    padding: 3px 9px;
    font-size: 11.5px;
  }

  .modal-actions .btn {
    flex: 1;
  }
}

.field-wide {
  grid-column: 1 / -1;
}

/* ------------------------------ v2.4：AI 帮写 / 周报 ------------------------------ */
.ai-btn {
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  transition: transform 0.15s, opacity 0.15s;
}

.ai-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ai-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.ai-status {
  font-size: 11.5px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .ai-btn {
    margin-left: 0;
  }

  .ai-status {
    width: 100%;
  }
}

/* ------------------------------ v2.5：默认 3 字段 + 更多选项 ------------------------------ */
.template-bar {
  gap: 7px;
}

.template-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.more-toggle {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
  text-align: left;
}

.more-toggle:hover {
  text-decoration: underline;
}

.more-chevron {
  font-size: 11px;
  color: var(--muted);
}

.entry-more {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.entry-more[hidden] {
  display: none;
}

.entry-more .form-grid {
  margin-bottom: 0;
}

/* ------------------------------ v2.6：待办看板 ------------------------------ */
.todo-compose {
  padding: 16px 18px;
  margin-bottom: 18px;
}

.todo-compose-row {
  display: flex;
  gap: 10px;
}

.todo-compose-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.todo-compose-row input[type="text"]:focus,
.todo-compose textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.todo-compose textarea {
  width: 100%;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.todo-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.todo-column {
  padding: 16px;
}

.todo-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.todo-column-head h2 {
  font-size: 15px;
}

.todo-count {
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.todo-card {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.todo-card:hover {
  border-color: var(--line-strong, var(--line));
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.04));
}

.todo-title-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.todo-title-row h3 {
  flex: 1;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.todo-check {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1.5px solid var(--line-strong, var(--line));
  border-radius: 50%;
  background: var(--surface);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.todo-check:hover {
  border-color: var(--accent);
}

.todo-check.checked {
  background: var(--green);
  border-color: var(--green);
}

.todo-detail {
  margin: 7px 0 0 29px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.todo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  padding-left: 29px;
  font-size: 11.5px;
  color: var(--muted);
}

.todo-actions {
  display: inline-flex;
  gap: 2px;
}

.todo-actions .icon-btn {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.todo-card.done h3 {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-card.done .todo-check {
  background: var(--green);
  border-color: var(--green);
}

.done-column .todo-card {
  background: var(--surface-2);
}

@media (max-width: 760px) {
  .todo-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .todo-compose-row {
    flex-direction: column;
  }

  .todo-compose-row .btn {
    width: 100%;
  }
}

/* ------------------------------ v3.0：多用户 / 登录 / 用户管理 ------------------------------ */
/* 顶栏用户菜单 */
.user-menu {
  position: relative;
  flex: none;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  max-width: 220px;
  padding: 0 10px 0 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s, color 0.16s;
}

.user-trigger:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.user-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.user-menu.open .user-trigger {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.avatar {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

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

.user-caret {
  font-size: 10px;
  color: var(--muted);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 208px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  animation: pop-in 0.14s ease;
}

.user-dropdown[hidden] {
  display: none;
}

.user-dropdown-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.user-dropdown-head strong {
  font-size: 13.5px;
  word-break: break-all;
}

.user-dropdown-head span {
  font-size: 11.5px;
  word-break: break-all;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

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

.user-menu-item.danger {
  color: var(--red);
}

.user-menu-item.danger:hover {
  background: var(--red-soft);
}

.user-menu-item[hidden] {
  display: none;
}

.user-dropdown-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

/* 未登录：隐藏主导航、记一笔与用户菜单 */
body.is-guest .main-nav,
body.is-guest #top-new-entry,
body.is-guest .user-menu {
  display: none;
}

body.is-guest .topbar {
  justify-content: space-between;
}

/* 登录 / 注册 */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 220px);
  padding: 8px 0 24px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 26px 26px 22px;
}

.auth-brand {
  margin-bottom: 18px;
}

.auth-title {
  font-size: 20px;
  letter-spacing: -0.01em;
}

.auth-sub {
  margin-top: 4px;
  margin-bottom: 18px;
  font-size: 12.5px;
  color: var(--muted);
}

.auth-notice,
.auth-error {
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  margin-bottom: 14px;
}

.auth-notice {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.auth-error {
  background: var(--red-soft);
  color: var(--red);
}

.auth-notice[hidden],
.auth-error[hidden] {
  display: none;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--surface-2);
  border-radius: 12px;
}

.auth-tab {
  flex: 1;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: var(--shadow);
}

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

.auth-form[hidden] {
  display: none;
}

.auth-form .field {
  margin: 0;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.auth-remember input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.auth-submit {
  width: 100%;
  height: 42px;
  justify-content: center;
  margin-top: 2px;
}

.auth-foot {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

/* 设置页账号卡片 */
.settings-card-wide {
  grid-column: 1 / -1;
}

.card-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-head-row h2 {
  font-size: 16px;
}

.card-head-row .card-sub {
  margin-bottom: 0;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.account-info dd {
  font-size: 12px;
}

.account-password {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 22px;
  border-left: 1px dashed var(--line);
}

.account-password h3 {
  font-size: 13.5px;
  color: var(--text-2);
}

.account-password .field {
  margin: 0;
}

.account-password .settings-actions {
  margin-top: 2px;
}

.form-error {
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  line-height: 1.55;
}

.form-error[hidden] {
  display: none;
}

/* 用户管理 */
.users-card {
  padding: 6px 18px 18px;
}

.users-table td {
  vertical-align: middle;
}

.users-table {
  min-width: 760px;
}

.users-table th,
.users-table td {
  white-space: nowrap;
}

.user-username {
  font-weight: 600;
  white-space: nowrap;
}

.user-display {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-username .chip {
  margin-left: 6px;
  vertical-align: middle;
}

.user-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}

table.records th.user-num {
  text-align: right;
}

.user-actions {
  text-align: right;
  white-space: nowrap;
}

.user-actions .link-btn + .link-btn {
  margin-left: 10px;
}

.link-btn {
  padding: 2px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: var(--red);
}

tr.is-disabled td {
  color: var(--muted);
}

.users-tip {
  margin-top: 12px;
}

@media (max-width: 860px) {
  .auth-page {
    min-height: auto;
    padding-top: 2px;
  }

  .user-name {
    max-width: 100px;
  }

  .account-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .account-password {
    padding-left: 0;
    padding-top: 16px;
    border-left: 0;
    border-top: 1px dashed var(--line);
  }
}

@media (max-width: 640px) {
  .user-trigger {
    gap: 0;
    padding: 0 4px 0 3px;
  }

  .user-name,
  .user-caret {
    display: none;
  }

  .user-dropdown {
    min-width: 184px;
  }

  .auth-card {
    padding: 22px 18px 18px;
  }

  .users-card {
    padding: 6px 12px 14px;
  }

  .user-actions .link-btn + .link-btn {
    margin-left: 8px;
  }
}

/* ==========================================================================
   v3.1 · AI 周报 / 月报（summary-panel 内）
   ========================================================================== */
.ai-summary-btn {
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  transition: transform 0.15s, opacity 0.15s;
}

.ai-summary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ai-summary-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.ai-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  color: #fff;
  vertical-align: middle;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.ai-summary-hint {
  margin: -2px 0 10px;
}

.summary-panel.is-ai {
  box-shadow: var(--shadow), inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.summary-panel.is-ai .markdown-preview {
  border-left: 3px solid var(--accent);
}

@media (max-width: 640px) {
  .ai-summary-btn {
    width: 100%;
  }

  .ai-badge {
    margin-left: 6px;
    font-size: 10.5px;
  }
}
