/* Shared Memory interface styles for light and dark themes.
   Archive reading keeps its existing layout in archive.css. */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS (方案 B：高定书房深杉墨绿 + 象牙纸质)
   -------------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  /* 基础画板底色 */
  --bg-canvas: #FAFAF7;       /* 方案B手账象牙白底 */
  --bg-surface: #FFFFFF;      /* 卡片、正文表面纯净白 */
  --bg-subtle: #F4F6F3;       /* 次级浅底、输入框衬底、工具栏衬底 */
  --bg-hover: #ECEFEA;        /* 悬停微底色 */
  --bg-active: #E3E8E1;       /* 激活按下底色 */

  /* 字体墨水色阶 (严格两级色彩) */
  --ink-primary: #222B27;     /* 第一级：深灰绿炭墨 (主标题与正文) */
  --ink-secondary: #536059;   /* 第二级：浅一点的次级文字/说明 */
  --ink-muted: #84918A;       /* 第二级辅助：时间、元数据、占位字 */
  --ink-disabled: #B4BFB8;    /* 禁用状态 */

  /* 边线规范 */
  --border-line: #E2E6E2;     /* 1px 精致边线 */
  --border-subtle: #EDF1EC;   /* 极轻微发丝线 */
  --border-focus: #355E4E;    /* 墨绿聚焦边线 */

  /* 核心主强调色：深杉墨绿 */
  --accent: #355E4E;
  --accent-hover: #294B3E;
  --accent-active: #213D32;
  --accent-soft: #EDF3EE;
  --accent-border: rgba(53, 94, 78, 0.22);

  /* 对话气泡专属色彩 */
  --user-bubble-bg: #EDF4EE;  /* 慵慵（用户）温润草木青书房色 */
  --user-bubble-border: #DCE6DE;
  --user-bubble-ink: #1F2E26;
  --assistant-bubble-bg: #FFFFFF;
  --assistant-bubble-border: #E2E6E2;

  /* 思考过程衬底 */
  --thought-bg: #F5F8F5;
  --thought-border: #DFE5E0;

  /* 状态色彩 */
  --danger: #AA443D;
  --danger-hover: #933933;
  --danger-soft: #FCF1F0;
  --success: #355E4E;
  --success-soft: #EDF3EE;
  --warning: #B37424;
  --warning-soft: #FDF6EC;

  /* 尺寸圆角 */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* 阴影规范 */
  --shadow-xs: 0 1px 2px rgba(30, 40, 35, 0.03);
  --shadow-sm: 0 1px 3px rgba(30, 40, 35, 0.05), 0 1px 2px rgba(30, 40, 35, 0.03);
  --shadow-md: 0 4px 12px -2px rgba(30, 40, 35, 0.07);
  --shadow-modal: 0 20px 48px -10px rgba(25, 35, 30, 0.18), 0 0 1px rgba(25, 35, 30, 0.12);

  /* 兼容旧别名 */
  --bg-paper: var(--bg-canvas);
  --paper: var(--bg-canvas);
  --surface: var(--bg-surface);
  --ink: var(--ink-primary);
  --muted: var(--ink-muted);
  --line: var(--border-line);
  --line-subtle: var(--border-subtle);
  --accent-sage: var(--accent);
  --accent-warm: #F4EFEB;
  --shadow-card: var(--shadow-sm);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg-canvas: #171C19;
  --bg-surface: #202723;
  --bg-subtle: #29322D;
  --bg-hover: #323D37;
  --bg-active: #3C4942;

  --ink-primary: #E8EDE9;
  --ink-secondary: #A4B2AA;
  --ink-muted: #74837B;
  --ink-disabled: #4F5C55;

  --border-line: #333F38;
  --border-subtle: #28322C;
  --border-focus: #528A73;

  --accent: #528A73;
  --accent-hover: #629D84;
  --accent-active: #72AC94;
  --accent-soft: rgba(82, 138, 115, 0.16);
  --accent-border: rgba(82, 138, 115, 0.32);

  --user-bubble-bg: #27362E;
  --user-bubble-border: #3A4E43;
  --user-bubble-ink: #EAF0EC;
  --assistant-bubble-bg: #202723;
  --assistant-bubble-border: #333F38;

  --thought-bg: #1B211D;
  --thought-border: #2D3730;

  --danger: #D4584E;
  --danger-hover: #E26E64;
  --danger-soft: rgba(212, 88, 78, 0.14);
  --success: #528A73;
  --success-soft: rgba(82, 138, 115, 0.14);
  --warning: #D6973E;
  --warning-soft: rgba(214, 151, 62, 0.14);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.65);

  --bg-paper: var(--bg-canvas);
  --paper: var(--bg-canvas);
  --surface: var(--bg-surface);
  --ink: var(--ink-primary);
  --muted: var(--ink-muted);
  --line: var(--border-line);
  --line-subtle: var(--border-subtle);
  --accent-sage: var(--accent);
  --accent-warm: #232C27;
  --shadow-card: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   2. 基础重置与严格三级字阶体系
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg-canvas);
  color: var(--ink-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  line-height: 1.65;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* 严格一级：标题 (Title: 15-17px, 加粗 600) */
h1, h2, h3, h4 {
  color: var(--ink-primary);
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}
h1 { font-size: 17px; }
h2 { font-size: 15.5px; }
h3 { font-size: 14px; }

/* 严格二级：正文 (Body: 13.5px, 正常 400) */
p {
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0 0 8px;
}
p:last-child {
  margin-bottom: 0;
}

/* 严格三级：备注/辅助信息 (Meta: 12px, 次级色/弱显色) */
.meta, .muted, small {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
}

code, pre {
  font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   3. 顶部导航与品牌区 (Header & Navigation)
   -------------------------------------------------------------------------- */
header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px max(18px, calc((100vw - 1140px)/2));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-line);
  backdrop-filter: blur(12px);
  gap: 14px;
  min-height: 48px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink-primary);
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.brand .brand-of {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-muted);
  margin: 0 4px;
}

