/* Today */
.today-header { align-items: center; }
.today-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-progress {
  gap: 8px;
  min-height: 42px;
  padding: 4px 14px 4px 6px;
  border-radius: 999px;
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
}
.status-progress > span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.status-progress strong { font-size: var(--fs-md); font-weight: 700; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.status-progress small { font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); white-space: nowrap; }
.ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-track { stroke: var(--neutral-soft); }
.ring stop:first-child { stop-color: var(--grad-start); }
.ring stop:last-child { stop-color: var(--grad-end); }
@keyframes ring-in { from { stroke-dashoffset: 94.25; } }
.ring-fill { stroke: url(#ring-grad); stroke-linecap: round; filter: drop-shadow(0 0 3px var(--glow)); animation: ring-in .8s var(--ease); }
.ring-fill.complete { stroke: var(--ok); }
.status-chip {
  gap: 5px;
  min-height: 42px;
  padding: 4px 14px;
  border-radius: 999px;
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-weight: 500;
  color: var(--text-2);
}
.status-chip strong { font-size: var(--fs-lg); font-weight: 700; color: var(--text); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.status-chip.danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.status-chip.danger strong { color: var(--danger); }
.today-list > .list-group:first-child { margin-top: 0; }
.today-list > .list-group:first-child > .group-title:first-child { margin-top: 0; }
.overdue-block { margin: 14px -10px 0; padding: 0 10px; }
.overdue-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--warn-soft);
  font-size: var(--fs-sm);
  color: var(--text);
}
.overdue-banner > .icon { flex-shrink: 0; color: var(--warn); }
.overdue-banner > span { flex: 1; min-width: 180px; }
.overdue-banner .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.overdue-list { padding-top: 4px; }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 14px; }
.week-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 4px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: var(--fs-xs);
}
.week-cell-day { color: var(--text-3); }
.week-cell-date { font-weight: 650; color: var(--text); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.week-cell-bar {
  width: 6px;
  height: 26px;
  margin-top: 2px;
  display: flex;
  align-items: flex-end;
  border-radius: 999px;
  background: var(--neutral-soft);
  overflow: hidden;
}
.week-cell-bar span { width: 100%; height: var(--h); border-radius: 999px; background: var(--grad-progress-v); }
.week-cell-count { min-height: 18px; font-weight: 650; color: var(--accent-text); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.week-cell.empty .week-cell-date { color: var(--text-3); }
.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.today-grid.has-panel { grid-template-columns: minmax(0, 1fr) 340px; }
.tasks-layout > .card { margin-top: 18px; }
.tasks-layout.has-panel { display: grid; grid-template-columns: minmax(520px, 1fr) minmax(0, 400px); gap: 18px; align-items: start; }
.tasks-layout.has-panel > .card { margin-top: 0; }
.tasks-layout.has-panel > .task-panel, .today-grid.has-panel > .task-panel { width: 100%; }
.matrix {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 18px;
  row-gap: 10px;
  margin-top: 12px;
}
.matrix-axis { font-size: var(--fs-xs); color: var(--text-3); }
.matrix-axis-x { text-align: center; }
.matrix-axis-y { display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; letter-spacing: 2px; }
.matrix-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 190px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  transition: background .15s, border-color .15s;
}
.matrix-cell.matrix-focus { background: var(--warn-soft); }
.matrix-cell.drop-over { border-color: var(--accent); background: var(--accent-soft); }
.matrix-cell-head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.matrix-cell-head .priority-dot { width: 10px; height: 10px; }
.matrix-cell-title { margin: 0; font-size: var(--fs-sm); font-weight: 650; color: var(--text); }
.matrix-cell-count { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.matrix-cell-add { margin-left: auto; }
.matrix-cell-note { margin: 0 0 4px 18px; font-size: var(--fs-xs); color: var(--text-3); }
.matrix-cell .task-row { padding-left: 0; padding-right: 0; }
.matrix-empty { margin: 12px 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.matrix-more { align-self: flex-start; margin-top: 8px; padding: 0 4px; color: var(--text-3); font-size: var(--fs-xs); }
@media (max-width: 899px) {
  .matrix { grid-template-columns: minmax(0, 1fr); row-gap: 12px; }
  .matrix-axis { display: none; }
  .matrix-cell { min-height: 0; padding: 10px; }
}
.task-panel {
  position: sticky;
  top: 14px;
  align-self: start;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: calc(100dvh - 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.task-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.task-panel-head h2 { margin: 0; font-size: var(--fs-lg); }
.task-panel-body { min-height: 0; overflow-y: auto; padding: 16px; overscroll-behavior: contain; }
.task-editor-done { margin: 0; }
.today-grid > .card, .today-side > .card { margin-top: 0; }
.today-side { display: grid; gap: 18px; }
.upcoming-group + .upcoming-group { margin-top: 12px; }
.upcoming-date { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.upcoming-list { margin: 4px 0 0; padding: 0; list-style: none; }
.upcoming-list li { display: flex; gap: 9px; align-items: center; padding: 4px 0; font-size: var(--fs-sm); color: var(--text-2); }
.side-project {
  display: grid;
  justify-content: stretch;
  justify-items: stretch;
  gap: 6px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: var(--clear);
  text-align: left;
  font-weight: 400;
  color: var(--text);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.side-project:first-of-type { border-top: 0; padding-top: 2px; }
.side-project:hover:not(:disabled) { background: var(--clear); transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.side-project:hover strong { color: var(--accent-text); }
.side-project-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.side-project-title { display: flex; align-items: flex-end; gap: 6px; flex: 1; min-width: 0; }
.side-project-title strong { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.side-project-title .project-dot { align-self: flex-start; margin-top: 5px; flex-shrink: 0; }
.side-project-head > .pill { flex-shrink: 0; }
.side-project-note { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Projects */
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.project-grid > .card { margin-top: 0; }
.project-grid + section { margin-top: 18px; }
.project-card {
  border-top: 3px solid var(--pc, var(--line));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  font-weight: 400;
  color: var(--text);
  transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
}
.project-card:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent-line);
  border-top-color: var(--pc, var(--accent-line));
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}
.project-card.blocked { border-color: var(--danger-line); border-top-color: var(--pc, var(--danger-line)); }
.project-card.done { opacity: .75; }
.project-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; font-size: var(--fs-lg); }
.project-title { display: flex; align-items: flex-end; gap: 6px; flex: 1; min-width: 0; }
.project-title strong { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.project-title .project-dot { align-self: flex-start; margin-top: 6px; flex-shrink: 0; }
.project-card-head > .pill { flex-shrink: 0; }
.project-card-head .project-dot { width: 10px; height: 10px; }
.kv { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px 12px; font-size: var(--fs-sm); }
.kv .k { color: var(--text-3); }
.kv .v { color: var(--text); overflow-wrap: anywhere; }
.kv .v.muted { color: var(--text-3); }
.kv .v.danger { color: var(--danger); font-weight: 550; }
.project-progress { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.progress { flex: 1; min-width: 60px; height: 6px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
@keyframes progress-in { from { width: 0; } }
.progress > span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  border-radius: 999px;
  background: var(--pc, var(--grad-progress));
  box-shadow: 0 0 8px color-mix(in srgb, var(--pc, transparent) 45%, transparent);
  animation: progress-in .8s var(--ease);
}
.progress.complete > span { background: var(--ok); box-shadow: none; }
.progress-count {
  color: var(--text-2);
  font-weight: 600;
  min-width: 32px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.project-card .project-progress, .side-project .project-progress { padding-top: 2px; }
.project-name { font-size: var(--fs-lg); font-weight: 600; }
.blocker-field textarea { border-color: var(--danger); }

/* Review */
.week-switch { display: flex; align-items: center; gap: 6px; }
.week-switch button { min-height: 34px; }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.review-grid > .card { margin-top: 0; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.plain-list li:last-child { border-bottom: 0; }
.review-attention { border-color: var(--danger-line); }
.review-summary textarea { width: 100%; min-height: 160px; }
.review-summary p { margin-top: 8px; font-size: var(--fs-xs); }
.conflict-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--fs-sm);
}
.conflict-bar .actions { gap: 6px; }

/* Review: daily completions and per-project progress */
.review-insights { align-items: start; }
.insight-summary { font-size: var(--fs-sm); color: var(--text-2); text-align: right; }
.insight-columns { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.insight-column {
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 4px 0;
  border: 0;
  border-radius: 8px;
  background: var(--clear);
  font-size: var(--fs-xs);
  font-weight: 450;
  color: var(--text-3);
}
.insight-column:hover:not(:disabled) { background: var(--surface-2); }
.insight-column:disabled { opacity: 1; }
/* The count sits just above the completed bar. */
.insight-count { position: absolute; inset: auto 0 calc(var(--h) + 2px); font-weight: 600; color: var(--text-2); line-height: 16px; }
.insight-track { position: relative; display: block; width: min(100%, 32px); height: 110px; margin-top: 18px; }
.insight-plan, .insight-done { position: absolute; inset: auto 0 0; height: var(--h); border-radius: 6px 6px 0 0; }
.insight-plan { height: var(--plan); }
.insight-plan { border: 1px dashed var(--line-strong); border-bottom: 0; }
.insight-done { background: var(--grad-progress-v); }
.insight-column.selected .insight-done { background: var(--grad-progress-v); }
.insight-column.selected .insight-date, .insight-column.selected .insight-count { color: var(--text); font-weight: 650; }
.insight-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: var(--fs-xs); color: var(--text-2); }
.insight-legend span { display: inline-flex; align-items: center; gap: 5px; }
.insight-legend .done::before, .insight-legend .plan::before { content: ''; width: 10px; height: 10px; border-radius: 3px; }
.insight-legend .done::before { background: var(--accent); }
.insight-legend .plan::before { border: 1px dashed var(--line-strong); }
.insight-legend .muted { margin-left: auto; }
.insight-tasks, .insight-projects { margin: 0; padding: 0; list-style: none; }
.insight-tasks li { display: flex; align-items: center; gap: 8px; min-height: 40px; border-bottom: 1px solid var(--line); }
.insight-tasks li:last-child { border-bottom: 0; }
.insight-tasks li > .icon { width: 15px; height: 15px; color: var(--ok); }
.insight-task {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: var(--clear);
  font-size: var(--fs-sm);
  font-weight: 450;
  color: var(--text);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insight-task:hover:not(:disabled) { background: var(--clear); text-decoration: underline; }
.insight-tasks .pill { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.insight-tasks time { flex-shrink: 0; width: 40px; text-align: right; font-size: var(--fs-xs); color: var(--text-3); }
.insight-projects li + li { border-top: 1px solid var(--line); }
.insight-project {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 14px;
  padding: 12px 6px;
  margin: 0 -6px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.insight-project:hover { background: var(--surface-2); text-decoration: none; }
.insight-project.no-project { --pc: var(--p4); }
.insight-project-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insight-project-count { grid-row: 1; grid-column: 2; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); text-align: right; }
.insight-project-stage {
  grid-column: 1 / -1;
  padding-left: 16px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insight-project-bar {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  margin-left: 16px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.insight-project-bar span { display: block; width: var(--progress); height: 100%; border-radius: 999px; background: var(--pc, var(--accent)); }
@media (max-width: 1199px) { .review-insights { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 540px) {
  .review-insights .card-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .insight-summary { text-align: left; }
  .insight-tasks .pill { display: none; }
}

/* Data */
.data-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
  margin-top: 18px;
}
.data-section h2 { margin-bottom: 10px; }
.data-section p { margin-bottom: 12px; font-size: var(--fs-sm); }
.data-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.data-pair .data-section { margin-top: 0; display: flex; flex-direction: column; align-items: flex-start; }
.data-pair .data-section button { margin-top: auto; }
.danger-zone { border-color: var(--danger-line); }
.backup-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.backup-list li { padding: 2px 10px; border-radius: 999px; background: var(--neutral-soft); font-size: var(--fs-xs); color: var(--text-2); }
.data-directory, .data-filename { overflow-wrap: anywhere; }
.backup-reminder { margin-top: 6px; font-size: var(--fs-sm); }
.backup-reminder.warn { color: var(--warn); }
.data-version { padding-top: 18px; font-size: var(--fs-xs); }
.shortcut-groups { display: grid; gap: 16px; margin-bottom: 10px; }
.import-options { display: grid; gap: 12px; padding: 12px; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); }
.import-options label { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-sm); }
.import-options input { height: 20px; flex-shrink: 0; }

@media (max-width: 1199px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .today-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  .desktop-only { display: none; }
  .page-header .mobile-only { display: inline; }
  .today-status { width: 100%; }
  .status-progress, .status-chip { min-height: 40px; }
  .status-progress { flex: 1; }
  .status-progress .status-today { display: none; }
  .today-side, .project-grid, .review-grid, .data-pair { grid-template-columns: minmax(0, 1fr); }
  .week-switch { width: 100%; }
  .week-switch button { flex: 1; }
  .task-filters .filter-tail { width: 100%; margin-left: 0; }
  .task-filters .small-select { width: 100%; }
}
.week-cell { min-height: 0; border: 1px solid var(--clear); font-weight: 400; color: var(--text); }
.week-cell:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent-line); }
.week-cell.selected, .week-cell.selected:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.day-detail { display: grid; gap: 8px; }
.quick-add.compact .chip select { max-width: 96px; }
.show-more { margin: 2px 0 8px 32px; }
.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px 32px;
  align-items: end;
  margin-bottom: 18px;
  border-color: var(--accent-line);
  background: var(--surface);
}
.welcome h2 { font-size: var(--fs-lg); }
.welcome-tips { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.welcome-tips b { color: var(--text); font-weight: 600; }
.welcome-actions { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 899px) { .welcome { grid-template-columns: minmax(0, 1fr); } .welcome-actions { flex-direction: row; flex-wrap: wrap; } }
.project-activity { font-size: var(--fs-xs); color: var(--text-3); margin-top: -6px; }
.login-brand { display: flex; align-items: center; gap: 11px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.login-card h1 { font-size: var(--fs-lg); margin-bottom: 16px; }

/* Daily loop: ritual bar, prompts, weekly focus, journal */
.ritual-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -2px 0 12px; }
.prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  font-size: var(--fs-sm);
  color: var(--text);
}
.prompt > .icon { color: var(--accent); }
.prompt > span { flex: 1; min-width: 200px; }
.focus-list { margin: 0; padding: 0; list-style: none; display: grid; font-size: var(--fs-md); }
.focus-list li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.focus-list li:last-child { border-bottom: 0; }
.focus-list li.done .focus-text { color: var(--text-3); text-decoration: line-through; }
.focus-list .segments { margin-left: auto; flex-shrink: 0; }
.focus-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.focus-text { overflow-wrap: anywhere; }
.focus-mark { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 18px; min-height: 22px; color: var(--ok); }
.focus-dot { width: 12px; height: 12px; border: 1.5px solid var(--line-strong); border-radius: 50%; }
.focus-progress { font-size: var(--fs-xs); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.focus-project {
  display: block;
  min-height: 0;
  padding: 0;
  font-weight: 400;
  border: 0;
  background: var(--clear);
  font-size: var(--fs-xs);
  color: var(--text-2);
  text-align: left;
}
.focus-project:hover:not(:disabled) { background: var(--clear); color: var(--text); }
.focus-project .icon { width: 13px; height: 13px; margin-right: 6px; vertical-align: -2px; }
.focus-project .project-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: 1px; }
.focus-today { color: var(--accent-text); }
.focus-fields { display: grid; gap: 12px; }
.focus-field { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 10px; }
.focus-field input, .focus-field select { width: 100%; }
@media (max-width: 599px) { .focus-field { grid-template-columns: minmax(0, 1fr); gap: 6px; } }
.journal-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.journal-line .icon { color: var(--accent); }
.journal-line button { flex-shrink: 0; white-space: nowrap; }
.focus-mobile { display: none; }
.journal-text { flex: 1; text-align: right; color: var(--text); }

/* Planner and shutdown */
.planner { display: grid; gap: 14px; }
.plan-list, .shutdown-list, .trash-list, .related-notes { margin: 0; padding: 0; list-style: none; }
.plan-row-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plan-row-item:last-child { border-bottom: 0; }
.plan-title { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: var(--fs-sm); }
.plan-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: var(--fs-xs); color: var(--text-3); }
button.primary-soft { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.steps { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 16px; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--text-3); }
.steps li.on { color: var(--accent-text); font-weight: 650; }
.steps li.done { color: var(--ok); }
.steps button { min-height: 28px; padding: 0; color: inherit; font-weight: inherit; }
.shutdown-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.shutdown-list .actions { gap: 6px; margin-top: 0; justify-content: flex-end; }
.shutdown-list li.handled { opacity: .6; }
.shutdown-title { flex: 1 1 180px; display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 500; }
.shutdown-title .priority-dot { --priority: var(--p4); }
.shutdown-title .priority-dot.p1 { background: var(--p1); }
.shutdown-title .priority-dot.p2 { background: var(--p2); }
.shutdown-title .priority-dot.p3 { background: var(--p3); }
.dialog:has(.shutdown) { width: min(700px, calc(100% - 32px)); }

/* Task drawer additions */
.plan-shortcuts { margin-top: -6px; }
.plan-shortcuts .text-button.selected { background: var(--accent-soft); color: var(--text); }
.plan-hint { font-size: var(--fs-xs); }
.checklist { display: grid; gap: 6px; }
.checklist ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.checklist li { display: flex; align-items: center; gap: 8px; }
.checklist li.done .checklist-text { text-decoration: line-through; color: var(--text-3); }
.checklist-text { flex: 1; height: 32px; border-color: var(--clear); background: var(--clear); padding: 4px 6px; }
.checklist-text:hover { border-color: var(--line); }
.checklist-add { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.checklist-add input { flex: 1; height: 34px; }
.checklist-progress { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xs); }
input.checkbox.small { flex-basis: 18px; width: 18px; height: 18px; min-height: 18px; margin: 0; --priority: var(--ok); }
input.checkbox.small:checked::after { top: 1px; left: 5px; }

/* Calendar */
.mobile-only { display: none; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.cal-day {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.cal-day.past { background: var(--surface-2); }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--highlight-soft), 0 0 22px -8px var(--glow); }
.cal-day.over { border-color: var(--accent); background: var(--accent-soft); }
.cal-head { display: flex; align-items: baseline; gap: 6px; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.cal-weekday { font-size: var(--fs-xs); color: var(--text-3); }
.cal-date { font-size: var(--fs-lg); font-weight: 700; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cal-day.today .cal-date { color: var(--accent); }
.cal-items {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 6px;
  padding: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.cal-items::-webkit-scrollbar { width: 6px; }
.cal-items::-webkit-scrollbar-thumb { border-radius: 999px; background: var(--line-strong); }
.cal-items::-webkit-scrollbar-track { background: var(--clear); }
.cal-card {
  display: grid;
  justify-items: start;
  justify-content: stretch;
  gap: 2px;
  width: 100%;
  min-height: 0;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--priority, var(--line-strong));
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 450;
  color: var(--text);
  cursor: grab;
}
.cal-card:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.cal-card.done { opacity: .55; cursor: pointer; }
.cal-card.done .cal-title { text-decoration: line-through; }
.cal-card.ghost { border-style: dashed; border-left-style: dashed; background: var(--clear); color: var(--text-3); cursor: pointer; }
.cal-time { font-weight: 650; color: var(--accent-text); }
.cal-title { font-size: var(--fs-sm); line-height: 1.4; overflow-wrap: anywhere; }
.cal-title-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; min-width: 0; max-width: 100%; }
.cal-title-row .cal-title { min-width: 0; }
.cal-area-dot { flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--c-orange); }
.cal-due { font-size: var(--fs-xs); color: var(--text-3); }
.cal-due.late { color: var(--danger); font-weight: 600; }
.cal-project { display: inline-flex; align-items: center; gap: 4px; color: var(--pc, var(--text-3)); }
.cal-more {
  justify-content: flex-start;
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: var(--clear);
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: left;
}
.cal-more:hover:not(:disabled) { background: var(--surface-2); color: var(--text-2); }
.day-dialog { display: grid; gap: 12px; }
.day-dialog .task-list { max-height: 55dvh; overflow-y: auto; }
.day-ghosts .group-title { margin-top: 4px; }
.dialog:has(.day-dialog) { width: min(560px, calc(100% - 32px)); }
.cal-inbox { margin-top: 18px; }
.cal-tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }

/* Weekly review wizard */
.wizard-step { display: grid; gap: 14px; }
.wizard-project { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-left: 3px solid var(--pc, var(--line)); border-radius: 12px; }
.journal-recap { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.journal-recap .group-title { margin-top: 0; }
.wizard-nav { position: sticky; bottom: -24px; padding: 12px 0; background: var(--surface); }

/* Settings and trash */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
.appearance-field { grid-column: 1 / -1; }
.appearance-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.style-card {
  display: grid;
  gap: 6px;
  justify-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}
.style-card:hover:not(:disabled) { background: var(--surface); border-color: var(--line-strong); }
.style-card.selected { border-color: var(--accent); box-shadow: var(--ring); }
.style-card strong { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.style-card small { font-size: var(--fs-xs); font-weight: 400; color: var(--text-3); }
.style-swatches { display: flex; gap: 6px; }
.style-swatches i { width: 18px; height: 18px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.style-swatches .swatch-text { background: var(--text); }
.style-swatches .swatch-accent { background: var(--preview-accent, var(--highlight)); }
.settings-grid .field .muted { font-weight: 400; font-size: var(--fs-xs); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text); }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.trash-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.trash-list li:last-child { border-bottom: 0; }
.trash-title { flex: 1; min-width: 160px; }
.related-notes li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: var(--fs-sm); }
.related-notes a { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 1100px) { .cal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* Seven columns use the whole first screen: the grid takes whatever is left after the header and
   the inbox, and each column scrolls its own tasks under a fixed date. Short windows keep 320px. */
@media (min-width: 1101px) {
  .calendar-page.week { display: flex; flex-direction: column; min-height: calc(100dvh - 38px); }
  .calendar-page.week .page-header { flex: 0 0 auto; }
  .calendar-page.week .cal-grid { flex: 1 1 0; min-height: 320px; grid-template-rows: minmax(0, 1fr); }
  .calendar-page.week .cal-inbox { flex: 0 0 auto; }
  .calendar-page.week .cal-head { cursor: pointer; }
}
@media (max-width: 899px) {
  .focus-mobile { display: block; margin: 0 0 16px; }
  .today-side .focus-card { display: none; }
  .cal-grid { grid-template-columns: minmax(0, 1fr); }
  .cal-day { min-height: 0; scroll-margin-top: 112px; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .appearance-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Calendar: view toggle and month grid */
.cal-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.month-weekday {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-3);
}
.month-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 112px;
  padding: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background .15s;
}
.month-cell:nth-of-type(7n) { border-right: 0; }
.month-cell.outside { background: var(--surface-2); }
.month-cell.outside .month-date { color: var(--text-3); }
.month-cell.over { background: var(--accent-soft); }
.month-date {
  align-self: flex-start;
  min-height: 24px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: var(--clear);
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--text);
}
.month-date:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-text); }
.month-cell.today .month-date { background: var(--accent); color: var(--on-accent); }
.month-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; min-width: 0; }
.month-name { margin-right: 2px; font-weight: 500; }
.month-more .short { display: none; }
.cal-card.compact {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 6px;
  border-width: 0 0 0 3px;
  border-radius: 5px;
  background: var(--surface-2);
}
.cal-card.compact .cal-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); }
.cal-card.compact .cal-time { flex-shrink: 0; }
.cal-card.compact.ghost { border-width: 1px 1px 1px 3px; background: var(--clear); }
.month-more {
  justify-content: flex-start;
  min-height: 22px;
  padding: 0 6px;
  border: 0;
  background: var(--clear);
  font-size: var(--fs-xs);
  color: var(--accent-text);
}
.month-more:hover:not(:disabled) { background: var(--accent-soft); }
@media (max-width: 899px) {
  .month-cell { min-height: 72px; padding: 3px; }
  .month-weekday { padding: 6px 4px; text-align: center; }
  /* Phone: each task is a thin bar in its priority colour; tap the date for the week. */
  .month-cell .cal-card.compact { height: 5px; min-height: 5px; padding: 0; border: 0; border-radius: 3px; background: var(--priority, var(--p4)); }
  .month-cell .cal-card.compact.ghost { background: var(--clear); border: 1px dashed var(--priority, var(--p4)); }
  .month-cell .cal-card.compact > * { display: none; }
  .month-cell .cal-card.done { opacity: .35; }
  .month-more { min-height: 16px; padding: 0 2px; }
  .month-more .long, .month-name { display: none; }
  .month-more .short { display: inline; }
  .month-date { padding: 0 4px; }
}

.versions { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; }
.versions ul { margin: 0; padding: 0; list-style: none; max-height: 320px; overflow-y: auto; }
.versions li button { width: 100%; justify-content: flex-start; border: 0; background: var(--clear); font-size: var(--fs-xs); font-weight: 450; }
.versions li button.selected { background: var(--accent-soft); color: var(--accent-text); }
.version-preview { max-height: 320px; overflow-y: auto; padding: 10px; border-radius: 8px; background: var(--surface-2); font-size: var(--fs-sm); }
.version-preview pre { margin: 6px 0 0; white-space: pre-wrap; font-family: var(--font); }
.dialog:has(.versions) { width: min(640px, calc(100% - 32px)); }
.source-note { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }

/* Memos: an independently scrolling category rail and a single card stream. */
.main.view-notes { padding: 0; }
.memo-page { display: grid; grid-template-columns: 260px minmax(0,1fr); min-height: 100dvh; }
.memo-sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; padding: 28px 22px 24px 26px; }
.memo-sidebar-content { display: flex; flex-direction: column; gap: 20px; }
/* The global sidebar already offers the view switch; the copy inside the desktop category rail
   would be a second focus stop. The phone drawer keeps it because it has no global row. */
.memo-sidebar .area-switch { display: none; }
.memo-sidebar-content .area-switch { margin: 0; padding: 0; }
.memo-sidebar-content .area-hint { display: none; }
.memo-sidebar .project-dot { width: 6px; height: 6px; }
.memo-trash { color: var(--text-3); }
.memo-stats { display: flex; justify-content: space-between; gap: 12px; }
.memo-stats > div { display: grid; gap: 0; }
.memo-stats strong { color: var(--text-2); font: 600 22px/1.2 var(--font); font-variant-numeric: tabular-nums; }
.memo-stats span { font-size: var(--fs-xs); color: var(--text-3); }
.memo-heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); grid-template-columns: repeat(12, 12px); gap: 4px; }
.memo-heat { width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; border-radius: 3px; background: var(--heat-0); cursor: pointer; }
.memo-heat.level-1 { background: var(--heat-1); }
.memo-heat.level-2 { background: var(--heat-2); }
.memo-heat.level-3 { background: var(--heat-3); }
.memo-heat.level-4 { background: var(--heat-4); }
.memo-heat.today { outline: 1.5px solid var(--highlight); outline-offset: 2px; }.memo-heat.future { opacity: .3; }
.memo-heat:disabled { cursor: default; }
.memo-heat.selected, .memo-heat.today.selected { outline: 2px solid var(--highlight); outline-offset: 2px; box-shadow: 0 0 0 1px var(--highlight-soft); }
.memo-heat:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.memo-heat-months {
  display: flex;
  justify-content: space-between;
  max-width: 188px;
  color: var(--text-3);
  font-size: var(--fs-xs);
  margin-top: -14px;
  pointer-events: none;
}
.memo-category, .memo-trash {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--clear);
  color: var(--text-2);
  font-weight: 450;
  text-align: left;
  width: 100%;
  text-decoration: none;
}
.memo-category > span:not(.memo-hash):not(.project-dot):not(.memo-icon-slot):not(.memo-tag-icon) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.memo-category small { color: var(--text-3); font: 12px var(--font-mono); margin-left: auto; }
.memo-category.selected, .memo-category-row.selected { background: var(--memo-card); color: var(--text); font-weight: 600; }
/* Tag rows: one highlight on the whole row, from the content edge, at every nesting level. The inner
   buttons never paint their own background, so hover and selection cannot stack or start at the indent. */
