:root {
  --bg: #faf8f4;
  --surface: #fffefb;
  --surface-2: #f4f1eb;
  --border: #e5dfd6;
  --border-focus: #a8c4b4;
  --text: #2d2926;
  --text-2: #7a6f65;
  --green: #4a7c65;
  --green-mid: #6b9e86;
  --green-light: #e4ede7;
  --amber-light: #fdf3e0;
  --amber-mid: #e8a84a;
  --blue: #4e7299;
  --blue-light: #e6eef6;
  --green-text: #376050;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow: 0 2px 12px rgba(45, 41, 38, 0.07);
  --shadow-lg: 0 8px 32px rgba(45, 41, 38, 0.1);
  --header-h: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.4; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(74, 124, 101, 0.3);
  outline-offset: 2px;
}

/* ─── Header ──────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
}

.app-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.nav-pills {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 4px;
}

.nav-tab {
  padding: 7px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  transition: background 140ms ease, color 140ms ease;
}

.nav-tab:hover { background: var(--green-light); color: var(--green); }

.nav-tab.active {
  background: var(--green);
  color: #fff;
}

.nav-tab--hidden { display: none; }

.sync-dot {
  flex-shrink: 0;
  margin-left: auto;
  appearance: none;
  width: 12px;
  height: 12px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--border);
  transition: background 150ms ease;
}

.sync-dot.is-synced { background: var(--green); }
.sync-dot.is-syncing { background: var(--amber-mid); }
.sync-dot.is-error { background: #c0392b; }

/* ─── Body ───────────────────────────────────────────────── */

.app-body {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

.view { display: none; }
.view.active { display: block; }

.view-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.view-top h2 {
  margin: 0;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

.view-top-heading {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.view-top-heading .view-date {
  font-size: 12px;
  font-weight: 500;
}

#view-journal .view-top {
  align-items: center;
}

.view-date {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 600;
  flex-shrink: 0;
}

/* ─── Cards ──────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-header h3 {
  margin: 0;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 18px;
  font-weight: 700;
}

.card-label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--green-text);
  font-size: 11px;
  font-weight: 800;
}

.text-muted { color: var(--text-2); line-height: 1.7; }

/* ─── Buttons ────────────────────────────────────────────── */

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 130ms ease, box-shadow 130ms ease, transform 80ms ease;
  white-space: nowrap;
}

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

.btn-primary:hover { background: var(--green-mid); border-color: var(--green-mid); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--green);
}

.btn-ghost:hover { background: var(--green-light); border-color: #b8d0c2; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ─── Inputs ─────────────────────────────────────────────── */

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  transition: border-color 130ms ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: #fff;
}

textarea { resize: vertical; line-height: 1.65; }

.full-width { grid-column: 1 / -1; }

/* ─── Today ──────────────────────────────────────────────── */

.pace-section { margin-bottom: 24px; }

.pace-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 0;
}

.pace-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 14px 12px;
  text-align: left;
  transition: border-color 150ms, background 150ms, box-shadow 150ms;
}

.pace-icon { font-size: 20px; margin-bottom: 2px; }
.pace-option strong { font-size: 14px; line-height: 1.3; }
.pace-option span { font-size: 12px; color: var(--text-2); line-height: 1.5; }

.pace-option:hover { border-color: #b8d0c2; background: var(--green-light); }

.pace-option[data-pace="rest"].active {
  border-color: #b0c6de;
  background: var(--blue-light);
  box-shadow: 0 -3px 0 var(--blue) inset;
}
.pace-option[data-pace="gentle"].active {
  border-color: #a4c8b4;
  background: var(--green-light);
  box-shadow: 0 -3px 0 var(--green) inset;
}
.pace-option[data-pace="open"].active {
  border-color: #d4b878;
  background: var(--amber-light);
  box-shadow: 0 -3px 0 var(--amber-mid) inset;
}

.pace-suggestion {
  margin: 14px 0 0;
  padding: 12px 4px 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-2);
}

.plan-card {
  border-left: 3px solid var(--border);
  transition: border-left-color 200ms ease;
}
.plan-card[data-pace="rest"] { border-left-color: var(--blue); }
.plan-card[data-pace="gentle"] { border-left-color: var(--green); }
.plan-card[data-pace="open"] { border-left-color: var(--amber-mid); }

.task-list { display: grid; gap: 10px; }

.task-empty { margin: 0; color: var(--text-2); line-height: 1.7; font-size: 14px; }