.brand:hover {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

nav {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-wrap: wrap;
}

nav button {
  min-height: 29px;
  height: 29px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-secondary);
  font-size: 12.5px;
  font-weight: 450;
  cursor: pointer;
  box-shadow: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

nav button:hover {
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

nav button[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-color: var(--accent-border);
}

/* 细腻极细 SVG 日夜切换图标 */
.theme-toggle {
  min-height: 29px;
  height: 29px;
  width: 29px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
}

.theme-toggle:hover {
  background: var(--bg-subtle);
  color: var(--accent);
  border-color: #CBD3CC;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --------------------------------------------------------------------------
   4. 主容器与全局通用标题栏 (彻底消灭冗余 h1，保证工具栏绝对平移不抖动)
   -------------------------------------------------------------------------- */
main {
  max-width: 1140px;
  margin: 16px auto 60px;
  padding: 0 18px;
}

/* 核心原则：彻底消灭页面内部重复出现的 h1 页面名字！ */
.heading h1 {
  display: none !important;
}

/* 顶栏操作区：高度恒定 32px，按钮绝对居右 */
.heading {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 32px;
  height: 32px;
}

/* 如果当前页面没有操作按钮，收起 heading 避免空占位 */
.heading:not(:has(button)) {
  display: none;
}

.heading .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: none;
}

/* --------------------------------------------------------------------------
   5. 通用操作按钮规范 (区分普通按钮与卡片 .item，追求 2 字与 4 字规整对称)
   -------------------------------------------------------------------------- */
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid var(--border-line);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button:not(.item) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 31px;
  height: 31px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}

button:not(.item):hover {
  background: var(--bg-subtle);
  border-color: #CBD3CC;
}

[data-theme="dark"] button:not(.item):hover {
  border-color: #48544D;
}

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--bg-subtle) !important;
  border-color: var(--border-subtle) !important;
}

button.primary, .primary {
  background: var(--accent) !important;
  color: #FFFFFF !important;
  border-color: var(--accent) !important;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(53, 94, 78, 0.25);
}

button.primary:hover, .primary:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}

button.danger, .danger {
  color: var(--danger) !important;
  border-color: rgba(170, 68, 61, 0.28) !important;
  background: transparent;
  box-shadow: none;
}

button.danger:hover, .danger:hover {
  background: var(--danger-soft) !important;
  border-color: var(--danger) !important;
}

/* 统一输入框与下拉选择框 */
input, textarea, select {
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 12.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input:not([type="checkbox"]):not([type="radio"]), select {
  height: 31px;
  padding: 0 9px;
}

input:hover, textarea:hover, select:hover {
  border-color: #CBD3CC;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  vertical-align: middle;
}

textarea {
  width: 100%;
  padding: 8px 10px;
  line-height: 1.6;
  resize: vertical;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-secondary);
}

