:root {
  color-scheme: light;
  --bg: #f2f5fa; --bg-subtle: #fff; --bg-hover: #e9eff9;
  --border: #d7e0ef; --border-muted: #e1e7f0;
  --fg: #18263b; --fg-muted: #52627a; --accent: #225abe;
  --tile: #eaf0fc; --sel: #dfeafa;
  --surface: #fff; --rail: #f8fafd; --top: #fff;
  --blue: #255dbc; --green: #097458; --gold: #855500; --purple: #6848b9;
  --blue-tint: #e7efff; --green-tint: #def6eb; --gold-tint: #fff1d7; --purple-tint: #eee8ff;
  --font: Inter, 'Segoe UI', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b111d; --bg-subtle: #101a2a; --bg-hover: #182640;
    --border: #24334c; --border-muted: #202e44;
    --fg: #f0f4fd; --fg-muted: #a2aec4; --accent: #91b7ff; --sel: #182947;
    --tile: #192944; --surface: #111b2c; --rail: #0d1523; --top: #0e1726;
    --blue: #91b9ff; --green: #75e3bd; --gold: #f2c77a; --purple: #c6aaff;
    --blue-tint: #1b2d4c; --green-tint: #15352f; --gold-tint: #352c25; --purple-tint: #2c2546;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b111d; --bg-subtle: #101a2a; --bg-hover: #182640;
  --border: #24334c; --border-muted: #202e44;
  --fg: #f0f4fd; --fg-muted: #a2aec4; --accent: #91b7ff; --sel: #182947;
  --tile: #192944; --surface: #111b2c; --rail: #0d1523; --top: #0e1726;
  --blue: #91b9ff; --green: #75e3bd; --gold: #f2c77a; --purple: #c6aaff;
  --blue-tint: #1b2d4c; --green-tint: #15352f; --gold-tint: #352c25; --purple-tint: #2c2546;
}
body { background: var(--bg); }
.topbar { height: 65px; padding: 0 26px; background: var(--top); }
.topbar .spacer { display: block; flex: 1; }
body[data-section=""]:not([data-page]) .topbar .spacer { display: none; }
.topbar .brand { margin-right: auto; gap: 11px; font: 650 1.08rem var(--font); letter-spacing: -.025em; white-space: nowrap; }
.brand img { width: 35px; height: 35px; border-radius: 10px; }
.topbar .icon-btn { border: 1px solid var(--border); border-radius: 10px; width: 38px; height: 38px; }
.topbar .icon-btn.burger { border-color: transparent; }
.theme-seg { background: var(--rail); }
.theme-seg button.on { background: var(--sel); }
.sidebar { width: 216px; padding: 24px 14px; background: var(--rail); }
.nav-link { gap: 12px; min-height: 43px; margin-bottom: 4px; font-size: .88rem; color: var(--fg-muted); }
.nav-link.active { background: var(--sel); color: var(--accent); }
.nav-label { font-size: .75rem; letter-spacing: .08em; font-weight: 650; margin: 26px 12px 9px; }
.page { max-width: 1470px; padding: 27px clamp(18px, 3vw, 43px) 56px; }
.preview-tag { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 20px; color: var(--fg-muted); font-size: .76rem; white-space: nowrap; }

