/* ============================================================
   梦食 Feedream — 样式
   移动优先，900px 以上切换为左右双栏
   ============================================================ */

:root {
  --paper: #FAF6EF;
  --paper-2: #F3EDE2;
  --surface: #FFFFFF;
  --ink: #2B2A27;
  --ink-soft: #5B564E;
  --muted: #9A9287;
  --line: #E7DFD2;
  --navy: #1F3864;
  --navy-soft: #2E4B7A;
  --accent: #A8442C;
  --accent-soft: #C9603F;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(43, 42, 39, .04), 0 6px 18px rgba(43, 42, 39, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button, textarea, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding-top: calc(12px + env(safe-area-inset-top));
}

.brand { display: flex; align-items: baseline; gap: 7px; min-width: 0; }

/* 顶栏里镜像的貘，比「梦食」两个字略大 */
.brand-icon {
  width: 33px;
  height: 33px;
  align-self: center;
  flex: 0 0 auto;
  transform: scaleX(-1);
  user-select: none;
  -webkit-user-drag: none;
}

.brand-mark {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--navy);
}

.brand-sub {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--muted);
}

.topbar-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ---------------- 按钮 ---------------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}

.btn-ghost {
  color: var(--ink-soft);
  border-color: var(--line);
  background: #fff;
}
.btn-ghost:hover { border-color: var(--muted); color: var(--navy); }

.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  padding: 8px 20px;
}
.btn-primary:hover { background: var(--navy-soft); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }

.btn-mini {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 3px 6px;
  border-radius: 6px;
}
.btn-mini:hover { color: var(--accent); background: var(--paper-2); }

/* ---------------- 工作区 ---------------- */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.panel {
  display: none;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  flex: 1 1 auto;
}

body[data-view="cards"]    .panel-cards    { display: flex; }
body[data-view="timeline"] .panel-timeline { display: flex; }

/* ---------------- 捕获区 ---------------- */
.capture {
  flex: 0 0 auto;
  margin: 8px 16px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 10px;
  transition: border-color .18s, box-shadow .18s;
}
.capture:focus-within {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31, 56, 100, .08), var(--shadow);
}

#captureInput {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 15.5px;
  line-height: 1.65;
  min-height: 52px;
  max-height: 160px;
}
#captureInput::placeholder { color: var(--muted); }

.capture-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.capture-hint { font-size: 11.5px; color: var(--muted); }

/* ---------------- 区块标题 ---------------- */
.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 18px 8px;
}
.panel-head-timeline { padding-top: 22px; }

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--navy);
}

.count {
  display: inline-block;
  min-width: 20px;
  margin-left: 2px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  vertical-align: 1px;
}

.panel-hint { font-size: 11.5px; color: var(--muted); }

/* ---------------- 搜索 ---------------- */
.searchbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 16px 8px;
  padding: 0 10px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.searchbar:focus-within {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31, 56, 100, .07);
}

