/* ============================================================================
   两页共用的「外壳」样式 —— 登录态切换 + 左右分栏 + 右栏 AI 对话
   ----------------------------------------------------------------------------
   配件KPI（index.html）与基础运营奖（base.html）都用这一份。
   ★ 共用是硬要求：两页版式一旦分头维护，很快就会出现「一页正常、另一页错位」，
     而且没人会发现（改的人只盯着自己那一页）。
   页面专属的东西留在各自页面里：
     index  → 店名条 header、得分概览 #summary（.scorerow/.mods/.kpi）
     base   → 深蓝店名条 .top、标签页 .tabs、各面板 .panel/.card2/.kv/.gtable
   ============================================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f4f5f7; --card: #ffffff; --line: #e3e6ea; --line2: #eef0f3;
  --tx: #1f2328; --tx2: #5c6470; --tx3: #8b939e;
  --accent: #185fa5; --accent-bg: #e6f1fb;
  --ok: #3b6d11; --ok-bg: #eaf3de; --warn: #854f0b; --warn-bg: #faeeda; --bad: #a32d2d; --bad-bg: #fcebeb;
}
html { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--tx);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  display: flex; flex-direction: column; min-height: 100%;
}
.hide { display: none !important; }

/* ---------- 首屏遮罩 ---------- */
/* 进页面时先不显示任何一侧。登录层若默认可见，**已登录的人会先看到一闪而过
   的登录框**（在公网上那一两百毫秒很明显，像是"被登出了"）。所以先只显示
   这一句，等 /api/me 回话，再由 showLogin() / showApp() 决定给哪一边。 */
#boot { flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px;
        color: var(--tx3); font-size: 13.5px; }
#boot .spin { width: 14px; height: 14px; border: 2px solid var(--line);
              border-top-color: var(--accent); border-radius: 50%;
              animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登录 ---------- */
#login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lbox { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
        border-radius: 16px; padding: 32px 28px; }
.lbox .logo { width: 42px; height: 42px; border-radius: 11px; background: var(--accent);
              display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 500; font-size: 17px; }
.lbox h1 { font-size: 19px; font-weight: 500; margin: 18px 0 6px; }
.lbox p.sub { margin: 0 0 24px; color: var(--tx2); font-size: 13px; }
.lbox label { display: block; font-size: 12.5px; color: var(--tx2); margin: 0 0 6px; }
.lbox input[type=text], .lbox input[type=password] {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; color: var(--tx); background: #fff; outline: none; transition: border-color .15s;
}
.lbox input:focus { border-color: var(--accent); }
.lbox .field { margin-bottom: 16px; }
.lbox button.primary {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 15px; font-family: inherit; cursor: pointer; transition: opacity .15s;
}
.lbox button.primary:hover { opacity: .9; }
.lbox button.primary:disabled { opacity: .5; cursor: default; }
#lerr { margin-top: 14px; color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- 主界面：左右分栏 ---------- */
/* 左栏 = 项目导航 + 本店内容；右栏 = AI 对话。中间 #gutter 拖动调宽。
   两栏各自内部滚动，所以 #app 铺满视口、把溢出藏住（整页不滚）。
   ★ 用 fixed 而不是 body(flex) + height:100vh：后者会让 body 也被内容撑高
   （实测 760px 的视口里 body 与 #app 一起变成 1370px），两栏就不再内部滚动、
   整页又开始滚，min-height:0 也救不回来。fixed 一步到位、不受 flex 假想尺寸影响。
   窄屏（<=820px）整段作废退回单列 —— 见文件末尾同断点的媒体查询，
   JS 里的 scrollDown() 也按同一个断点判断该滚窗口还是滚 #feed。 */
#app { position: fixed; top: 0; right: 0; bottom: 0; left: 0;
       display: flex; flex-direction: column; overflow: hidden; }
#split { flex: 1; display: flex; min-height: 0; }
/* 宽度拖动改的就是这个变量（写在 #split 上、由 #left 继承） */
#left { flex: 0 0 auto; width: var(--leftw, 42%); min-width: 240px; max-width: 72%;
        display: flex; flex-direction: column; min-height: 0; background: var(--card); }
/* 导航条常驻左栏顶部（左栏里各页自己的店名条也一起常驻，只是内容区滚） */
#left > #nav { flex: 0 0 auto; }

/* 分隔条：9px 抓取区（比看上去宽，好点中），视觉上是细线 + 中间一个小抓手。
   ★ 抓手必须**常驻可见**（不是只有 hover 才出现）：一根 1px 的浅灰线在两个
   浅色栏之间几乎看不出来，用户不会知道这里能拖 —— 实测 40% 透明度的抓手
   在截图里依然找不到，所以又加了底色 + 提高到 70%。
   悬停/拖动/键盘聚焦时整条变主题色，同时说明"可以拖"和"正在拖"。 */
#gutter { flex: 0 0 9px; position: relative; cursor: col-resize; touch-action: none;
          background: #eceff3; }
#gutter::before { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px;
                  background: var(--line); transition: background .15s; }
#gutter::after { content: ""; position: absolute; top: 50%; left: 50%; width: 4px; height: 36px;
                 margin: -18px 0 0 -2px; border-radius: 2px;
                 background: var(--tx3); opacity: .7; transition: opacity .15s, background .15s; }
#gutter:hover::before, #gutter.dragging::before, #gutter:focus-visible::before { background: var(--accent); }
#gutter:hover::after, #gutter.dragging::after, #gutter:focus-visible::after {
  opacity: 1; background: var(--accent);
}
#gutter:focus-visible { outline: none; }

