/* AInote — 交易思考日记
   视觉基准：Apple Notes
   · 系统字体栈、克制的字重与字号阶梯
   · 弱化边框（hairline）+ 单一强调色（Apple Blue）
   · 输入控件统一为「软底 + 圆角 + 聚焦光环」
   · 留白优先，深色模式同构 */

/* ============ 设计变量 ============ */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #ffffff;
  --sidebar-bg: #f6f6f8;
  --panel-bg: #ffffff;
  --field-bg: #f5f5f7;
  --ai-bg: #fafafc;
  --input-bg: #ffffff;

  --border: #e5e5ea;
  --separator: rgba(60, 60, 67, 0.12);

  --text: #1d1d1f;
  --text-muted: #86868b;
  --text-faint: #aeaeb2;
  --placeholder: #b8b8bd;

  --accent: #007aff;
  --accent-strong: #0066d6;
  --accent-soft: rgba(0, 122, 255, 0.10);
  --on-accent: #ffffff;

  --hover: rgba(0, 0, 0, 0.045);
  --active-bg: rgba(0, 122, 255, 0.12);
  --active-fg: #0a5fcc;
  --chip-bg: #f2f2f7;
  --board-col-bg: #f5f5f7;
  --code-bg: #f2f2f7;
  --code-block-bg: #f7f7f9;
  --q-bg: rgba(0, 122, 255, 0.10);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);

  --scroll-thumb: rgba(0, 0, 0, 0.16);
  --scroll-thumb-hover: rgba(0, 0, 0, 0.28);
}

/* 夜间模式：同一套结构，换一套灰阶 */
body.night {
  --bg: #0a0a0b;
  --sidebar-bg: #161618;
  --panel-bg: #1c1c1e;
  --field-bg: #242426;
  --ai-bg: #101012;
  --input-bg: #1c1c1e;

  --border: #2c2c2e;
  --separator: rgba(255, 255, 255, 0.10);

  --text: #f5f5f7;
  --text-muted: #98989d;
  --text-faint: #6e6e73;
  --placeholder: #5d5d63;

  --accent: #0a84ff;
  --accent-strong: #409cff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --on-accent: #ffffff;

  --hover: rgba(255, 255, 255, 0.06);
  --active-bg: rgba(10, 132, 255, 0.22);
  --active-fg: #8fc4ff;
  --chip-bg: #242426;
  --board-col-bg: #161618;
  --code-bg: #242426;
  --code-block-bg: #1c1c1e;
  --q-bg: rgba(10, 132, 255, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);

  --scroll-thumb: rgba(255, 255, 255, 0.18);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.30);
}

/* ============ 基础 ============ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

::selection { background: var(--active-bg); color: var(--active-fg); }

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ============ 左侧目录 ============ */
#sidebar {
  width: 20%;
  min-width: 200px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--separator);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 16px 14px 10px;
}

.logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex: 1;
}

#newDocBtn,
#settingsBtn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#newDocBtn { font-size: 19px; }
#newDocBtn:hover,
#settingsBtn:hover { background: var(--hover); color: var(--text); }

#docList {
  list-style: none;
  margin: 0;
  padding: 2px 8px 8px;
  overflow-y: auto;
  flex: 1;
}

#docList li { margin: 0; padding: 0; }

.doc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.12s;
}
.doc-row:hover { background: var(--hover); }
#docList li.active > .doc-row {
  background: var(--active-bg);
  color: var(--active-fg);
  font-weight: 500;
}

