/* ============================================================
   tree2 —— 资料库浏览器
   版式沿用「报纸」基因（衬线刊名、双线、纸张底色），但交互换成
   左侧目录树 + 右侧阅读区，像 CMS 管理后台，而不是一页长报纸。
   ============================================================ */

:root {
  --paper: #fffaf0;
  --paper-2: #fdf3dd;
  --card: #ffffff;
  --ink: #1e3a5f;
  --ink-2: #33506f;
  --line: #d9cdb5;
  --line-soft: #ece1ca;
  --sub: #8a7f6e;
  --red: #e8503a;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --green: #22a06b;
  --purple: #7c5cd6;
  --shadow: 0 1px 2px rgba(30, 58, 95, .06), 0 8px 24px -12px rgba(30, 58, 95, .25);
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", "STSong", serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --radius: 10px;
  --tree-w: 336px;
  --head-h: 56px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font: 14px/1.6 var(--sans);
  background:
    radial-gradient(1200px 420px at 50% -10%, #fff6e0 0%, rgba(255, 246, 224, 0) 70%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------------------------------------------------------- 顶栏 */

.t2-top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  height: var(--head-h); padding: 0 16px;
  background: rgba(255, 250, 240, .86);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.t2-brand { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-weight: 900; letter-spacing: .06em; white-space: nowrap; }
.t2-brand img { width: 24px; height: 24px; }
.t2-brand small { font: 500 11px/1 var(--sans); letter-spacing: .18em; color: var(--sub); }

.t2-seasons { display: flex; align-items: center; gap: 4px; padding: 3px; background: var(--paper-2); border-radius: 999px; }
.t2-season { padding: 5px 12px; border: 0; background: none; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.t2-season[aria-current="true"] { background: var(--ink); color: #fff; }
.t2-season:disabled { opacity: .38; cursor: not-allowed; }

.t2-search { position: relative; flex: 1; min-width: 140px; max-width: 460px; margin-left: auto; }
.t2-search input {
  width: 100%; height: 36px; padding: 0 68px 0 34px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font: inherit; color: var(--ink); outline: none;
}
.t2-search input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(30, 58, 95, .12); }
.t2-search .t2-search-ico { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--sub); pointer-events: none; }
.t2-search kbd {
  position: absolute; right: 10px; top: 50%; translate: 0 -50%;
  padding: 1px 6px; border: 1px solid var(--line-soft); border-bottom-width: 2px; border-radius: 5px;
  font: 600 10px/16px var(--mono); color: var(--sub); background: var(--paper);
}

.t2-iconbtn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line-soft); border-radius: 10px; background: #fff; cursor: pointer;
}
.t2-iconbtn:hover { border-color: var(--line); background: var(--paper-2); }
.t2-iconbtn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------------------------------------------------------- 主体布局 */

.t2-shell { display: grid; grid-template-columns: var(--tree-w) minmax(0, 1fr); height: calc(100dvh - var(--head-h)); }
.t2-shell.no-tree { grid-template-columns: minmax(0, 1fr); }
.t2-shell.no-tree .t2-side { display: none; }

/* 左：目录树 */
.t2-side {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(253, 243, 221, .35));
}

.t2-filters { padding: 12px 12px 8px; border-bottom: 1px solid var(--line-soft); display: grid; gap: 8px; }
.t2-filters select {
  height: 32px; padding: 0 8px; border: 1px solid var(--line-soft); border-radius: 8px; background: #fff; font: inherit; color: var(--ink);
}
.t2-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.t2-chip {
  padding: 3px 9px; border: 1px solid var(--line-soft); border-radius: 999px; background: #fff;
  font-size: 12px; cursor: pointer; color: var(--ink-2); white-space: nowrap;
}
.t2-chip:hover { border-color: var(--line); }
.t2-chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.t2-tree { flex: 1; min-height: 0; overflow: auto; padding: 8px 8px 40px; scrollbar-width: thin; }

