/* ───────── Theme ─────────
   Change --accent to re-theme the whole site. */
:root {
  --accent: #ff7a1a;
  --accent-2: #ffa24d;
  --accent-soft: rgba(255, 122, 26, .28);
  --glass: rgba(255, 255, 255, .16);
  --glass-strong: rgba(255, 255, 255, .2);
  --glass-side: rgba(255, 255, 255, .07);
  --stroke: rgba(255, 255, 255, .3);
  --text: #fff;
  --text-dim: rgba(255, 255, 255, .68);
  --radius: 20px;
  --font: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

/* form controls don't inherit the page font by default (that's where Arial came from) */
button, input, select, textarea { font-family: inherit; }

body {
  font-family: var(--font);
  color: var(--text);
  overflow: hidden;
  background: #000;
  -webkit-font-smoothing: antialiased;
}

.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: clamp(8px, 2vw, 28px);
}

/* ───────── Window ───────── */
.window {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 2200px;
  display: flex;
  border-radius: var(--radius);
  /* glass: soft white sheen, blurred over black */
  background: linear-gradient(160deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .04));
  -webkit-backdrop-filter: blur(48px) saturate(180%);
  backdrop-filter: blur(48px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, .15);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .22),
    0 30px 80px rgba(0, 0, 0, .7);
  overflow: hidden;
  animation: pop .5s cubic-bezier(.2, .8, .2, 1);
}
/* green light = fullscreen */
.stage:has(.window.max) { padding: 0; }
.stage:has(.window.max) .foot { display: none; }
.window.max { max-width: none; border-radius: 0; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } }

/* ───────── Sidebar ───────── */
.sidebar {
  width: clamp(190px, 16vw, 250px);
  flex: none;
  padding: 16px 10px;
  background: var(--glass-side);
  border-right: 1px solid rgba(255, 255, 255, .14);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.lights { display: flex; align-items: center; gap: 8px; padding: 2px 8px 18px; }
.light {
  flex: none;
  display: block;
  width: 13px; height: 13px; padding: 0;
  border: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .28);
  cursor: pointer;
  transition: filter .15s, transform .15s;
}
.light.red { background: #ff5f57; }
.light.yellow { background: #febc2e; }
.light.green { background: #28c840; }
.light:hover { filter: brightness(1.12); }
.light:active { transform: scale(.9); }

.side-label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--text-dim); padding: 0 10px 4px;
}
.side-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text);
  background: none; border: 0; text-align: left; cursor: pointer;
  width: 100%;
}
.side-item svg { width: 20px; height: 17px; flex: none; }
.side-item:hover { background: rgba(255, 255, 255, .12); }
.side-item.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(255, 150, 70, .45); }
#side { display: flex; flex-direction: column; gap: 2px; }

/* ───────── Content ───────── */
.content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }

.toolbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}
.nav, .seg { display: flex; gap: 2px; }
.tb {
  width: 32px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: none; border: 0; color: var(--text); cursor: pointer;
}
.tb svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tb:hover { background: rgba(255, 255, 255, .16); }
.tb:disabled { opacity: .3; cursor: default; background: none; }
.seg { background: rgba(255, 255, 255, .1); border-radius: 9px; padding: 2px; }
.seg .tb { width: 30px; height: 24px; border-radius: 7px; }
.seg .tb.on { background: rgba(255, 255, 255, .26); }

.title { font-weight: 600; font-size: 14px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; align-items: center; gap: 10px; }

.search {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 9px; padding: 0 10px; height: 28px; width: 200px;
  transition: box-shadow .2s, background .2s;
}
.search:focus-within { background: rgba(255, 255, 255, .2); box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent-2); }
.search svg { width: 15px; height: 15px; fill: none; stroke: var(--text-dim); stroke-width: 2; stroke-linecap: round; }
.search input { all: unset; font-size: 13px; width: 100%; color: var(--text); }
.search input::placeholder { color: var(--text-dim); }
.search input::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  width: 14px; height: 14px; opacity: .7;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
}
.search input::-webkit-search-cancel-button:hover { opacity: 1; }

.crumbs {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 8px 18px; font-size: 12.5px; color: var(--text-dim);
}
.crumbs button {
  all: unset; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.crumbs button:hover { background: rgba(255, 255, 255, .14); color: var(--text); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { opacity: .5; }

.body { flex: 1; overflow-y: auto; padding: 8px 18px 18px; -webkit-overflow-scrolling: touch; }
.body::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 10px; }
.body::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .25); border-radius: 10px; border: 3px solid transparent; background-clip: content-box;
}

