/* Journal page: /journal/ */

.journal-page {
  height: auto;
  overflow-y: auto;
  --site-max: 1040px;
  --site-gutter: 24px;
  --jr-rail: 76px;
  --jr-line: rgba(0, 0, 0, 0.08);
  --jr-line-strong: rgba(0, 0, 0, 0.16);
  --jr-surface: rgba(255, 255, 255, 0.72);
  --jr-surface-solid: #ffffff;
  --jr-field-bg: rgba(255, 255, 255, 0.9);
  --jr-ink: #1d1d1f;
  --jr-blue: #0b63ce;
  --jr-green: #18794e;
  --jr-amber: #a35200;
  --jr-red: #c4271f;
  --jr-gray: #6e6e73;
  --jr-violet: #5b3fb8;
  --jr-violet-bg: rgba(106, 72, 200, 0.12);
  --jr-violet-line: rgba(123, 90, 220, 0.4);
}

:root[data-theme="dark"] .journal-page {
  --jr-line: rgba(255, 255, 255, 0.09);
  --jr-line-strong: rgba(255, 255, 255, 0.18);
  --jr-surface: rgba(22, 22, 24, 0.72);
  --jr-surface-solid: #161618;
  --jr-field-bg: rgba(255, 255, 255, 0.05);
  --jr-ink: #f5f5f7;
  --jr-blue: #5ba6ff;
  --jr-green: #4cc38a;
  --jr-amber: #f0a64a;
  --jr-red: #ff6b61;
  --jr-gray: #98989d;
  --jr-violet: #c0a8ff;
  --jr-violet-bg: rgba(150, 120, 255, 0.18);
  --jr-violet-line: rgba(170, 145, 255, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .journal-page {
    --jr-line: rgba(255, 255, 255, 0.09);
    --jr-line-strong: rgba(255, 255, 255, 0.18);
    --jr-surface: rgba(22, 22, 24, 0.72);
    --jr-surface-solid: #161618;
    --jr-field-bg: rgba(255, 255, 255, 0.05);
    --jr-ink: #f5f5f7;
    --jr-blue: #5ba6ff;
    --jr-green: #4cc38a;
    --jr-amber: #f0a64a;
    --jr-red: #ff6b61;
    --jr-gray: #98989d;
    --jr-violet: #c0a8ff;
    --jr-violet-bg: rgba(150, 120, 255, 0.18);
    --jr-violet-line: rgba(170, 145, 255, 0.45);
  }
}

.journal-page .bg-glow .glow-orb { opacity: 0.12; }

.jr-main {
  min-height: 100vh;
  padding: 96px 48px 96px calc(var(--jr-rail) + 48px);
  position: relative;
  z-index: 1;
}

.jr-container {
  margin: 0;
  max-width: none;
  width: 100%;
}

/* ---------- left vertical rail ---------- */

.jr-rail {
  align-items: center;
  border-right: 1px solid var(--jr-line);
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: flex-start;
  left: 0;
  padding-top: 47px;
  pointer-events: none;
  position: fixed;
  top: 49px;
  width: var(--jr-rail);
  z-index: 20;
}

.jr-rail-crumb {
  color: var(--jr-blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-orientation: upright;
  writing-mode: vertical-rl;
}

.jr-rail-title {
  color: var(--jr-ink);
  font-size: clamp(28px, 2.6vw, 42px);
  font-weight: 720;
  letter-spacing: 0.14em;
  line-height: 1;
  text-orientation: upright;
  writing-mode: vertical-rl;
}

/* ---------- header ---------- */

.jr-head {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  justify-content: space-between;
  margin-bottom: 28px;
}

/* 桌面端列表页不显示标题栏（标题在左侧竖排栏），移动端保留横向标题。 */
@media (min-width: 641px) {
  .jr-head--list { display: none; }
}
.jr-head-actions { margin-left: auto; }
.jr-head-main--hidden {
  border: 0;
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.jr-crumb {
  color: var(--jr-blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-decoration: none;
}

.jr-title {
  color: var(--jr-ink);
  font-size: clamp(30px, 4.6vw, 46px);
  font-weight: 720;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-top: 10px;
  max-width: 1100px;
  overflow-wrap: anywhere;
}

.jr-head-actions,
.jr-panel-actions,
.jr-row-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jr-head-actions[hidden] { display: none; }

.jr-back { margin-bottom: 20px; }

/* ---------- buttons & inputs ---------- */

.jr-btn {
  align-items: center;
  background: var(--jr-surface);
  border: 1px solid var(--jr-line-strong);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  gap: 6px;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
  white-space: nowrap;
}
.jr-btn:hover:not(:disabled) { border-color: var(--jr-blue); color: var(--jr-blue); }
.jr-btn:disabled { cursor: not-allowed; opacity: 0.45; }
.jr-btn--primary { background: var(--jr-blue); border-color: var(--jr-blue); color: #fff; }
.jr-btn--primary:hover:not(:disabled) { color: #fff; filter: brightness(1.08); }
.jr-btn--danger { color: var(--jr-red); }
.jr-btn--danger:hover:not(:disabled) { border-color: var(--jr-red); color: var(--jr-red); }
.jr-btn--primary.jr-btn--danger { background: var(--jr-red); border-color: var(--jr-red); color: #fff; }
.jr-btn--sm { font-size: 12px; min-height: 30px; padding: 0 10px; }

/* 日记页所有按钮统一胶囊形（含导航登录/注册/退出与登录弹窗按钮）。 */
.journal-page .btn-nav,
.journal-page .btn-logout,
.journal-page .modal-actions button,
.journal-page .btn-sm { border-radius: 999px; }

.jr-icon-btn {
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--text2);
  cursor: pointer;
  font-size: 20px;
  height: 32px;
  line-height: 1;
  width: 32px;
}
.jr-icon-btn:hover { background: var(--card); color: var(--text); }

.jr-input {
  background: var(--jr-field-bg);
  border: 1px solid var(--jr-line-strong);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  min-height: 38px;
  min-width: 0;
  outline: none;
  padding: 8px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}
.jr-input:focus { border-color: var(--jr-blue); box-shadow: 0 0 0 3px var(--accent-glow); }
.jr-input--sm { font-size: 13px; min-height: 34px; padding: 6px 10px; width: auto; }
select.jr-input { cursor: pointer; }
/* 未启用自定义下拉框时（脚本被禁用等）的兜底：让原生选项列表跟随深色模式，
   避免系统白底 + 继承白色文字造成「白底白字」。 */
select.jr-input option {
  background: var(--jr-surface-solid);
  color: var(--text);
}
:root[data-theme="dark"] .journal-page input[type="date"],
:root[data-theme="dark"] .journal-page select.jr-input { color-scheme: dark; }
.jr-textarea { line-height: 1.6; resize: vertical; }
.jr-textarea--mono, .jr-mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 12.5px; }

.jr-link-quiet { color: var(--text2); font-size: 13px; text-decoration: none; }
.jr-link-quiet:hover { color: var(--jr-blue); }

.jr-muted { color: var(--text2); }

/* ---------- toolbar ---------- */

.jr-toolbar {
  border-bottom: 1px solid var(--jr-line);
  display: grid;
  gap: 14px;
  margin-bottom: 8px;
  padding-bottom: 18px;
}

.jr-toolbar-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* 列表页超管操作（写日记 / 日记设置）与筛选工具栏同排，右侧对齐。 */
.jr-toolbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Left hamburger filter menu */

.jr-filter-menu {
  flex: 0 0 auto;
  position: relative;
}

.jr-menu-toggle {
  align-items: center;
  background: var(--jr-surface);
  border: 1px solid var(--jr-line-strong);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.jr-menu-toggle:hover,
.jr-menu-toggle.is-open { border-color: var(--jr-blue); color: var(--jr-blue); }

.jr-menu-lines { display: inline-flex; flex-direction: column; gap: 3px; width: 16px; }
.jr-menu-lines i {
  background: currentColor;
  border-radius: 2px;
  display: block;
  height: 1.5px;
  transition: transform 0.25s ease, opacity 0.2s ease;
  width: 100%;
}
.jr-menu-toggle.is-open .jr-menu-lines i:nth-child(1) { transform: translateY(4.5px) rotate(45deg); }
.jr-menu-toggle.is-open .jr-menu-lines i:nth-child(2) { opacity: 0; }
.jr-menu-toggle.is-open .jr-menu-lines i:nth-child(3) { transform: translateY(-4.5px) rotate(-45deg); }

.jr-menu-count {
  background: var(--jr-ink);
  border-radius: 999px;
  color: var(--bg);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  padding: 1px 5px;
  text-align: center;
}
.jr-menu-toggle.is-open .jr-menu-count { background: var(--jr-blue); color: #fff; }

.jr-filter-panel {
  background: var(--jr-surface-solid);
  border: 1px solid var(--jr-line-strong);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 16px;
  left: 0;
  max-height: min(70vh, 520px);
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  position: absolute;
  top: calc(100% + 10px);
  width: min(340px, calc(100vw - 48px));
  z-index: 70;
}
.jr-filter-panel[hidden] { display: none; }
.jr-filter-panel:not([hidden]) { animation: jr-panel-in 0.18s ease; }

@keyframes jr-panel-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.jr-filter-group { display: grid; gap: 8px; }
.jr-filter-group-title {
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 0;
}
.jr-filter-group .jr-chips { gap: 6px; }
.jr-filter-group .jr-chip { font-size: 12.5px; padding: 4px 11px; }
.jr-filter-empty { color: var(--text2); font-size: 12.5px; }
.jr-filter-foot {
  align-items: center;
  border-top: 1px solid var(--jr-line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding-top: 12px;
}
.jr-filter-foot .jr-muted { font-size: 12px; }
.jr-chip-count { color: var(--text2); font-size: 11px; margin-left: 5px; }
.jr-chip.is-active .jr-chip-count { color: currentColor; opacity: 0.7; }

.jr-search { display: flex; flex: 1 1 240px; gap: 8px; max-width: 560px; }
.jr-search .jr-input { flex: 1 1 auto; }

.jr-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.jr-chip {
  border: 1px solid var(--jr-line);
  border-radius: 999px;
  color: var(--text2);
  font-size: 13px;
  padding: 5px 12px;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
a.jr-chip:hover { border-color: var(--jr-line-strong); color: var(--text); }
.jr-chip.is-active { background: var(--jr-ink); border-color: var(--jr-ink); color: var(--bg); }
.jr-chip--static { font-size: 12px; padding: 3px 10px; }

.jr-filter-row { align-items: center; display: flex; flex-wrap: wrap; gap: 8px 12px; }
.jr-date-range { align-items: center; display: inline-flex; gap: 6px; font-size: 13px; }

/* ---------- list view switch ---------- */

.jr-view-switch {
  align-items: center;
  background: var(--jr-surface);
  border: 1px solid var(--jr-line-strong);
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  padding: 3px;
  scrollbar-width: none;
}
.jr-view-switch::-webkit-scrollbar { display: none; height: 0; width: 0; }

.jr-view-btn {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--text2);
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  min-height: 28px;
  padding: 0 12px;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.jr-view-btn:hover { color: var(--text); }
.jr-view-btn:focus-visible { outline: 2px solid var(--jr-blue); outline-offset: 1px; }
.jr-view-btn.is-active {
  background: var(--jr-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  color: var(--bg);
}

/* 「按时间」分段：激活按钮 + 按月/按日下拉 */
.jr-view-time {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
}
.jr-view-caret {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  height: 28px;
  justify-content: center;
  padding: 0 8px 0 3px;
  transition: color 0.2s ease;
}
.jr-view-caret:hover { color: var(--text); }
.jr-view-caret:focus-visible { outline: 2px solid var(--jr-blue); outline-offset: 1px; }
.jr-caret {
  border-bottom: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  display: block;
  height: 5px;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.2s ease;
  width: 5px;
}
.jr-view-caret.is-open .jr-caret { transform: rotate(225deg) translate(-1px, -1px); }

.jr-view-time.is-active {
  background: var(--jr-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}
.jr-view-time.is-active .jr-view-btn,
.jr-view-time.is-active .jr-view-btn:hover {
  background: transparent;
  box-shadow: none;
  color: var(--bg);
}
.jr-view-time.is-active .jr-view-caret,
.jr-view-time.is-active .jr-view-caret:hover { color: var(--bg); }

.jr-view-menu {
  background: var(--jr-surface-solid);
  border: 1px solid var(--jr-line-strong);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 2px;
  min-width: 108px;
  padding: 6px;
  position: fixed;
  z-index: 90;
}
.jr-view-menu[hidden] { display: none; }

.jr-view-menu-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 13px;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 10px;
  text-align: left;
}
.jr-view-menu-item:hover { background: var(--card); color: var(--jr-blue); }
.jr-view-menu-item.is-active { color: var(--jr-blue); font-weight: 650; }
.jr-view-menu-item.is-active::after { content: '✓'; font-size: 12px; }

/* ---------- grouped list views ---------- */

.jr-groups { display: grid; gap: 30px; margin-top: 20px; }

.jr-group { display: grid; gap: 12px; }

.jr-group-head {
  align-items: center;
  border-bottom: 1px solid var(--jr-line);
  display: flex;
  gap: 10px;
  padding-bottom: 8px;
}

.jr-group-title {
  align-items: center;
  color: var(--jr-ink);
  display: inline-flex;
  font-size: 14px;
  font-weight: 680;
  gap: 8px;
  letter-spacing: 0.01em;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.jr-group-dot {
  background: var(--jr-blue);
  border-radius: 50%;
  flex: 0 0 auto;
  height: 7px;
  width: 7px;
}
.jr-group-dot.jr-cat--investigation { background: var(--jr-amber); }
.jr-group-dot.jr-cat--decision { background: #7a4fd6; }
.jr-group-dot.jr-cat--learning { background: var(--jr-green); }
.jr-group-dot.jr-cat--plan { background: #0e7c86; }
.jr-group-dot.jr-cat--note { background: var(--jr-gray); }
:root[data-theme="dark"] .jr-group-dot.jr-cat--decision { background: #b08cff; }
:root[data-theme="dark"] .jr-group-dot.jr-cat--plan { background: #4fd1db; }

.jr-group-count {
  color: var(--text2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  white-space: nowrap;
}

.jr-group .jr-list { margin-top: 0; }

/* ---------- list ---------- */

.jr-count { color: var(--text2); font-size: 12px; margin: 14px 0 0; }

/* Responsive card grid: several cards per row on wide screens, stacked on phones. */
.jr-list {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  margin-top: 18px;
}

.jr-card {
  background: var(--jr-surface);
  border: 1px solid var(--jr-line);
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.jr-card:hover {
  border-color: var(--jr-line-strong);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.09);
  transform: translateY(-2px);
}
/* 点开详情、等预取数据时的即时反馈，避免手机上看着像没点中。 */
.jr-card.is-opening {
  border-color: var(--jr-line-strong);
  opacity: 0.7;
  transition: border-color 0.12s ease, opacity 0.12s ease;
}

/* 视图切换时飞行中的卡片克隆：脱离布局、悬浮在其他内容之上。 */
.jr-card--flying {
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
  left: 0;
  margin: 0 !important;
  pointer-events: none;
  position: fixed;
  top: 0;
  will-change: transform;
  z-index: 60;
}
.jr-card--flying * { pointer-events: none; }

.jr-meta {
  align-items: center;
  color: var(--text2);
  display: flex;
  flex-wrap: wrap;
  font-size: 12.5px;
  gap: 6px 14px;
}
.jr-meta time { font-variant-numeric: tabular-nums; }
.jr-meta a { color: inherit; text-decoration: none; }
.jr-meta a:hover { color: var(--jr-blue); }
.jr-meta-project::before { content: '◇ '; opacity: 0.6; }

.jr-cat { font-weight: 650; }
.jr-meta .jr-cat { color: var(--jr-blue); }
.jr-meta .jr-cat--investigation { color: var(--jr-amber); }
.jr-meta .jr-cat--decision { color: #7a4fd6; }
.jr-meta .jr-cat--learning { color: var(--jr-green); }
.jr-meta .jr-cat--plan { color: #0e7c86; }
.jr-meta .jr-cat--note { color: var(--jr-gray); }
:root[data-theme="dark"] .jr-meta .jr-cat--decision { color: #b08cff; }
:root[data-theme="dark"] .jr-meta .jr-cat--plan { color: #4fd1db; }

.jr-card-title {
  font-size: 17.5px;
  font-weight: 680;
  letter-spacing: -0.005em;
  line-height: 1.4;
  margin: 0;
}
.jr-card-title a { color: var(--jr-ink); text-decoration: none; }
.jr-card-title a:hover { color: var(--jr-blue); }

.jr-card-summary {
  color: var(--text2);
  display: -webkit-box;
  flex: 1 1 auto;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.jr-card-foot {
  align-items: center;
  border-top: 1px solid var(--jr-line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: auto;
  padding-top: 10px;
}

.jr-author { color: var(--text2); font-size: 12.5px; }

.jr-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.jr-tag {
  align-items: center;
  background: var(--card);
  border: 1px solid var(--jr-line);
  border-radius: 6px;
  color: var(--text2);
  display: inline-flex;
  font-size: 12px;
  gap: 4px;
  padding: 2px 8px;
  text-decoration: none;
}
a.jr-tag:hover { border-color: var(--jr-blue); color: var(--jr-blue); }
.jr-tag--active { border-color: var(--jr-blue); color: var(--jr-blue); }
.jr-tag-clear { background: none; border: 0; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 0 0 2px; }

.jr-status {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.5;
  padding: 0 8px;
  white-space: nowrap;
}
.jr-status--published { color: var(--jr-green); }
.jr-status--draft { color: var(--jr-amber); }
.jr-status--withdrawn { color: var(--jr-gray); }
.jr-status--archived { color: var(--jr-blue); }
.jr-status--trash { color: var(--jr-red); }

/* 可见性标签（隐私 / 内部 / 私有）与状态标签分开：
   状态是琥珀色描边的空心胶囊，可见性用紫色虚线描边 + 浅色填充，形状和配色都不同。 */
.jr-status--private {
  background: var(--jr-violet-bg);
  border-color: var(--jr-violet-line);
  border-style: dashed;
  color: var(--jr-violet);
}

.jr-pager {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
}
.jr-pager-label { color: var(--text2); font-size: 13px; font-variant-numeric: tabular-nums; }

.jr-empty {
  align-items: center;
  border: 1px dashed var(--jr-line-strong);
  border-radius: 12px;
  color: var(--text2);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
  padding: 48px 20px;
  text-align: center;
}
.jr-empty--error p { color: var(--text); }

.jr-loading {
  color: var(--text2);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

/* ---------- article ---------- */

/* 正文列 + 右侧信息列：宽屏并排铺开，避免详情页右半屏留白。 */
.jr-article { max-width: 900px; }

.jr-entry-cols {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
}
.jr-entry-main { min-width: 0; }
.jr-entry-side { display: grid; gap: 8px; min-width: 0; }
.jr-entry-side .jr-section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }

@media (min-width: 1200px) {
  .jr-article { max-width: 1400px; }
  .jr-entry-cols {
    align-items: start;
    column-gap: 56px;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  }
  .jr-entry-cols--single { grid-template-columns: minmax(0, 1fr); }
}

.jr-meta--detail { margin-bottom: 18px; }

.jr-article-summary {
  border-left: 2px solid var(--jr-blue);
  color: var(--text2);
  font-size: 16px;
  line-height: 1.75;
  margin-bottom: 26px;
  overflow-wrap: anywhere;
  padding-left: 14px;
}

.jr-fields {
  background: var(--jr-surface);
  border: 1px solid var(--jr-line);
  border-radius: 12px;
  display: grid;
  gap: 12px 20px;
  grid-template-columns: max-content minmax(0, 1fr);
  margin-bottom: 28px;
  padding: 18px 20px;
}
.jr-fields dt { color: var(--text2); font-size: 13px; font-weight: 600; padding-top: 1px; }
.jr-fields dd { font-size: 14.5px; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-line; }
.jr-fields ul { list-style: none; white-space: normal; }
.jr-fields li { padding-left: 14px; position: relative; }
.jr-fields li + li { margin-top: 2px; }
.jr-fields li::before { color: var(--text2); content: '–'; left: 0; position: absolute; }

.jr-prose {
  color: var(--text);
  font-size: 16px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}
.jr-prose > * + * { margin-top: 1em; }
.jr-prose h1, .jr-prose h2, .jr-prose h3, .jr-prose h4 { color: var(--jr-ink); line-height: 1.35; margin-top: 1.6em; }
.jr-prose h1 { font-size: 1.5em; }
.jr-prose h2 { font-size: 1.3em; }
.jr-prose h3 { font-size: 1.12em; }
.jr-prose a { color: var(--jr-blue); text-underline-offset: 3px; }
.jr-prose ul, .jr-prose ol { padding-left: 1.4em; }
.jr-prose li + li { margin-top: 0.3em; }
.jr-prose blockquote { border-left: 3px solid var(--jr-line-strong); color: var(--text2); padding-left: 14px; }
.jr-prose code { background: var(--card); border: 1px solid var(--jr-line); border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.86em; padding: 1px 5px; }
.jr-prose pre, .jr-pre {
  background: var(--card);
  border: 1px solid var(--jr-line);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  padding: 14px 16px;
  white-space: pre;
}
.jr-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.jr-prose pre code { background: none; border: 0; font-size: inherit; padding: 0; }
.jr-prose img { border-radius: 10px; height: auto; max-width: 100%; }
.jr-prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.jr-prose th, .jr-prose td { border: 1px solid var(--jr-line); padding: 6px 10px; }
.jr-prose hr { border: 0; border-top: 1px solid var(--jr-line); }

.jr-section { border-top: 1px solid var(--jr-line); margin-top: 32px; padding-top: 20px; }
.jr-section h3 { color: var(--text2); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; margin-bottom: 12px; }
.jr-sources, .jr-related { display: grid; gap: 8px; list-style: none; }
.jr-sources li, .jr-related li { align-items: center; display: flex; flex-wrap: wrap; font-size: 14px; gap: 8px; overflow-wrap: anywhere; }
.jr-sources a, .jr-related a { color: var(--jr-blue); text-decoration: none; }
.jr-sources a:hover, .jr-related a:hover { text-decoration: underline; }

.jr-article-foot {
  border-top: 1px solid var(--jr-line);
  color: var(--text2);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 6px 18px;
  margin-top: 36px;
  padding-top: 16px;
}

/* ---------- entry admin menu ---------- */

.jr-head-static-actions,
.jr-entry-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}
.jr-head-static-actions[hidden],
.jr-entry-actions[hidden] { display: none; }

.jr-admin-menu { position: relative; }

.jr-admin-menu-toggle .jr-chevron {
  border-bottom: 1px solid currentColor;
  border-right: 1px solid currentColor;
  display: inline-block;
  height: 6px;
  margin-left: 2px;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.2s ease;
  width: 6px;
}
.jr-admin-menu.is-open .jr-chevron { transform: rotate(225deg) translate(-1px, -1px); }

.jr-admin-menu-panel {
  background: var(--jr-surface-solid);
  border: 1px solid var(--jr-line-strong);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 2px;
  min-width: 180px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 75;
}
.jr-admin-menu-panel[hidden] { display: none; }

.jr-admin-item {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.jr-admin-item:hover { background: var(--card); color: var(--jr-blue); }
.jr-admin-item--primary { color: var(--jr-blue); font-weight: 600; }
.jr-admin-item--danger { color: var(--jr-red); }
.jr-admin-item--danger:hover { background: var(--card); color: var(--jr-red); }
.jr-admin-sep { border: 0; border-top: 1px solid var(--jr-line); margin: 4px 0; }

/* ---------- project ---------- */

.jr-project {
  display: grid;
  gap: 14px;
  margin-bottom: 26px;
  max-width: 760px;
}
.jr-project-desc { color: var(--text2); font-size: 15.5px; line-height: 1.75; overflow-wrap: anywhere; white-space: pre-line; }
.jr-project-stats { align-items: center; color: var(--text2); display: flex; flex-wrap: wrap; font-size: 13px; gap: 6px 18px; }
.jr-project-stats a { color: var(--jr-blue); text-decoration: none; }

/* ---------- admin ---------- */

/* 设置页无页头，标签栏与主操作同一行。 */
.jr-head--hidden { display: none; }

.jr-admin-nav {
  align-items: flex-end;
  border-bottom: 1px solid var(--jr-line);
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.jr-admin-nav-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding-bottom: 6px;
}

.jr-tabs {
  display: flex;
  flex: 1 1 auto;
  gap: 4px;
  margin-bottom: -1px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.jr-tabs::-webkit-scrollbar { display: none; }
.jr-tab {
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-size: 14px;
  margin-bottom: -1px;
  padding: 10px 14px;
  text-decoration: none;
  white-space: nowrap;
}
.jr-tab:hover { color: var(--text); }
.jr-tab.is-active { border-bottom-color: var(--jr-ink); color: var(--jr-ink); font-weight: 650; }

.jr-panel-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}
.jr-panel-head h2 { font-size: 20px; font-weight: 680; }
.jr-subhead { color: var(--text2); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; margin: 30px 0 12px; }

.jr-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
.jr-stat {
  background: var(--jr-surface);
  border: 1px solid var(--jr-line);
  border-radius: 12px;
  color: var(--text2);
  display: grid;
  font-size: 13px;
  gap: 4px;
  padding: 16px;
  text-decoration: none;
  transition: border-color 0.2s ease;
}
.jr-stat:hover { border-color: var(--jr-blue); }
.jr-stat strong { color: var(--jr-ink); font-size: 26px; font-variant-numeric: tabular-nums; font-weight: 700; }
.jr-stat--warn strong { color: var(--jr-red); }

.jr-table-wrap {
  border: 1px solid var(--jr-line);
  border-radius: 12px;
  overflow-x: auto;
}
.jr-table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.jr-table th {
  background: var(--card);
  color: var(--text2);
  font-size: 12px;
  font-weight: 650;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}
.jr-table td { border-top: 1px solid var(--jr-line); padding: 10px 14px; vertical-align: top; }
.jr-table td a { color: var(--text); text-decoration: none; }
.jr-table td a:hover { color: var(--jr-blue); }
.jr-table td .jr-btn { color: var(--text); }
.jr-table td .jr-btn:hover { color: var(--jr-blue); }
.jr-table .jr-muted { font-size: 12px; margin-top: 2px; }
.jr-row-actions { flex-wrap: nowrap; justify-content: flex-end; }
.jr-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.jr-form--panel {
  background: var(--jr-surface);
  border: 1px solid var(--jr-line);
  border-radius: 12px;
  max-width: 720px;
  padding: 20px;
}
.jr-kv { display: grid; font-size: 13.5px; gap: 12px; grid-template-columns: 96px minmax(0, 1fr); }
.jr-kv > span:first-child { color: var(--text2); }
.jr-kv code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; overflow-wrap: anywhere; }
.jr-key-box {
  border: 1px solid var(--jr-amber);
  border-radius: 10px;
  display: grid;
  font-size: 13.5px;
  gap: 10px;
  line-height: 1.6;
  padding: 14px;
}
.jr-key-box[hidden] { display: none; }

/* ---------- forms & dialog ---------- */

.jr-form { display: grid; gap: 16px; }
.jr-form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.jr-field { display: grid; gap: 6px; min-width: 0; }
.jr-field-label { color: var(--text); font-size: 13px; font-weight: 600; }
.jr-field-hint { color: var(--text2); font-size: 12px; line-height: 1.55; }
.jr-inline-fields { display: flex; gap: 8px; margin-top: 8px; }
.jr-inline-fields[hidden] { display: none; }
.jr-check { align-items: center; cursor: pointer; display: inline-flex; font-size: 13.5px; gap: 8px; }
.jr-check input { accent-color: var(--jr-blue); height: 16px; width: 16px; }

/* 表单分组只用一条分隔线 + 小标题，不再套一层带边框的卡片。 */
.jr-form-section {
  border-top: 1px solid var(--jr-line);
  display: grid;
  gap: 12px;
  min-width: 0;
  padding-top: 16px;
}
.jr-form-section-title {
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0;
}
.jr-form-fields { display: grid; gap: 12px; min-width: 0; }
.jr-form-subsection { display: grid; gap: 8px; min-width: 0; }
.jr-details summary { color: var(--text2); cursor: pointer; font-size: 12.5px; }
.jr-details[open] summary { margin-bottom: 8px; }

.jr-sources-edit { display: grid; gap: 8px; }
.jr-source-row { align-items: center; display: grid; gap: 8px; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto auto; }

/* 弹窗打开时锁住页面滚动，只让弹窗内容区滚动，避免页面和弹窗各出一条滚动条。 */
html { scrollbar-gutter: stable; }
html.jr-dialog-open,
html.jr-dialog-open body { overflow: hidden; }

.jr-dialog {
  background: var(--jr-surface-solid);
  border: 1px solid var(--jr-line-strong);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  color: var(--text);
  margin: auto;
  max-height: min(880px, calc(100vh - 32px));
  max-height: min(880px, calc(100dvh - 32px));
  max-width: min(820px, calc(100vw - 24px));
  overflow: hidden;
  padding: 0;
  position: relative;
  width: 100%;
}
.jr-dialog[open] { display: flex; flex-direction: column; }
.jr-dialog::backdrop { background: rgba(0, 0, 0, 0.42); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.jr-dialog-inner {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}
.jr-dialog-head {
  align-items: center;
  border-bottom: 1px solid var(--jr-line);
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  padding: 14px 16px 14px 24px;
}
.jr-dialog-head h2 { font-size: 17px; font-weight: 680; }
.jr-dialog-body {
  /* 滚动条隐藏但仍可滚动：双滚动条里另一条来自页面，这里只保留顺滑的滚动体验。 */
  -ms-overflow-style: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 24px 20px;
  scrollbar-width: none;
}
.jr-dialog-body::-webkit-scrollbar { display: none; height: 0; width: 0; }
.jr-dialog-foot {
  background: var(--jr-surface-solid);
  border-top: 1px solid var(--jr-line);
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 24px;
  position: relative;
  z-index: 3;
}
/* 隐藏滚动条后，在内容区底部压一层渐隐，提示还能继续往下滚。 */
.jr-dialog-foot::before {
  background: linear-gradient(to bottom, transparent, var(--jr-surface-solid));
  bottom: 100%;
  content: '';
  height: 22px;
  left: 0;
  pointer-events: none;
  position: absolute;
  right: 0;
}

.jr-dialog-error {
  color: var(--jr-red);
  font-size: 13px;
  line-height: 1.5;
  margin-right: auto;
  align-self: center;
  overflow-wrap: anywhere;
}
.jr-dialog-error[hidden] { display: none; }

.jr-history-wrap { display: grid; gap: 16px; grid-template-columns: minmax(200px, 0.8fr) minmax(0, 1.4fr); }
.jr-history { display: grid; align-content: start; gap: 6px; }
.jr-history-item {
  background: transparent;
  border: 1px solid var(--jr-line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  font: inherit;
  font-size: 13px;
  gap: 2px;
  padding: 8px 10px;
  text-align: left;
}
.jr-history-item:hover { border-color: var(--jr-blue); }
.jr-history-item .jr-muted { font-size: 11.5px; }
.jr-history-preview { display: grid; align-content: start; gap: 10px; font-size: 13.5px; min-width: 0; }
.jr-history-preview h4 { font-size: 16px; }
.jr-history-preview .jr-pre { max-height: 360px; overflow: auto; }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .jr-main { padding: 80px 24px 80px; }
  .jr-rail { display: none; }
  .jr-head-main--hidden {
    clip-path: none;
    height: auto;
    overflow: visible;
    position: static;
    white-space: normal;
    width: auto;
  }
  .jr-head { align-items: flex-start; flex-direction: column; }
  .jr-admin-nav { flex-wrap: wrap; row-gap: 4px; }
  .jr-admin-nav-actions { margin-left: auto; }
  .jr-toolbar-bar { align-items: flex-start; }
  .jr-search { flex: 1 1 100%; max-width: none; }
  .jr-filter-row .jr-input--sm { flex: 1 1 140px; }
  .jr-date-range { flex: 1 1 100%; }
  .jr-date-range .jr-input { flex: 1; }
  .jr-view-switch { flex: 1 1 100%; justify-content: space-between; }
  .jr-view-btn { font-size: 12px; padding: 0 9px; }
  .jr-view-caret { padding: 0 6px 0 3px; }
  .jr-groups { gap: 24px; }
  .jr-list { grid-template-columns: 1fr; gap: 12px; }
  .jr-card { padding: 16px; }
  .jr-fields { grid-template-columns: 1fr; gap: 4px; }
  .jr-fields dd + dt { margin-top: 10px; }
  .jr-source-row { grid-template-columns: minmax(0, 1fr) auto; }
  .jr-source-row .jr-input:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .jr-history-wrap { grid-template-columns: 1fr; }
  .jr-kv { grid-template-columns: 1fr; gap: 4px; }
  .jr-card-title { font-size: 17px; }
  .jr-dialog { border-radius: 14px; max-height: calc(100dvh - 16px); }
  .jr-dialog-body { padding: 16px; }
  .jr-dialog-head { padding: 12px 8px 12px 16px; }
  .jr-dialog-foot { padding: 10px 16px; }
}

/* ---------- shadcn Aria DatePicker 适配 ---------- */

.jr-date-range .dp { flex: 1 1 auto; min-width: 0; }
.jr-filter-row .dp-trigger { min-width: 210px; }
.jr-form .dp,
.jr-form-grid .dp { width: 100%; }
.jr-form .dp-trigger { width: 100%; }

@media (max-width: 640px) {
  .jr-date-range { display: flex; width: 100%; }
  .jr-date-range .dp { width: 100%; }
  .jr-filter-row .dp-trigger { width: 100%; }
}

/* ---------- shared element transition ---------- */

/* 卡片标题 ↔ 详情页标题的共享元素转场，元素名由 journal.js 动态设置（jr-shared-card）。 */
::view-transition-group(jr-shared-card) {
  animation-duration: 0.38s;
  animation-timing-function: cubic-bezier(0.22, 0.68, 0.24, 1);
}
::view-transition-old(jr-shared-card),
::view-transition-new(jr-shared-card) {
  animation-duration: 0.28s;
}

/* 整页内容只做轻微交叉淡入，把注意力留给共享元素。 */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.24s;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}
::view-transition-old(root) { animation-name: jr-vt-fade-out; }
::view-transition-new(root) { animation-name: jr-vt-fade-in; }

@keyframes jr-vt-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes jr-vt-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .jr-btn, .jr-chip, .jr-input, .jr-stat, .jr-card, .jr-view-btn, .jr-view-caret { transition: none; }
  .jr-filter-panel:not([hidden]) { animation: none; }
  .jr-menu-lines i { transition: none; }
  .jr-caret { transition: none; }
}
