/* MyBrain webui — 浅色主题，系统字体栈（无外部运行时请求，D-07/NFR-4 口径） */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #3b66f5;
  --accent-weak: #eef2ff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.hidden { display: none !important; }
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 0.95rem;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { opacity: 0.9; color: #fff; }
.btn.sm { padding: 3px 10px; font-size: 0.85rem; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- token 门 ---- */
.token-gate {
  position: fixed; inset: 0; z-index: 100; background: rgba(246,247,249,0.96);
  display: flex; align-items: center; justify-content: center;
}
.token-gate-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 36px; width: min(360px, 90vw); text-align: center;
  box-shadow: 0 8px 30px rgba(31,41,55,0.08);
}
.token-gate-card h1 { margin: 0 0 8px; font-size: 1.4rem; }
.token-gate-card p { color: var(--muted); font-size: 0.9rem; }
.token-gate-card input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem; margin: 12px 0;
}
.token-error { color: var(--danger) !important; }

/* ---- 顶栏 ---- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.5px; }
.quick-capture { flex: 1 1 320px; display: flex; gap: 8px; min-width: 260px; }
.quick-capture input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.95rem; background: var(--bg);
}
.tabs { display: flex; gap: 4px; }
.tab {
  border: none; background: transparent; padding: 8px 16px; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-size: 0.98rem;
}
.tab.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }

main { flex: 1; width: min(1080px, 100% - 32px); margin: 16px auto; }
.view { display: none; }
.view.active { display: block; }

/* ---- 对话 ---- */
#view-chat { display: none; flex-direction: column; height: calc(100vh - 170px); }
#view-chat.active { display: flex; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px 4px; display: flex; flex-direction: column; gap: 14px; }
.chat-empty { color: var(--muted); text-align: center; margin-top: 12vh; line-height: 2; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.derivation-note {
  align-self: center; background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 6px 14px; border-radius: 999px; font-size: 0.85rem;
}
.citations { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cite-chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 2px 10px; font-size: 0.8rem; cursor: pointer; color: var(--muted);
}
.cite-chip:hover { border-color: var(--accent); color: var(--accent); }
.cite-detail {
  margin-top: 6px; border-left: 3px solid var(--accent); background: var(--bg);
  padding: 8px 12px; font-size: 0.88rem; border-radius: 0 8px 8px 0; color: var(--ink);
}
.chat-input-row { display: flex; gap: 8px; padding-top: 10px; }
.chat-input-row textarea {
  flex: 1; resize: none; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 0.98rem; font-family: inherit; background: var(--card);
}
.chat-error { color: var(--danger); font-size: 0.85rem; align-self: center; }

/* ---- 时间线 ---- */
.month-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.month-label { font-weight: 600; min-width: 110px; text-align: center; }
.heatmap {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 8px 2px; margin-bottom: 14px;
}
.timeline-list { display: flex; flex-direction: column; gap: 18px; }
.day-group h3 {
  margin: 0 0 8px; font-size: 0.95rem; color: var(--muted); font-weight: 600;
  border-bottom: 1px dashed var(--line); padding-bottom: 5px;
}
.item-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.12s;
}
.item-card:hover { border-color: var(--accent); }
.item-card.highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.item-head { display: flex; align-items: center; gap: 8px; }
.type-badge {
  font-size: 0.72rem; border-radius: 6px; padding: 2px 6px; background: var(--accent-weak);
  color: var(--accent); flex-shrink: 0;
}
.item-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.processed { background: var(--ok); }
.status-dot.queued, .status-dot.processing { background: var(--warn); }
.status-dot.failed { background: var(--danger); }
.item-summary { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  background: var(--bg); border-radius: 6px; padding: 1px 8px; font-size: 0.75rem; color: var(--muted);
}
.item-detail { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; font-size: 0.88rem; }
.item-detail pre {
  background: var(--bg); padding: 8px 10px; border-radius: 8px; overflow-x: auto;
  font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; margin: 6px 0;
}
.detail-label { color: var(--muted); font-size: 0.78rem; margin-top: 6px; }

/* ---- 二级信息 ---- */
.bento { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; min-width: 0;
}
.card h2 { margin: 0 0 10px; font-size: 1.02rem; }
.span2 { grid-column: span 2; }
.todo-group { margin-bottom: 12px; }
.todo-group h4 { margin: 0 0 6px; color: var(--muted); font-size: 0.85rem; }
.todo-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: 8px; border: 1px solid transparent; margin-bottom: 4px; background: var(--bg);
}
.todo-row input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; }
.todo-row input[type="checkbox"]:disabled { cursor: not-allowed; }
.todo-row .todo-text { flex: 1; font-size: 0.93rem; }
.todo-row.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-row.dropped .todo-text { color: var(--muted); text-decoration: line-through wavy #d1d5db; }
.due-chip { font-size: 0.75rem; border-radius: 6px; padding: 1px 8px; flex-shrink: 0; }
.due-chip.today { background: #fff7ed; color: var(--warn); border: 1px solid #fed7aa; }
.due-chip.overdue { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.md { font-size: 0.92rem; line-height: 1.7; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { font-size: 1rem; margin: 10px 0 6px; }
.md ul, .md ol { padding-left: 20px; margin: 6px 0; }
.md code { background: var(--bg); border-radius: 4px; padding: 1px 5px; font-size: 0.85em; }
.placeholder { color: var(--muted); font-size: 0.88rem; }
.event-day { margin-bottom: 8px; }
.event-day h4 { margin: 0 0 4px; color: var(--muted); font-size: 0.82rem; }
.event-row {
  display: flex; gap: 8px; align-items: baseline; font-size: 0.9rem;
  padding: 4px 8px; background: var(--bg); border-radius: 8px; margin-bottom: 3px;
}
.event-time { color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0; font-size: 0.82rem; }

.footer {
  display: flex; justify-content: space-between; padding: 8px 20px;
  color: var(--muted); font-size: 0.78rem; border-top: 1px solid var(--line); background: var(--card);
}

@media (max-width: 720px) {
  .bento { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .msg { max-width: 92%; }
  .topbar { gap: 8px; }
}
