:root {
  --ink: #221c16;
  --ink-soft: #5c5146;
  --muted: #6a5e52;
  --paper: #f3ecdf;
  --desk: #efe4d2;
  --sheet: #fbf8f2;
  --line: #e3d5c2;
  --dash: rgba(168, 140, 102, 0.55);
  --cover: #24312c;
  --cover-ink: #1b2622;
  --cream: #f3eadc;
  --cream-dim: #cbbfa8;
  --seal: #c2503a;
  --seal-deep: #8c3224;
  --brass: #c4a15a;
  --brass-deep: #8d6b2f;
  --moss: #3e5346;
  --shadow: 0 18px 40px rgba(36, 30, 24, 0.08);
  --font: system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--desk);
  text-rendering: optimizeLegibility;
}

::selection { background: #f0c7b4; color: var(--ink); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 80;
  background: var(--cover);
  color: var(--cream);
  padding: 8px 12px;
  text-decoration: none;
}
.skip:focus { top: 12px; }

html.boot .listing { visibility: hidden; }

.app {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 0 16px 14px;
  background:
    linear-gradient(180deg, rgba(196, 161, 90, 0.16), transparent 120px),
    var(--cover);
  color: var(--cream);
  overflow: auto;
}

.side::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: linear-gradient(90deg, #8c3224 0%, #c4a15a 28%, #f0e2b8 50%, #c4a15a 72%, #8c3224 100%);
}

.side :focus-visible { outline-color: #f0d7a2; }

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-right: 12px;
  padding: 8px 8px 16px;
  border-bottom: 1px solid rgba(243, 234, 220, 0.14);
}

.seal {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--seal);
  color: #f8f1e6;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  border-radius: 3px;
  transform: rotate(-8deg);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.28);
}

.brand-name {
  display: block;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.brand-sub {
  display: block;
  margin-top: 2px;
  color: var(--cream-dim);
  font-size: 12px;
  letter-spacing: 0.16em;
}

.side-nav { margin-right: 12px; }

.nav-label {
  margin: 16px 10px 6px;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--brass);
}

.nav-quick { display: flex; flex-direction: column; gap: 2px; }

.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li ul {
  margin: 2px 0 2px 16px;
  padding-left: 8px;
  border-left: 1px solid rgba(196, 161, 90, 0.35);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 10px 0 0 10px;
  color: var(--cream);
  text-decoration: none;
  line-height: 1.35;
}

.nav-item .lbl { flex: 1; min-width: 0; }
.nav-item .count {
  font-size: 12px;
  color: var(--cream-dim);
  font-variant-numeric: tabular-nums;
}
.nav-item:hover { background: rgba(243, 234, 220, 0.08); }
.nav-item[aria-current="page"] {
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--seal);
}
.nav-item[aria-current="page"] .count { color: var(--muted); }

.side-foot {
  margin-top: auto;
  margin-right: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(243, 234, 220, 0.14);
}

.who {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  color: var(--cover);
  font-weight: 700;
  flex: none;
}

.who strong { display: block; font-size: 14px; }
.who span { display: block; color: var(--cream-dim); font-size: 12px; }

.quota {
  margin: 2px 4px 0;
  color: var(--cream-dim);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.main {
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  overflow: auto;
  padding: 22px 28px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--desk);
}

.top,
.sheet { width: min(1040px, 100%); }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 14px;
}

.menu-btn,
.row-open,
.card-hit,
.seg button,
.clear-q {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.menu-btn {
  display: none;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.82);
}

.crumbs { flex: 1 1 180px; min-width: 0; }
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}
.crumbs li { display: inline-flex; align-items: center; min-width: 0; max-width: 100%; }
.crumbs li:not(:last-child)::after {
  content: "/";
  margin: 0 6px;
  color: #b5a48c;
}
.crumbs a,
.crumbs [aria-current="page"] {
  border-radius: 4px;
  padding: 2px 4px;
  text-decoration: none;
}
.crumbs a { color: var(--ink-soft); }
.crumbs a:hover { color: var(--ink); background: rgba(255, 252, 247, 0.7); }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 700; }

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 320px;
  justify-content: flex-end;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 180px;
  min-width: 0;
  height: 42px;
  padding: 0 8px 0 12px;
  background: rgba(255, 252, 247, 0.78);
  border: 1px solid #ddcfb8;
  border-radius: 999px;
}
.search-ico { flex: none; color: var(--muted); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0;
}
.search input:focus { outline: none; }
.search input[type="search"]::-webkit-search-cancel-button,
.search input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.clear-q {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
}
.clear-q:hover { background: rgba(36, 49, 44, 0.06); }

