/* 备忘记账本 —— 素纸、细线、密度够用，不要渐变不要光 */
:root {
  --bg: #eeeee9;
  --paper: #ffffff;
  --side: #f4f4f0;
  --card: #fafaf7;
  --line: #e4e4de;
  --line2: #d4d4cc;
  --ink: #1b1b1d;
  --ink2: #63636a;
  --ink3: #97979d;
  --sel: #e8e8df;
  --link: #2f6fd0;
  --warn: #8f5600;
  --err: #a8231c;
  --ok: #2f7a3f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.7 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  max-width: 1440px;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

/* ================= 顶栏 ================= */
.topbar {
  height: 54px;
  flex: 0 0 54px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line2);
  background: var(--side);
}
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand .mark { font-size: 15px; font-weight: 600; letter-spacing: .5px; }
.brand .brandSub { font-size: 11.5px; color: var(--ink3); }


.topActions { display: flex; gap: 8px; margin-left: auto; }

.btn {
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--ink);
}
.btn:hover { border-color: #b9b9ae; background: #fbfbf6; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #333; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }

/* ================= 骨架 ================= */
.layout { flex: 1; display: flex; min-height: 0; }

/* ---------------- 侧栏 ---------------- */
.sidebar {
  width: 286px;
  flex: 0 0 286px;
  background: var(--side);
  border-right: 1px solid var(--line2);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.sideSection { border-bottom: 1px solid var(--line); padding: 12px 12px 14px; }
.sideTitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink2);
  letter-spacing: .4px;
  margin-bottom: 8px;
}
.sideTools { color: var(--ink3); font-size: 11.5px; display: flex; gap: 6px; }
.mini {
  border: 1px solid var(--line2);
  background: #fff;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  line-height: 1;
  font-size: 12px;
  color: var(--ink2);
  padding: 0;
}
.mini:hover { border-color: #b9b9ae; }
.sideBtns { display: flex; gap: 6px; margin-bottom: 9px; }

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.items li {
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 6px 7px;
  cursor: pointer;
  background: transparent;
}
.items li:hover { background: #ececE4; }
.items li.on { background: #e5e5db; border-color: #d5d5ca; }
.items li .iTop { display: flex; align-items: center; gap: 6px; }
.items li .badge {
  font: 10px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--ink2);
  background: #e6e6de;
  border-radius: 3px;
  padding: 1px 4px;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.items li .iTitle {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.items li .iMeta {
  font-size: 11px;
  color: var(--ink3);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.items li .acts { display: none; gap: 6px; }
.items li:hover .acts { display: flex; }
.items li .act {
  font-size: 11px;
  color: var(--ink2);
  background: none;
  border: 0;
  padding: 0;
}
.items li .act:hover { color: var(--link); text-decoration: underline; }
.items li .act.del:hover { color: var(--err); }
.items .empty {
  font-size: 12px;
  color: var(--ink3);
  padding: 4px 2px 2px;
  line-height: 1.6;
  cursor: default;
}
.items .empty:hover { background: transparent; }


/* ---------------- 右纸 ---------------- */
.paper { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--paper); }

.paperBar {
  height: 46px;
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.ctx {
  flex: 1;
  font-size: 12px;
  color: var(--ink2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctx b { color: var(--ink); font-weight: 600; }

.modes { display: flex; border: 1px solid var(--line2); border-radius: 5px; overflow: hidden; background: #fff; }
.modes button {
  border: 0;
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--ink2);
  border-right: 1px solid var(--line);
}
.modes button:last-child { border-right: 0; }
.modes button:hover { background: #f6f6f0; }
.modes button.on { background: var(--ink); color: #fff; }

.kbSwitch { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink2); cursor: pointer; }
.kbSwitch input { accent-color: #333; }

.thread { flex: 1; overflow-y: auto; padding: 22px 22px 6px; }
.threadInner { max-width: 720px; margin: 0 auto; }

.work { flex: 1; display: flex; min-height: 0; }

/* 空状态 */
.welcome { padding: 6px 0 0; }
.welcome h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.welcome p { margin: 0 0 16px; color: var(--ink2); }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card h4 { margin: 0; font-size: 13px; font-weight: 600; }
.card p { margin: 0; font-size: 11.5px; color: var(--ink3); line-height: 1.6; flex: 1; }
.card button {
  align-self: flex-start;
  margin-top: 6px;
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: var(--ink2);
}
.card button:hover { border-color: #b9b9ae; color: var(--ink); }
.welcome ol { margin: 0; padding-left: 20px; color: var(--ink2); font-size: 12.5px; }
.welcome ol li { margin: 3px 0; }

/* 对话 */
.turn { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid #f0f0ea; }
.turn:last-child { border-bottom: 0; }
.turn .who {
  font-size: 11px;
  letter-spacing: .6px;
  color: var(--ink3);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.turn .who .when { color: #b9b9b2; letter-spacing: 0; }
.turn.me .body {
  background: #f5f5ef;
  border: 1px solid #ecece4;
  border-radius: 6px;
  padding: 9px 13px;
}
.turn.ai .body { padding: 0; }

.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p { margin: 0 0 9px; }
.body h1, .body h2, .body h3, .body h4 { font-size: 14px; font-weight: 600; margin: 16px 0 7px; }
.body ul, .body ol { margin: 7px 0 9px; padding-left: 21px; }
.body li { margin: 3px 0; }
.body code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  background: #f4f4ee;
  border: 1px solid #e6e6de;
  border-radius: 3px;
  padding: 1px 4px;
}
.body pre {
  background: #f8f8f3;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 11px 13px;
  overflow-x: auto;
  margin: 9px 0;
  font-size: 12.5px;
  line-height: 1.6;
}
.body pre code { background: none; border: 0; padding: 0; }
.body table { border-collapse: collapse; font-size: 12.5px; margin: 9px 0; display: block; overflow-x: auto; }
.body th, .body td { border-bottom: 1px solid var(--line); padding: 5px 14px 5px 0; text-align: left; white-space: nowrap; }
.body th { color: var(--ink2); font-weight: 500; border-bottom-color: var(--line2); }
.body th.n, .body td.n { text-align: right; font-variant-numeric: tabular-nums; padding-right: 18px; }
.body tr:hover td { background: #fafaf5; }
.body img { max-width: 320px; border-radius: 5px; border: 1px solid var(--line); display: block; }
.body a { color: var(--link); }

.meta { margin-top: 9px; font-size: 11px; color: var(--ink3); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.meta .seg { display: flex; gap: 10px; align-items: center; flex: 1; flex-wrap: wrap; }
.meta details { display: inline-block; }
.meta summary { cursor: pointer; color: var(--ink2); }
.meta summary:hover { color: var(--ink); }
.meta .panel {
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  padding: 9px 11px;
  font-size: 12px;
  color: var(--ink2);
  line-height: 1.65;
}
.meta .panel pre { margin: 0; background: none; border: 0; padding: 0; white-space: pre-wrap; font-size: 11.5px; }
.meta .panel .c { padding: 5px 0; border-bottom: 1px dashed #ecece4; }
.meta .panel .c:last-child { border-bottom: 0; }
.meta .panel .c b { color: var(--ink); font-weight: 600; }
.meta .panel .c em { font-style: normal; color: var(--ink3); }

.thinking { color: var(--ink3); font-size: 12.5px; }
.thinking i { font-style: normal; animation: fade 1.3s infinite; }
.thinking i:nth-child(2) { animation-delay: .18s; }
.thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes fade { 0%, 100% { opacity: .22 } 50% { opacity: 1 } }

.error { color: var(--err); }
.warn { color: var(--warn); }

/* ---------------- 输入区 ---------------- */
.composer { border-top: 1px solid var(--line2); padding: 10px 22px 12px; background: var(--card); }
.composer > * { max-width: 720px; margin-left: auto; margin-right: auto; }

.cols { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.cols .colChip {
  font-size: 11px;
  color: var(--ink2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 7px;
}
.cols .colChip:hover { border-color: #bcbcb0; color: var(--ink); }
.cols .colChip.num { border-bottom: 2px solid #d8e4d9; }
.cols .colChip.date { border-bottom: 2px solid #dde1ee; }
.cols .label { font-size: 11px; color: var(--ink3); align-self: center; margin-right: 2px; }

.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.suggest .sugChip {
  font-size: 11.5px;
  color: var(--ink2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px 11px;
}
.suggest .sugChip:hover { border-color: #b9b9ae; color: var(--ink); background: #fbfbf5; }

.attach { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attach .chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 6px 3px 4px;
}
.attach .chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 3px; }
.attach .chip b { color: var(--ink); font-weight: 500; }
.attach .chip .x { color: #b3b3ab; padding: 0 2px; cursor: pointer; }
.attach .chip .x:hover { color: var(--err); }
.attach .chip.file { padding: 3px 6px 3px 5px; }
.attach .chip .badge {
  font: 10px/1.5 ui-monospace, Consolas, monospace;
  color: var(--ink2);
  background: #eaeae2;
  border-radius: 3px;
  padding: 1px 4px;
  flex: 0 0 auto;
}
.attach .chip .info { color: var(--ink3); font-size: 11px; }
.attach .note { font-size: 11.5px; color: var(--warn); padding: 3px 0; }

.row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--line2);
  border-radius: 6px;
  padding: 5px 6px 5px 8px;
  background: #fff;
}
.row:focus-within { border-color: #a9a99e; }
.row textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  line-height: 1.7;
  padding: 5px 0;
  max-height: 150px;
}
.row .plain {
  background: none;
  border: 0;
  color: var(--ink3);
  font-size: 12px;
  padding: 6px 2px;
}
.row .plain:hover { color: var(--ink); }
.row .go {
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 5px;
  padding: 6px 16px;
  font-size: 12.5px;
}
.row .go:disabled { opacity: .35; cursor: default; }

.composerFoot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink3);
  margin-top: 6px;
}
.composerFoot .dim { color: #b3b3ab; }

/* ---------------- 弹层 ---------------- */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 26, .3);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 50px 16px;
  z-index: 40;
  overflow-y: auto;
}
.sheet.open { display: flex; }
.sheetBox {
  width: 560px;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 18px 20px 16px;
}
.sheetBox.wide { width: 760px; }
.sheetHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheetHead h2 { margin: 0; font-size: 14px; font-weight: 600; }
.sheetBox h3 {
  margin: 16px 0 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  letter-spacing: .5px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.sheetBox h3:first-of-type { margin-top: 4px; }
.field { margin-bottom: 9px; }
.field label { display: block; font-size: 11.5px; color: var(--ink2); margin-bottom: 3px; }
.field input {
  width: 100%;
  border: 1px solid var(--line2);
  border-radius: 5px;
  padding: 7px 9px;
  background: #fdfdfa;
  outline: none;
  font-size: 12.5px;
}
.field input:focus { border-color: #a9a99e; background: #fff; }
.two { display: flex; gap: 10px; }
.two .field { flex: 1; }
.hint { margin: 0 0 9px; font-size: 11.5px; color: var(--ink3); line-height: 1.65; }
.envBox {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  padding: 8px 10px;
  font: 11.5px/1.7 ui-monospace, Consolas, monospace;
  color: var(--ink2);
  white-space: pre-wrap;
}
.sheetFoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.sheetOut {
  margin: 10px 0 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  padding: 9px 11px;
  font: 11.5px/1.6 ui-monospace, Consolas, monospace;
  color: var(--ink2);
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
}
.sheetOut.ok { color: #26663a; border-color: #cfe2d2; background: #f4faf5; }
.sheetOut.err { color: #9c211a; border-color: #eed3cf; background: #fdf5f4; }
.sheetOut .modelPick {
  display: inline-block;
  margin: 3px 4px 0 0;
  padding: 2px 8px;
  font: 11px/1.6 ui-monospace, Consolas, monospace;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 4px;
  cursor: pointer;
}
.sheetOut .modelPick:hover { border-color: #a9a99e; background: #fbfbf5; }

.previewBody { font-size: 12.5px; color: var(--ink2); line-height: 1.7; max-height: 62vh; overflow: auto; }
.previewBody h4 { margin: 14px 0 6px; font-size: 12.5px; color: var(--ink); }
.previewBody h4:first-child { margin-top: 0; }
.previewBody .seg {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  padding: 8px 10px;
  margin-bottom: 7px;
  white-space: pre-wrap;
}
.previewBody .seg em { font-style: normal; color: var(--ink3); font-size: 11px; display: block; margin-bottom: 3px; }
.previewBody table { border-collapse: collapse; font-size: 11.5px; width: 100%; }
.previewBody th, .previewBody td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; white-space: nowrap; }
.previewBody th { background: var(--card); color: var(--ink2); font-weight: 500; }
.previewBody .scroll { overflow-x: auto; }

/* ---------------- 提示条 ---------------- */
.bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #2b2b28;
  color: #fff;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 5px;
  z-index: 60;
  opacity: 0;
  transition: opacity .18s;
  pointer-events: none;
  max-width: 80vw;
}
.bar.show { opacity: 1; }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 900px) {
  .app { border: 0; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 290px;
    transform: translateX(-100%);
    transition: transform .2s;
    box-shadow: 1px 0 0 var(--line2);
  }
  .sidebar.open { transform: none; }
  .cards { grid-template-columns: 1fr; }
  .thread { padding: 16px 14px 6px; }
  .composer { padding: 8px 14px 10px; }
  .paperBar { padding: 0 14px; gap: 8px; }
  .brand .brandSub { display: none; }
}