.search-icon {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  transform: translateY(-1px);
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13.5px;
}
.search-input::placeholder { color: #B9B1A4; }

.search-clear {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.search-clear:hover { background: var(--muted); color: #fff; }

mark {
  background: rgba(200, 118, 40, .25);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* 搜索状态下，拖动视觉上弱化 */
#tlList.is-filtered .tl-dot { opacity: .45; }
#tlList.is-filtered .tl-handle { cursor: not-allowed; }

/* 时间标签命中搜索时也标出来 */
.tl-label.is-match {
  background: rgba(200, 118, 40, .13);
  border-radius: 4px;
}

/* ---------------- 碎片类型：事件 / 背景 ---------------- */
.capture-kinds {
  display: flex;
  gap: 6px;
}

.kind-opt {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, border-color .15s, color .15s;
}
.kind-opt:hover { border-color: var(--muted); color: var(--ink-soft); }
.kind-opt.is-active[data-kind="character"] {
  background: #266E64;
  border-color: #266E64;
  color: #fff;
}
.kind-opt.is-active[data-kind="background"] {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: #fff;
}
.kind-opt.is-active[data-kind="other"] {
  background: #7A6F62;
  border-color: #7A6F62;
  color: #fff;
}

/* 新建分类 / 删除分类 */
.kind-add {
  flex: 0 0 auto;
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: 20px;
  height: 24px;
  padding: 0 8px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.kind-add:hover { border-color: var(--navy); color: var(--navy); }

.kind-del {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  color: #B8B0A3;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.kind-del:hover { color: var(--accent); background: rgba(168, 68, 44, .08); }

.kind-edit {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  border-radius: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: #B8B0A3;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.kind-edit:hover { color: var(--navy); background: var(--paper-2); }
.kind-opt.is-active[data-kind="event"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* ---------------- 类型筛选 ---------------- */
.filterbar {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  margin: 0 16px 6px;
  padding-left: 2px;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--muted); color: var(--ink-soft); }
.chip.is-active {
  background: var(--paper-2);
  border-color: var(--ink-soft);
  color: var(--navy);
}

/* ---------------- 卡片上的类型标签 ---------------- */
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.kind-tag {
  flex: 0 0 auto;
  border: none;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: filter .15s;
}
.kind-tag.is-character {
  background: rgba(38, 110, 100, .13);
  color: #266E64;
}
.kind-tag.is-background {
  background: rgba(168, 68, 44, .12);
  color: var(--accent);
}
.kind-tag.is-event {
  background: rgba(31, 56, 100, .08);
  color: var(--navy);
}
.kind-tag.is-other {
  background: rgba(122, 111, 98, .13);
  color: #6B6154;
}
.kind-tag:hover { filter: brightness(.93); }

/* ---------------- 时间轴：收起 / 展开 ---------------- */
.head-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tl-collapse-btn {
  display: none;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  transition: border-color .15s, color .15s;
}
.tl-collapse-btn:hover { border-color: var(--navy); color: var(--navy); }

.tl-expand-btn {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 18px 0;
  border: none;
  background: transparent;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  cursor: pointer;
  transition: background .15s;
}
.tl-expand-btn:hover { background: rgba(31, 56, 100, .04); }
.tl-expand-chev { font-size: 14px; opacity: .55; }
.tl-expand-text { writing-mode: vertical-rl; }

/* ---------------- 滚动区 ---------------- */
.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

/* ---------------- 卡片 ---------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px 10px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  animation: rise .22s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.card.is-linked { border-left: 3px solid var(--accent-soft); }

.card-text {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.card-tools { display: flex; align-items: center; gap: 2px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(168, 68, 44, .08);
  border-radius: 20px;
  padding: 2px 9px;
}

/* 已进时间轴的卡片：显示它带着的时间标注 */
.badge-linked {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* 编辑态 */
.card-edit textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  resize: vertical;
  min-height: 74px;
  outline: none;
  background: var(--paper);
  line-height: 1.65;
}
.card-edit textarea:focus { border-color: var(--navy); background: #fff; }
.card-edit-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---------------- 时间轴 ---------------- */
.tl-item {
  position: relative;
  display: flex;
  gap: 12px;
  padding-bottom: 4px;
}

.tl-axis {
  position: relative;
  flex: 0 0 22px;
  display: flex;
  justify-content: center;
}
.tl-axis::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: -4px;
  width: 1px;
  background: var(--line);
}
.tl-item:first-child .tl-axis::before { top: 16px; }
.tl-item:last-child  .tl-axis::before { bottom: calc(100% - 16px); }

.tl-dot {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  margin-top: 11px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--paper);
  transition: transform .15s, background .15s;
}

.tl-item:hover .tl-dot { transform: scale(1.25); }

/* 拖动热区：盖住圆点，鼠标和手指都能按住 */
.tl-handle {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 30px;
  z-index: 3;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.is-dragging-tl {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}
body.is-dragging-tl .tl-handle { cursor: grabbing; }

.tl-item.is-dragging { z-index: 20; }
.tl-item.is-dragging .tl-dot {
  background: var(--accent);
  transform: scale(1.35);
}
.tl-item.is-dragging .tl-body {
  border-color: var(--accent-soft);
  box-shadow: 0 14px 32px rgba(43, 42, 39, .18), 0 2px 6px rgba(43, 42, 39, .08);
}
.tl-item.is-dragging .tl-pos { opacity: .45; }

#tlList { position: relative; }

/* 时间轴上显示碎片自带的标签 */
.tl-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 7px 0 1px;
}
.tl-tag {
  font-size: 10.5px;
  line-height: 1.5;
  padding: 1px 8px;
  border-radius: 20px;
  background: var(--paper-2);
  color: var(--ink-soft);
  white-space: nowrap;
}

.tl-drop-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 68, 44, .12);
  pointer-events: none;
  z-index: 10;
}

.tl-body {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 13px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.tl-label {
  display: block;
  width: 100%;
  border: none;
  border-bottom: 1px dashed var(--line);
  background: transparent;
  outline: none;
  padding: 2px 0 5px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  transition: border-color .15s;
}
.tl-label::placeholder { color: #C4BCAF; font-weight: 500; letter-spacing: 0; }
.tl-label:focus { border-bottom-color: var(--accent); }

.tl-text {
  margin: 8px 0 6px;
  font-size: 15px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.tl-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

.tl-pos {
  margin-right: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 空状态 ---------------- */
.empty {
  margin: 28px 6px;
  padding: 26px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .45);
}
.empty-title { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.empty-text { font-size: 12.5px; line-height: 1.75; }

/* ---------------- 底部标签（仅移动端） ---------------- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  border-top: 1px solid var(--line);
  background: rgba(250, 246, 239, .96);
  backdrop-filter: blur(8px);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  padding: 9px 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  transition: color .15s;
}
.tab-icon { font-size: 15px; line-height: 1; }
.tab.is-active { color: var(--navy); }

/* ---------------- 状态条 ---------------- */
.statusbar {
  flex: 0 0 auto;
  padding: 0 16px 10px;
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: rgba(43, 42, 39, .93);
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 84vw;
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

/* ---------------- 故事标题与梗概 ---------------- */
.story {
  flex: 0 0 auto;
  padding: 14px 16px 0;
}

.story-title {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  padding: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--navy);
  line-height: 1.4;
}
.story-title::placeholder { color: #C9C1B4; font-weight: 600; }

.story-synopsis-wrap { margin-top: 1px; }

.story-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 5px 0;
  text-align: left;
  cursor: pointer;
}

.story-toggle-label {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent);
}

.story-preview {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}

.chev {
  flex: 0 0 auto;
  width: 15px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  transition: transform .18s, color .15s;
}
.story-toggle:hover .chev { color: var(--accent); }
.story-synopsis-wrap.is-collapsed .chev { transform: rotate(-90deg); }
.story-synopsis-wrap:not(.is-collapsed) .story-preview { display: none; }
.story-synopsis-wrap.is-collapsed .story-synopsis-body { display: none; }

.story-synopsis-body { margin-top: 5px; }

.story-synopsis {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  resize: vertical;
  min-height: 58px;
  outline: none;
  line-height: 1.7;
  font-size: 14px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.story-synopsis:focus { border-color: var(--navy); }
.story-synopsis::placeholder { color: #C4BCAF; }

.story-synopsis-hint {
  text-align: right;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------------- 时间轴：行内编辑 ---------------- */
.tl-text-edit {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 9px 11px;
  margin: 8px 0 6px;
  resize: vertical;
  min-height: 76px;
  outline: none;
  line-height: 1.7;
  font-size: 14.5px;
  transition: border-color .15s, background .15s;
}
.tl-text-edit:focus { border-color: var(--navy); background: #fff; }

.tl-tools-edit { gap: 8px; }

.tl-item.is-editing .tl-body {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31, 56, 100, .07), var(--shadow);
}

/* ---------------- 时间轴：直接添加 ---------------- */
.tl-add { padding: 2px 0 10px; }

.tl-add-btn {
  width: 100%;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, .5);
  border-radius: var(--radius);
  padding: 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}
.tl-add-btn:hover {
  border-color: var(--accent-soft);
  color: var(--accent);
  background: #fff;
}

.tl-add-form {
  background: var(--surface);
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  padding: 12px 13px 10px;
  box-shadow: 0 0 0 3px rgba(31, 56, 100, .07), var(--shadow);
}

#tlNewText {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  min-height: 52px;
  font-size: 15px;
  line-height: 1.7;
}
#tlNewText::placeholder { color: var(--muted); }

.tl-add-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}
.tl-add-hint { font-size: 11px; color: var(--muted); }
.tl-add-btns { display: flex; gap: 8px; }

/* ---------------- 时间轴：在某条下方直接插入 ---------------- */
.tl-insert {
  margin-left: 34px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  padding: 11px 13px 10px;
  box-shadow: 0 0 0 3px rgba(31, 56, 100, .07), var(--shadow);
  animation: rise .18s ease-out;
}

.tl-insert-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  min-height: 52px;
  font-size: 15px;
  line-height: 1.7;
}
.tl-insert-input::placeholder { color: var(--muted); }

.tl-insert-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}
.tl-insert-hint { font-size: 11px; color: var(--muted); }
.tl-insert-btns { display: flex; gap: 8px; }

.btn-mini-add {
  color: var(--accent);
  font-weight: 600;
}
.btn-mini-add:hover { color: #fff; background: var(--accent); }

/* ============================================================
   屏幕切换：书架 / 工作台
   ============================================================ */
body[data-screen="shelf"] .workspace,
body[data-screen="shelf"] .tabbar { display: none; }
body[data-screen="work"] .shelf { display: none; }

body[data-screen="shelf"] #btnBackShelf { display: none; }
body[data-screen="work"] #btnNewWork { display: none; }

/* ---------------- 书架 ---------------- */
.shelf {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 16px 40px;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* 右上角的貘：中心对准内容区右边缘（内容区 1000px 居中，图标 170px） */
.shelf-mascot {
  position: absolute;
  top: 4px;
  right: max(20px, calc(50vw - 585px));
  width: 170px;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* 窄屏藏起来，避免压到内容 */
@media (max-width: 979px) {
  .shelf-mascot { display: none; }
}

/* 手机端顶栏空间不够：不显示图标，恢复到原来的纯文字品牌 */
@media (max-width: 899px) {
  .brand-icon { display: none; }

  /* 顶栏让出空间，避免按钮被挤出屏幕 */
  .brand-sub { display: none; }
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .btn { padding-left: 9px; padding-right: 9px; }
}

.shelf-intro { margin: 0 2px 18px; }
.shelf-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 6px;
}
.shelf-intro h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .02em;
}

.sort-btn {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 20px;
  padding: 3px 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.sort-btn:hover {
  border-color: var(--muted);
  color: var(--navy);
  background: var(--paper-2);
}

/* 书架搜索框：和标题左对齐，上方留出间距
   （用 .shelf-intro 提高优先级，压过下面桌面端的 .searchbar 边距） */
.shelf-intro .shelf-search {
  margin: 18px 0 0;
  max-width: 420px;
}
.shelf-intro p { margin: 0; font-size: 12.5px; color: var(--muted); }

.shelf-list { display: flex; flex-direction: column; gap: 12px; }

.work {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.work:hover { border-color: var(--accent-soft); }

.work-main { padding: 16px 16px 13px; cursor: pointer; }

.work-title {
  margin: 0 26px 6px 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.4;
}

.work-syn {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.is-empty-text { color: #C0B8AB; }

.work-meta {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.work-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.work-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper-2);
  border-radius: 20px;
  padding: 2px 9px;
}
.work-tag.is-more { color: var(--muted); }

.work-del {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  color: #C4BCAF;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.work-del:hover { color: var(--accent); background: rgba(168, 68, 44, .08); }

/* 置顶按钮（在统计行最右） */
.work-pin {
  margin-left: auto;
  align-self: center;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.work-pin:hover { border-color: var(--navy); color: var(--navy); }
.work.is-pinned .work-pin {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* 置顶作品：加粗的深蓝边框，四边一致 */
.work.is-pinned {
  border: 2px solid var(--navy);
  box-shadow: 0 6px 18px rgba(31, 56, 100, .12);
}
.work.is-pinned:hover { border-color: var(--navy); }
.work.is-pinned .work-title { color: var(--navy); }

.shelf-empty { margin-top: 30px; }

/* 书架末尾的「新建作品」空格子 */
.work-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 132px;
  padding: 24px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: #B8B0A3;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.work-add:hover {
  border-color: var(--accent-soft);
  color: var(--accent);
  background: rgba(255, 255, 255, .55);
}
.work-add-plus { font-size: 26px; line-height: 1; }
.work-add-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
}

/* ---------------- 卡片标签 ---------------- */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  background: var(--paper-2);
  overflow: hidden;
}

.tag-name {
  border: none;
  background: transparent;
  padding: 2px 4px 2px 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .15s;
}
.tag-name:hover { color: var(--accent); }

.tag-x {
  border: none;
  background: transparent;
  padding: 2px 7px 2px 2px;
  font-size: 12px;
  line-height: 1;
  color: #B8B0A3;
  cursor: pointer;
  transition: color .15s;
}
.tag-x:hover { color: var(--accent); }

.tag-add {
  border: none;
  background: transparent;
  padding: 2px 5px;
  font-size: 11px;
  font-weight: 600;
  color: #B8B0A3;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tag-add:hover { color: var(--accent); background: var(--paper-2); }

.tag-input {
  width: 112px;
  border: 1px solid var(--navy);
  border-radius: 20px;
  background: #fff;
  padding: 2px 10px;
  font-size: 11px;
  outline: none;
}

/* ---------------- 捕获区：排名行 / 标签 / 折叠 ---------------- */
.capture-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.capture-toggle {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.capture-toggle:hover { color: var(--navy); background: var(--paper-2); }

.capture.is-collapsed .capture-body { display: none; }
.capture.is-collapsed {
  padding-bottom: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.capture.is-collapsed:hover { border-color: var(--muted); }

/* 收起时：隐藏「收起」按钮，只留一行小字提示 */
.capture-hint-expand {
  display: none;
  font-size: 11.5px;
  color: var(--muted);
  user-select: none;
}
.capture.is-collapsed .capture-toggle { display: none; }
.capture.is-collapsed .capture-hint-expand { display: inline; }

.capture-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 8px;
  min-height: 22px;
}

.tag-chip-text {
  padding: 2px 4px 2px 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}

.tag-input-capture {
  width: 86px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: var(--paper);
  padding: 2px 10px;
  font-size: 11px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.tag-input-capture:focus { background: #fff; border-color: var(--navy); }
.tag-input-capture::placeholder { color: #B9B1A4; }

/* ---------------- 标签联想 ---------------- */
.tag-cancel {
  border: none;
  background: transparent;
  padding: 2px 5px;
  font-size: 14px;
  line-height: 1;
  color: #B8B0A3;
  border-radius: 50%;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tag-cancel:hover { color: var(--accent); background: var(--paper-2); }

.tag-suggest {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0;
}

.tag-suggest-item {
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.tag-suggest-item:hover {
  border-style: solid;
  border-color: var(--accent-soft);
  color: var(--accent);
  background: rgba(168, 68, 44, .06);
}

/* ---------------- 碎片面板：整体滚动 ---------------- */
.panel-cards { position: relative; }

.panel-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 28px;
}

#cardList { padding: 4px 16px 0; }

/* ---------------- 右下角悬浮快捷键 ---------------- */
.fab-stack {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 30;
}

.fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 6px 18px rgba(43, 42, 39, .16);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(43, 42, 39, .2); }
.fab:active { transform: translateY(0); }

.fab-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-size: 22px;
}
.fab-primary:hover { background: var(--navy-soft); }

/* ============================================================
   桌面端：左右双栏
   ============================================================ */
@media (min-width: 900px) {
  body { font-size: 15px; }

  .panel { display: flex !important; }

  .panel-cards    { border-right: 1px solid var(--line); }

  .panel-timeline { background: linear-gradient(180deg, #FCFAF6 0%, var(--paper) 100%); }

  /* 双栏各占一半，宽度不随内容长短变化 */
  .panel-cards, .panel-timeline { flex: 1 1 0; min-width: 0; }

  .story { padding: 20px 24px 0; }
  .story-title { font-size: 22px; }
  .story-synopsis-wrap { margin-top: 4px; }
  .story-synopsis { min-height: 64px; }

  .capture { margin: 10px 22px 12px; }
  .panel-head { padding: 24px 24px 10px; }
  .searchbar { margin: 0 24px 10px; }
  .filterbar { margin: 0 24px 8px; }
  .scroll { padding: 4px 22px 32px; }
  #cardList { padding: 4px 22px 0; }

  .tl-collapse-btn { display: inline-flex; }

  /* 书架：桌面端两列以上 */
  .shelf { padding: 34px 28px 56px; }
  .shelf-intro { max-width: 1000px; margin: 0 auto 22px; }
  .shelf-intro h1 { font-size: 26px; }
  .shelf-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    max-width: 1000px;
    margin: 0 auto;
  }
  .shelf-empty { max-width: 1000px; margin-left: auto; margin-right: auto; }

  /* 收起后的时间轴：只剩右侧一条竖栏 */
  body.is-tl-collapsed .panel-cards { flex: 1 1 auto; }
  body.is-tl-collapsed .panel-timeline {
    flex: 0 0 46px;
    min-width: 46px;
    background: transparent;
    border-left: 1px solid var(--line);
  }
  body.is-tl-collapsed .panel-timeline .panel-head,
  body.is-tl-collapsed .panel-timeline .searchbar,
  body.is-tl-collapsed .panel-timeline .scroll { display: none; }
  body.is-tl-collapsed .tl-expand-btn { display: flex; }

  /* 收起时间轴后，碎片一屏两列 */
  body.is-tl-collapsed #cardList {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
    padding: 4px 22px 0;
  }
  body.is-tl-collapsed #cardList > .card { margin-bottom: 0; }
  body.is-tl-collapsed #cardList > .empty { grid-column: 1 / -1; }

  .tabbar { display: none; }

  .statusbar { padding-bottom: 8px; }

  .toast { bottom: 44px; }

  .card { margin-bottom: 12px; }
  .tl-body { margin-bottom: 12px; }
}

@media (min-width: 1280px) {
  .workspace { gap: 0; }
  /* 宽屏同样各占一半，宽度不随碎片文字量变化 */
  .panel-cards, .panel-timeline { flex: 1 1 0; min-width: 0; }
}

/* ---------------- 滚动条 ---------------- */
@media (min-width: 900px) {
  .scroll::-webkit-scrollbar { width: 9px; }
  .scroll::-webkit-scrollbar-thumb {
    background: #DED6C8;
    border-radius: 9px;
    border: 3px solid var(--paper);
  }
  .scroll::-webkit-scrollbar-thumb:hover { background: #CFC5B4; }
  .scroll::-webkit-scrollbar-track { background: transparent; }
}

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

/* ============================================================
   时间轴全屏
   ============================================================ */
body.is-tl-full { overflow: hidden; }

body.is-tl-full .topbar,
body.is-tl-full .tabbar,
body.is-tl-full .statusbar,
body.is-tl-full .panel-cards { display: none !important; }

body.is-tl-full .panel-timeline {
  display: flex !important;
  position: fixed;
  inset: 0;
  z-index: 90;
  flex: 1 1 auto;
  border: 0;
  background: var(--paper);
}

body.is-tl-full .panel-head {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 24px 8px;
}
body.is-tl-full .panel-head-timeline { padding-top: 20px; }
body.is-tl-full .searchbar {
  width: 100%;
  max-width: 1092px;
  margin: 0 auto 10px;
}
body.is-tl-full .scroll {
  padding: 8px 24px 90px;
}
body.is-tl-full .tl-expand-btn { display: none !important; }
body.is-tl-full #tlCollapse { display: none; }

/* 轴居中，碎片交错排在两侧 */
@media (min-width: 900px) {
  body.is-tl-full #tlList,
  body.is-tl-full .tl-add {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
  }

  body.is-tl-full .tl-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
    column-gap: 20px;
    padding-bottom: 6px;
  }
  /* 全屏是为了「一眼看到更多」，卡片收紧一点 */
  body.is-tl-full .tl-body {
    margin-bottom: 0;
    padding: 8px 12px;
  }
  body.is-tl-full .tl-axis::before { bottom: -8px; }
  body.is-tl-full .tl-axis {
    grid-column: 2;
    grid-row: 1;
  }
  body.is-tl-full .tl-item > .tl-body {
    grid-column: 3;
    grid-row: 1;
  }
  body.is-tl-full .tl-item:nth-child(even) > .tl-body {
    grid-column: 1;
  }
  /* 全屏时卡片不做悬停上浮，避免交错排布跳动 */
  body.is-tl-full .tl-item:hover .tl-body { transform: none; }
}