.doc-toggle {
  width: 12px;
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

.doc-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-add,
.doc-del {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}
.doc-add { color: var(--accent); }
.doc-del { color: var(--text-faint); }
.doc-row:hover .doc-add,
.doc-row:hover .doc-del { opacity: 1; }
.doc-del:hover { color: #ff3b30; }

.doc-child { padding-left: 16px; }

.doc-children { list-style: none; margin: 0; padding: 0; }
.doc-children.collapsed { display: none; }

#emptyHint {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.9;
  padding: 28px 20px;
}

/* ============ 主区域三栏 ============ */
#main { flex: 1; min-width: 0; overflow: hidden; }

.journal-wrap {
  height: 100%;
  display: flex;
  align-items: stretch;
}

.journal-main {
  flex: 0 0 calc(62.5% - 2.5px);
  min-width: 340px;
  overflow-y: auto;
  padding: 32px 44px 96px;
}

.journal-resizer {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  height: 100%;
  transition: background 0.15s;
}
.journal-resizer:hover,
.journal-resizer.active { background: var(--accent); }

.journal-side {
  flex: 0 0 calc(37.5% - 2.5px);
  min-width: 260px;
  height: 100%;
  overflow: hidden;
  border-left: 1px solid var(--separator);
  background: var(--ai-bg);
  display: flex;
  flex-direction: column;
}

/* ============ 记录正文 ============ */
.doc-flow {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 标题 */
.title-zone {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 2px 0 6px;
  min-height: 40px;
}
.title-zone .page-title {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
  margin: 0;
  font-family: var(--font);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text);
}
.title-zone .page-title::placeholder {
  color: var(--placeholder);
  font-weight: 600;
}

/* 字段行：标签（次要色）+ 软底输入框 */
.anchor-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.anchor {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.anchor-line input[type="text"],
.anchor-line input[type="date"],
.anchor-line textarea,
.observe-inline input[type="text"],
.observe-inline input[type="date"],
.note-inline {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: var(--field-bg);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  outline: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.anchor-line input[type="text"]:hover,
.anchor-line input[type="date"]:hover,
.anchor-line textarea:hover,
.observe-inline input:hover,
.note-inline:hover { border-color: var(--border); }

.anchor-line input[type="text"]:focus,
.anchor-line input[type="date"]:focus,
.anchor-line textarea:focus,
.observe-inline input:focus,
.note-inline:focus {
  background: var(--input-bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.anchor-line input::placeholder,
.anchor-line textarea::placeholder,
.observe-inline input::placeholder,
.note-inline::placeholder { color: var(--placeholder); }

.anchor-line textarea {
  resize: none;
  overflow: hidden;
  min-height: 34px;
}

/* 单值输入框统一宽度，行右缘对齐（不像散落的裸文本框） */
.anchor-line input[type="text"] { flex: 1 1 300px; max-width: 300px; font-variant-numeric: tabular-nums; }
.anchor-line input[type="date"] { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.anchor-line input[type="date"]::-webkit-calendar-picker-indicator { display: none; }

/* 品种 + 叙事 同一行 */
.anchor-line.pair-line { align-items: flex-start; gap: 14px; }
.anchor-line.pair-line .pair-symbol { flex: 1 1 32%; min-width: 90px; }
.anchor-line.pair-line .pair-narrative { flex: 1 1 68%; min-width: 140px; }

/* 旧的裸文本行（保留兼容） */
.title-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}
.title-bar input,
.title-bar textarea {
  border: none;
  background: transparent;
  padding: 2px 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  outline: none;
  resize: none;
}

.footer-line { align-items: center; justify-content: flex-end; gap: 12px; margin-top: 6px; }
.footer-line input[type="date"] { flex-shrink: 0; font-size: 13px; color: var(--text-muted); }

.observe-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.observe-inline input[type="date"] { width: 150px; }

/* ============ 图片区 ============ */
.img-zone { min-height: 0; }
.img-zone.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 6px;
  border-radius: 12px;
}

.img-drop {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 34px 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  cursor: pointer;
  background: var(--field-bg);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.img-drop:hover,
.img-drop.drag-over {
  border-color: var(--accent);
  background: var(--input-bg);
  color: var(--accent);
}
.img-drop[hidden] { display: none; }

.img-list {
  display: grid;
  gap: 8px;
  width: 64%;
}
.img-list:empty { display: none; }

.img-list.n-1 { grid-template-columns: 1fr; }
.img-list.n-2 { grid-template-columns: 1fr 1fr; }
.img-list.n-3 { grid-template-columns: 1fr 1fr; }
.img-list.n-3 .img-item:first-child { grid-column: 1 / -1; }
.img-list.n-4 { grid-template-columns: repeat(3, 1fr); }
.img-list.n-4 .img-item:first-child { grid-column: 1 / -1; }
.img-list.n-5 { grid-template-columns: repeat(4, 1fr); }
.img-list.n-5 .img-item:first-child { grid-column: 1 / -1; }
.img-list.n-6 { grid-template-columns: repeat(5, 1fr); }
.img-list.n-6 .img-item:first-child { grid-column: 1 / -1; }

.img-item {
  position: relative;
  border-radius: 8px;
  overflow: visible;
}
.img-frame { position: relative; }
.img-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  cursor: zoom-in;
}
.img-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  backdrop-filter: blur(4px);
}
.img-del:hover { background: rgba(0, 0, 0, 0.8); }

.img-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 44px;
  height: 44px;
  cursor: nwse-resize;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.15s;
}
.img-resize::after {
  content: '';
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(255, 255, 255, 0.9);
  border-bottom: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 0 0 2px 0;
}
.img-frame:hover .img-resize { opacity: 1; }

/* ============ 右侧 AI 栏 ============ */
.chat-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px 12px;
}

.chat-msg { margin-bottom: 14px; }

.chat-msg.user { text-align: right; }
.chat-msg.user .chat-bubble {
  display: inline-block;
  max-width: 85%;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 18px 18px 4px 18px;
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.55;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.ai { text-align: left; }
.chat-msg.ai .chat-ai {
  display: inline-block;
  max-width: 100%;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}
.chat-msg.ai .chat-ai p { margin: 0.35em 0; }
.chat-msg.ai .chat-ai ul,
.chat-msg.ai .chat-ai ol { margin: 0.35em 0; padding-left: 1.4em; }
.chat-msg.ai .chat-ai code {
  background: var(--code-bg);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.chat-msg.ai .chat-ai pre {
  background: var(--code-block-bg);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.chat-msg.ai.loading .chat-ai { color: var(--text-muted); }

.chat-input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px 16px;
  border-top: 1px solid var(--separator);
}

.chat-tools {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}
.chat-tools button {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 9px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.chat-tools button:hover { background: var(--hover); color: var(--text); }

.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 5px 5px 14px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  max-height: 160px;
  line-height: 1.5;
  padding: 7px 0;
}
.chat-input-box textarea::placeholder { color: var(--placeholder); }

#chatSend {
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 15px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
#chatSend:hover { background: var(--accent-strong); }
#chatSend:disabled { opacity: 0.45; cursor: default; }

/* ============ 设置面板 ============ */
#settingsModal { position: fixed; inset: 0; z-index: 1000; }
.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(3px);
}
.settings-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 420px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--separator);
  font-size: 15px;
  font-weight: 600;
}
#settingsClose {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
#settingsClose:hover { background: var(--hover); color: var(--text); }