.seg {
  display: flex;
  flex: none;
  border: 1px solid #ddcfb8;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 252, 247, 0.78);
}
.seg button {
  height: 40px;
  padding: 0 14px;
  color: var(--ink-soft);
}
.seg button[aria-pressed="true"] {
  background: var(--cover);
  color: var(--cream);
}

.sheet {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 2px 18px 6px 6px;
  box-shadow: var(--shadow);
  padding: 18px 18px 12px 48px;
}

.sheet::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 22px;
  bottom: 22px;
  width: 10px;
  background: radial-gradient(circle, #c9b89a 2.4px, transparent 2.8px) center 0 / 10px 28px repeat-y;
  pointer-events: none;
}
.sheet::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 12px;
  bottom: 12px;
  border-left: 1px solid rgba(194, 80, 58, 0.55);
  pointer-events: none;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 12px 18px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 2px 6px 12px;
}

.kicker {
  margin: 0;
  color: var(--seal-deep);
  font-size: 12px;
  letter-spacing: 0.18em;
}

h1, h2 { font-weight: 700; letter-spacing: 0.03em; }
h1 {
  margin: 2px 0 0;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: 0;
}
.dek {
  margin: 6px 0 0;
  max-width: 46em;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

.sheet-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}
#summary { margin: 0; }

.sort {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  white-space: nowrap;
}
.sort select {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid #c4b49a;
  border-radius: 0;
  padding: 2px 2px 2px 0;
}

.num { font-variant-numeric: tabular-nums; }

