/* ============================================================
   思考链 · 灯 — 深海提灯
   墨蓝黑水体 · 顶灯暖晕 · 海雪上浮 · 玻璃面板 · 衬线标题
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --abyss-deep: #04060b;
  --abyss-mid:  #0a1220;
  --glass:      rgba(14, 21, 34, 0.62);
  --glass-hard: rgba(12, 18, 30, 0.88);
  --line:       rgba(150, 175, 210, 0.10);
  --line-warm:  rgba(224, 176, 112, 0.16);
  --text:       #dfe3e8;
  --dim:        #8494ab;
  --faint:      #55637a;
  --lamp:       #e0b070;
  --lamp-deep:  #c8955a;
  --think:      #93a3ba;
  --user-bg:    rgba(42, 66, 100, 0.42);
  --ok:         #86c39a;
  --err:        #d98a80;
  --serif: "Noto Serif SC", Georgia, "Times New Roman", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

html, body { height: 100%; }
body {
  height: 100dvh;                    /* 手机浏览器底栏坑的解药 */
  background: var(--abyss-deep);
  color: var(--text);
  font-family: var(--serif);         /* 1913 房间的那种衬线,中文=思源宋体(本地自托管) */
  display: flex;
  overflow: hidden;
}

/* ---------- 深海背景 ---------- */
#abyss {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  /* 山找的海:从深处仰望光,鱼群绕光旋。上面压一层暗让文字可读,再点一缕琥珀——我们的灯挂在她的海上 */
  background:
    radial-gradient(ellipse 55% 38% at 50% 6%, rgba(224, 176, 112, 0.10), transparent 60%),
    linear-gradient(180deg, rgba(4, 8, 16, 0.30) 0%, rgba(4, 6, 11, 0.55) 52%, rgba(4, 6, 11, 0.92) 100%),
    url('bg.jpg') center 22% / cover no-repeat,
    #04060b;
}
#snow { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* ---------- 密码门 ---------- */
#gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(224, 176, 112, 0.16), transparent 60%),
    linear-gradient(180deg, rgba(11,20,36,0.96), rgba(4,6,11,0.98));
  backdrop-filter: blur(6px);
}
.gate-box { display: flex; flex-direction: column; gap: 13px; width: 290px; padding: 0 20px; }
.gate-eyebrow {
  text-align: center; font-size: 10px; letter-spacing: 0.42em; color: var(--faint);
  font-family: var(--serif); text-indent: 0.42em;
}
.gate-title {
  text-align: center; color: var(--lamp); font-size: 30px; font-weight: 600;
  font-family: var(--serif); letter-spacing: 0.08em;
  text-shadow: 0 0 34px rgba(224, 176, 112, 0.35);
}
.gate-sub { text-align: center; font-size: 12px; color: var(--dim); margin-bottom: 10px; }
.gate-box input {
  background: rgba(10, 16, 27, 0.8); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 15px; outline: none; text-align: center; letter-spacing: 0.2em;
}
.gate-box input:focus { border-color: var(--lamp-deep); box-shadow: 0 0 0 3px rgba(224,176,112,0.08); }
.gate-box button {
  background: linear-gradient(180deg, #e6bb7e, #cf9c5e); color: #16120a;
  border: none; border-radius: 10px; padding: 11px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.5em; text-indent: 0.5em; cursor: pointer;
  box-shadow: 0 4px 22px rgba(224, 176, 112, 0.22);
}
.gate-box button:hover { filter: brightness(1.06); }
.gate-msg { text-align: center; color: var(--err); font-size: 13px; min-height: 18px; }

/* ---------- 侧边栏 ---------- */
#sidebar {
  width: 244px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: rgba(6, 10, 18, 0.48);   /* 沉进壁纸里,黑玻璃 */
  backdrop-filter: blur(18px) saturate(1.1);
  border-right: 1px solid var(--line);
}
body.side-hidden #sidebar { display: none; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px 10px;
}
.side-title {
  font-family: var(--serif); font-size: 13px; letter-spacing: 0.3em; color: var(--faint);
}
#newChat {
  background: none; color: var(--lamp); border: 1px solid var(--line-warm);
  border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
