/* =========================================================
   拾匣 · 私有文件柜
   公开浏览，密码解锁下载 / 上传。
   ========================================================= */

body {
  font-family: Inter, 'Noto Sans SC', -apple-system, 'PingFang SC', sans-serif;
}
main#article {
  max-width: 1080px;
  padding-top: clamp(88px, 12vh, 116px);
  padding-bottom: 80px;
}
.read-progress,
.toc { display: none; }

.cb {
  --ok: #6b8f71;
  --ok-soft: rgba(107, 143, 113, .14);
  max-width: 1000px;
  margin: 0 auto;
}
:root[data-theme="dark"] .cb {
  --ok: #7fae86;
  --ok-soft: rgba(127, 174, 134, .16);
}

/* ---------- 头部 ---------- */
.cb-head {
  text-align: center;
}
.cb-eyebrow {
  margin: 0 0 16px;
  color: var(--ink-faint);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .26em;
}
.cb-eyebrow span { margin-right: 8px; color: var(--gold); font-size: 10px; }

.cb-head h1 {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 900;
  line-height: 1.35;
  letter-spacing: .01em;
  text-wrap: balance;
}
.cb-sub {
  max-width: 560px;
  margin: 0 auto;
  color: var(--ink-faint);
  font-size: 13px;
  line-height: 1.9;
}

/* ---------- 工具条 ---------- */
.cb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 30px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cb-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  font-size: 12.5px;
}
.cb-crumbs a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .2s ease;
}
.cb-crumbs a:hover { color: var(--accent); }
.cb-crumbs span { color: var(--ink); font-weight: 600; }
.cb-crumbs i { color: var(--ink-faint); font-style: normal; opacity: .6; }

.cb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cb-lock {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--ink-faint);
  font-size: 11.5px;
  letter-spacing: .03em;
}
.cb-lock i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .6;
}
.cb-lock.is-open {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: var(--ok-soft);
}
.cb-lock.is-open i {
  opacity: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
}

.cb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s ease;
}
.cb-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.cb-btn:disabled { opacity: .55; cursor: wait; transform: none; }
.cb-upload-trigger { cursor: pointer; user-select: none; }
.cb-file-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.cb-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-faint);
}
.cb-btn-ghost:hover { background: var(--paper-soft); }
.cb-btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 22px -14px var(--accent);
}
.cb-btn-primary:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent));
  border-color: transparent;
}

/* ---------- 统计 ---------- */
.cb-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--ink-faint);
  font-size: 11.5px;
}
.cb-meta i {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
}
.cb-hint {
  margin-left: auto;
  color: var(--accent);
  font-size: 11px;
}

/* ---------- 区块 ---------- */
.cb-section { margin-top: 30px; }
.cb-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--ink-faint);
  font-family: 'Noto Serif SC', serif;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .14em;
}
.cb-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

/* ---------- 分类卡 ---------- */
.cb-folders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.cb-folder {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.cb-folder:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  box-shadow: var(--shadow);
}
.cb-folder-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}
.cb-folder-icon svg { width: 20px; height: 20px; }
.cb-folder-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.cb-folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-family: 'Noto Serif SC', serif;
  font-size: 14.5px;
  font-weight: 700;
}
.cb-folder-meta {
  color: var(--ink-faint);
  font-size: 11px;
}
.cb-folder-arrow {
  margin-left: auto;
  color: var(--ink-faint);
  font-size: 13px;
  opacity: .5;
  transition: transform .2s ease, opacity .2s ease;
}
.cb-folder:hover .cb-folder-arrow {
  opacity: 1;
  transform: translateX(3px);
  color: var(--accent);
}

/* ---------- 文件列表 ---------- */
.cb-files {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cb-file {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 92px 132px 76px;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .18s ease;
}
.cb-file:last-child { border-bottom: 0; }
.cb-file:not(.cb-file-head) { cursor: pointer; }
.cb-file:hover { background: var(--paper-soft); }

.cb-file-head {
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: .12em;
  background: var(--paper-soft);
  padding-top: 9px;
  padding-bottom: 9px;
}
.cb-file-head:hover { background: var(--paper-soft); }

.cb-file-icon {
  display: grid;
  place-items: center;
  color: var(--ink-faint);
}
.cb-file-icon svg { width: 17px; height: 17px; }

.cb-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 13px;
}
.cb-file-size,
.cb-file-time {
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.cb-download {
  justify-self: end;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s ease;
}
.cb-download:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
}
.cb-download:disabled { opacity: .55; cursor: wait; }

/* ---------- 空状态 / 说明 ---------- */
.cb-empty {
  margin-top: 30px;
  padding: 60px 20px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  text-align: center;
}
.cb-empty-mark {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 22px;
}
.cb-empty h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-family: 'Noto Serif SC', serif;
  font-size: 17px;
}
.cb-empty p {
  margin: 0;
  color: var(--ink-faint);
  font-size: 12.5px;
}

.cb-note {
  margin: 30px 0 0;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.9;
}

/* ---------- 弹窗 ---------- */
.cb-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(18, 14, 9, .62);
  pointer-events: auto;
}
.cb-modal[hidden] { display: none; }
.cb-modal-card {
  position: relative;
  z-index: 1;
  width: min(92vw, 400px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, .45);
  pointer-events: auto;
  animation: cb-fade .18s ease both;
}
.cb-modal-eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: .2em;
}
.cb-modal-card h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-family: 'Noto Serif SC', serif;
  font-size: 19px;
  font-weight: 900;
}
.cb-modal-sub {
  margin: 0 0 16px;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.8;
}
.cb-modal-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.cb-modal-card input:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cb-modal-error {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 12px;
}
.cb-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- 上传进度 ---------- */
.cb-upload {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  width: min(86vw, 320px);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: cb-rise .25s ease both;
}
.cb-upload[hidden] { display: none; }
.cb-upload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
}
.cb-upload-close {
  width: 20px; height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.cb-upload-close:hover { background: var(--paper-soft); color: var(--ink); }
.cb-progress {
  height: 4px;
  margin-top: 12px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.cb-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width .2s ease;
}
.cb-upload-meta {
  margin: 8px 0 0;
  color: var(--ink-faint);
  font-size: 10.5px;
  line-height: 1.7;
  word-break: break-word;
}

/* ---------- Toast ---------- */
.cb-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 1100;
  transform: translateX(-50%);
  max-width: 86vw;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: cb-fade .2s ease both;
}
.cb-toast[hidden] { display: none; }
.cb-toast.is-error {
  background: var(--accent);
  color: #fff;
}

body.cb-modal-open,
html.cb-modal-open { overflow: hidden; }

@keyframes cb-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cb-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .cb-head h1 { font-size: 1.7rem; }
  .cb-bar { align-items: flex-start; }
  .cb-actions { width: 100%; }
  .cb-actions .cb-btn { flex: 1; justify-content: center; }
  .cb-lock { order: 5; }

  .cb-file-head { display: none; }
  .cb-file {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 3px 10px;
    padding: 12px 14px;
  }
  .cb-file-icon { grid-row: 1 / span 2; align-self: center; }
  .cb-file-name { grid-column: 2; grid-row: 1; }
  .cb-file-size { grid-column: 2; grid-row: 2; font-size: 10.5px; }
  .cb-file-time { display: none; }
  .cb-download { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
}

@media (max-width: 520px) {
  .cb-folders { grid-template-columns: 1fr; }
  .cb-upload { right: 12px; bottom: 12px; }
  .cb-hint { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .cb-modal, .cb-modal-card, .cb-upload, .cb-toast { animation: none; }
}
