:root {
  --bg: #0e1014;
  --panel: #161a21;
  --panel-2: #1c222b;
  --line: #262d38;
  --text: #e9edf3;
  --dim: #97a2b3;
  --accent: #4da3ff;
  --accent-soft: rgba(77, 163, 255, .14);
  --good: #38c172;
  --warn: #e0a800;
  --bad: #ef5350;
  --radius: 12px;
  --header-h: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: var(--header-h); padding: 0 12px;
  background: rgba(14, 16, 20, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.top .drive { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.top .sub { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .right { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--dim); white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.pill.on .dot { background: var(--good); box-shadow: 0 0 0 3px rgba(56, 193, 114, .15); }
.pill.off .dot { background: var(--bad); }
.ghost {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
  border-radius: 9px; padding: 7px 10px; font-size: 12.5px; cursor: pointer;
}
.ghost.light { color: var(--text); }
.bars, .bars::before, .bars::after {
  display: block; width: 16px; height: 2px; background: var(--text); border-radius: 2px; content: "";
}
.bars { position: relative; }
.bars::before { position: absolute; top: -5px; }
.bars::after { position: absolute; top: 5px; }

/* ---------- tabs ---------- */
.tabs {
  position: sticky; top: var(--header-h); z-index: 39;
  display: flex; gap: 4px; padding: 8px 10px;
  background: rgba(14, 16, 20, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; background: transparent; border: 0; cursor: pointer;
  color: var(--dim); padding: 8px 14px; border-radius: 999px; font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.tab.active { background: var(--accent-soft); color: var(--accent); }

.stage { padding: 10px 10px 40px; }
.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- breadcrumbs ---------- */
.crumbs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb {
  flex: 0 0 auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: var(--dim); cursor: pointer;
}
.crumb.last { color: var(--text); border-color: #33465e; }
.crumb .sep { color: #3d4757; margin-left: 6px; }

.barlist { margin: 0 2px 10px; font-size: 12.5px; color: var(--dim); min-height: 16px; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; min-height: 56px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.row:active { transform: scale(.995); background: var(--panel-2); }
.row .ic {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line);
}
.row.dir .ic { background: rgba(77, 163, 255, .12); border-color: rgba(77, 163, 255, .28); }
.row .body { min-width: 0; flex: 1 1 auto; }
.row .name {
  font-size: 14.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.row .meta {
  font-size: 12px; color: var(--dim); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .meta .sep { color: #3d4757; margin: 0 6px; }
.row .flag {
  flex: 0 0 auto; font-size: 10.5px; color: var(--accent); border: 1px solid #33465e;
  border-radius: 999px; padding: 2px 7px; background: var(--accent-soft);
}
.row .flag.cloud { color: var(--warn); border-color: #4a3f1f; background: rgba(224, 168, 0, .12); }
.thumb {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  background: var(--panel-2); border: 1px solid var(--line);
}

.more {
  width: 100%; margin: 12px 0 0; padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--dim); cursor: pointer;
}
.empty { color: var(--dim); font-size: 13.5px; padding: 20px 4px; text-align: center; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; font-size: 12.5px; color: var(--dim); cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: #33465e; }

/* ---------- pictures grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 6px; }
.tile {
  position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s ease; }
.tile img.ready { opacity: 1; }
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 7px 6px;
  font-size: 10.5px; color: #dfe6ef; background: linear-gradient(transparent, rgba(6, 8, 11, .88));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- search ---------- */
.searchbox { padding-bottom: 8px; }
.searchbox input {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 12px 16px; outline: none;
}
.searchbox input:focus { border-color: #33465e; background: var(--panel-2); }
.countline { font-size: 12.5px; color: var(--dim); padding: 0 4px 8px; }

/* ---------- viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 60; background: rgba(6, 8, 11, .97);
  display: flex; flex-direction: column; animation: fade .16s ease;
}
.viewer-top {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.viewer-name {
  flex: 1 1 auto; font-size: 13.5px; color: #dfe6ef; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.viewer-stage { flex: 1 1 auto; display: grid; place-items: center; padding: 8px; overflow: hidden; }
.viewer-stage img { max-width: 100%; max-height: 100%; border-radius: 8px; animation: fade .2s ease; }
.viewer-stage .spin { color: var(--dim); font-size: 13px; }
.viewer-bottom {
  padding: 10px 14px 18px; font-size: 12.5px; color: var(--dim);
  border-top: 1px solid rgba(255, 255, 255, .07); display: flex; gap: 8px;
  align-items: center; justify-content: space-between;
}
.viewer-bottom .nav { display: flex; gap: 8px; }

/* ---------- sheet + toast ---------- */
.sheet { position: fixed; inset: 0; z-index: 55; background: rgba(6, 8, 11, .72); display: grid; place-items: end center; }
.sheet-card {
  width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 16px 16px 24px; animation: up .2s ease;
}
@keyframes up { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-card h2 { margin: 0 0 12px; font-size: 15px; }
.sheet-close { float: right; background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 13px; }
.sheet-body { display: flex; flex-direction: column; gap: 8px; }
.sheet-body .btn, .sheet-body button { text-align: left; }
.btn {
  display: block; width: 100%; padding: 13px 14px; border-radius: 10px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 14px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06111f; font-weight: 600; }
.btn.quiet { color: var(--dim); }
.stat { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); padding: 6px 0; border-bottom: 1px solid var(--line); }
.stat b { color: var(--text); font-weight: 550; }

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 70; max-width: min(92vw, 520px);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 14px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  animation: fade .16s ease;
}
.toast.bad { border-color: #59272a; color: #ffc9c6; }
.toast.good { border-color: #23533a; color: #c8f0da; }

/* ---------- PIN page ---------- */
.pin-body { display: grid; place-items: center; min-height: 100vh; background:
  radial-gradient(1100px 600px at 50% -10%, #1a2436 0%, var(--bg) 55%); }
.pin-wrap { width: 100%; max-width: 420px; padding: 24px; }
.pin-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px 22px; animation: fade .25s ease;
}
.pin-mark { font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.pin-card h1 { font-size: 22px; margin: 10px 0 8px; }
.pin-sub { color: var(--dim); font-size: 13.5px; margin: 0 0 18px; }
.pin-input {
  width: 100%; padding: 14px 16px; border-radius: 10px; letter-spacing: .3em; text-align: center;
  background: var(--panel-2); border: 1px solid var(--line); outline: none; font-size: 19px;
}
.pin-input:focus { border-color: #33465e; }
.pin-card .btn { margin-top: 12px; }
.pin-msg { min-height: 20px; font-size: 13px; color: var(--bad); margin: 12px 0 0; }
.pin-note { font-size: 12px; color: var(--dim); margin: 6px 0 0; }

@media (min-width: 760px) {
  .stage { max-width: 900px; margin: 0 auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
}

/* ---------- videos in the media wall and the viewer ---------- */
.chips { padding: 2px 0 6px; }
.chips:last-of-type { padding-bottom: 10px; }
.tile.vitile .cap { padding-top: 22px; }
.tile .vbadge { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.tile .vbadge svg { filter: drop-shadow(0 1px 6px rgba(0, 0, 0, .55)); }
.tile .vbadge .audio {
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #0b0e13;
  background: rgba(255, 255, 255, .92); border-radius: 999px; padding: 3px 9px;
}
.tile .vbadge .t {
  position: absolute; right: 6px; bottom: 6px; font-size: 10.5px; color: #fff;
  background: rgba(6, 8, 11, .74); border-radius: 6px; padding: 2px 6px;
}
.row .flag.vid { color: #ffd479; border-color: #4a3f1f; background: rgba(224, 168, 0, .14); }
.viewer-stage { position: relative; }
.viewer-stage video { max-width: 100%; max-height: 100%; border-radius: 8px; background: #000; animation: fade .2s ease; }
.vnote {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
  background: rgba(6, 8, 11, .72); border-radius: 999px; padding: 3px 9px;
}