/* --------------------------------------------------------------------------
   6. 统一工具栏与筛选器 (同一生态位绝对平移替换，切换零抖动)
   -------------------------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
  min-height: 47px;
  width: 100%;
}

.toolbar label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.toolbar label span.meta {
  color: var(--ink-muted);
  font-size: 11.5px;
}

.toolbar input, .toolbar select {
  height: 29px;
  min-height: 29px;
  padding: 0 8px;
  font-size: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
}

.toolbar input:focus, .toolbar select:focus {
  background: var(--bg-surface);
}

/* 固定各通用字段宽度，切换标签绝不乱跳 */
.toolbar input[name="query"], .toolbar #global-query { width: 220px; }
.toolbar select[name="status"], .toolbar select[name="search_mode"], .toolbar select[name="mode"], .toolbar select[name="sort"], .toolbar select[name="scope"], .toolbar select[name="kind"] { width: 96px; }
.toolbar input[name="tag"], .toolbar input[name="author"], .toolbar input[name="memory_type"] { width: 110px; }
.toolbar input[type="date"] { width: 125px; }
.toolbar button { min-height: 29px; height: 29px; padding: 0 11px; }

/* --------------------------------------------------------------------------
   7. 列表与卡片项 (自适应高度、12px 16px 紧凑内边距、加载更多左对齐)
   -------------------------------------------------------------------------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.item {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 12px 16px !important;
  margin: 0 !important;
  text-align: left !important;
  white-space: normal !important;
  line-height: normal !important;
  border: 1px solid var(--border-line) !important;
  border-radius: var(--radius-md) !important;
  background: var(--bg-surface) !important;
  box-shadow: var(--shadow-xs) !important;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.item:hover {
  background: var(--bg-surface) !important;
  border-color: rgba(53, 94, 78, 0.4) !important;
  box-shadow: var(--shadow-sm) !important;
  transform: translateY(-1px);
}

[data-theme="dark"] .item:hover {
  border-color: rgba(82, 138, 115, 0.45) !important;
}

.item strong {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-primary);
  margin-bottom: 5px;
  line-height: 1.4;
  white-space: normal;
}

.item p {
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

.meta {
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  line-height: 1.4;
  white-space: normal;
}

/* 加载更多按钮：左对齐停靠，与卡片流自然平齐 */
#more, #more-diaries, #library-more, #global-more, #more-candidates {
  display: inline-flex;
  margin: 14px 0 0 0;
  min-height: 31px;
}

/* 胶囊标签 (Pill Tag) */
.tag {
  display: inline-block;
  padding: 1px 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.35;
}

.empty {
  padding: 36px 20px;
  color: var(--ink-muted);
  text-align: center;
  background: var(--bg-surface);
  border: 1px dashed var(--border-line);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin: 10px 0;
}

.panel {
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  margin: 14px 0;
  box-shadow: var(--shadow-xs);
}

.panel h2 {
  margin-bottom: 10px;
}

.narrow {
  max-width: 400px;
  margin: 50px auto;
  box-shadow: var(--shadow-md);
}

/* --------------------------------------------------------------------------
   8. 属性面板规范 (两列属性面板：统一 84px 标签防转弯换行、输入框定宽精致)
   -------------------------------------------------------------------------- */
.properties-shelf, .summary-property-shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin: 12px 0 16px;
}

.prop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-width: 0;
}

.prop-label {
  width: 84px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--ink-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.prop-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
  border: 1px solid var(--border-line);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.prop-input:focus {
  border-color: var(--border-focus);
}

.prop-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

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

/* --------------------------------------------------------------------------
   9. 弹窗详情与编辑器 (详情弹窗右上角钉牢关闭、消灭冗余折叠、呼吸感留白)
   -------------------------------------------------------------------------- */
dialog {
  width: min(800px, calc(100vw - 28px));
  max-height: 86vh;
  padding: 24px 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  color: var(--ink-primary);
  position: fixed;
  inset: 0;
  margin: auto;
  overflow-y: auto;
}

dialog::backdrop {
  background: rgba(20, 26, 23, 0.45);
  backdrop-filter: blur(6px);
}

/* 详情弹窗右上角绝对钉牢的关闭按钮 */
dialog > .close {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 20;
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  color: var(--ink-secondary);
  cursor: pointer;
}
dialog > .close:hover {
  background: var(--bg-hover);
  color: var(--ink-primary);
}

/* 详情弹窗标题与元信息呼吸感 */
dialog h2 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 8px;
  padding-right: 60px; /* 避让右上角关闭按钮 */
  color: var(--ink-primary);
}

