:root {
  --bg: #f5f6f8; --card: #fff; --text: #1f2328; --muted: #6b7280; --line: #e3e6ea;
  --accent: #1f6feb; --accent-weak: #e8f0fe; --good: #1a7f37; --warn: #b35900; --bad: #c62828;
  --mark: #fff3a3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --card: #1e2125; --text: #e6e8eb; --muted: #9aa1aa; --line: #30353b;
    --accent: #4c8dff; --accent-weak: #1d2a40; --good: #4ac26b; --warn: #e3a04a; --bad: #ff6b6b;
    --mark: #5c4d00;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
h3 { font-size: 15px; margin: 14px 0 6px; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
mark { background: var(--mark); color: inherit; padding: 0 1px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.r { text-align: right; }

/* 顶栏 */
.top {
  display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 52px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 600; color: var(--text); white-space: nowrap; }
.top nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); white-space: nowrap; }
.top nav a.on, .top nav a:hover { background: var(--accent-weak); color: var(--accent); text-decoration: none; }
.me { position: relative; }
.me summary { cursor: pointer; list-style: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.me summary::after { content: " ▾"; color: var(--muted); }
.me .menu {
  position: absolute; right: 0; top: 38px; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; min-width: 140px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.me .menu a, .me .menu button { display: block; width: 100%; text-align: left; padding: 6px 10px; border-radius: 6px; color: var(--text); }
.me .menu a:hover, .me .menu button:hover { background: var(--accent-weak); text-decoration: none; }

main { max-width: 1180px; margin: 0 auto; padding: 16px 20px 60px; }
main.narrow { max-width: 460px; padding-top: 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
.narrowish { max-width: 520px; margin-top: 24px; }

/* 提示 */
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.notice.ok { background: #e6f4ea; color: #145c2c; }
.notice.bad { background: #fdecea; color: #8a1c1c; }
@media (prefers-color-scheme: dark) {
  .notice.ok { background: #16321f; color: #8fe0a6; }
  .notice.bad { background: #3a1a1a; color: #ffb4b4; }
}

/* 表单、按钮 */
label { display: block; margin: 10px 0; font-size: 14px; color: var(--muted); }
input[type=text], input:not([type]), input[type=password] {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text);
}
label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); }
.btn {
  display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--text); font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .6; cursor: default; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; white-space: nowrap; }
button.link.danger, .danger { color: var(--bad); }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0 4px; }
form.inline input { display: inline-block; width: auto; margin: 0; padding: 5px 8px; font-size: 14px; }
.login h1 { font-size: 20px; }
.login .btn { width: 100%; margin-top: 8px; padding: 9px; }

/* 首页 */
.bigsearch { display: flex; gap: 8px; margin: 8px 0 18px; }
.bigsearch input { margin: 0; padding: 10px 14px; font-size: 16px; }
.libs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.lib { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; color: var(--text); }
.lib:hover { border-color: var(--accent); text-decoration: none; }
.lib h3 { margin: 0 0 4px; }
.lib p { margin: 0 0 8px; color: var(--muted); font-size: 13px; min-height: 40px; }
.lib .num { font-size: 13px; color: var(--accent); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.cols h2 { margin-top: 0; }
.todo, .log { padding-left: 18px; margin: 6px 0; }
.log { list-style: none; padding: 0; }
.log li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.log .when { color: var(--muted); font-size: 12px; margin-right: 4px; }

/* 文件夹 */
.crumbs { font-size: 13px; color: var(--muted); margin-top: 4px; }
.readme { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; margin-bottom: 14px; }
.readme summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.readme pre { white-space: pre-wrap; font-family: inherit; font-size: 14px; margin: 6px 0; }
.upload {
  border: 2px dashed var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
  background: var(--card); transition: border-color .15s, background .15s;
}
.upload.over { border-color: var(--accent); background: var(--accent-weak); }
.upload p { margin: 4px 0; }
#queue { list-style: none; padding: 0; margin: 6px 0 0; max-height: 260px; overflow-y: auto; }
#queue li { display: grid; grid-template-columns: 1fr 140px 120px; gap: 10px; align-items: center; font-size: 13px; padding: 2px 0; }
#queue li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#queue li.bad .s { color: var(--bad); }
#queue li.done .s { color: var(--good); }
#queue progress { width: 100%; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px -4px; }
table.files { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.files th, .files td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.files th { font-size: 13px; color: var(--muted); font-weight: 500; background: var(--bg); }
.files th.r, .files td.r { text-align: right; white-space: nowrap; }
.scrollx { overflow-x: auto; }
.files form.rename, .titlebar form.rename { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.files form.rename input[name=name], .titlebar form.rename input[name=name] { flex: 1 1 12em; width: auto; margin: 0; padding: 5px 8px; font-size: 14px; }
.files form.rename .btn, .titlebar form.rename .btn { padding: 5px 12px; }
.titlebar { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.titlebar form.rename { flex: 1 1 100%; max-width: 520px; margin: 18px 0 14px; }
.files td.r [data-rename] + form.inline { margin: 0 0 0 12px; }
.users th, .users td { white-space: nowrap; }
.files tr:last-child td { border-bottom: 0; }
.files tr.off td { opacity: .55; }
.files td.name { word-break: break-all; }
.files .ico { margin-right: 6px; }
.files .pv { margin-left: 8px; }
.files form { margin: 0; display: inline; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.samples { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 14px; }
.sample { color: var(--text); }
.sample:hover { border-color: var(--accent); text-decoration: none; }
.sample h3 { margin-top: 0; }
.sample p { margin: 2px 0; }

/* 预览 */
.sheets { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.sheets a { padding: 3px 10px; border: 1px solid var(--line); border-radius: 14px; font-size: 13px; }
.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table.sheet { border-collapse: collapse; font-size: 13px; }
.sheet th, .sheet td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; max-width: 420px; }
.sheet th { background: var(--accent-weak); position: sticky; top: 0; }
pre.text { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; font-size: 13px; }

/* 搜索 */
.book { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 18px 14px; margin-bottom: 16px; }
.book h2 a { margin-left: 8px; font-weight: normal; }
.item { border-top: 1px solid var(--line); padding: 10px 0; }
.item .head { margin-bottom: 4px; }
.item dl { display: grid; grid-template-columns: 76px 1fr; gap: 2px 10px; margin: 4px 0; font-size: 14px; }
.item dt { color: var(--muted); }
.item dd { margin: 0; }
.item p { margin: 4px 0; }
.notes { border-left: 3px solid var(--accent); padding: 2px 10px; margin: 6px 0; font-size: 14px; background: var(--accent-weak); border-radius: 0 6px 6px 0; }
.notes.all { border-left-color: var(--line); background: none; }
details summary { cursor: pointer; }

/* 链接框 */
.linkbox { display: flex; gap: 8px; margin: 10px 0; }
.linkbox input { margin: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px; }
  .top nav { order: 3; width: 100%; flex: none; }
  main { padding: 12px 12px 40px; }
  .cols { grid-template-columns: 1fr; }
  .files:not(.users) th:nth-child(3), .files:not(.users) td:nth-child(3), .files:not(.users) th:nth-child(4), .files:not(.users) td:nth-child(4) { display: none; }
  .users th:nth-child(5), .users td:nth-child(5) { display: none; }
  #queue li { grid-template-columns: 1fr 70px; }
  #queue li progress { display: none; }
}