.memo-category-row .memo-category,
.memo-category-row .memo-category:hover:not(:disabled),
.memo-category-row .memo-tree-toggle:hover:not(:disabled) { background: var(--clear); }
.memo-category-row:hover:not(.selected) { background: var(--surface-2); }
.memo-category-row small { opacity: 0; }
.memo-category-row:hover small, .memo-category-row:focus-within small { opacity: 1; }
.memo-sidebar-section { display: grid; gap: 4px; }
.memo-sidebar-section h2 { margin: 0 0 6px 10px; color: var(--text-3); font: 400 12px var(--font); }
.memo-sidebar-section > p { padding: 0 10px; margin: 0; font-size: var(--fs-xs); }
.memo-category-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.memo-category-row .memo-category { flex: 1; padding-left: 10px; }
.memo-hash { flex: 0 0 16px; width: 16px; text-align: center; color: var(--text-3); font-weight: 400; }
.memo-tag-icon { flex: 0 0 16px; width: 16px; height: 16px; }
.memo-icon-slot { display: contents; }
.memo-tree-children { margin-left: 18px; }
.memo-tree-toggle {
  position: absolute;
  z-index: 1;
  left: -2px;
  top: 50%;
  width: 40px;
  height: 40px;
  min-height: 0;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: var(--clear);
  color: var(--text-3);
}
.memo-tree-toggle .icon { width: 12px; height: 12px; transition: transform 120ms ease; }
.memo-tree-toggle.collapsed .icon { transform: rotate(-90deg); }
.memo-tree-toggle:hover, .memo-tree-toggle:focus-visible { color: var(--text); }
.memo-views { display: grid; gap: 4px; }
.memo-views .memo-category .icon, .memo-all .icon { width: 16px; height: 16px; color: var(--text-3); }
.memo-views .memo-category.selected .icon { color: var(--highlight); }
.memo-row-menu-wrap { position: relative; flex-shrink: 0; }
.memo-row-more { opacity: 0; flex-shrink: 0; width: 28px; min-height: 28px; padding: 4px; border: 0; background: var(--clear); color: var(--text-3); }
.memo-category-row:hover .memo-row-more, .memo-category-row:focus-within .memo-row-more { opacity: 1; }
.memo-row-more .icon { width: 14px; height: 14px; }
/* Fixed so the rail's overflow-y cannot clip it; left/top come from the "…" button rect. */
.memo-row-menu {
  position: fixed;
  z-index: 8;
  display: grid;
  gap: 1px;
  min-width: 120px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-pop);
}
.memo-row-menu button {
  justify-content: flex-start;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: var(--clear);
  text-align: left;
  font-size: 13px;
  font-weight: 450;
}
.memo-row-menu button:hover, .memo-row-menu button:focus-visible { background: var(--surface-2); }
.memo-stream { width: 100%; max-width: 776px; min-width: 0; padding: 24px 48px 32px; margin-inline: auto; }
.memo-page-header { display: flex; align-items: center; gap: 12px; min-height: 40px; margin-bottom: 14px; }
.memo-page-heading { display: grid; gap: 1px; min-width: 0; }
.memo-page-header h1 { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 16px; margin: 0; }
.memo-subtitle { margin: 0; padding-left: 2px; color: var(--memo-time); font-size: 12px; }
.memo-clear-date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  min-height: 24px;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: var(--memo-search);
  color: var(--text-3);
}
.memo-clear-date:hover { color: var(--text); }
.memo-clear-date .icon { width: 12px; height: 12px; }
.memo-title-button {
  padding: 0;
  min-height: 36px;
  border: 0;
  background: var(--clear);
  font: 600 16px var(--font);
  color: var(--text);
  text-align: left;
  overflow-wrap: anywhere;
}
.memo-mobile-chevron { display: inline; padding-left: 6px; color: var(--text-3); }
.memo-mobile-chevron .icon { width: 13px; height: 13px; }
.memo-mobile-search, .memo-mobile-sync { display: none; }
.memo-search-tools { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.memo-search { width: 280px; height: 40px; border-radius: 12px; background: var(--memo-search); }
.memo-search input { width: 100%; min-width: 0; height: 40px; border: 0; padding-right: 30px; background: var(--clear); font-size: 13px; box-shadow: none; }
.memo-search kbd { position: absolute; right: 14px; border: 0; background: var(--clear); color: var(--memo-time); padding: 0; }
.memo-filter-wrap { position: relative; }
.memo-filter-menu, .memo-menu, .memo-format-menu, .memo-suggestions {
  position: absolute;
  z-index: 8;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-pop);
}
.memo-filter-menu { right: 0; top: 44px; width: 150px; display: grid; gap: 8px; }
.memo-filter-menu label { display: flex; align-items: center; gap: 8px; }
.memo-editor {
  position: relative;
  padding: 16px 18px 12px;
  border: 1px solid var(--memo-line);
  border-radius: 16px;
  background: var(--memo-card);
  box-shadow: none;
  margin-bottom: 14px;
  min-width: 0;
}
.memo-editor:focus-within { border-color: var(--line-strong); }
.memo-input.ql-container { font: 15px/1.7 var(--font); border: 0; }
.memo-input .ql-editor { min-height: 48px; max-height: 50dvh; padding: 0 0 10px; overflow-y: auto; overflow-wrap: anywhere; color: var(--memo-text); }
.memo-input .ql-editor:focus-visible { outline: 0; }
.memo-input .ql-editor.ql-blank::before { left: 0; right: 0; font-style: normal; color: var(--text-3); }
.memo-input .ql-editor img { max-width: 100%; max-height: 240px; border-radius: 8px; }
.memo-tag-highlight { color: var(--highlight); }
.memo-editor-bottom { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.memo-toolbar { display: flex; align-items: center; gap: 2px; min-width: 0; }
.memo-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--clear);
  color: var(--memo-tool);
  font-size: 15px;
}
.memo-tool:hover:not(:disabled) { background: var(--memo-control-hover); color: var(--text); }
.memo-tool-divider { width: 1px; height: 16px; margin: 0 4px; flex-shrink: 0; background: var(--memo-line); }
.memo-tool .icon { width: 18px; height: 18px; }
.memo-format-wrap { position: relative; }
.memo-format-menu { top: 36px; display: flex; gap: 4px; left: 0; }
.memo-format-menu .memo-tool { color: var(--text-2); }
.memo-editor-meta { display: flex; align-items: center; gap: 8px; min-width: 0; margin-left: auto; }
.memo-editor-properties { display: flex; align-items: center; gap: 4px; min-width: 0; margin-right: 4px; }
.memo-project {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 160px;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--memo-control);
  font-size: 13px;
  cursor: pointer;
}
.memo-project:hover { background: var(--memo-control-hover); color: var(--text); }
.memo-project:has(select:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.memo-project-icon, .memo-project-arrow { display: inline-flex; flex-shrink: 0; }
.memo-project-icon .icon { width: 14px; height: 14px; }
.memo-project-arrow .icon { width: 12px; height: 12px; }
.memo-project-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memo-project select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.memo-area {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: var(--clear);
  color: var(--memo-control);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
}
.memo-area .area-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--c-blue); }
.memo-area[data-area="personal"] .area-dot { background: var(--c-orange); }
.memo-area:hover:not(:disabled) { background: var(--memo-control-hover); color: var(--text); }
.memo-area:disabled { color: var(--memo-tool); cursor: default; }
.memo-area:disabled .area-dot { background: var(--memo-tool); }
.memo-cancel { height: 32px; min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; color: var(--memo-control); font-size: 13px; font-weight: 400; }
.memo-cancel:hover:not(:disabled) { background: var(--memo-control-hover); color: var(--text); }
.memo-key { display: none; }
.memo-submit.primary {
  flex-shrink: 0;
  width: 52px;
  min-width: 52px;
  height: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  box-shadow: none;
}
.memo-submit.primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: none; }
.memo-submit.primary:disabled { background: var(--memo-send-off); color: var(--memo-send-icon); opacity: 1; }
.memo-submit.primary:disabled .icon { color: var(--memo-tool); }
.memo-submit .icon { width: 15px; height: 15px; fill: var(--current); stroke: none; }
.memo-submit-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.memo-status { margin: 6px 0 0; font-size: 12px; }
.memo-suggestions { position: relative; width: min(320px, 100%); max-height: 160px; margin-bottom: 10px; overflow-y: auto; }
.memo-suggestions button {
  width: 100%;
  justify-content: flex-start;
  min-height: 36px;
  padding: 5px 10px;
  border: 0;
  background: var(--clear);
  color: var(--text);
  text-align: left;
}
.memo-suggestions button.active { background: var(--highlight-soft); color: var(--highlight); }
.memo-feed { display: grid; gap: 12px; }
.memo-card { position: relative; min-width: 0; padding: 20px 22px; border: 0; border-radius: 16px; background: var(--memo-card); scroll-margin-block: 24px; }
.memo-card.highlighted { outline: 1px solid var(--highlight); }
.memo-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--memo-time); font-size: 13px; }
.memo-card-head time { font: inherit; }
.memo-card-info { min-width: 0; overflow-wrap: anywhere; }
.memo-card-label {
  display: inline-block;
  margin-right: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--memo-tag-bg);
  color: var(--memo-tag-text);
  font-size: 12px;
  line-height: 19px;
  white-space: nowrap;
  vertical-align: 1px;
}
.memo-unsynced { margin-left: 4px; color: var(--memo-time); font-size: 12px; white-space: nowrap; }
.memo-unsynced::before { content: ' · '; }
.memo-card-info a { color: inherit; text-decoration: none; }
.memo-card-info a:hover { color: var(--memo-link); }
.memo-card-head > span .icon { width: 11px; height: 11px; color: var(--highlight); }
.memo-menu-wrap { position: relative; margin-left: auto; }
.memo-card-head .icon-button { width: 28px; height: 20px; min-height: 20px; padding: 4px; color: var(--memo-time); }
.memo-menu { right: 0; top: 32px; width: 200px; display: grid; gap: 1px; }
.memo-menu button { border: 0; background: var(--clear); min-height: 36px; justify-content: flex-start; font-weight: 450; text-align: left; }
.memo-menu button:hover { background: var(--surface-2); }
.memo-card-body { max-height: 190px; overflow: hidden; font-size: 15px; line-height: 1.7; color: var(--memo-text); overflow-wrap: anywhere; }
.memo-card-body.expanded { max-height: none; }
.memo-card-body p { margin: 0 0 14px; min-height: 1em; }
.memo-card-body p:last-child { margin-bottom: 0; }
.memo-card-body h1 { font-size: 22px; }.memo-card-body h2 { font-size: 19px; }.memo-card-body h3 { font-size: 16px; }
.memo-card-body h1, .memo-card-body h2, .memo-card-body h3 { margin: 8px 0 4px; font-family: var(--font-display); }
.memo-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--memo-tag-bg);
  color: var(--memo-tag-text);
  font-size: 13px;
  line-height: 1.6;
  text-decoration: none;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.memo-tag:hover { color: var(--memo-link); }