.settings-body { padding: 18px; overflow-y: auto; }

.settings-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0 0 16px;
}

.settings-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  margin: 0 0 6px;
}

#apiKeyInput,
#tavilyKeyInput,
#systemPromptInput,
.instrument-manage-select-row select,
.instrument-manage-add input,
.instrument-picker-panel select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text);
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#apiKeyInput,
#tavilyKeyInput { margin-bottom: 8px; }
#systemPromptInput {
  font-size: 13px;
  line-height: 1.65;
  margin-bottom: 8px;
  resize: vertical;
}
#apiKeyInput:focus,
#tavilyKeyInput:focus,
#systemPromptInput:focus,
.instrument-manage-select-row select:focus,
.instrument-manage-add input:focus,
.instrument-picker-panel select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-status { font-size: 12px; color: #ff3b30; margin: 4px 0 12px; }
.settings-status.ok { color: #34c759; }

.settings-actions { margin-top: 18px; text-align: right; }

#apiKeySave {
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 9px;
  padding: 8px 20px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
#apiKeySave:hover { background: var(--accent-strong); }
#apiKeySave:disabled { opacity: 0.45; cursor: default; }

/* 标的管理 */
.instrument-manage-select-row { display: flex; gap: 8px; margin-bottom: 8px; }
.instrument-manage-select-row select { flex: 1; min-width: 0; }
.instrument-manage-select-row button,
.instrument-manage-add button {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.instrument-manage-select-row button:hover,
.instrument-manage-add button:hover { background: var(--hover); }

.instrument-manage-add { display: flex; gap: 8px; margin-bottom: 8px; }
.instrument-manage-add input { flex: 1; min-width: 0; }

.instrument-manage-list { display: flex; flex-direction: column; gap: 6px; }
.instrument-manage-row { display: flex; align-items: center; gap: 8px; }
.instrument-manage-name { flex: 1; }
.instrument-manage-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12.5px;
  padding: 2px 6px;
}
.instrument-manage-btn:hover { color: var(--accent); }

.instrument-picker-panel { max-width: 360px; }

/* ============ 回收站 ============ */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--separator);
}
#trashBtn {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 7px 10px;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#trashBtn:hover { background: var(--hover); color: var(--text); }