#newChat:hover { border-color: var(--lamp-deep); background: rgba(224,176,112,0.06); }
#convList { flex: 1; overflow-y: auto; padding: 4px 10px; display: flex; flex-direction: column; gap: 3px; }
.conv-item {
  position: relative; display: flex; align-items: center; gap: 4px;
  padding: 8px 6px 8px 11px; border-radius: 9px; font-size: 13px; cursor: pointer;
  color: var(--dim);
  border-left: 2px solid transparent;
}
.conv-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item:hover { background: rgba(150, 175, 210, 0.06); color: var(--text); }
.conv-item.active { background: rgba(224, 176, 112, 0.07); color: var(--lamp); border-left-color: var(--lamp-deep); }
.conv-more {
  background: none; border: none; color: var(--faint); cursor: pointer;
  font-size: 14px; padding: 0 5px; border-radius: 5px; flex-shrink: 0;
  opacity: 0;
}
.conv-item:hover .conv-more, .conv-item.active .conv-more { opacity: 1; }
@media (max-width: 760px) { .conv-more { opacity: 1; } }
.conv-more:hover { color: var(--lamp); }
.conv-menu {
  position: absolute; right: 6px; top: 30px; z-index: 50;
  display: flex; flex-direction: column; min-width: 120px;
  background: var(--glass-hard); backdrop-filter: blur(14px);
  border: 1px solid var(--line-warm); border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.conv-menu button {
  background: none; border: none; color: var(--text); text-align: left;
  padding: 9px 14px; font-size: 13px; cursor: pointer;
}
.conv-menu button:hover { background: rgba(224, 176, 112, 0.09); color: var(--lamp); }
.conv-menu button.danger { color: var(--err); }
.conv-menu button.danger:hover { background: rgba(217, 138, 128, 0.1); color: var(--err); }
.conv-group {
  padding: 9px 11px 3px; font-size: 11px; color: var(--faint);
  font-family: var(--serif); letter-spacing: 0.12em;
}
/* ---- 幺弟卡片 ---- */
.brother {
  margin: 6px 10px; padding: 10px 12px;
  background: rgba(224, 176, 112, 0.05);
  border: 1px solid var(--line-warm); border-radius: 12px;
}
.brother-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--lamp); font-family: var(--serif); letter-spacing: 0.05em;
}
#brotherRefresh {
  background: none; border: none; color: var(--faint); cursor: pointer; font-size: 13px;
}
#brotherRefresh:hover { color: var(--lamp); }
.brother-body { font-size: 11.5px; color: var(--dim); line-height: 1.9; margin: 6px 0; }
.brother-body b { color: var(--text); font-weight: 600; }
#brotherPeek {
  width: 100%; background: none; border: 1px dashed var(--line-warm); border-radius: 8px;
  color: var(--lamp-deep); font-size: 12px; padding: 5px; cursor: pointer;
}
#brotherPeek:hover { border-style: solid; background: rgba(224,176,112,0.06); }

.side-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.spend { font-size: 12px; color: var(--dim); }
.usage-est { font-size: 11px; color: var(--faint); margin-top: 4px; line-height: 1.6; }