#right { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
         min-height: 0; background: var(--bg); }
#right > #chips, #right > footer { flex: 0 0 auto; }

/* 右栏自己滚（窄屏退回整页滚，见末尾媒体查询） */
#feed { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px;
        display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 11px; max-width: 100%; }
.msg .av { width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto; font-size: 11px;
           display: flex; align-items: center; justify-content: center; }
.msg.bot .av { background: var(--accent-bg); color: var(--accent); }
.msg.me { flex-direction: row-reverse; }
.msg.me .av { background: #e7e9ed; color: var(--tx2); }
.bubble { padding: 11px 15px; border-radius: 12px; font-size: 14.5px; max-width: calc(100% - 44px);
          line-height: 1.7; overflow-wrap: break-word; }
.msg.bot .bubble { background: var(--card); border: 1px solid var(--line); }
.msg.me .bubble { background: var(--accent); color: #fff; }

.bubble h4 { font-size: 14px; font-weight: 500; margin: 14px 0 6px; }
.bubble h4:first-child { margin-top: 0; }
.bubble p { margin: 0 0 9px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 6px 0 10px; padding-left: 20px; }
.bubble li { margin: 3px 0; }
.bubble strong { font-weight: 500; }
.bubble code { background: #f0f2f5; padding: 1px 5px; border-radius: 4px; font-size: 12.5px;
               font-family: ui-monospace, Consolas, monospace; }
.bubble blockquote { margin: 10px 0 0; padding: 7px 12px; border-left: 2px solid var(--line);
                     color: var(--tx2); font-size: 13px; background: #fafbfc; border-radius: 0 6px 6px 0; }
.bubble table { border-collapse: collapse; width: 100%; margin: 8px 0 10px; font-size: 13px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.bubble th { background: #f7f8fa; font-weight: 500; }

.note { font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 8px;
        padding: 8px 11px; margin-bottom: 10px; }
.src { font-size: 11.5px; color: var(--tx3, #9aa3ad); margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.src b { font-weight: 500; color: var(--accent); }
.src.fast b { color: var(--ok, #2e9e6b); }

/* 政策出处：贴在答案底部，回答"这条依据是哪来的" */
.psrc { margin-top: 11px; padding-top: 9px; border-top: 1px dashed var(--line);
        display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.psrc .plabel { font-size: 11.5px; color: var(--tx3); flex: 0 0 auto; }
.psrc .ptag { font-size: 11.5px; padding: 2px 9px; border-radius: 6px; background: var(--line2);
              color: var(--tx2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.cursor::after { content: "▍"; color: var(--accent); animation: bl 1s steps(2) infinite; }
@keyframes bl { 50% { opacity: 0; } }

#chips { display: flex; gap: 7px; flex-wrap: wrap; padding: 0 20px 12px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--tx2); border-radius: 999px;
        padding: 6px 13px; font-size: 12.5px; cursor: pointer; font-family: inherit; transition: .15s; }
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* 输入区：分栏布局下它就是右栏 flex 的最后一个子项，天然贴底，不需要 sticky；
   窄屏退回整页滚动时才需要吸底（见末尾媒体查询）。 */
footer { padding: 0 20px 20px; background: var(--bg); }
.composer { display: flex; gap: 9px; background: var(--card); border: 1px solid var(--line);
            border-radius: 14px; padding: 7px 7px 7px 15px; align-items: flex-end; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; font: inherit; font-size: 14.5px; color: var(--tx);
  padding: 6px 0; max-height: 140px; background: transparent; line-height: 1.5;
}
.composer button.send {
  width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--accent); color: #fff;
  cursor: pointer; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.composer button.send:disabled { opacity: .4; cursor: default; }
.hint { text-align: center; font-size: 11.5px; color: var(--tx3); margin-top: 9px; }

@media (max-width: 640px) {
  #feed, #chips, footer { padding-left: 14px; padding-right: 14px; }
  .bubble { max-width: calc(100% - 38px); }
}

/* ---------- 窄屏（<=820px）退回单列 ----------
   手机/窄窗口上左右并排两条栏都没法用（对话区会被压成一条缝），所以直接放弃
   分栏，回到"整页滚动"的老样子：导航吸顶、输入框吸底、分隔条隐藏。
   ★ 断点要和上面 #app/#split 那套、以及 JS 里的 NARROW_MQ 保持一致。
   左栏里各页自己的内容（#summary / #dashBody）该改成"不自己滚"，
   由页面各自的样式补 —— 这里只管外壳。 */
@media (max-width: 820px) {
  /* 这里要的是"内容多高就多高"，所以把 fixed 定位与上一套约束一起撤掉，
     让 #app 回到普通流里按内容撑开（整页滚动）。 */
  #app { position: static; top: auto; right: auto; bottom: auto; left: auto;
         flex: 0 0 auto; height: auto; min-height: 0; overflow: visible; }
  #split { flex-direction: column; }
  #gutter { display: none; }
  #left { width: auto; max-width: none; min-width: 0; }
  #feed { flex: 1 0 auto; overflow: visible; }
  /* 整页滚动时导航会跟着滚走，而它是切换项目的唯一入口，
     所以这里才需要吸顶；分栏布局下它常驻左栏顶部，不用 sticky。 */
  #nav { position: sticky; top: 0; }
  #right > footer { position: sticky; bottom: 0; }
}