.task-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: background 120ms;
}

.task-item:hover { background: var(--green-light); }

.task-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--green);
  cursor: pointer;
}

.task-item.done span { text-decoration: line-through; color: var(--text-2); }

.quick-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 4px;
}

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

.quick-form { display: grid; gap: 14px; }

/* ─── Stories ────────────────────────────────────────────── */

.stories-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}

.story-browser {
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 48px);
  display: flex;
  flex-direction: column;
}

.story-browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 14px;
}

.story-browser-header h3 {
  margin: 0;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.story-list {
  display: grid;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.story-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 120ms;
  cursor: pointer;
  min-height: 48px;
}

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

.story-list-item:hover { background: var(--green-light); }

.story-list-item.active {
  background: var(--green-light);
  box-shadow: inset 3px 0 0 var(--green);
}

.story-list-number {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  padding-top: 2px;
}

.story-list-item.active .story-list-number {
  color: var(--green);
}

.story-list-details { display: grid; gap: 4px; min-width: 0; }

.story-list-details strong {
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-list-meta { font-size: 11px; color: var(--text-2); line-height: 1.4; }
.story-list-feedback {
  width: fit-content;
  font-size: 11px;
  font-weight: 800;
  color: var(--green-text);
  background: var(--green-light);
  padding: 2px 7px;
  border-radius: 6px;
}

.story-reader {
  background: #fffefb;
  border: 1px solid var(--border);
  border-top: 3px solid var(--amber-mid);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  scroll-margin-top: var(--header-h);
}

.story-reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.story-back { display: none; }

.story-copy { padding: 32px 36px 36px; }

.story-kicker {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.story-copy > h3 {
  margin: 0 0 8px;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.story-theme {
  margin: 0 0 24px;
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
}

.story-body {
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 17px;
  line-height: 2.1;
  color: #383130;
}

.story-body p { margin: 0 0 1.2em; }

.story-response { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.story-response .card-label { margin-bottom: 12px; }

.story-response-options { display: flex; flex-wrap: wrap; gap: 8px; }

.story-response-options button {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  transition: all 130ms;
}

.story-response-options button:hover,
.story-response-options button.active {
  border-color: var(--border-focus);
  background: var(--green-light);
  color: var(--green);
}

.story-pager {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 26px;
}

.story-position { font-size: 12px; }

/* ─── Record form ────────────────────────────────────────── */

.record-form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

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

/* ─── Record list ────────────────────────────────────────── */

.record-list { display: grid; gap: 12px; }

.record-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-2);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.record-item {
  position: relative;
  padding: 18px 44px 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.record-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.record-item-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.record-item-type {
  font-size: 12px;
  color: var(--green-text);
  background: var(--green-light);
  padding: 2px 8px;
  border-radius: 999px;
}

.record-item-concept {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 15px;
}

.record-item-body {
  margin: 0 0 6px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.record-item-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-2);
}

.record-item-del {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
}

.record-item-del:hover { background: var(--surface-2); color: var(--text); }

/* ─── Library ────────────────────────────────────────────── */

.library-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.library-item {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}

.library-item:last-child { border-bottom: none; }

.library-item h3 {
  margin: 0 0 8px;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 17px;
}
.library-item > p { margin: 0 0 14px; font-size: 14px; line-height: 1.7; color: var(--text-2); }

.mini-task {
  background: var(--blue-light);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
}

.mini-task p { margin: 0 0 6px; }
.mini-task p:last-child { margin-bottom: 0; }
.mini-task strong { color: var(--text); }

/* ─── Toast ──────────────────────────────────────────────── */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 25;
  max-width: min(320px, calc(100vw - 40px));
  background: var(--text);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

.toast-undo-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.5);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 120ms;
}
.toast-undo-btn:hover { background: rgba(255,255,255,0.15); }

/* ─── Animations ────────────────────────────────────────── */

@keyframes iconGrow {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  40%       { transform: translateY(-4px) rotate(-2deg); }
  70%       { transform: translateY(-2px) rotate(1.5deg); }
}

@keyframes iconWiggle {
  0%   { transform: rotate(0deg) scale(1); }
  20%  { transform: rotate(-10deg) scale(1.1); }
  50%  { transform: rotate(8deg) scale(1.08); }
  75%  { transform: rotate(-4deg) scale(1.04); }
  100% { transform: rotate(0deg) scale(1); }
}

.brand-mark {
  animation:
    iconGrow   500ms cubic-bezier(0.22, 1, 0.36, 1) both,
    iconFloat  4s ease-in-out 500ms infinite;
}

.brand-mark:hover {
  animation: iconWiggle 500ms cubic-bezier(0.22, 1, 0.36, 1);
}


@keyframes slideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scalePop {
  0%   { transform: scale(1); }
  35%  { transform: scale(0.93); }
  65%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.view.active .view-top {
  animation: slideUp 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.view.active > *:not(.view-top) {
  animation: slideUp 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.view.active > *:nth-child(3) { animation-delay: 55ms; }
.view.active > *:nth-child(4) { animation-delay: 110ms; }
.view.active > *:nth-child(5) { animation-delay: 165ms; }

.library-item:nth-child(1) { animation: slideUp 340ms cubic-bezier(0.22, 1, 0.36, 1) 80ms both; }
.library-item:nth-child(2) { animation: slideUp 340ms cubic-bezier(0.22, 1, 0.36, 1) 140ms both; }
.library-item:nth-child(3) { animation: slideUp 340ms cubic-bezier(0.22, 1, 0.36, 1) 200ms both; }
.library-item:nth-child(4) { animation: slideUp 340ms cubic-bezier(0.22, 1, 0.36, 1) 260ms both; }

.story-list-item { animation: slideUp 220ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.story-list-item:nth-child(2) { animation-delay: 30ms; }
.story-list-item:nth-child(3) { animation-delay: 60ms; }
.story-list-item:nth-child(4) { animation-delay: 90ms; }
.story-list-item:nth-child(5) { animation-delay: 120ms; }
.story-list-item:nth-child(6) { animation-delay: 150ms; }
.story-list-item:nth-child(7) { animation-delay: 180ms; }
.story-list-item:nth-child(8) { animation-delay: 210ms; }

.pace-option { transform-origin: center; transition: border-color 150ms, background 150ms, transform 100ms; }
.pace-option:active { transform: scale(0.94); }
.pace-option.popping { animation: scalePop 320ms cubic-bezier(0.22, 1, 0.36, 1); }

.nav-tab { transition: background 180ms ease, color 180ms ease, transform 80ms ease; }
.nav-tab:active { transform: scale(0.93); }

.btn-primary { transition: background 130ms ease, border-color 130ms ease, transform 80ms ease, box-shadow 130ms ease; }
.btn-ghost   { transition: background 130ms ease, border-color 130ms ease, transform 80ms ease; }
.btn-primary:active, .btn-ghost:active { transform: scale(0.95); transition-duration: 50ms; }

.task-item { transition: background 120ms ease, transform 80ms ease; }
.task-item:active { transform: scale(0.99); }

.task-item span { transition: color 200ms ease; }

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 720px) {
  .app-header {
    padding: 0 16px;
    gap: 10px;
  }

  .nav-pills {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    justify-content: space-around;
    gap: 4px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(250, 248, 244, 0.96);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(45, 41, 38, 0.06);
  }

  .nav-tab {
    flex: 1;
    padding: 8px 6px;
    font-size: 13px;
    border-radius: 10px;
  }


  .app-body {
    padding: 20px 16px calc(80px + env(safe-area-inset-bottom));
  }

  .view-top h2 { font-size: 24px; }

  .pace-options { grid-template-columns: repeat(3, 1fr); }

  /* Stories on mobile */
  .stories-layout {
    display: block;
    position: static;
  }

  .story-browser {
    position: static;
    max-height: none;
    margin-bottom: 16px;
  }

  .story-reader { display: none; }

  .stories-layout.is-reading .story-browser { display: none; }
  .stories-layout.is-reading .story-reader { display: block; }
  #view-stories.is-reading > .view-top { display: none; }

  .story-reader {
    margin: 0 -16px;
    border: none;
    border-top: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    overflow: visible;
  }

  .story-reader-toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 5;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255, 254, 251, 0.96);
    backdrop-filter: blur(10px);
  }

  .story-back { display: inline-flex; }
  .story-copy { padding: 20px 16px 32px; }
  .story-copy > h3 { font-size: 24px; }
  .story-body { font-size: 17px; }

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

  .toast {
    bottom: calc(64px + env(safe-area-inset-bottom) + 12px);
  }
}

@media (max-width: 480px) {
  .pace-options { grid-template-columns: 1fr; gap: 8px; }
  .pace-option { flex-direction: row; align-items: center; gap: 12px; }
  .pace-icon { font-size: 22px; margin: 0; }
  .pace-option strong, .pace-option span { display: inline; }
  .pace-option > span:not(.pace-icon)::before { content: " · "; }
}

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

/* ─── Journal ────────────────────────────────────────────── */

.journal-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.journal-section:last-of-type { border-bottom: none; }

.journal-section-title {
  margin: 0 0 16px;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.journal-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.journal-section-head .journal-section-title { margin-bottom: 0; }

/* 待办 */

.journal-todo-form {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.journal-todo-form input {
  flex: 1;
  border: none;
  border-bottom: 1.5px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 10px 0;
  font-size: 15px;
  color: var(--text);
  transition: border-color 150ms;
}

.journal-todo-form input:focus {
  outline: none;
  border-bottom-color: var(--green);
  background: transparent;
}

.jf-confirm {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--green);
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  display: grid;
  place-items: center;
  transition: background 120ms, color 120ms;
}

.jf-confirm:hover, .jf-confirm:active { background: var(--green-light); }

.journal-todo-list { display: grid; gap: 2px; }

/* 清晰之志 chips */
.journal-anchor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.journal-anchor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px 7px 16px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
  line-height: 1;
}

.journal-anchor-chip:hover { border-color: var(--border-focus); color: var(--text); }

.journal-anchor-chip.done {
  background: var(--green-light);
  border-color: var(--green, #5a8a6a);
  color: var(--green-text, #3a6a4a);
}

.anchor-del {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: transparent;
  cursor: pointer;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: background 120ms, color 120ms;
  flex-shrink: 0;
}

@media (hover: hover) {
  .journal-anchor-chip:hover .anchor-del { color: var(--text-2); }
}
.anchor-del:hover, .anchor-del:active { background: rgba(0,0,0,0.08); color: var(--text) !important; }

.journal-empty {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
}

.journal-todo-item {
  display: grid;
  grid-template-columns: 22px 1fr 24px;
  gap: 8px;
  align-items: center;
  padding: 10px 4px 10px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms;
}

.journal-todo-item:hover { border-bottom-color: var(--border); }

.journal-todo-item.is-dragging {
  opacity: 0.5;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.journal-todo-item.done .jt-text {
  text-decoration: line-through;
  color: var(--text-2);
}

.jt-handle {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 14px;
  color: var(--text-3, var(--text-2));
  opacity: 0.4;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  text-align: center;
  transition: opacity 120ms;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 4px;
}

@media (hover: hover) {
  .journal-todo-item:hover .jt-handle { opacity: 0.7; }
}
.jt-handle:active { opacity: 0.7; }
.jt-handle.menu-open { opacity: 0.9; background: var(--green-light); }

.jt-check {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  cursor: pointer;
  justify-self: center;
}

.jt-text {
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jt-del {
  border: none;
  background: transparent;
  color: transparent;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  transition: background 120ms, color 120ms;
  cursor: pointer;
}

@media (hover: hover) {
  .journal-todo-item:hover .jt-del { color: var(--text-2); }
}
.jt-del:hover, .jt-del:active { background: #f5e0e0; color: #c0392b !important; }

/* 待办操作菜单 */

.jt-menu {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  min-width: 88px;
  overflow: hidden;
}

.jt-menu.open { display: flex; }

.jt-menu button {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 100ms;
  width: 100%;
}

.jt-menu button + button { border-top: 1px solid var(--border); }

.jt-menu button:hover,
.jt-menu button:active { background: var(--green-light); }

.jt-menu button:disabled {
  color: var(--text-2);
  opacity: 0.35;
  cursor: not-allowed;
}

.jt-menu button:disabled:hover { background: transparent; }

.jt-menu .jt-menu-del { color: #c0392b; }
.jt-menu .jt-menu-del:hover,
.jt-menu .jt-menu-del:active { background: #f5e0e0; }

/* 时间块 */

.journal-add-todo-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.journal-add-todo-btn:hover, .journal-add-todo-btn:active { background: var(--green-light); border-color: var(--border-focus); }

.journal-add-todo-btn.is-cancel {
  color: var(--text-2);
  border-color: var(--border);
  padding: 4px 10px;
}

.journal-add-block {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 130ms, border-color 130ms;
  white-space: nowrap;
}

.journal-add-block:hover, .journal-add-block:active { background: var(--green-light); border-color: var(--border-focus); }

.journal-blocks-list { display: grid; gap: 8px; margin-bottom: 20px; }

.journal-block {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  position: relative;
  cursor: pointer;
  transition: background 120ms;
}

.journal-block:hover, .journal-block:focus-visible {
  background: #ede9e1;
  outline: none;
}

.journal-block:active { background: var(--green-light); }

.jb-time-cell {
  display: flex;
  align-items: center;
  padding: 10px 10px 10px 14px;
  gap: 8px;
}

.jb-time-cell .jb-time-text { flex: 1; }

.jb-del {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 120ms, background 120ms, color 120ms;
}

.jb-del:hover, .jb-del:active { opacity: 1; background: #f5e0e0; color: #c0392b; }

.jb-plan, .jb-actual {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
}

.jb-plan { border-top: 1px solid rgba(0,0,0,0.06); }
.jb-actual { border-top: 1px solid rgba(0,0,0,0.06); }

.jb-plan-text, .jb-actual-text {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jb-mins-text {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
}

.jb-summary-empty {
  color: var(--text-2);
  opacity: 0.65;
}
.jb-time-text {
  font-size: 14px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--text);
}



/* 统计区 */

/* ─── Journal Status Bar ─── */

.journal-status-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 20px;
}

.jsb-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.jsb-label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.jsb-label-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.jsb-value {
  font-size: 22px;
  font-weight: 700;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  color: var(--text);
  line-height: 1.2;
}

.jsb-value .unit {
  font-size: 12px;
  font-weight: 600;
  margin: 0 2px;
}

.jsb-divider {
  width: 1px;
  height: 48px;
  background: var(--border);
  flex-shrink: 0;
}

.jsb-edit-btn {
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  line-height: 0;
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: color 120ms, opacity 120ms, background 120ms;
}

.jsb-edit-btn svg { width: 14px; height: 14px; }

.jsb-edit-btn:hover, .jsb-edit-btn:active {
  color: var(--green);
  opacity: 1;
  background: var(--green-bg, #e8f5e9);
}

/* ─── Avail Picker Modal ─── */

.avail-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

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

.avail-modal {
  width: 100%;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 40px;
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.avail-modal-overlay.open .avail-modal {
  transform: translateY(0);
}

.avail-modal-title {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
}

.avail-picker-wrap {
  position: relative;
  height: 68px;
  margin: 0 -20px 28px;
  overflow: hidden;
}

.avail-picker-track {
  display: flex;
  align-items: center;
  height: 100%;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.avail-picker-track::-webkit-scrollbar { display: none; }

.avail-picker-item {
  flex-shrink: 0;
  width: 96px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
}

.avail-picker-item .api-num {
  font-size: 22px;
  font-weight: 700;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  color: var(--text);
  line-height: 1.1;
}

.avail-picker-item .api-unit {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 1px;
}

.avail-picker-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 96px;
  height: 56px;
  border: 2px solid var(--green);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.avail-modal-actions {
  display: flex;
  gap: 12px;
}

.avail-modal-actions .btn-ghost,
.avail-modal-actions .btn-primary {
  flex: 1;
  text-align: center;
}

/* ─── 时间段编辑弹窗 ─── */

.block-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

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

.block-modal {
  width: 100%;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 40px;
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.block-modal-overlay.open .block-modal {
  transform: translateY(0);
}

.block-modal-title {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
}

.bm-time-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.bm-time-input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 20px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--text);
  text-align: center;
  width: 96px;
  padding: 10px 4px;
}

.bm-time-input:focus { outline: none; background: var(--green-light); border-color: var(--green); }

.bm-time-sep { font-size: 18px; color: var(--text-2); }

.bm-field-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

.bm-text-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  padding: 11px 12px;
}

.bm-mins-input {
  flex: none;
  width: 68px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  text-align: center;
  padding: 11px 4px;
  -moz-appearance: textfield;
}

.bm-mins-input::-webkit-outer-spin-button,
.bm-mins-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.bm-mins-display {
  flex: none;
  width: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.bm-text-input:focus, .bm-mins-input:focus { outline: none; border-color: var(--green); }

.bm-field-plan .bm-text-input:focus { background: var(--green-light); }
.bm-field-actual .bm-text-input:focus, .bm-field-actual .bm-mins-input:focus { background: var(--blue-light); }

.block-modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.block-modal-actions .btn-ghost,
.block-modal-actions .btn-primary {
  flex: 1;
  text-align: center;
}

.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

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

.confirm-modal {
  width: 100%;
  max-width: 320px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92);
  transition: transform 200ms cubic-bezier(0.32, 0.72, 0, 1);
}

.confirm-modal-overlay.open .confirm-modal {
  transform: scale(1);
}

.confirm-modal-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
}

.confirm-modal-desc {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  color: var(--text-2);
}

.confirm-modal-actions {
  display: flex;
  gap: 12px;
}

.confirm-modal-actions .btn-ghost,
.confirm-modal-actions .btn-danger,
.confirm-modal-actions .btn-primary {
  flex: 1;
  text-align: center;
}

.sync-token-input {
  width: 100%;
  margin-bottom: 12px;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #c0392b;
  border-radius: var(--radius-sm);
  background: #c0392b;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  white-space: nowrap;
  transition: background 130ms ease, border-color 130ms ease, transform 80ms ease;
}

.btn-danger:hover { background: #a53324; border-color: #a53324; }
.btn-danger:active { transform: scale(0.95); transition-duration: 50ms; }

.journal-efficiency {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--green-text);
  line-height: 1.7;
  text-align: center;
}

/* 备注 */

#journal-notes-card textarea {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 10px 0;
  font-size: 14px;
  line-height: 1.85;
  resize: none;
  transition: border-color 150ms;
}

#journal-notes-card textarea:focus {
  outline: none;
  border-bottom-color: var(--green);
  background: transparent;
}

/* 重置链接 */

.journal-reset-link {
  margin: 8px 0 0;
  text-align: center;
}

.journal-reset-link button {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 120ms, background 120ms;
}

.journal-reset-link button:hover, .journal-reset-link button:active { color: #c0392b; background: #f5e0e0; }

/* ─── 手账历史（只读 bottom sheet） ─── */

.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

.bottom-sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.bottom-sheet-overlay.open .bottom-sheet {
  transform: translateY(0);
}

.bottom-sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bottom-sheet-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
}

.jh-back,
.bottom-sheet-close {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
}

.jh-back:hover,
.bottom-sheet-close:hover { background: var(--surface-2); color: var(--text); }

.bottom-sheet-body {
  padding: 12px 20px 28px;
  overflow-y: auto;
}

.jh-list {
  display: grid;
  gap: 10px;
}

.jh-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
}

.jh-list-item:hover { border-color: var(--border-focus); }

.jh-list-date { font-weight: 700; font-size: 14px; }
.jh-list-summary { font-size: 12px; color: var(--text-2); }

.jh-detail-date {
  margin: 4px 0 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
}

.jh-detail-h {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.jh-detail-h:first-of-type { margin-top: 0; }

.jh-detail-anchors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jh-detail-todo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
}

.jh-detail-todo.done { color: var(--text-2); text-decoration: line-through; }

.jh-detail-todo-mark {
  width: 16px;
  color: var(--green);
  font-weight: 700;
}

.jh-detail-block {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.jh-detail-block:last-child { border-bottom: none; }

.jh-detail-block-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
}

.jh-detail-block-line {
  margin: 4px 0 0;
  font-size: 14px;
}

.jh-detail-notes {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
  white-space: pre-wrap;
  line-height: 1.5;
}

/* 响应式 */

@media (max-width: 720px) {
  /* 区块间距收窄 */
  .journal-section { padding: 18px 0; }

  /* 待办：触控友好，handle 始终可见 */
  .journal-todo-item {
    grid-template-columns: 24px 1fr 28px;
    gap: 10px;
    padding: 13px 4px 13px 0;
  }
  .jt-handle { opacity: 0.5 !important; font-size: 15px; }
  .jt-check { width: 20px; height: 20px; }
  .anchor-del { color: var(--text-2) !important; }

  /* 输入框加高，触摸友好 */
  .journal-todo-form input { padding: 13px 0; font-size: 16px; }

  /* 时间安排卡片在移动端稍微加大点击区域 */
  .jb-time-cell { padding: 8px 8px 8px 14px; }
  .jb-plan, .jb-actual { padding: 10px 14px; }
  .jb-time-text { font-size: 15px; }
  .jb-plan-text, .jb-actual-text { font-size: 14px; }
  .jb-del { width: 36px; height: 36px; font-size: 18px; opacity: 0.6; }

  /* 状态栏适配 */
  .journal-status-bar { padding: 16px 14px; margin-bottom: 16px; }
  .jsb-value { font-size: 20px; }
  .jsb-label { font-size: 12px; }

  /* 备注输入加高 */
  #journal-notes-card textarea { font-size: 16px; padding: 12px 0; }
}