/* Grid view */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(112px, 9vw, 150px), 1fr)); gap: 8px 6px; }
.item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px 8px; border-radius: 12px; cursor: pointer;
  background: none; border: 0; color: inherit; font: inherit; text-align: center;
  animation: fade .3s both;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.item .ico { width: 84px; height: 74px; display: grid; place-items: center; position: relative; }
.item .ico svg.folder { width: 84px; height: 71px; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3)); }
.item .name {
  font-size: 12.5px; line-height: 1.25; max-width: 100%;
  padding: 2px 6px; border-radius: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.item:hover { background: rgba(255, 255, 255, .09); }
.item.sel { background: rgba(255, 255, 255, .14); }
.item.sel .name { background: var(--accent); }
.item .sub { font-size: 11px; color: var(--text-dim); }

/* File icon */
.doc {
  width: 54px; height: 66px; border-radius: 6px 14px 6px 6px;
  background: linear-gradient(#fff, #eef0f3);
  box-shadow: 0 4px 8px rgba(0, 0, 0, .3);
  position: relative; overflow: hidden; color: #333;
}
.doc::after {
  content: ""; position: absolute; top: 0; right: 0; width: 16px; height: 16px;
  background: linear-gradient(225deg, transparent 50%, #cfd4db 50%);
}
.doc .tag {
  position: absolute; left: 0; right: 0; bottom: 10px;
  font-size: 10px; font-weight: 800; letter-spacing: .05em; text-align: center; color: #fff;
  padding: 2px 0; background: #8a8f98;
}
.doc.pdf .tag { background: #ff5a1f; }
.doc.img .tag { background: #ff9f1c; }
.doc.txt .tag { background: #6b7280; }
.thumb { width: 66px; height: 66px; object-fit: cover; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 4px 8px rgba(0, 0, 0, .3); background: rgba(255, 255, 255, .2); }

/* List view */
.list { display: flex; flex-direction: column; }
.list .head, .list .row {
  display: grid; grid-template-columns: 1fr 90px 150px; gap: 12px; align-items: center;
  padding: 6px 10px; font-size: 13px;
}
.list .head { font-size: 11.5px; font-weight: 600; color: var(--text-dim); border-bottom: 1px solid rgba(255, 255, 255, .15); }
.list .row { border-radius: 8px; cursor: pointer; animation: fade .25s both; }
.list .row:nth-child(even) { background: rgba(255, 255, 255, .04); }
.list .row:hover { background: rgba(255, 255, 255, .1); }
.list .row.sel { background: var(--accent); }
.list .nm { display: flex; align-items: center; gap: 9px; min-width: 0; }
.list .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .nm .mini { width: 22px; height: 20px; flex: none; }
.list .dim { color: var(--text-dim); }
.list .row.sel .dim { color: rgba(255, 255, 255, .85); }
.mini-doc { width: 16px; height: 20px; border-radius: 3px 5px 3px 3px; background: #fff; position: relative; flex: none; margin: 0 3px; }
.mini-doc.pdf { box-shadow: inset 0 -6px 0 #ff5a1f; }
.mini-doc.img { box-shadow: inset 0 -6px 0 #ff9f1c; }
.mini-doc.txt { box-shadow: inset 0 -6px 0 #6b7280; }

.empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.empty b { display: block; font-size: 16px; color: var(--text); margin-bottom: 4px; }

.status {
  padding: 7px 18px; font-size: 12px; color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, .12);
  text-align: center;
}

/* ───────── Preview ───────── */
.preview {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  background: #0a0806;
  -webkit-backdrop-filter: blur(40px) saturate(160%);
  backdrop-filter: blur(40px) saturate(160%);
  animation: fade .25s both;
}
.preview[hidden] { display: none; }
.pv-bar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}
.pv-name { flex: 1; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-actions { display: flex; align-items: center; gap: 6px; }
.btn-dl {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; height: 30px; border-radius: 9px;
  background: #cc4c08;
  color: #fff; font-size: 13px; font-weight: 700; text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  transition: transform .15s, filter .15s;
}
.btn-dl:hover { background: #dc5a0c; }
.btn-dl svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.pv-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 14px; overflow: auto; }
.pv-stage iframe { width: 100%; height: 100%; border: 0; border-radius: 12px; background: #fff; }
.pv-stage img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, .4); }
.pv-stage pre {
  width: 100%; height: 100%; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: rgba(255, 255, 255, .92); color: #1c1c1e; border-radius: 12px; padding: 18px 20px;
  font: 13.5px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; text-align: left;
}
.pv-stage .nofile { text-align: center; color: var(--text-dim); font-size: 14px; display: grid; gap: 14px; justify-items: center; }

/* ───────── Small screens ───────── */
@media (max-width: 760px) {
  body { overflow: auto; }
  .stage { padding: 10px; height: 100dvh; }
  .window { flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center; gap: 6px;
    padding: 10px; border-right: 0; border-bottom: 1px solid rgba(255, 255, 255, .14);
    overflow-x: auto; overflow-y: hidden;
  }
  .lights, .side-label { display: none; }
  #side { flex-direction: row; gap: 4px; }
  .side-item { width: auto; white-space: nowrap; padding: 5px 11px; background: rgba(255, 255, 255, .1); }
  .title { display: none; }
  .toolbar { gap: 8px; }
  .tools { flex: 1; justify-content: flex-end; }
  .search { width: 100%; max-width: 190px; }
  .list .head, .list .row { grid-template-columns: 1fr 70px; }
  .list .head span:last-child, .list .row span:last-child { display: none; }
}

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

/* ───────── Contribute ───────── */
.btn-contrib {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 28px; padding: 0 12px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: #fff;
  background: var(--accent-soft); border: 1px solid rgba(255, 150, 70, .55);
  transition: background .15s, transform .15s;
}
.btn-contrib:hover { background: rgba(255, 122, 26, .42); transform: translateY(-1px); }
.btn-contrib svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.modal {
  position: absolute; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 18px;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fade .2s both;
}
.modal[hidden] { display: none; }
.modal .card {
  position: relative; width: min(480px, 100%);
  padding: 26px 26px 22px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .07)), rgba(18, 18, 18, .85);
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 30px 80px rgba(0, 0, 0, .7);
}
.modal .close { position: absolute; top: 12px; right: 12px; }
.modal h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; padding-right: 30px; }
.modal .lead { font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.modal .lead b { color: #fff; font-weight: 600; word-break: break-word; }
.modal ol { margin: 16px 0 4px 20px; display: grid; gap: 8px; font-size: 13.5px; line-height: 1.5; color: rgba(255, 255, 255, .85); }
.modal ol li::marker { color: var(--accent-2); font-weight: 700; }
.modal .warn { margin-top: 12px; font-size: 12.5px; color: #ffb27a; background: rgba(255, 122, 26, .12); border: 1px solid rgba(255, 122, 26, .35); padding: 8px 10px; border-radius: 9px; }
.modal code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.modal .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.modal .btn-dl { height: 36px; }
.btn-ghost {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: #fff; text-decoration: none;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .18); }
@media (max-width: 760px) { .btn-contrib span { display: none; } .btn-contrib { padding: 0 9px; } }

/* ───────── Links ───────── */
.doc.link .tag { background: #2f8cf0; }
.doc.link::before {
  content: "\2197"; position: absolute; left: 0; right: 0; top: 17px;
  text-align: center; font-size: 22px; font-weight: 700; color: #2f8cf0; line-height: 1;
}
.mini-doc.link { box-shadow: inset 0 -6px 0 #2f8cf0; }

/* ───────── Built-by bar ───────── */
.credit {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 5px 6px 5px 18px; border-radius: 999px;
  font-size: 13px; color: var(--text-dim);
  background: linear-gradient(160deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .04));
  border: 1px solid rgba(255, 255, 255, .15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
  -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px);
}
.credit[hidden] { display: none; }
.credit b { color: #fff; font-weight: 600; }
.credit .sep { width: 1px; height: 16px; background: rgba(255, 255, 255, .22); }
.credit .links { display: flex; gap: 2px; }
.credit a {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  color: rgba(255, 255, 255, .8); transition: background .15s, color .15s, transform .15s;
}
.credit a:hover { background: #cc4c08; color: #fff; transform: translateY(-1px); }
.credit svg { width: 16px; height: 16px; }
.credit:not(:has(.links)) { padding-right: 18px; }

/* ───────── Stats pill ───────── */
.foot { flex: none; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.credit.stats { padding: 5px 6px 5px 18px; gap: 14px; }
.stats .chip { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.stats .chip b { font-variant-numeric: tabular-nums; }
.stats .chip svg { width: 13px; height: 13px; align-self: center; fill: var(--accent-2); }
.stats .btn-contrib { height: 30px; border-radius: 999px; padding: 0 14px; }
@media (max-width: 760px) {
  .stats .chip.opt { display: none; }
  .credit.stats { gap: 10px; padding-left: 14px; }
}