:root {
  --bg: #f5f7fa; --surface: #fff; --line: #e4e7ee; --line-2: #eef0f5;
  --ink: #111827; --ink-2: #374151; --muted: #6b7280; --faint: #9aa1ae;
  --accent: #0519B0; --accent-2: #2a3fd1; --accent-soft: #eef0ff; --mark: #fff1a8;
  --s: #0e7c66; --k: #c2410c; --t: #7c3aed; --m: #0519B0;
  --r: 10px; --r-sm: 8px;
  --sh: 0 1px 2px rgba(17, 24, 39, .05), 0 4px 16px rgba(17, 24, 39, .05);
  --font: Inter, system-ui, -apple-system, Segoe UI, sans-serif; --display: 'Plus Jakarta Sans', var(--font);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; margin: 0; }

/* gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--sh); display: grid; gap: 14px; }
.gate-card h1 { font-size: 22px; }
.gate-card p { margin: -6px 0 4px; color: var(--muted); }
.gate-card label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; color: var(--ink-2); }
.gate-card input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; background: #fff; }
.gate-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; font-size: 1.05rem; }
.err { color: #b42318; font-size: 13px; min-height: 1em; }

.btn { height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #cfd4de; background: #fafbfc; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; height: 40px; justify-content: center; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; }
.icon-btn { width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid transparent; background: none; display: inline-grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); }

/* shell */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand span { display: grid; line-height: 1.15; }
.brand strong { font-family: var(--display); font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
#nav { display: grid; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; }
#nav a:hover { background: var(--bg); text-decoration: none; }
#nav a.on { background: var(--accent-soft); color: var(--accent); }
#nav a .n { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 500; }
#nav a.on .n { color: var(--accent); }
#nav .ni { width: 18px; text-align: center; }
.sync .link { font-size: 12.5px; margin-top: 4px; }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding: 10px 8px 0; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.me { display: flex; justify-content: space-between; gap: 8px; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; background: rgba(245, 247, 250, .92); backdrop-filter: blur(8px); padding: 12px 24px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; }
.topsearch { flex: 1; max-width: 760px; position: relative; }
.topsearch input { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: var(--r); padding: 0 40px 0 36px; background: #fff; }
.topsearch input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.topsearch .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--faint); font-size: 18px; }
.topsearch kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 11px var(--font); color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--bg); }
.view { padding: 20px 24px 60px; max-width: 1320px; }

