/* 信源引擎 v2.3 · 多栏独立滚动规范
   目标：外壳固定；每个分栏各自滚动；内容不溢出时不出现滚动条；
        栏头与表头粘性固定；横向只在表格栏内滚动。 */

/* ---------- 1. 外壳固定，整页不滚动 ---------- */
html, body {
  height: 100%;
  overflow: hidden;
}
.app-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}
.sidebar {
  position: relative;
  top: auto;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.main-area {
  min-height: 0;
  overflow: hidden;
}
.topbar {
  position: relative;
  top: auto;
}

/* ---------- 2. 主内容区：单列页面的内容栏 ---------- */
.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* 全高分栏页面：标题区固定，分栏区占满剩余高度 */
.view.view-fill {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.view.view-fill > .page-head {
  flex: 0 0 auto;
  margin-bottom: 12px;
}
.view.view-fill > .notice,
.view.view-fill > .tabs {
  flex: 0 0 auto;
}

/* ---------- 3. 写作：历史 / 对话 / 预览 三栏独立滚动 ---------- */
.writing-layout {
  flex: 1;
  min-height: 0;
  height: auto;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}
.writing-layout > .panel {
  height: 100%;
  min-height: 0;
}
.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.panel-head,
.panel-foot,
.preview-toolbar,
.metrics-strip,
.v22-hint {
  flex: 0 0 auto;
}

/* ---------- 4. 审核：全文 / 清单 两栏独立滚动 ---------- */
.review-layout {
  flex: 1;
  min-height: 0;
  height: auto;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}
.review-layout > * {
  min-height: 0;
  height: 100%;
}
.review-doc {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: none;
}
.review-doc > .card-head {
  flex: 0 0 auto;
}
.review-doc > .card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.review-layout > .card:not(.review-doc) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.review-layout > .card:not(.review-doc) > .card-head,
.review-foot {
  flex: 0 0 auto;
}
.checklist {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------- 5. 规则集：列表 / 编辑 两栏独立滚动 ---------- */
.ruleset-layout {
  flex: 1;
  min-height: 0;
  height: auto;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}
.ruleset-layout > .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.ruleset-layout > .card > .card-head,
.ruleset-layout > .card > .card-foot {
  flex: 0 0 auto;
}
.ruleset-layout > .card .ruleset-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ruleset-layout > .card .card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------- 6. 长列表：在本栏内滚动，不撑高页面 ---------- */
.msg-list,
.activity {
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* 页面内两栏 / 三栏卡片栅格：每栏独立纵向滚动 */
.grid-2,
.grid-2-1,
.grid-3 {
  align-items: start;
}
.grid-2 > .card,
.grid-2-1 > .card,
.grid-3 > .card {
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.grid-2 > .card:hover,
.grid-2-1 > .card:hover,
.grid-3 > .card:hover {
  scrollbar-color: #c9d3e2 transparent;
}
.grid-2 > .card > .card-head,
.grid-2-1 > .card > .card-head,
.grid-3 > .card > .card-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
}
.card-body.tight > .table-wrap {
  max-height: calc(100vh - 320px);
  overflow: auto;
  overscroll-behavior: contain;
}
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-width: 100%;
  overscroll-behavior-x: contain;
}

/* 表头在所属滚动栏内固定 */
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fbfcfe;
}

/* ---------- 7. 弹窗内的多栏 ---------- */
.modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.diff-cols {
  max-height: calc(100vh - 360px);
}
.diff-cols > * {
  min-height: 0;
  max-height: calc(100vh - 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal .pp-grid,
.modal .material-grid {
  max-height: calc(100vh - 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------- 8. 滚动条：默认极淡，悬停该栏才可感知 ---------- */
.view,
.sidebar,
.panel-body,
.checklist,
.modal-body,
.ruleset-list,
.table-wrap,
.msg-list,
.activity,
.diff-cols > *,
.sw-editor {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.view:hover,
.sidebar:hover,
.panel-body:hover,
.checklist:hover,
.modal-body:hover,
.ruleset-list:hover,
.table-wrap:hover,
.msg-list:hover,
.activity:hover,
.diff-cols > *:hover,
.sw-editor:hover {
  scrollbar-color: #c9d3e2 transparent;
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
}
.view:hover::-webkit-scrollbar-thumb,
.sidebar:hover::-webkit-scrollbar-thumb,
.panel-body:hover::-webkit-scrollbar-thumb,
.checklist:hover::-webkit-scrollbar-thumb,
.modal-body:hover::-webkit-scrollbar-thumb,
.ruleset-list:hover::-webkit-scrollbar-thumb,
.table-wrap:hover::-webkit-scrollbar-thumb,
.msg-list:hover::-webkit-scrollbar-thumb,
.activity:hover::-webkit-scrollbar-thumb,
.diff-cols > *:hover::-webkit-scrollbar-thumb,
.sw-editor:hover::-webkit-scrollbar-thumb {
  background: #ccd5e2;
}

/* ---------- 9. 窄屏（1366×768 及以下） ---------- */
@media (max-width: 1280px) {
  .view { padding: 16px; }
  .review-layout { grid-template-columns: minmax(0, 1fr) 380px; }
}
@media (max-width: 1080px) {
  .sidebar { position: fixed; height: 100vh; }
  .review-layout {
    height: auto;
    display: block;
  }
  .review-layout > * {
    height: auto;
    margin-bottom: 12px;
  }
  .review-doc > .card-body { max-height: 50vh; }
  .checklist { max-height: 52vh; }
  .writing-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .writing-layout .panel-history { display: none; }
}
@media (max-width: 760px) {
  .view { padding: 12px; }
  .writing-layout {
    display: block;
    height: auto;
  }
  .writing-layout > .panel {
    height: auto;
    max-height: 55vh;
    margin-bottom: 12px;
  }
  .ruleset-layout {
    display: block;
    height: auto;
  }
  .ruleset-layout > .card {
    height: auto;
    max-height: 55vh;
    margin-bottom: 12px;
  }
  .msg-list,
  .activity,
  .card-body.tight > .table-wrap {
    max-height: 50vh;
  }
}