#trashModal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(3px);
}
#trashModal[hidden] { display: none; }

.trash-panel {
  width: 440px;
  max-width: calc(100vw - 48px);
  max-height: 70vh;
  background: var(--panel-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.trash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--separator);
  font-size: 15px;
  font-weight: 600;
}
#trashClose {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
}
.trash-body { padding: 8px; overflow-y: auto; }
.trash-empty {
  text-align: center;
  color: var(--text-faint);
  padding: 32px 20px;
  font-size: 13px;
}

.trash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--separator);
  font-size: 13.5px;
  font-weight: 600;
}
.trash-panel-head button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.trash-panel-head button:hover { background: var(--hover); }

.trash-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 7px;
  cursor: default;
  transition: background 0.12s;
}
.trash-item:hover { background: var(--hover); }
.trash-title { flex: 1; font-size: 13px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-date { font-size: 11.5px; color: var(--text-faint); }
.trash-item button {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

.trash-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--separator);
}
.trash-preview-head span { font-size: 16px; font-weight: 600; }
.trash-preview-head button {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  margin-left: 6px;
  font-family: var(--font);
  font-size: 12.5px;
}
.trash-preview-head button:hover { background: var(--hover); }
.trash-preview-body { max-height: 60vh; overflow-y: auto; padding: 0 22px; }
.trash-preview-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--separator);
  white-space: pre-wrap;
  font-size: 14.5px;
  line-height: 1.75;
}
.trash-view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--separator);
}
.trash-view-head span { font-size: 16px; font-weight: 600; }
.trash-view-head button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
}

/* ============ 分隔条 / 拖拽 ============ */
#sidebarResizer {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
}
#sidebarResizer:hover,
#sidebarResizer:active { background: var(--accent); }

.doc-row.drop-target { background: var(--active-bg); }

/* ============ 顶部工具栏 ============ */
.journal-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  padding: 0 24px 6px;
}
#boardBtn,
#themeBtn {
  border: none;
  background: none;
  border-radius: 7px;
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
#boardBtn:hover,
#themeBtn:hover { background: var(--hover); color: var(--text); }

/* ============ 看板 ============ */
.board-modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(4px);
}
.board-modal[hidden] { display: none; }

.board-panel {
  position: absolute;
  inset: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--separator);
  font-size: 16px;
  font-weight: 600;
}
#boardClose {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
#boardClose:hover { background: var(--hover); color: var(--text); }

.board-tabs { display: flex; gap: 6px; padding: 14px 22px 10px; flex-wrap: wrap; }
.board-tab {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  border-radius: 999px;
  padding: 5px 14px;
  font-family: var(--font);
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.board-tab:hover { background: var(--hover); color: var(--text); }
.board-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}