.t2-node { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.t2-node:hover { background: rgba(30, 58, 95, .05); }
.t2-node[data-active="true"] { background: var(--ink); color: #fff; }
.t2-node[data-active="true"] .t2-count { color: rgba(255, 255, 255, .78); }

.t2-caret {
  flex: 0 0 22px; width: 22px; height: 26px; display: grid; place-items: center;
  border: 0; background: none; cursor: pointer; color: var(--sub); font-size: 10px;
  transition: transform .15s ease;
}
.t2-node[data-open="true"] > .t2-caret { transform: rotate(90deg); }
.t2-node[data-leaf="true"] .t2-caret { visibility: hidden; }

.t2-label {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 0; border: 0; background: none; text-align: left; cursor: pointer;
  font-size: 13px; line-height: 26px;
}
.t2-label .t2-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t2-count { font: 500 11px/1 var(--mono); color: var(--sub); }
.t2-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.t2-kind { flex: 0 0 auto; font: 600 9px/14px var(--mono); padding: 0 4px; border-radius: 3px; color: #fff; }
.t2-kind[data-k="pdf"] { background: var(--red); }
.t2-kind[data-k="docx"] { background: var(--blue); }
.t2-kind[data-k="image"] { background: var(--green); }
.t2-kind[data-k="audio"] { background: var(--amber); }
.t2-kind[data-k="text"] { background: var(--sub); }
.t2-kind[data-k="sheet"] { background: #16a34a; }
.t2-kind[data-k="slides"] { background: #d97706; }

.t2-children { margin-left: 12px; padding-left: 6px; border-left: 1px dashed var(--line-soft); }
.t2-children[hidden] { display: none; }

.t2-empty { padding: 24px 12px; text-align: center; color: var(--sub); font-size: 13px; }

/* 右：阅读区 */
.t2-main { min-width: 0; overflow: auto; scroll-behavior: smooth; }
.t2-main > * { max-width: 1180px; margin-inline: auto; padding-inline: clamp(14px, 3vw, 36px); }

.t2-hero { padding-top: 26px; padding-bottom: 18px; border-bottom: 3px double var(--ink); }
.t2-kicker { font: 500 11px/1 var(--sans); letter-spacing: .22em; color: var(--sub); text-transform: uppercase; margin-bottom: 10px; }
.t2-title { font-family: var(--serif); font-weight: 900; font-size: clamp(26px, 3.4vw, 40px); line-height: 1.15; margin: 0 0 10px; letter-spacing: .02em; }
.t2-title em { color: var(--red); font-style: normal; }
.t2-deck { color: var(--sub); font-size: 14px; margin: 0; max-width: 62em; }
/* 打不开清单时的补救入口：一排能点的按钮，而不是让人干瞪眼 */
.t2-fatal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 12px; }
.t2-fatal-actions .t2-btn { text-decoration: none; height: 34px; }
.t2-fatal-tip { font-size: 13px; }
.t2-fatal-tip code { background: rgba(30, 58, 95, .07); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.t2-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.t2-stat { display: flex; align-items: baseline; gap: 6px; padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: #fff; }
.t2-stat b { font: 800 18px/1 var(--serif); }
.t2-stat span { font-size: 12px; color: var(--sub); }

/* 吸附在 .t2-main 自己的顶边（它是滚动容器，不是页面），所以 top 是 0 而不是 --head-h；
   底色必须不透明，否则滚动时上方会透出被盖住的内容。 */
.t2-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-block: 12px; position: sticky; top: 0; z-index: 5;
  background: var(--paper);
  box-shadow: 0 1px 0 var(--line-soft);
}
.t2-bar .t2-grow { flex: 1; }
.t2-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.t2-btn:hover { background: var(--paper-2); }
.t2-btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.t2-btn.primary:hover { background: var(--ink-2); }
.t2-btn.ghost { border-color: transparent; background: transparent; }
.t2-btn.ghost:hover { background: rgba(30, 58, 95, .06); }
.t2-btn:disabled { opacity: .45; cursor: not-allowed; }
.t2-sort { height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 8px; font: inherit; font-size: 13px; }

/* 文件列表 */
.t2-list { list-style: none; margin: 4px 0 40px; padding: 0 clamp(14px, 3vw, 36px); max-width: 1180px; margin-inline: auto; }
.t2-file {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: #fff;
  margin-bottom: 6px; cursor: pointer;
}
.t2-file:hover { border-color: var(--line); box-shadow: var(--shadow); }
.t2-file.is-online .t2-file-ico { box-shadow: inset 0 0 0 2px var(--green); }
.t2-file-ico {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 9px;
  background: var(--paper-2); font: 800 10px/1 var(--mono); letter-spacing: .02em; color: var(--ink-2);
}
.t2-file-ico[data-k="pdf"] { background: #fdece9; color: #b5311d; }
.t2-file-ico[data-k="docx"] { background: #e8f0fe; color: #1f4fbf; }
.t2-file-ico[data-k="image"] { background: #e7f7ef; color: #18794e; }
.t2-file-ico[data-k="audio"] { background: #fff4de; color: #a8620a; }
.t2-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t2-file-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--sub); }
.t2-file-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.t2-tag { font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--paper-2); color: var(--ink-2); }
.t2-tag.ok { background: #e7f7ef; color: #18794e; }
.t2-tag.wait { background: #fbeff2; color: #a13652; }
.t2-file-act { display: flex; gap: 6px; }
.t2-file-act .t2-btn { height: 30px; }

/* 空态/引导 */
.t2-start { padding: 28px clamp(14px, 3vw, 36px) 60px; }
.t2-grid3 { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.t2-tile { padding: 14px; border: 1px solid var(--line-soft); border-radius: 12px; background: #fff; cursor: pointer; }
.t2-tile:hover { border-color: var(--line); box-shadow: var(--shadow); }
.t2-tile h4 { margin: 0 0 4px; font: 700 15px/1.4 var(--serif); }
.t2-tile p { margin: 0; font-size: 12px; color: var(--sub); }
.t2-steps { counter-reset: s; list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; }
.t2-steps li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; font-size: 13px; }
.t2-steps li::before { content: counter(s); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font: 700 12px/1 var(--sans); }

/* ---------------------------------------------------------- 预览抽屉 */

.t2-viewer {
  position: fixed; inset: 0; z-index: 80; display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: #2b2f36; color: #eee; translate: 0 100%; transition: translate .22s ease, visibility .22s;
  /* 关闭时必须真正"让开"：只靠 translate 挪走的话，这个满屏 fixed 层仍然在视口里
     接住点击，左侧目录树会整片点不动。visibility 顺手让里面的 iframe/canvas 不再渲染。 */
  visibility: hidden; pointer-events: none;
}
.t2-viewer[data-open="true"] { translate: 0 0; visibility: visible; pointer-events: auto; }
.t2-viewer-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #1f2329; border-bottom: 1px solid #3a3f47;
}
.t2-viewer-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.t2-viewer-title small { display: block; font-weight: 400; font-size: 12px; color: #9aa3ad; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t2-viewer .t2-btn { background: #2f343b; border-color: #454b54; color: #eee; }
.t2-viewer .t2-btn:hover { background: #3a4048; }
.t2-viewer-body { overflow: auto; padding: 18px; display: grid; place-items: start center; }
.t2-viewer-body .pad { padding: 40px; text-align: center; color: #c9ced6; }
.t2-viewer-body img.t2-img { max-width: min(100%, 1100px); height: auto; background: #fff; border-radius: 6px; }
.t2-viewer-body .t2-pdf { display: grid; gap: 14px; justify-items: center; width: 100%; }
.t2-viewer-body .t2-pdf .t2-pdfpage { background: #fff; box-shadow: 0 4px 24px rgba(0, 0, 0, .45); border-radius: 2px; }
.t2-viewer-body .t2-pdf canvas { display: block; max-width: 100%; height: auto; }
.t2-viewer-body .t2-doc { background: #fff; color: #222; border-radius: 6px; padding: 8px; max-width: 100%; overflow: auto; }
.t2-viewer-body .t2-doc .docx-wrapper { background: transparent; padding: 0; }
.t2-viewer-body .t2-doc .docx-wrapper > section.docx { box-shadow: 0 4px 24px rgba(0, 0, 0, .25); margin-bottom: 14px; }
.t2-viewer-body .t2-audio { width: min(680px, 100%); padding: 26px; background: #fff; color: var(--ink); border-radius: 12px; display: grid; gap: 14px; }
.t2-viewer-body .t2-audio audio { width: 100%; }
.t2-viewer-body pre.t2-text { width: min(980px, 100%); margin: 0; padding: 16px; background: #fff; color: #222; border-radius: 8px; font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; }
.t2-viewer-body .t2-sheet { width: min(1100px, 100%); background: #fff; color: #222; border-radius: 8px; padding: 10px; overflow: auto; }
.t2-viewer-body .t2-sheet table { border-collapse: collapse; font-size: 12.5px; }
.t2-viewer-body .t2-sheet td, .t2-viewer-body .t2-sheet th { border: 1px solid #ddd; padding: 3px 8px; white-space: nowrap; }

.t2-progress { width: 260px; height: 4px; border-radius: 4px; background: #3a3f47; overflow: hidden; }
.t2-progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .2s; }

/* ---------------------------------------------------------- 上传面板 */

.t2-drop {
  position: fixed; inset: 0; z-index: 90; display: none; place-items: center;
  background: rgba(30, 58, 95, .28); backdrop-filter: blur(2px);
}
.t2-drop[data-on="true"] { display: grid; }
.t2-drop-inner { padding: 40px 56px; border: 2px dashed #fff; border-radius: 18px; color: #fff; font: 700 18px/1.4 var(--serif); background: rgba(30, 58, 95, .55); }

.t2-uploads {
  position: fixed; right: 16px; bottom: 16px; z-index: 70; width: min(420px, calc(100vw - 32px));
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  display: none;
}
.t2-uploads[data-on="true"] { display: block; }
.t2-up-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-weight: 700; }
.t2-up-head .t2-grow { flex: 1; }
.t2-up-list { max-height: 42vh; overflow: auto; padding: 8px; display: grid; gap: 8px; }
.t2-up-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; font-size: 12.5px; }
.t2-up-item .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t2-up-item .s { color: var(--sub); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.t2-up-item .bar { grid-column: 1 / -1; height: 4px; background: var(--paper-2); border-radius: 4px; overflow: hidden; }
.t2-up-item .bar i { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
.t2-up-item[data-state="error"] .bar i { background: var(--red); }
.t2-up-item[data-state="dup"] .bar i { width: 100% !important; background: var(--blue); }

.t2-toast {
  position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 100;
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 13px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .18s, translate .18s;
}
.t2-toast[data-on="true"] { opacity: 1; translate: -50% -6px; }
.t2-toast[data-bad="true"] { background: var(--red); }

/* ---------------------------------------------------------- 响应式 */

.t2-menu { display: none; }

@media (max-width: 900px) {
  .t2-shell { grid-template-columns: minmax(0, 1fr); }
  .t2-side {
    position: fixed; inset: var(--head-h) 0 auto 0; z-index: 30; height: calc(100dvh - var(--head-h));
    translate: -100% 0; transition: translate .2s ease; box-shadow: var(--shadow);
  }
  .t2-shell.tree-open .t2-side { translate: 0 0; }
  .t2-menu { display: inline-grid; }
  .t2-brand small { display: none; }
  .t2-search { max-width: none; }
  .t2-search kbd { display: none; }
  .t2-search input { padding-right: 12px; }
  .t2-file { grid-template-columns: 40px minmax(0, 1fr); }
  .t2-file-act { grid-column: 2; }
  .t2-file-path { max-width: 60vw; }
  .t2-viewer-body { padding: 8px; }
}

@media (max-width: 560px) {
  .t2-season { padding: 5px 8px; font-size: 12px; }
  .t2-stats { gap: 6px; }
  .t2-stat { padding: 6px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