dialog > .meta {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

dialog .markdown {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-primary);
  margin: 14px 0 18px;
}



dialog .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* 沉浸式编辑器弹窗 */
dialog:has(.document-editor), dialog:has(.modern-editor) {
  padding: 0;
  overflow: hidden;
}

dialog:has(.document-editor) > .close, dialog:has(.modern-editor) > .close {
  display: none;
}

.document-editor, .modern-editor {
  display: flex;
  flex-direction: column;
  max-height: 86vh;
  background: var(--bg-surface);
}

.editor-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-line);
}

/* 编辑器标题：不再莫名其妙缩成小徽章，恢复为标准的优雅标题 */
.editor-badge {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--ink-primary) !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
}

.editor-canvas {
  padding: 18px 24px 32px;
  overflow-y: auto;
  min-height: 0;
}

.title-input {
  width: 100%;
  font-size: 18px !important;
  font-weight: 600 !important;
  border: none !important;
  border-bottom: 1px solid transparent !important;
  background: transparent !important;
  padding: 6px 0 10px !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: var(--ink-primary);
  line-height: 1.35;
  outline: none !important;
}

.title-input:focus {
  border-bottom-color: var(--border-line) !important;
}

.main-textarea {
  width: 100%;
  min-height: 240px;
  font-size: 13.5px;
  line-height: 1.7;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  color: var(--ink-primary);
}

.main-textarea:focus {
  border-color: var(--border-focus);
}

/* --------------------------------------------------------------------------
   11. 摘要与提示词工作流 (返回居右、输入框定长防转弯、手动整理单行不换行)
   -------------------------------------------------------------------------- */
.summary-generation {
  display: grid;
  gap: 18px;
}

.summary-generation .summary-section-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.summary-generation .summary-section-heading h2 {
  font-size: 15px;
  font-weight: 600;
}

.summary-generation .summary-property-shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.summary-generation .summary-property-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  min-width: 0;
}

/* 提示字绝对禁止折行转弯 */
.summary-generation .summary-property-row > span {
  font-size: 12px;
  color: var(--ink-secondary);
  font-weight: 500;
  white-space: nowrap !important;
  flex-shrink: 0;
}

/* 输入框定宽，精致小巧，绝不无限拉长 */
.summary-generation .summary-property-row input:not([type="checkbox"]) {
  width: 130px !important;
  max-width: 130px !important;
  height: 29px;
  padding: 0 8px;
  font-size: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.summary-generation .summary-property-wide {
  grid-column: 1 / -1;
}
.summary-generation .summary-property-wide input {
  width: 100% !important;
  max-width: 100% !important;
}

/* 手动整理：单行横向排布，不折行 */
.summary-date-range {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.summary-date-range label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
}
.summary-date-range input[type="date"] {
  width: 130px;
  height: 29px;
}

.summary-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.summary-period-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-line);
}

.summary-period-tabs button {
  min-height: 32px;
  height: 32px;
  padding: 0 4px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 13px;
  box-shadow: none;
}

.summary-period-tabs button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.summary-source-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.summary-source-tabs button {
  min-height: 27px;
  height: 27px;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-secondary);
  box-shadow: none;
}

.summary-source-tabs button[aria-selected="true"],
.summary-source-tabs button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.summary-period-editor textarea {
  display: block;
  min-height: 260px;
  padding: 12px 14px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  color: var(--ink-primary);
  background: var(--bg-surface);
  font-size: 13px;
  line-height: 1.65;
  margin-bottom: 10px;
}

.summary-clear-section {
  padding: 16px 20px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-line);
  border-radius: var(--radius-md);
  margin-top: 10px;
}

/* --------------------------------------------------------------------------
   12. 珍藏与新增表达 (双卡片选人设计，温暖精致)
   -------------------------------------------------------------------------- */
.speaker-picker-dialog {
  padding: 4px;
}
.speaker-picker-dialog h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}
.speaker-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}
.speaker-card {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  padding: 16px !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-line) !important;
  background: var(--bg-surface) !important;
  text-align: left !important;
  cursor: pointer;
  white-space: normal !important;
  height: auto !important;
  min-height: 80px !important;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-xs) !important;
}
.speaker-card:hover {
  border-color: var(--accent) !important;
  background: var(--bg-subtle) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm) !important;
}
.speaker-card strong {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-primary);
  margin-bottom: 6px;
}
.speaker-card p {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.5;
  margin: 0;
}