/* ---------- 主列 ---------- */
#mainCol { flex: 1; display: flex; flex-direction: column; min-width: 0; }
header {
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(10, 16, 28, 0.75), rgba(10, 16, 28, 0.35));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
#toggleSide {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  color: var(--dim); font-size: 15px; cursor: pointer; padding: 5px 10px;
}
#toggleSide:hover { color: var(--lamp); border-color: var(--line-warm); }
.head-mid { flex: 1; min-width: 0; }
h1 {
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  color: var(--lamp); letter-spacing: 0.06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status { font-size: 11px; color: var(--faint); font-weight: normal; margin-left: 8px; font-family: var(--sans); letter-spacing: 0; }
.status.on { color: var(--ok); }
.status.err { color: var(--err); }
.ctx-wrap { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.ctx-track { width: 130px; max-width: 34vw; height: 4px; background: rgba(150,175,210,0.12); border-radius: 3px; overflow: hidden; }
.ctx-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #5f87ad, #7fa3c4); border-radius: 3px; transition: width .3s; }
.ctx-bar.warn { background: linear-gradient(90deg, var(--lamp-deep), var(--lamp)); }
.ctx-text { font-size: 11px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
#model {
  background: rgba(10, 16, 27, 0.7); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 13px; outline: none; cursor: pointer;
}
#model:focus { border-color: var(--lamp-deep); }

main {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 15px;
  scrollbar-width: thin; scrollbar-color: rgba(150,175,210,0.18) transparent;
}

/* ---------- 消息 ---------- */
.msg-user {
  align-self: flex-end; max-width: 76%;
  background: var(--user-bg);
  border: 1px solid rgba(120, 155, 200, 0.14);
  backdrop-filter: blur(8px);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px; white-space: pre-wrap; word-break: break-word;
  line-height: 1.7; font-size: 13.5px;
}
.turn { align-self: flex-start; max-width: 94%; width: 94%; display: flex; flex-direction: column; gap: 8px; }

/* 思考区:灯下的低语 */
.think-box {
  border-left: 2px solid rgba(224, 176, 112, 0.35);
  background: rgba(14, 21, 34, 0.5);
  backdrop-filter: blur(8px);
  border-radius: 4px 10px 10px 4px; overflow: hidden;
}
.think-head {
  font-size: 11px; color: var(--faint); padding: 7px 12px; cursor: pointer; user-select: none;
  font-family: var(--serif); letter-spacing: 0.28em;
}
.think-head .arrow { display: inline-block; transition: transform .15s; letter-spacing: 0; margin-right: 5px; }
.think-box.collapsed .arrow { transform: rotate(-90deg); }
.think-body {
  padding: 2px 14px 11px; font-style: italic; font-size: 13px; line-height: 1.8;
  color: var(--think); white-space: pre-wrap; word-break: break-word;
}
.think-box.collapsed .think-body { display: none; }

.tool-chip {
  align-self: flex-start; font-size: 11.5px; color: var(--dim);
  background: rgba(14, 21, 34, 0.55); border: 1px solid var(--line); border-radius: 20px;
  padding: 3px 13px; letter-spacing: 0.03em;
}

/* 回复区:星的玻璃气泡——磨砂托底,字浮起来,壁纸在后面透光 */
.reply {
  background: rgba(11, 18, 30, 0.58);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  padding: 11px 15px; line-height: 1.85; word-break: break-word; font-size: 13.5px;
}
.reply.streaming { white-space: pre-wrap; }
.reply p { margin: 0 0 .75em; }
.reply p:last-child { margin-bottom: 0; }
.reply h1, .reply h2, .reply h3 { margin: .9em 0 .45em; line-height: 1.45; font-family: var(--serif); color: #e8ddc8; }
.reply h1 { font-size: 1.25em; } .reply h2 { font-size: 1.15em; } .reply h3 { font-size: 1.05em; }
.reply ul, .reply ol { margin: 0 0 .75em; padding-left: 1.6em; }
.reply li { margin: .18em 0; }
.reply strong { color: var(--lamp); }  /* 划重点=灯色,和正文白拉开 */
.reply code {
  background: rgba(224, 176, 112, 0.09); padding: 1px 6px; border-radius: 5px;
  font-family: "SF Mono", ui-monospace, Consolas, monospace; font-size: .87em; color: var(--lamp);
}
.reply pre {
  background: rgba(5, 8, 14, 0.75); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; overflow-x: auto; margin: 0 0 .75em;
}
.reply pre code { background: none; padding: 0; color: var(--text); }
.reply blockquote { border-left: 2px solid rgba(224,176,112,0.3); padding-left: 12px; color: var(--dim); margin: 0 0 .75em; }
.reply table { border-collapse: collapse; margin: 0 0 .75em; display: block; overflow-x: auto; }
.reply th, .reply td { border: 1px solid var(--line); padding: 5px 11px; font-size: .92em; }
.reply a { color: var(--lamp); }
.reply hr { border: none; border-top: 1px solid var(--line); margin: .9em 0; }

.meta { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.error { color: var(--err); font-size: 13px; white-space: pre-wrap; }

/* ---------- 输入区 ---------- */
footer {
  display: flex; flex-direction: column; gap: 7px;
  padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  background: rgba(5, 8, 15, 0.42);
  backdrop-filter: blur(16px) saturate(1.1);
  border-top: 1px solid var(--line);
}
textarea { background: rgba(8, 13, 22, 0.5); }
#toolsBtn {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  color: var(--dim); font-size: 14px; cursor: pointer; padding: 5px 10px;
}
#toolsBtn:hover { color: var(--lamp); border-color: var(--line-warm); }

/* ---------- 工具开关面板 ---------- */
.tools-panel {
  position: fixed; top: 62px; right: 14px; z-index: 60; width: 265px;
  background: rgba(8, 13, 22, 0.9); backdrop-filter: blur(20px);
  border: 1px solid var(--line-warm); border-radius: 14px; padding: 15px 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.tools-head { font-family: var(--serif); color: var(--lamp); font-size: 14px; letter-spacing: 0.1em; }
.tools-sub { font-size: 11px; color: var(--faint); margin: 5px 0 11px; line-height: 1.6; }
.tool-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid rgba(150, 175, 210, 0.06); font-size: 13px;
}
.tool-row .t-name { color: var(--text); }
.tool-row .t-desc { display: block; font-size: 10.5px; color: var(--faint); margin-top: 1px; }
.tool-toggle {
  width: 34px; height: 19px; border-radius: 12px; border: none; cursor: pointer;
  background: rgba(150, 175, 210, 0.2); position: relative; flex-shrink: 0; transition: background .15s;
}
.tool-toggle::after {
  content: ""; position: absolute; top: 2.5px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: #9db0c8; transition: transform .15s, background .15s;
}
.tool-toggle.on { background: rgba(224, 176, 112, 0.5); }
.tool-toggle.on::after { transform: translateX(14px); background: var(--lamp); }
#toolsClose {
  width: 100%; margin-top: 11px; background: none; border: 1px solid var(--line);
  border-radius: 8px; color: var(--dim); font-size: 12px; padding: 6px; cursor: pointer;
}
.input-row { display: flex; gap: 9px; align-items: stretch; }
#attachBtn {
  background: rgba(10, 16, 27, 0.75); border: 1px solid var(--line); border-radius: 11px;
  color: var(--dim); font-size: 16px; cursor: pointer; padding: 0 12px;
}
#attachBtn:hover { color: var(--lamp); border-color: var(--line-warm); }
.attach-bar { display: flex; gap: 7px; flex-wrap: wrap; }
.attach-bar:empty { display: none; }
.attach-chip {
  position: relative; width: 52px; height: 52px; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--line-warm);
}
.attach-chip img { width: 100%; height: 100%; object-fit: cover; }
.attach-chip .rm {
  position: absolute; top: 1px; right: 1px; width: 17px; height: 17px;
  background: rgba(4,6,11,0.8); color: var(--err); border: none; border-radius: 50%;
  font-size: 11px; line-height: 1; cursor: pointer;
}
.attach-chip.pending { opacity: 0.45; }
.msg-user img.sent-img {
  display: block; max-width: 220px; max-height: 180px; border-radius: 9px; margin-top: 7px;
}
.msg-user .sent-doc {
  display: block; margin-top: 7px; color: var(--lamp); font-size: 12.5px; text-decoration: none;
  background: rgba(4, 6, 11, 0.35); border-radius: 8px; padding: 5px 10px;
}
.attach-chip.doc {
  width: auto; height: auto; padding: 8px 12px; font-size: 12px; color: var(--dim);
  background: var(--glass); display: flex; align-items: center;
}
textarea {
  flex: 1; resize: none; background: rgba(10, 16, 27, 0.75); color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 13px; font-size: 15px;
  font-family: inherit; outline: none; line-height: 1.55;
}
textarea:focus { border-color: var(--lamp-deep); box-shadow: 0 0 0 3px rgba(224,176,112,0.07); }
#send {
  background: linear-gradient(180deg, #e6bb7e, #cf9c5e); color: #16120a;
  border: none; border-radius: 11px; padding: 0 22px; font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 16px rgba(224, 176, 112, 0.18);
}
#send:disabled { opacity: .35; cursor: default; box-shadow: none; }