.board-body {
  flex: 1;
  display: flex;
  gap: 14px;
  overflow: auto;
  padding: 6px 22px 22px;
  align-items: flex-start;
}

.board-col {
  min-width: 240px;
  max-width: 280px;
  flex-shrink: 0;
  background: var(--board-col-bg);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.board-col-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 4px 4px;
}
.board-col-name {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-col-count { font-size: 11.5px; color: var(--text-faint); }
.board-col-sum { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.board-col-sum.pos { color: #34c759; }
.board-col-sum.neg { color: #ff3b30; }

.board-card {
  background: var(--panel-bg);
  border: 1px solid var(--separator);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.board-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.board-card-img { width: 100%; height: 104px; object-fit: cover; display: block; }
.board-card-info { padding: 9px 11px; }
.board-card-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-card-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.board-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.board-tag {
  font-size: 10.5px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 5px;
  padding: 2px 6px;
}
body.night .board-tag { color: var(--accent); }
.board-empty { color: var(--text-faint); text-align: center; padding: 48px; font-size: 13px; }

/* ============ 价差 ============ */
.spread {
  font-size: 13px;
  font-weight: 600;
  margin-left: 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.spread.pos { color: #34c759; }
.spread.neg { color: #ff3b30; }

/* ============ 图片放大 ============ */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  backdrop-filter: blur(6px);
}
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 6px; }

/* ============ 标的下拉 ============ */
.instrument-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  background-color: var(--field-bg);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 10px 6px;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 30px 7px 10px;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  outline: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.instrument-select:hover { border-color: var(--border); }
.instrument-select:focus {
  background-color: var(--input-bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.instrument-select option { color: var(--text); background: var(--panel-bg); }

/* ============ 行情思考 ============ */
.thoughts-block { width: 100%; margin-top: 6px; }
#thoughtList { width: 100%; }
.thought-item {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--separator);
}
.thought-item:last-child { border-bottom: none; }
.thought-text {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: transparent;
  resize: none;
  overflow: hidden;
  outline: none;
  padding: 0;
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--text);
}
.thought-text::placeholder { color: var(--placeholder); }
.thought-ts {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.4;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* 无障碍：键盘聚焦有清晰反馈，鼠标点击不打扰 */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ 访问 PIN ============ */
.settings-pin-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.settings-pin-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text);
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 4px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.settings-pin-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.settings-pin-row button,
#lockBtn {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.settings-pin-row button:hover,
#lockBtn:hover { background: var(--hover); }
#lockBtn { margin-right: 8px; }
/* ============ 回收站：展开/收起（主目录保持可见） ============ */
#trashPanel {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  max-height: 46%;
  border-top: 1px solid var(--separator);
  background: var(--sidebar-bg);
}
#trashPanel .trash-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
#trashBtn.active {
  background: var(--active-bg);
  color: var(--active-fg);
}

/* ============ 品种 + 叙事：像文章正文，无框、基线对齐 ============ */
.anchor-line.pair-line {
  align-items: baseline;
  gap: 8px;
}
.anchor-line.pair-line .pair-symbol {
  flex: 1 1 30%;
  min-width: 80px;
  border: none;
  background-color: transparent;
  border-radius: 0;
  padding: 0 18px 0 0;
  background-position: right 5px center;
  line-height: 1.7;
  box-shadow: none;
}
.anchor-line.pair-line .pair-symbol:hover,
.anchor-line.pair-line .pair-symbol:focus {
  border: none;
  background-color: transparent;
  box-shadow: none;
}
.anchor-line.pair-line .pair-narrative {
  flex: 1 1 70%;
  min-width: 140px;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
  line-height: 1.7;
  min-height: 0;
  box-shadow: none;
}
.anchor-line.pair-line .pair-narrative:hover,
.anchor-line.pair-line .pair-narrative:focus {
  border: none;
  background: transparent;
  box-shadow: none;
}