.archive-hero {
  isolation: isolate;
  position: relative;
  overflow: hidden;
  min-height: 272px;
  display: flex;
  align-items: center;
  padding: 32px clamp(24px, 4.1vw, 61px);
  background: radial-gradient(ellipse at 77% 85%, #234a81 0, transparent 52%), linear-gradient(112deg,#142844 0%,#17345e 58%,#1b4374 100%);
  border: 1px solid #375989;
  border-radius: 23px;
  color: #f5f8ff;
}
.hero-content { position: relative; z-index: 2; width: min(100%, 510px); }
.archive-hero h1 { margin: 0; font: 720 clamp(2.35rem, 5vw, 4rem)/1.03 var(--font); letter-spacing: -.065em; }
.archive-hero p { max-width: 400px; margin: 14px 0 23px; color: #d1def4; font-size: 1.03rem; line-height: 1.55; }
.archive-hero .top-search { display: flex; margin: 0; max-width: 436px; }
.archive-hero .top-search svg { left: 15px; top: 17px; color: #a6bad8; }
.archive-hero .top-search input { height: 50px; padding-left: 43px; padding-right: 51px; background: #102341; border: 1px solid #5575a2; border-radius: 11px; color: #fff; font-size: .94rem; color-scheme: dark; }
.archive-hero .top-search input::placeholder { color: #c4d2e8; opacity: 1; }
.archive-hero .top-search kbd { position: absolute; inset: 12px 13px 12px auto; display: grid; place-items: center; width: 25px; border-radius: 5px; color: #b7c8e2; border: 1px solid #49618a; background: #1e365b; font: .8rem var(--mono); pointer-events: none; }
.archive-hero .top-search:focus-within kbd { display: none; }
.hero-art { z-index: 1; position: absolute; inset: 0 0 0 48%; pointer-events: none; }
.hero-art::before { content: ""; position: absolute; inset: 0; background: linear-gradient(#96baff1e 1px,transparent 1px),linear-gradient(90deg,#96baff1e 1px,transparent 1px); background-size: 31px 31px; mask-image: radial-gradient(ellipse at 61% 51%,#000 0%,transparent 74%); }
.art-scene { position: absolute; width: 352px; height: 234px; top: 50%; left: 57%; transform: translate(-50%,-50%); }
.art-orbit { position: absolute; inset: 10px 19px; border: 1px solid #a3c7ff29; border-radius: 50%; transform: rotate(-20deg); }
.art-orbit::after { content: ""; position: absolute; inset: 17px -22px; border: 1px solid #a3c7ff20; border-radius: 50%; }
.art-folder { position: absolute; width: 183px; height: 132px; top: 72px; left: 82px; transform: rotate(-10deg); }
.folder-back { position: absolute; inset: 8px 2px 6px; border-radius: 12px; background: linear-gradient(140deg,#739fff,#345fc2); box-shadow: 0 18px 43px #091c49aa; }
.folder-back::before { content: ""; position: absolute; width: 65px; height: 25px; left: 0; top: -12px; border-radius: 11px 12px 0 0; transform: skewX(10deg); transform-origin: bottom left; background: #75a1ff; }
.folder-paper { position: absolute; width: 98px; height: 123px; left: 56px; top: -34px; border-radius: 10px; border: 1px solid #f9fbff; background: linear-gradient(155deg,#edf5ff,#a9c9ff); box-shadow: 0 5px 14px #173b9a54; transform: rotate(14deg); }
.folder-paper::before { content: ""; display: block; margin: 19px 15px 8px; width: 24px; height: 24px; border-radius: 6px; background: #98b9fb; }
.folder-paper::after { content: ""; display: block; width: 62px; height: 15px; margin-left: 15px; background: repeating-linear-gradient(to bottom,#81a9eb 0 2px,transparent 2px 7px); }
.folder-paper.behind { transform: rotate(-13deg); left: 25px; top: -18px; background: linear-gradient(150deg,#c9dfff,#90aff6); }
.folder-paper.behind::before, .folder-paper.behind::after { display: none; }
.folder-front { position: absolute; inset: 29px -7px 0 6px; border-radius: 13px; background: linear-gradient(155deg,#acccff 0,#759fff 51%,#517be4 100%); border: 1px solid #b6d5ff; box-shadow: 0 10px 17px #1228595c, inset 0 1px 1px #fff6; transform: skewX(-9deg); }
.folder-front::after { content: ""; position: absolute; width: 38px; height: 12px; border: 1px solid #d3e3ff99; border-radius: 4px; left: 16px; bottom: 17px; background: #bbd4ff65; }
.art-chip { position: absolute; display: grid; place-items: center; width: 49px; height: 49px; border-radius: 13px; box-shadow: 0 7px 20px #081a3b66; }
.art-chip.book { top: 16px; right: 30px; color: #eee4ff; background: #7656c1; border: 1px solid #a990ec; transform: rotate(11deg); }
.art-chip.play { left: 17px; bottom: 30px; color: #c7ffe9; background: #21766e; border: 1px solid #55ad9e; transform: rotate(-11deg); }
.art-chip.doc { right: 19px; bottom: 24px; width: 38px; height: 38px; color: #fde3b7; background: #88663c; border: 1px solid #be9d67; transform: rotate(13deg); }
.art-spark { position: absolute; color: #bad5ff; font-size: 23px; line-height: 1; }
.art-spark.first { top: 22px; left: 30px; } .art-spark.second { top: 92px; right: 1px; font-size: 15px; }

.archive-dashboard { display: grid; gap: 29px; margin-top: 25px; }
.archive-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; min-height: 30px; }
.archive-heading h2 { margin: 0; color: var(--fg); font-size: 1.21rem; font-weight: 650; letter-spacing: -.025em; }
.archive-sections { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 14px; }
.archive-card { min-width: 0; min-height: 147px; border: 1px solid var(--border); border-radius: 16px; padding: 15px; display: flex; flex-direction: column; align-items: flex-start; background: var(--surface); color: var(--fg); transition: border-color .16s, background .16s; }
.archive-card:hover { text-decoration: none; background: var(--bg-hover); border-color: var(--accent); }
.archive-card strong { margin-top: 11px; font-size: .96rem; font-weight: 650; line-height: 1.26; }
.archive-card .category-meta { margin-top: auto; padding-top: 7px; color: var(--fg-muted); font-size: .81rem; line-height: 1.35; }
.category-icon { width: 43px; height: 43px; flex: none; display: grid; place-items: center; border-radius: 12px; color: var(--blue); background: var(--blue-tint); }
[data-category="library"] .category-icon { color: var(--purple); background: var(--purple-tint); }
[data-category="other"] .category-icon { color: var(--gold); background: var(--gold-tint); }
[data-category="downloads"] .category-icon { color: var(--green); background: var(--green-tint); }
[data-category="github"] .category-icon { color: var(--fg); background: var(--bg-hover); }

.archive-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, .36fr); gap: 21px; align-items: start; }
.archive-columns > * { min-width: 0; }
.archive-list { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.archive-file, .archive-list-labels { display: grid; grid-template-columns: minmax(0,1fr) minmax(98px,.35fr) 76px; align-items: center; gap: 13px; padding: 0 15px; }
.archive-list-labels { min-height: 41px; color: var(--fg-muted); font-size: .77rem; background: var(--rail); border-bottom: 1px solid var(--border-muted); }
.archive-file { min-height: 55px; color: var(--fg); }
.archive-file + .archive-file { border-top: 1px solid var(--border-muted); }
.archive-file:hover { text-decoration: none; background: var(--bg-hover); }
.archive-file:focus-visible { outline-offset: -3px; }
.archive-file-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: .89rem; font-weight: 550; }
.archive-file-name b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: inherit; }
.archive-file .category-icon { width: 31px; height: 31px; border-radius: 8px; }
.archive-file-meta { color: var(--fg-muted); font-size: .8rem; line-height: 1.3; }
.archive-file-size { text-align: right; white-space: nowrap; }
.archive-dashboard .linkbtn { border: 1px solid var(--border); border-radius: 8px; padding: 3px 10px; min-height: 31px; text-decoration: none; font-size: .8rem; }
.archive-dashboard .linkbtn:hover { background: var(--bg-hover); }
.archive-empty { color: var(--fg-muted); font-size: .89rem; padding: 15px; margin: 0; }
.archive-panel { border: 1px solid var(--border); border-radius: 16px; padding: 15px; background: var(--surface); margin-bottom: 13px; }
.archive-panel .panel-head { justify-content: flex-start; gap: 10px; margin: 0 0 12px; color: var(--fg); font-size: .93rem; }
.archive-panel .panel-head > svg { color: var(--accent); }
.archive-panel .panel-head .badge { margin-left: auto; }
.archive-panel .bar { margin: 10px 0 0; }
.archive-panel .sys-row { padding: 5px 0; font-size: .83rem; }
.archive-panel .muted { font-size: .84rem; }
.storage-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 5px 12px; }
#disk-num { font-size: 1.12rem; letter-spacing: -.03em; }
#sresults:not([hidden]) { margin-top: 23px; }
.archive-dashboard .media-row img { object-fit: cover; width: 100%; }
.archive-dashboard [hidden], .archive-home [hidden] { display: none !important; }
.archive-notice { max-width: 640px; padding: 25px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.archive-notice h1 { margin: 0 0 10px; font-size: 1.6rem; }
.archive-notice p { margin: 0 0 18px; color: var(--fg-muted); font-size: 1rem; }

@media (max-width: 1150px) {
  .sidebar { width: 191px; }
  .archive-columns { grid-template-columns: minmax(0, 1fr) minmax(205px, .38fr); gap: 14px; }
  .art-scene { left: 61%; transform: translate(-50%,-50%) scale(.83); }
  .hero-content { width: min(62%, 490px); }
  .archive-card { padding: 13px; }
}
@media (max-width: 980px) {
  .archive-columns { grid-template-columns: minmax(0,1fr); }
  .archive-info { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .archive-info .archive-heading { grid-column: 1 / -1; margin-bottom: 0; }
  .archive-info .archive-panel { margin: 0; }
  .archive-sections { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .archive-card { min-height: 133px; }
}
@media (max-width: 800px) {
  .topbar { height: 58px; padding: 0 12px; gap: 8px; flex: none; }
  .sidebar { top: 58px; width: min(260px, 82vw); visibility: hidden; padding: 15px 11px; }
  body.menu-open .sidebar { visibility: visible; }
  .page { padding: 16px 14px 40px; }
  .archive-hero { min-height: 238px; }
  .archive-hero .top-search input { font-size: 1rem; }
  .archive-heading h2 { scroll-margin-top: 16px; }
  .archive-sections { gap: 11px; }
}
@media (max-width: 560px) {
  .brand img { width: 29px; height: 29px; border-radius: 8px; }
  .topbar .brand { gap: 6px; font-size: .9rem; }
  .topbar .icon-btn { width: 32px; height: 34px; }
  .theme-seg { background: transparent; }
  .preview-tag { font-size: .70rem; padding: 2px 6px; }
  body:not([data-section=""]) .topbar .brand span { display: none; }
  .topbar .spacer { display: none; }
  .archive-hero { min-height: 228px; padding: 25px 18px; border-radius: 17px; }
  .archive-hero h1 { font-size: 2.52rem; }
  .archive-hero p { margin: 12px 0 18px; max-width: 230px; font-size: .92rem; }
  .hero-content { width: 100%; }
  .art-scene { transform: translate(-50%,-61%) scale(.48); left: 67%; opacity: .48; }
  .archive-hero .top-search kbd { display: none; }
  .archive-hero .top-search input { padding-right: 12px; }
  .archive-dashboard { margin-top: 19px; gap: 23px; }
  .archive-sections { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .archive-card strong { font-size: .88rem; }
  .archive-card .category-meta { font-size: .75rem; }
  .archive-file, .archive-list-labels { grid-template-columns: minmax(0,1fr) 54px; padding: 0 10px; gap: 7px; }
  .archive-file .file-section, .archive-list-labels .file-section { display: none; }
  .archive-file-name { font-size: .81rem; gap: 8px; }
  .archive-info { grid-template-columns: minmax(0,1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .archive-card, .archive-panel .bar i { transition: none; }
}

@media (min-width: 801px) { .topbar .burger { display: none; } }
@media (max-width: 370px) { .topbar .brand span { display: none; } }

/* Заполнение диска из /api/system. */
#disk-meter { display: block; width: 100%; accent-color: var(--blue); }
#disk-meter[hidden] { display: none; }
#disk-meter { appearance: none; border: 0; }
#disk-meter::-webkit-progress-bar { background: var(--border); }
#disk-meter::-webkit-progress-value { background: var(--blue); }
#disk-meter::-moz-progress-bar { background: var(--blue); }
.archive-panel .panel-head .badge { white-space: nowrap; }