.treasure-reading {
  margin: 16px 0;
}
.treasure-passage {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.treasure-speaker {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   13. 比较面板、凭据与 Markdown 深度排版
   -------------------------------------------------------------------------- */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.comparison .panel {
  margin: 0;
  padding: 12px 14px;
}
.token {
  font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-line);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  user-select: all;
  margin: 8px 0;
}

.markdown {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-primary);
  overflow-wrap: anywhere;
}
.markdown p { margin: 0 0 10px; }
.markdown p:last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 14px 0 6px; }
.markdown h1:first-child, .markdown h2:first-child, .markdown h3:first-child { margin-top: 0; }
.markdown ul, .markdown ol { margin: 6px 0 10px; padding-left: 20px; }
.markdown li { margin-bottom: 3px; }
.markdown blockquote {
  margin: 10px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-secondary);
}
.markdown pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.5;
}
.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
}
.markdown th, .markdown td {
  padding: 6px 10px;
  border: 1px solid var(--border-line);
  text-align: left;
}
.markdown th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--ink-secondary);
}
.markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   14. 响应式与移动端适配
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  header {
    padding: 8px 12px;
    flex-wrap: wrap;
  }
  .properties-shelf, .summary-generation .summary-property-shelf {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .prop-item.full-width, .summary-generation .summary-property-wide {
    grid-column: auto;
  }
dialog {
    width: calc(100vw - 20px);
    padding: 18px 16px;
  }
}

.brand {
  font-family: "Cormorant Garamond", "Didot", "Playfair Display", "Bodoni MT", "Songti SC", "Source Han Serif SC", "Georgia", serif;
  font-size: 21px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.brand .brand-of {
  font-family: "Cormorant Garamond", "Georgia", serif;
  font-style: italic;
  font-size: 16px;
  font-weight: 400;
  color: var(--muted);
  margin: 0 4px;
}

/* Native hidden state must win over reusable list/button display rules. */
[hidden] { display: none !important; }
/* Reserve the scrollbar gutter and page-action row so switching between long
   and short pages keeps the filter frame's top and side edges in place. */
html { scrollbar-gutter: stable; }
main:has(> form.toolbar) > .heading { display: flex !important; height: 32px; min-height: 32px; margin-bottom: 12px; }
.load-more { display: inline-flex; margin: 14px 0 0; min-height: 31px; }

/* Feedback floats below the main navigation instead of moving the page. */
#notice {
  position: fixed;
  top: 64px;
  right: max(18px, calc((100vw - 1140px)/2));
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(400px, calc(100vw - 36px));
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-primary);
}
#notice:empty { display: none; }
#notice.error { border-left-color: var(--danger); }
#notice .notice-close { flex-shrink: 0; width: 22px; height: 22px; min-height: 22px; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: 18px; color: var(--ink-secondary); }
#notice .notice-close:hover { background: var(--bg-subtle); color: var(--ink-primary); }
/* Keep the destructive-action confirmation at its existing compact width. */
dialog:has(.summary-clear-confirm) { width: min(440px, calc(100vw - 28px)); }

/* Detail metadata remains readable and its linked-source controls stay live. */
.detail-properties { display: grid; gap: 8px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.detail-properties h3 { font-size: 12px; font-weight: 500; color: var(--ink-secondary); }
.detail-properties p { margin: 0; }
.detail-properties > div { display: flex; flex-wrap: wrap; gap: 6px; }

/* A long interface address spans the property grid, including the input. */
.summary-generation .summary-property-row.summary-property-wide input:not([type="checkbox"]) { flex: 1 1 0; width: 0 !important; max-width: 100% !important; min-width: 0; }
@media (max-width: 768px) {
  .summary-date-range { flex-wrap: wrap; }
  .summary-generation .summary-section-heading { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .summary-generation .summary-property-row { gap: 8px; }
  .summary-generation .summary-property-row input:not([type="checkbox"]) { width: 42% !important; max-width: 42% !important; min-width: 0; }
  .summary-generation .summary-property-row.summary-property-wide input:not([type="checkbox"]) { width: 0 !important; max-width: 100% !important; }
  .summary-period-tabs { gap: 10px; flex-wrap: wrap; }
  .summary-source-tabs { flex-wrap: wrap; }
}