.ico { width: 22px; height: 22px; display: inline-grid; place-items: center; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }
.ico-folder { color: var(--brass-deep); }
.ico-text { color: var(--moss); }
.ico-pdf { color: var(--seal-deep); }
.ico-image { color: #3d5c68; }
.ico-zip { color: #6b5344; }
.side .ico { color: #e0c27a; }
.side .nav-item[aria-current="page"] .ico { color: var(--brass-deep); }

.ledger .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 76px 52px;
  column-gap: 10px;
  align-items: center;
  padding: 2px 8px 2px 2px;
  border-bottom: 1px dashed var(--dash);
  color: inherit;
  text-decoration: none;
}
.ledger a.row { color: inherit; }
.ledger .row:hover { background: rgba(194, 80, 58, 0.05); }
.ledger .row-head {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  padding-top: 0;
  padding-bottom: 8px;
}
.ledger .row-head:hover { background: transparent; }
.head-name { padding-left: 32px; }
.row-open {
  display: flex;
  width: 100%;
  min-width: 0;
  text-align: left;
  padding: 8px 0;
}
.name-block { min-width: 0; flex: 1; }
.name-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.name-line .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.ledger .sub {
  display: none;
  margin-top: 2px;
  padding-left: 32px;
  color: var(--muted);
  font-size: 12px;
}
.ledger .has-sub .sub { display: block; }
.cell { color: var(--ink-soft); font-size: 13px; }
.act {
  justify-self: end;
  color: var(--seal-deep);
  text-decoration: none;
  font-size: 13px;
}
.act:hover { text-decoration: underline; }
.row.is-open { background: rgba(194, 80, 58, 0.09); }
.row:focus-within { background: rgba(194, 80, 58, 0.07); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
  padding: 4px 2px 8px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 198px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 2px 14px 3px 3px;
  color: inherit;
  text-decoration: none;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 18px;
  height: 18px;
  background: linear-gradient(225deg, var(--desk) 50%, #d9cbb6 50%);
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform 0.16s ease, box-shadow 0.16s ease; }
  .card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(36, 30, 24, 0.08); }
}
.card.is-open { box-shadow: inset 0 0 0 2px rgba(194, 80, 58, 0.45); }
.card-hit {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}
.thumb {
  height: 108px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #efe6d6;
}
.thumb .ico { width: 42px; height: 42px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.folder { background: linear-gradient(160deg, #f3e6d2, #e7d3b4); }
.thumb.text { background: #e7eee8; }
.thumb.pdf { background: #f3e7df; }
.thumb.image { background: #e6e1d8; }
.thumb.zip { background: #f0e6d8; }
.zip-mark {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #6b5344;
}
.card-body { padding: 8px 10px 2px; min-width: 0; }
.card .name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 650;
}
.card .sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.card-dl {
  margin: 4px 10px 10px;
  align-self: flex-start;
  color: var(--seal-deep);
  font-size: 12px;
  text-decoration: none;
}
.card-dl:hover { text-decoration: underline; }

mark {
  background: #f3c7a4;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.empty { padding: 34px 8px 24px; max-width: 36em; }
.empty-title { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.empty p { margin: 0 0 8px; color: var(--ink-soft); }
.empty .btn { margin-top: 8px; }

.colophon {
  margin: 16px 6px 2px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  background: var(--cover);
  color: var(--cream);
  text-decoration: none;
  border: 1px solid var(--cover);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--cover-ink); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: #cfc0aa;
}
.btn-ghost:hover { background: rgba(36, 49, 44, 0.06); }

.preview {
  width: min(880px, calc(100vw - 32px));
  max-height: min(86vh, 840px);
  max-height: min(86dvh, 840px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px 16px 6px 6px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(20, 16, 12, 0.35);
}
.preview::backdrop { background: rgba(28, 32, 30, 0.55); }
.preview-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.preview-bar h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.preview-actions { display: flex; gap: 8px; flex: none; }
.preview-body {
  overflow: auto;
  max-height: min(58vh, 620px);
  padding: 14px 16px;
}
.preview-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(56vh, 640px);
  margin: 0 auto;
  background: #efe6d6;
  border: 1px solid var(--line);
}
.prose {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.75;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-left: 3px solid var(--seal);
  padding: 14px 16px 16px 18px;
}
.fine { margin: 10px 0 0; color: var(--ink-soft); font-size: 13px; }
.warn { color: var(--seal-deep); }
.zip-list { list-style: none; margin: 8px 0 0; padding: 0; }
.zip-list li {
  padding: 8px 2px;
  border-bottom: 1px dashed var(--dash);
}
.preview-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  padding: 4px 16px 16px;
  font-size: 13px;
}
.preview-meta dt { color: var(--muted); }
.preview-meta dd { margin: 0; overflow-wrap: anywhere; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(28, 24, 20, 0.48);
}

.static-list {
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 20px 72px;
}
.static-list .brand { border: 0; margin: 0 0 12px; padding: 0; color: var(--ink); }
.static-list .brand-sub,
.static-list .who span,
.static-list .quota { color: var(--muted); }
.group { margin-top: 18px; }
.group h2 { margin: 0 0 6px; font-size: 16px; }
.group ul { margin: 0; padding-left: 1.15em; }
.group li { margin: 4px 0; }
.group a { color: var(--seal-deep); }

.miss-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(700px 320px at 10% 0%, rgba(194, 80, 58, 0.07), transparent 55%),
    var(--desk);
}
.miss-card { width: min(480px, 100%); margin: 0; min-height: 0; }
.miss-card .seal { margin-bottom: 14px; }
.miss-card .btn { margin-top: 8px; }

@media (max-width: 860px) {
  .app { display: block; min-height: 100vh; }
  .side {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .side.is-open { transform: translateX(0); }
  .side:not(.is-open) { visibility: hidden; }
  .menu-btn { display: inline-flex; }
  .main { height: auto; overflow: visible; padding: 14px 12px 36px; }
  body.menu-open { overflow: hidden; }
}

@media (max-width: 720px) {
  h1 { font-size: 24px; }
  .tools { flex: 1 1 100%; }
  .sheet { padding: 14px 10px 14px 34px; }
  .ledger .row { grid-template-columns: minmax(0, 1fr) auto; padding: 4px 2px; }
  .cell-date, .cell-size { display: none; }
  .ledger .row.row-head { display: none; }
  .sheet-meta { width: 100%; justify-content: space-between; }
  .ledger .sub { display: block; }
  .preview { width: calc(100vw - 16px); }
  .preview-bar { flex-direction: column; }
  .preview-actions { width: 100%; }
  .preview-actions .btn { flex: 1; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .side, .tools, .menu-btn, .scrim, .colophon { display: none !important; }
  .app { display: block; }
  .main { height: auto; overflow: visible; background: white; }
  .sheet { box-shadow: none; }
}