/* headings & stats */
.vh { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.vh h1 { font-size: 22px; }
.vh p { margin: 2px 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat b { display: block; font: 700 22px/1.2 var(--display); }
.stat span { color: var(--muted); font-size: 12.5px; }
.bus { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* toolbar */
.toolbar { position: sticky; top: 63px; z-index: 4; background: var(--bg); padding: 8px 0 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search], .toolbar select { height: 34px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; padding: 0 10px; }
.toolbar input[type=search] { min-width: 220px; flex: 1; max-width: 340px; }
.toolbar select { max-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: #cfd4de; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; height: 32px; padding: 0 10px; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* tags */
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag.warn { background: #fff4e5; color: #9a5b00; height: 20px; font-size: 11.5px; margin-right: 6px; }
.bu-S { background: #e6f4f0; color: var(--s); } .bu-K { background: #fdeee4; color: var(--k); } .bu-T { background: #f1eafe; color: var(--t); } .bu-M { background: var(--accent-soft); color: var(--m); }
.code { font: 500 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.tag.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* list */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 140px 74px 170px 64px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line-2); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: #fafbff; }
.row.head { cursor: default; background: #fafbfc; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 14px; }
.row.head:hover { background: #fafbfc; }
.row .t { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .m { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .d { font-size: 12.5px; color: var(--muted); text-align: right; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; display: grid; gap: 8px; align-content: start; }
.card:hover { border-color: #c9cff0; box-shadow: var(--sh); }
.card .t { font-weight: 600; }
.card .sub { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.more { display: flex; justify-content: center; padding: 12px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* search results */
.sr-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.big-search { position: relative; margin-bottom: 10px; }
.big-search input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: var(--r); padding: 0 16px; background: #fff; font-size: 15px; }
.big-search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12.5px; margin: -2px 0 12px; }
.meta-hits { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.meta-hit { display: inline-flex; gap: 6px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 10px; font-size: 13px; cursor: pointer; max-width: 100%; }
.meta-hit:hover { border-color: var(--accent); }
.meta-hit span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-res { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; }
.doc-res .dh { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-res .dn { font-weight: 600; color: var(--ink); }
.doc-res .dsub { font-size: 12.5px; color: var(--muted); }
.hits { margin-top: 8px; display: grid; gap: 4px; }
.hit { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; align-items: baseline; padding: 6px 8px; border-radius: var(--r-sm); font-size: 13px; }
.hit:hover { background: var(--bg); }
.hit .hl { font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hit .hs { color: var(--ink-2); }
.hit .ha { display: flex; gap: 8px; font-size: 12px; white-space: nowrap; }
.mime { width: 18px; height: 18px; border-radius: 4px; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none; }
.mime.slides { background: #f4b400; } .mime.docs { background: #4285f4; } .mime.sheets { background: #0f9d58; } .mime.pdf { background: #db4437; } .mime.other { background: #9aa1ae; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(17, 24, 39, .28); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(760px, 100%); background: var(--surface); overflow: auto; padding: 22px 26px 60px; box-shadow: -8px 0 32px rgba(17, 24, 39, .12); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.drawer-x { position: sticky; top: 0; float: right; background: #fff; }
.dmeta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-right: 40px; }
.dt { font-size: 20px; margin: 6px 0 10px; padding-right: 40px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 13px; margin: 12px 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-line; }
.sec { margin-top: 18px; }
.sec h3 { font-size: 14px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.prose { white-space: pre-line; font-size: 13.5px; color: var(--ink-2); background: var(--bg); border-radius: var(--r-sm); padding: 10px 12px; }
.docbox { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; }
.docbox .dbh { display: flex; gap: 8px; align-items: center; padding: 10px 12px; flex-wrap: wrap; }
.docbox .dbh .dn { font-weight: 600; flex: 1; min-width: 180px; }
.outline { border-top: 1px solid var(--line-2); max-height: 320px; overflow: auto; }
.oi { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 6px 12px; font-size: 12.5px; color: var(--ink-2); border-top: 1px solid var(--line-2); }
.oi:first-child { border-top: 0; }
.oi a { font-weight: 600; }
.note { font-size: 12.5px; color: var(--muted); padding: 8px 12px; border-top: 1px solid var(--line-2); }
.rec { border: 1px solid var(--line); background: var(--bg); padding: 8px 12px; border-radius: var(--r-sm); margin-bottom: 6px; font-size: 13px; }
.rec .rm { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.reader-chunk { padding: 12px 0; border-top: 1px solid var(--line-2); }
.reader-chunk.focus { background: #fffbe6; margin: 0 -12px; padding: 12px; border-radius: var(--r-sm); }
.reader-chunk h4 { margin: 0 0 4px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.reader-chunk div { white-space: pre-line; font-size: 13.5px; color: var(--ink-2); }

/* recs table */
.rlist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ritem { padding: 12px 14px; border-top: 1px solid var(--line-2); display: grid; gap: 4px; }
.ritem:first-child { border-top: 0; }
.ritem .rt { font-size: 13.5px; white-space: pre-line; }
.ritem .rd { font-size: 12.5px; color: var(--muted); white-space: pre-line; }
.ritem .rmeta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.folder-g { margin-bottom: 14px; }
.folder-g h3 { font-size: 13px; color: var(--muted); font-family: var(--font); font-weight: 600; margin: 0 0 6px; }
.frow { display: grid; grid-template-columns: 20px minmax(0, 1fr) 120px 90px; gap: 10px; align-items: center; padding: 7px 12px; border-top: 1px solid var(--line-2); font-size: 13px; }
.frow:first-child { border-top: 0; }
.frow .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: var(--r-sm); font-size: 13px; z-index: 30; }

@media (max-width: 960px) {
  .row { grid-template-columns: 84px minmax(0, 1fr) 110px 64px; }
  .row > :nth-child(5), .row > :nth-child(6) { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 15; left: 0; width: 248px; transform: translateX(-100%); transition: transform .18s; box-shadow: 4px 0 24px rgba(17, 24, 39, .12); }
  .app.nav-open .side { transform: none; }
  .menu-btn { display: inline-grid; }
  .top { padding: 10px 16px; }
  .topsearch kbd { display: none; }
  .view { padding: 16px 16px 60px; }
  .toolbar { top: 59px; }
  .toolbar input[type=search] { min-width: 0; max-width: none; flex-basis: 100%; }
  .row { grid-template-columns: minmax(0, 1fr) 60px; padding: 10px 12px; }
  .row > :nth-child(1), .row > :nth-child(3), .row > :nth-child(5), .row > :nth-child(6) { display: none; }
  .row.head { display: none; }
  .hit { grid-template-columns: 1fr; gap: 2px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 6px; }
  .drawer-panel { padding: 16px 16px 60px; }
  .frow { grid-template-columns: 20px minmax(0, 1fr) 70px; }
  .frow > :nth-child(3) { display: none; }
}
