:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel2: #0e1626;
  --line: #1e2b45;
  --text: #e6edf7;
  --muted: #8aa0c2;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  display: flex;
}
a { color: #7db4ff; }
code, pre { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; }

#side {
  width: 250px; min-width: 250px; height: 100vh; overflow: auto;
  background: var(--panel2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0;
}
.brand { padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.brand b { font-size: 16px; display: block; }
.brand span { color: var(--muted); font-size: 12px; }
#nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
#nav button {
  all: unset; cursor: pointer; padding: 8px 12px; border-radius: 8px; color: var(--text);
  display: flex; align-items: center; gap: 8px; font-size: 14px;
}
#nav button:hover { background: #17233c; }
#nav button.active { background: #1c2f52; color: #cfe3ff; font-weight: 600; }
#nav button .ico { width: 20px; text-align: center; }
.foot { margin-top: auto; padding: 12px 16px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

#main { flex: 1; min-width: 0; padding: 18px 22px 60px; max-width: 1280px; }
#bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
#bar h1 { font-size: 20px; margin: 0; }
.bar-right { display: flex; gap: 8px; align-items: center; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  background: #173a2a; color: #6ee7a8; border: 1px solid #1d5138;
}
.chip.off { background: #2a1c1c; color: #fca5a5; border-color: #5b2b2b; }
.chip.ok { background: #10281a; color: #86efac; border-color: #1f4d31; }
.chip.warn { background: #3a2d13; color: #fcd34d; border-color: #5c4a1d; }
.chip.info { background: #14283f; color: #7db4ff; border-color: #234066; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card h4 { margin: 14px 0 6px; font-size: 14px; color: #cfe3ff; }
.card.err { border-color: #7f1d1d; background: #2a1414; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.row.gap { gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
input, select, textarea {
  background: #0c1526; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font: inherit; min-width: 0;
}
textarea { width: 100%; min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }
label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

button {
  background: #1c3a66; color: #dbeafe; border: 1px solid #2b528c; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font: inherit;
}
button:hover { background: #24497e; }
button:disabled { opacity: .55; cursor: default; }
button.mini { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
button.danger { background: #4a1a1a; border-color: #7f2c2c; color: #fecaca; }
button.danger:hover { background: #611f1f; }
button.go { background: #14432c; border-color: #1f6b45; color: #d1fae5; }
button.go:hover { background: #1a5a3b; }

/* 登录方式切换：密码 / 微信扫码 / 手机验证码 */
.tabs { display: flex; gap: 6px; margin: 4px 0 12px; border-bottom: 1px solid var(--line); }
.tab {
  background: transparent; border: 1px solid transparent; border-bottom: none;
  border-radius: 8px 8px 0 0; color: var(--muted); padding: 7px 14px;
}
.tab:hover { background: #14233c; color: var(--text); }
.tab.active {
  background: var(--panel); border-color: var(--line); color: #dbeafe; font-weight: 600;
  margin-bottom: -1px;
}
.qr-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.qr {
  width: 200px; height: 200px; border-radius: 10px; background: #fff;
  padding: 8px; border: 1px solid var(--line); image-rendering: pixelated;
}
.qr-side { display: flex; flex-direction: column; gap: 8px; min-width: 180px; }
.qr-side button { align-self: flex-start; }
.ok-text { color: #86efac; }
.err-text { color: #fca5a5; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #9db8e0; font-weight: 600; background: #0f1b30; position: sticky; top: 0; }
.tbl-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table.kv th { width: 190px; }
pre { background: #0a1120; border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow: auto; max-height: 420px; font-size: 12px; }
details.jd { margin: 8px 0; }
details.jd summary { cursor: pointer; color: #7db4ff; font-size: 12px; }

.post { padding: 12px 14px; }
.post-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.thumb { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); margin: 4px 6px 0 0; }
.list { margin: 6px 0; padding-left: 20px; }
.list li { margin: 3px 0; }
.crumb button { font-size: 12px; }

input[type="checkbox"] { width: auto; min-width: auto; }
.course-grid td { min-width: 96px; height: 42px; font-size: 12px; }
.course { border-left: 3px solid #3b82f6; background: #14233c; border-radius: 6px; padding: 3px 6px; margin: 2px 0; }
.course b { display: block; font-size: 12px; }
.course span { color: var(--muted); font-size: 11px; }
iframe.plan { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #14283f; border: 1px solid #234066; color: #dbeafe; border-radius: 10px; padding: 9px 14px; box-shadow: 0 6px 18px rgba(0,0,0,.4); max-width: 380px; }
.toast.err { background: #2a1414; border-color: #7f1d1d; }
.toast.ok { background: #14311f; border-color: #1f6b45; }
.toast.warn { background: #2a2210; border-color: #7a5a12; color: #fde68a; }
.section-note { color: var(--muted); font-size: 12px; margin: 4px 2px 10px; }

/* ---- 资讯列表（沿用旧版阅读节奏：日期块 + 标题 + 摘要） ---- */
.news-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.news-tab {
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.news-tab:hover { color: var(--text); border-color: #2c4470; }
.news-tab.on { background: #14283f; border-color: #234066; color: #cfe3ff; }
.news-list { padding: 4px 0; }
.news-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 8px;
  border-bottom: 1px dashed var(--line); cursor: pointer;
}
.news-item:last-child { border-bottom: 0; }
.news-item:hover { background: #0f1a2d; }
.news-when {
  min-width: 62px; text-align: center; color: var(--muted);
  border-right: 1px solid var(--line); padding-right: 10px;
}
.news-when b { display: block; font-size: 19px; color: var(--text); line-height: 1.2; }
.news-when span { font-size: 11px; }
.news-main { flex: 1; min-width: 0; }
.news-title2 { font-size: 14.5px; line-height: 1.5; color: var(--text); }
.news-item:hover .news-title2 { color: #9ec7ff; }
.news-sub {
  margin-top: 3px; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.news-go { color: var(--muted); padding-left: 6px; font-size: 18px; }
.article-body { margin-top: 12px; font-size: 14.5px; line-height: 1.9; color: #d7e2f2; word-break: break-word; }
.cal-img {
  width: 100%; margin-top: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; cursor: zoom-in;
}
.cal-img:active { transform: scale(1.01); }
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.link-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; color: var(--text);
}
.link-card:hover { border-color: #2c4470; background: #101c31; }
.link-card b { font-size: 14px; }
.link-card .tiny { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 统一支付平台的验证码是 60x20 的 BMP，放大后必须保持硬边，不能糊。 */
.captcha {
  height: 40px; width: 120px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; image-rendering: pixelated;
}
.captcha:hover { border-color: #2c4470; }

/* 付款码卡片：视觉上必须和普通查询卡区分开，避免顺手点。 */
.warn-card { border-color: #6b4a13; background: #1a1608; }
.warn-card h3 { color: var(--warn); }
.warn-card .go { background: #b45309; }
.warn-card .go:hover { background: #92400e; }

/* 电费位置树：楼层和房间用网格，一层 39 个房间也能一屏点完，不用往下滚。 */
.elec-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 6px; margin: 2px 0 10px;
}
.elec-cell {
  background: #16233c; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 9px 6px; font-size: 12px; text-align: center;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: none;
}
.elec-cell:hover { background: #1e3054; border-color: #2b528c; }
/* 空调账户：每层两个账户里常挂表的那一个，用紫色和照明区分 */
.elec-cell.ac { background: #1b1733; border-color: #3b2f6a; color: #c4b5fd; }
.elec-cell.ac:hover { background: #241d44; border-color: #57489c; }
/* 房间（点一下即保存并查询） */
.elec-cell.leaf { background: #10301f; border-color: #1f6b45; color: #d1fae5; }
.elec-cell.leaf:hover { background: #14432c; border-color: #2f8c5c; }
/* 「查整层读数」之后：有表的房间把度数压在名字下面 */
.elec-cell.has { border-color: #2f8c5c; }
.elec-cell.has.leaf { background: #123424; }
.elec-kwh { display: block; font-size: 10px; color: #7dd3a0; margin-top: 2px; }

/* ---- 校园 AI 聊天 ---- */
.ai-card { display: flex; flex-direction: column; gap: 10px; }
.ai-head { align-items: flex-start; }
.ai-log {
  min-height: 280px; max-height: min(58vh, 640px); overflow: auto;
  padding: 10px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; display: flex; flex-direction: column; gap: 10px;
}
.ai-empty { margin: auto; text-align: center; max-width: 760px; }
.ai-empty .row { justify-content: center; }
.ai-msg { display: flex; gap: 10px; align-items: flex-start; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-avatar {
  width: 30px; height: 30px; min-width: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; background: #1e3054; color: #cfe3ff;
}
.ai-msg.user .ai-avatar { background: #14532d; color: #d1fae5; }
.ai-body {
  max-width: min(86%, 880px); background: #111c31; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 11px; min-width: 0;
}
.ai-msg.user .ai-body { background: #10243a; border-color: #24476e; }
.ai-text { white-space: normal; word-break: break-word; line-height: 1.65; }
.ai-text code { background: #0b1220; padding: 1px 4px; border-radius: 4px; }
.ai-pre {
  background: #0b1220; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; overflow: auto; max-height: 280px;
}
.ai-tools { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.ai-tool {
  border: 1px solid #263a5c; border-radius: 8px; padding: 6px 8px;
  background: #0d1728; font-size: 12px;
}
.ai-tool-head { gap: 6px; align-items: center; flex-wrap: wrap; }
.ai-tool-args { margin-top: 4px; }
.ai-tool-args code { color: #9db4d6; font-size: 11px; word-break: break-all; }
.ai-preview { margin-top: 4px; }
.ai-preview summary { cursor: pointer; color: var(--muted); }
.ai-preview pre { margin: 6px 0 0; max-height: 220px; overflow: auto; white-space: pre-wrap; }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.ai-dot.run { background: var(--warn); animation: ai-pulse 1s infinite; }
.ai-dot.ok { background: var(--accent2); }
.ai-dot.bad { background: var(--bad); }
@keyframes ai-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.ai-compose textarea {
  width: 100%; min-height: 64px; resize: vertical; background: #0b1220;
  color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit;
}
.ai-compose textarea:focus { outline: none; border-color: #2b528c; }
.ai-actions { margin-top: 6px; }
.err-text { color: #fca5a5; }
.ai-suggest { max-width: 100%; white-space: normal; text-align: left; }

/* ---- 对话组件：思考区 / 工具状态条 / 来源 / 推荐问题 ---- */
.ai-reason {
  border: 1px solid var(--line); border-radius: 10px; background: #0a1526;
  margin-bottom: 8px;
}
.ai-reason > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--muted); user-select: none;
}
.ai-reason > summary::-webkit-details-marker { display: none; }
.ai-reason[open] > summary { border-bottom: 1px solid var(--line); }
.ai-reason-body {
  padding: 8px 10px; font-size: 12px; line-height: 1.65; color: #9db4d6;
  white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto;
}
.ai-spin {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  border: 2px solid #2b528c; border-top-color: transparent;
  animation: ai-spin .8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

.ai-status {
  border: 1px solid var(--line); border-radius: 10px; background: #0a1526;
  margin-bottom: 8px; font-size: 12px;
}
.ai-status-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; color: #a9c0e0;
}
.ai-status.live .ai-status-head { color: #9ec5ff; }
.ai-status.live { border-color: #24476e; }
.ai-status-head .ai-tool-toggle { margin-left: auto; }
.ai-check { color: var(--accent2); font-weight: 700; }
.ai-status .ai-tools { padding: 2px 10px 8px; border-top: 1px dashed var(--line); }
.ai-status .ai-tool {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 5px 0; border: 0; background: none;
}
.ai-status .ai-tool b { font-size: 12px; font-weight: 600; color: var(--text); }
.ai-src-idx {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #1c2f52; color: #9ec5ff; font-size: 11px; font-weight: 600;
}

/* 正文里的来源角标 */
.ai-cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; padding: 0 3px; margin: 0 1px;
  border-radius: 7px; background: #1c2f52; color: #9ec5ff;
  font-size: 10px; font-weight: 700; cursor: pointer; vertical-align: super;
  line-height: 1;
}
.ai-cite:hover { background: #2b528c; color: #fff; }

/* 来源列表 */
.ai-src-list { margin-top: 8px; font-size: 12px; }
.ai-src-list > summary {
  cursor: pointer; color: var(--muted); padding: 3px 0; list-style: none;
}
.ai-src-list > summary::-webkit-details-marker { display: none; }
.ai-src-list > summary::before { content: '▸ '; }
.ai-src-list[open] > summary::before { content: '▾ '; }
.ai-source {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 6px; color: var(--muted);
}
.ai-source.hit { background: #1c2f52; color: var(--text); transition: background .2s; }
.ai-source-title { color: var(--text); }

/* 推荐问题 */
.ai-followup { margin-top: 10px; }
.ai-fu-title { color: var(--muted); font-size: 12px; margin-bottom: 4px; }

/* 空容器不要留下边框和空隙 */
.ai-status:empty, .ai-sources:empty, .ai-followup:empty, .ai-actions:empty { display: none; }
@media (max-width: 720px) {
  .ai-log { max-height: 52vh; min-height: 220px; }
  .ai-body { max-width: calc(100% - 42px); }
}

/* ---- 移动端：侧栏抽屉 + 底部快捷导航 ---- */
.nav-toggle { display: none; }
#nav-backdrop { display: none; }
#tabbar { display: none; }
#bar h1 { flex: 1; min-width: 0; }

@media (max-width: 720px) {
  body { display: block; }
  #side {
    position: fixed; left: 0; top: 0; z-index: 40;
    width: min(84vw, 310px); min-width: 0; height: 100dvh;
    transform: translateX(-102%); transition: transform .18s ease;
    box-shadow: 12px 0 32px rgba(0, 0, 0, .45);
  }
  body.nav-open #side { transform: translateX(0); }
  body.nav-open #nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 30;
    background: rgba(2, 6, 18, .62); backdrop-filter: blur(2px);
  }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0; margin-right: 8px;
    background: var(--panel); border-color: var(--line); font-size: 18px;
  }
  #main { padding: 10px 12px calc(76px + env(safe-area-inset-bottom)); max-width: none; }
  #bar {
    position: sticky; top: 0; z-index: 20; margin: -10px -12px 12px;
    padding: 10px 12px; background: rgba(11, 18, 32, .96);
    border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
  }
  #bar h1 { font-size: 18px; }
  .bar-right { gap: 4px; }
  .bar-right .chip { font-size: 11px; padding: 2px 7px; }
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 12px; border-radius: 10px; }
  .row > input, .row > select { flex: 1 1 140px; }
  .row > button { flex: 0 0 auto; }
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; }
  th, td { padding: 6px; }
  pre { max-height: 320px; }
  .news-sub { white-space: normal; }
  .news-when { min-width: 54px; padding-right: 8px; }
  .news-when b { font-size: 17px; }
  .link-grid { grid-template-columns: 1fr; }
  .qr-wrap { gap: 12px; }
  .qr { width: 168px; height: 168px; }
  #toasts { right: 10px; left: 10px; bottom: calc(70px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  #tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: rgba(14, 22, 38, .98); border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
  }
  #tabbar button {
    all: unset; flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 1px; padding: 5px 2px; border-radius: 8px; color: var(--muted);
    font-size: 10px; cursor: pointer;
  }
  #tabbar button span { font-size: 18px; line-height: 1.1; }
  #tabbar button.active { color: #cfe3ff; background: #17233c; }
}

@media (max-width: 480px) {
  #bar h1 { font-size: 16px; }
  .bar-right .chip { display: none; }
  .bar-right .chip:first-child { display: inline-block; }
  .card h3 { font-size: 14px; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; padding: 7px 10px; }
  .course-grid td { min-width: 78px; }
}