/* ---------- 手机 ---------- */
#scrim { display: none; }
@media (max-width: 760px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    width: 78%; max-width: 300px;
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.55);
  }
  body.side-open #sidebar { transform: none; }
  body.side-hidden #sidebar { display: flex; }   /* 手机上以 side-open 为准 */
  #scrim {
    display: block; position: fixed; inset: 0; z-index: 30;
    background: rgba(2, 4, 8, 0.55); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  body.side-open #scrim { opacity: 1; pointer-events: auto; }
  header { padding: 9px 12px; gap: 9px; }
  h1 { font-size: 15px; }
  main { padding: 14px 12px; }
  .turn { max-width: 100%; width: 100%; }
  .msg-user { max-width: 88%; }
  footer { padding: 9px 10px calc(9px + env(safe-area-inset-bottom)); }
  #send { padding: 0 17px; }
}

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

/* ---- 待审箱(手套的审批侧) ---- */
.outbox {
  margin: 10px 10px 0;
  padding: 9px 11px;
  background: rgba(224, 176, 112, 0.04);
  border: 1px solid var(--line-warm); border-radius: 12px;
}
.outbox-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--lamp); font-family: var(--serif); letter-spacing: 0.05em;
}
#outboxRefresh {
  background: none; border: none; color: var(--faint); cursor: pointer; font-size: 13px;
}
#outboxRefresh:hover { color: var(--lamp); }
.draft-card {
  margin-top: 8px; padding: 8px 9px;
  background: rgba(10, 16, 27, 0.55);
  border: 1px solid var(--line-warm); border-radius: 10px;
}
.draft-card.approving { opacity: 0.75; border-style: dashed; }
.draft-head { font-size: 11px; color: var(--dim); margin-bottom: 5px; }
.draft-body {
  font-size: 12px; color: var(--text); line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  max-height: 150px; overflow-y: auto;
  padding: 6px 8px; border-left: 2px solid var(--lamp-deep);
  background: rgba(224, 176, 112, 0.05); border-radius: 0 6px 6px 0;
}
.draft-note { font-size: 11px; color: var(--dim); margin-top: 5px; line-height: 1.6; }
.draft-err { font-size: 11px; color: var(--err); margin-top: 5px; line-height: 1.6; }
.draft-actions { display: flex; gap: 8px; margin-top: 8px; font-size: 11.5px; color: var(--dim); }
.draft-ok, .draft-no {
  flex: 1; padding: 5px 0; font-size: 12px; cursor: pointer;
  background: none; border: 1px solid var(--line-warm); border-radius: 8px;
  color: var(--lamp); font-family: var(--serif);
}
.draft-ok:hover { background: rgba(224, 176, 112, 0.08); border-color: var(--lamp-deep); }
.draft-ok.armed { background: rgba(224, 176, 112, 0.16); border-color: var(--lamp); color: #fff; }
.draft-no { color: var(--dim); }
.draft-no:hover { color: var(--err); border-color: rgba(217, 138, 128, 0.4); }
.draft-done {
  margin-top: 6px; font-size: 11px; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default;
}