.memo-card mark, .memo-editor mark { background: var(--memo-mark); color: inherit; border-radius: 3px; padding-inline: 2px; }
.memo-card-body pre, .memo-input .ql-code-block-container {
  white-space: pre-wrap;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: 13px/1.7 var(--font-mono);
}
.memo-card-body code { font-family: var(--font-mono); background: var(--surface-2); border-radius: 4px; padding: 1px 4px; }
.memo-card-body blockquote { margin: 14px 0; padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.memo-list { margin: 14px 0; padding-left: 22px; }
.memo-list.indent-1 { margin-left: 18px; }.memo-list.indent-2 { margin-left: 36px; }.memo-list.indent-3 { margin-left: 54px; }
.memo-check { display: flex; gap: 10px; align-items: flex-start; }
.memo-check .done { text-decoration: line-through; color: var(--text-3); }
.memo-check input { flex-shrink: 0; width: 15px; height: 15px; padding: 0; margin: 5px 0 0; border-color: var(--memo-line); accent-color: var(--ok); }
.memo-expand { display: block; margin-top: 8px; padding: 0; min-height: 28px; color: var(--memo-link); font-size: 14px; font-weight: 400; }
.memo-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.memo-images button { padding: 0; border: 0; width: 150px; height: 150px; overflow: hidden; border-radius: 10px; background: var(--surface-2); }
.memo-images img { width: 150px; height: 150px; object-fit: cover; }
.memo-image-preview { display: flex; align-items: center; gap: 12px; }
.memo-image-preview img { min-width: 0; max-width: calc(100% - 100px); max-height: 70dvh; object-fit: contain; }
.memo-editor.card { margin: 0; }
.memo-editor.card .memo-editor-bottom { border-top: 1px solid var(--memo-line); padding-top: 10px; margin-top: 8px; }
.memo-load-more { color: var(--text-3); font-size: 12px; text-align: center; padding: 24px 0; }
.memo-missing { padding: 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); }
.memo-recovered { margin: 16px 0; display: grid; gap: 12px; }
/* Daily review and random walk */
.memo-review .memo-card { scroll-margin-block: 24px; }
.memo-random { display: grid; gap: 14px; }
.memo-random-actions { display: flex; align-items: center; gap: 10px; }
.memo-random-next {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--memo-line);
  border-radius: 10px;
  background: var(--memo-card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.memo-random-next:hover:not(:disabled) { border-color: var(--line-strong); }
.memo-random-next:disabled { color: var(--memo-time); }
.memo-random-actions .muted { font-size: 12px; }
/* Tag rename dialog */
.tag-rename { display: grid; gap: 12px; }
.tag-rename-current { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.tag-rename .memo-status { margin: 0; }
.dialog:has(.tag-rename) { width: min(460px, calc(100% - 32px)); }
@media (min-width: 900px) and (max-width: 1180px) {
  .memo-page { grid-template-columns: 240px minmax(0, 1fr); }
  .memo-sidebar { padding-inline: 14px; }.memo-stream { padding-inline: 20px; }
  .memo-page-header { flex-wrap: wrap; }.memo-search-tools { width: 100%; }.memo-search { width: 100%; }
  .memo-editor-bottom { flex-wrap: wrap; }
}
@media (max-width: 899px) {
  .main.view-notes { padding: 0 12px calc(80px + env(safe-area-inset-bottom)); min-height: 100dvh; }
  .memo-page { display: block; min-height: 0; }.memo-sidebar { display: none; }
  .memo-stream { max-width: 720px; padding: 0; }
  .memo-page-header { flex-wrap: wrap; min-height: 52px; margin-bottom: 4px; gap: 4px; }
  .memo-search-tools { margin-left: auto; }.memo-mobile-search { display: inline-flex; width: 44px; height: 44px; min-height: 44px; }
  .memo-search { display: none; }.memo-search.open { display: flex; width: 100%; }
  .memo-search-tools:has(.memo-search.open) { flex-wrap: wrap; width: 100%; }.memo-search.open { order: 4; }
  .memo-filter-wrap { display: none; }
  .memo-search-tools:has(.memo-search.open) .memo-filter-wrap { display: block; }
  .memo-filter-wrap > button { width: 44px; height: 44px; min-height: 44px; }
  .memo-page-header h1 { flex: 1; }.memo-title-button { font-size: 16px; }
  .memo-page-heading { flex: 1; min-width: 0; }.memo-clear-date { width: 40px; min-height: 40px; flex-shrink: 0; }
  .memo-subtitle { padding-left: 0; }
  .memo-mobile-sync { display: block; }.memo-mobile-sync .sync-badge { padding: 0 2px; gap: 5px; font-weight: 400; }
  .memo-mobile-sync .sync-badge .status-dot { box-shadow: none; }
  .memo-editor { padding: 12px 14px; }.memo-input .ql-editor { min-height: 70px; }
  .memo-editor.composer:not(.expanded) { padding-right: 66px; min-height: 60px; }
  .memo-editor.composer:not(.expanded) .ql-editor { min-height: 34px; max-height: 34px; padding: 4px 0; }
  .memo-editor.composer:not(.expanded) .memo-editor-bottom { position: absolute; right: 12px; top: 12px; }
  .memo-editor.composer:not(.expanded) .memo-toolbar,
  .memo-editor.composer:not(.expanded) .memo-editor-properties,
  .memo-editor.composer:not(.expanded) .memo-cancel { display: none; }
  .memo-editor-bottom { flex-wrap: wrap; gap: 8px; }
  .memo-tool { width: 40px; height: 40px; min-height: 40px; }.memo-key { display: none; }
  .memo-project, .memo-area, .memo-cancel { height: 40px; min-height: 40px; }
  .memo-submit.primary { height: 40px; min-height: 40px; }
  .memo-card { padding: 18px 18px 20px; }.memo-feed { gap: 12px; }
  .memo-card-head .icon-button { width: 44px; height: 32px; min-height: 32px; }
  .memo-format-menu { left: -12px; }
  .memo-menu { width: 200px; }.memo-menu button { min-height: 44px; }
  .memo-row-more { width: 44px; min-height: 44px; opacity: 1; }
  .memo-row-menu button { min-height: 44px; }
  .memo-views .memo-category { min-height: 44px; }
  .bottom-drawer {
    animation: memo-bottom-in 180ms ease-out;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 82dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 22px 22px 0 0;
    padding: 18px 22px calc(22px + env(safe-area-inset-bottom));
  }
  .bottom-drawer::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: 0 auto 16px; }
  .bottom-drawer .memo-sidebar-content { gap: 18px; }
  /* Touch-sized heatmap grid in the mobile panel; the whole row still fits 360px without scrolling. */
  .bottom-drawer .memo-heatmap { justify-content: start; grid-template-rows: repeat(7, 20px); grid-template-columns: repeat(12, 20px); gap: 5px; }
  .bottom-drawer .memo-heat-months { max-width: 295px; }
  .dialog:has(.tag-rename) .dialog-actions > button { min-height: 44px; }
  .memo-random-actions .muted { display: none; }
  .versions { grid-template-columns: minmax(0,1fr); }
}

@keyframes memo-bottom-in { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.memo-filter-menu input { width: 16px; height: 16px; padding: 0; accent-color: var(--highlight); }

.memo-card-head > span[title="已置顶"] { display: inline-flex; align-items: center; gap: 3px; color: var(--highlight); }

.memo-menu.above { top: auto; bottom: 32px; }

/* Notes rail on desktop: everything sits on two vertical lines. A holds the stats block, heatmap,
   headings, row icons and tag "#"; B holds row text (A + 16px icon + 8px gap). Row backgrounds
   still start at the content edge, so only the inside of each row moves. Each stat is centred in
   its third of the heatmap width. */
@media (min-width: 900px) {
  /* The rail is sticky, so it already forms a stacking context; lifting it above the notes column
     lets the fixed tag menu paint over the cards when it hangs past the rail. Toasts (20) and the
     top-layer dialogs/drawers stay above it. */
  .memo-sidebar { z-index: 2; }
  .memo-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; width: 188px; margin-inline-start: 10px; }
  .memo-stats > div { justify-items: center; text-align: center; }
  .memo-heatmap { width: 188px; margin-inline-start: 10px; }
  .memo-heat-months { width: 188px; margin-inline-start: 10px; }
  .memo-category, .memo-trash { font-size: var(--fs-sm); font-weight: 450; }
  .memo-trash .icon { width: 16px; height: 16px; }
  .memo-views .memo-category .icon, .memo-all .icon { flex: 0 0 16px; }
  .memo-icon-slot { flex: 0 0 16px; width: 16px; height: 16px; display: grid; place-items: center start; }
  .memo-category-row { padding-left: var(--memo-indent, 0px); }
  .memo-tree-children { margin-left: 0; }
  .memo-category-row .memo-tree-toggle {
    left: calc(var(--memo-indent, 0px) + 10px);
    top: 0;
    bottom: 0;
    width: 16px;
    height: auto;
    transform: none;
  }
  .memo-sidebar-section { gap: 0; }
  .memo-sidebar-section h2 { margin-bottom: 4px; }
  .memo-sidebar-section .memo-category { min-height: 30px; padding-block: 4px; border-radius: 8px; }
  .memo-sidebar-section .memo-category-row { border-radius: 8px; }
  /* No transform here: it would become the containing block of the fixed menu. */
  .memo-category-row .memo-row-menu-wrap { position: absolute; right: 10px; top: 50%; margin-top: -12px; }
  .memo-category-row .memo-row-more { width: 24px; min-height: 24px; padding: 5px; opacity: 0; }
  .memo-category-row small { opacity: 1; }
  .memo-category-row:hover .memo-category small,
  .memo-category-row:focus-within .memo-category small { opacity: 0; }
  .memo-category-row:hover .memo-row-more,
  .memo-category-row:focus-within .memo-row-more { opacity: 1; }
  .memo-stream { max-width: 776px; padding: 24px 24px 32px 32px; margin-inline: 0; }
}
