/* CryptoCloud - theme from glitchlinux.wtf/file-browser.html */
:root {
  --bg: #1a1a1a;
  --bar: #222;
  --panel: #2a2a2a;
  --panel-hi: #333;
  --line: #3a3a3a;
  --line-hi: #555;
  --text: #e8e8e8;
  --text-2: #d0d0d0;
  --muted: #888;
  --accent: #32cd32;
  --accent-fill: rgba(50, 205, 50, 0.1);
  --accent-glow: rgba(50, 205, 50, 0.5);
  --danger: #d09090;
  --danger-bg: #4a2525;
  --danger-line: #5a3030;
  --busy-1: #e07020;
  --busy-2: #c06018;
  --mono: 'Courier New', monospace;
  --sans: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { background: var(--bg); color: var(--text); font-family: var(--sans); min-height: 100%; }
body { overscroll-behavior-y: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Buttons (the .tb style) ---------- */
.tb {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  background: linear-gradient(135deg, #333 0%, #2a2a2a 100%);
  color: var(--text-2); border: 1px solid #404040; border-radius: 6px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.tb:active { transform: scale(0.97); }
.tb:disabled { opacity: 0.4; pointer-events: none; }
.tb.accent { background: var(--accent-fill); border-color: var(--accent); color: var(--accent); }
.tb.danger { background: linear-gradient(135deg, #4a2525 0%, #3a1a1a 100%); border-color: var(--danger-line); color: var(--danger); }
.tb.icon { min-width: 44px; padding: 0; font-size: 1.5rem; line-height: 1; }
.tb.wide { width: 100%; }
@media (hover: hover) {
  .tb:hover { border-color: var(--line-hi); }
  .tb.accent:hover { box-shadow: 0 0 14px var(--accent-glow); }
}

/* ---------- Lock screen ---------- */
.lock { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--top)) 24px calc(24px + var(--bottom)); }
.lock-inner { width: 100%; max-width: 420px; text-align: center; animation: rise 0.8s ease-out; }
.lock-icon { font-size: 6rem; line-height: 1; margin-bottom: 28px; animation: pulse 2s infinite; }
.lock-title { font-size: 1.5rem; font-weight: 600; color: #d5d5d5; margin-bottom: 6px; }
.lock-hint { color: var(--muted); margin-bottom: 28px; font-size: 0.95rem; }
.lock form { display: grid; gap: 14px; }
.pw {
  width: 100%; padding: 15px; background: var(--accent-fill);
  border: 2px solid var(--accent); border-radius: 10px;
  font-family: var(--mono); font-size: 1.25rem; color: var(--accent); text-align: center;
  transition: box-shadow 0.3s;
}
.pw::placeholder { color: rgba(50, 205, 50, 0.35); }
.pw:focus { outline: none; box-shadow: 0 0 20px var(--accent-glow); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(1.05); } }
@keyframes rise { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
.lock.shake .lock-inner { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

.msg { min-height: 1.4em; margin-top: 14px; color: var(--danger); font-size: 0.9rem; }
.msg.info { color: var(--muted); }

/* ---------- App frame ---------- */
.screen { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(84px + var(--bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--top)) 14px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { width: 28px; height: 28px; }
.brand h1 { font-size: 1.2rem; color: #d5d5d5; font-weight: 700; }

.crumbs {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none; font-family: var(--mono); font-size: 0.9rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; min-height: 44px;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs button { background: none; border: 0; color: var(--text-2); padding: 10px 4px; cursor: pointer; white-space: nowrap; }
.crumbs button:last-child { color: var(--accent); }
.crumbs .sep { color: #666; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px calc(12px + var(--bottom));
  background: var(--bar); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.4);
}
.bottombar > .tb { flex: 1; }
.bottombar .count { flex: 1; color: var(--text-2); font-weight: 600; }

/* ---------- Storage meter ---------- */
.budget { margin: 16px 14px 6px; }
.budget-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.disk-row { margin: 6px 0 0; font-size: 0.78rem; font-family: var(--mono); }
.bar { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
.bar-fill.busy {
  background: repeating-linear-gradient(-45deg, var(--busy-1), var(--busy-1) 6px, var(--busy-2) 6px, var(--busy-2) 12px);
  background-size: 17px 17px; animation: barberpole 0.6s linear infinite;
}
@keyframes barberpole { to { background-position: 17px 0; } }

/* ---------- Vault list ---------- */
.vault-list { list-style: none; display: grid; gap: 10px; padding: 14px; }
.vault-row { display: flex; gap: 8px; align-items: stretch; }
.vault-row .vault { flex: 1; min-width: 0; }
.vault-del { min-width: 56px; padding: 0; font-size: 1.25rem; border-radius: 8px; }
.vault {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px; min-height: 72px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.vault:active { background: var(--panel-hi); }
.vault-glyph { font-size: 1.6rem; width: 36px; text-align: center; }
.vault-main { flex: 1; min-width: 0; }
.vault-name { display: block; font-weight: 600; font-size: 1.05rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vault-meta { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 3px; font-family: var(--mono); }
.pill { font-size: 0.75rem; font-weight: 600; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { color: var(--accent); border-color: var(--accent); background: var(--accent-fill); }
.pill.mid { color: #f0a040; border-color: #6a4a20; }

.empty { text-align: center; color: var(--muted); padding: 48px 24px; line-height: 1.5; }
.empty strong { display: block; color: var(--text-2); font-size: 1.05rem; margin-bottom: 6px; }

/* ---------- Upload strip ---------- */
.upload { padding: 10px 14px; background: var(--bar); border-bottom: 1px solid var(--line); }
.upload-row { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 6px; color: var(--text-2); }
.upload-pct { color: #f0a040; font-family: var(--mono); font-weight: 700; }

/* ---------- Media grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 3px; padding: 3px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; padding: 10px; } }
.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tile img.thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .glyph { font-size: 2.4rem; line-height: 1; }
.tile .ext { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); margin-top: 6px; text-transform: lowercase; }
.tile .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px;
  font-size: 0.72rem; color: var(--text-2); background: rgba(0, 0, 0, 0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.tile.folder { background: #222; }
.tile .play {
  position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; font-size: 0.7rem; color: #fff;
}
.tile.sel { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent); }
.tile.sel::after {
  content: "✓"; position: absolute; left: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #1a1a1a; font-weight: 700; display: grid; place-items: center; font-size: 0.85rem;
}
.selecting .tile:not(.sel)::after {
  content: ""; position: absolute; left: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7); background: rgba(0, 0, 0, 0.3);
}

/* ---------- Viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.viewer-top, .viewer-bottom {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: rgba(26, 26, 26, 0.85); z-index: 2;
}
.viewer-top { padding-top: calc(8px + var(--top)); }
.viewer-bottom { padding-bottom: calc(8px + var(--bottom)); justify-content: space-between; }
.viewer-name { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-pos { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: pan-y pinch-zoom; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-stage audio { width: min(92%, 520px); }
.viewer-stage .glyph { font-size: 5rem; }
.viewer.chrome-off .viewer-top, .viewer.chrome-off .viewer-bottom { opacity: 0; pointer-events: none; }
.viewer-top, .viewer-bottom { transition: opacity 0.2s; }

/* ---------- Auto-lock countdown ---------- */
.autolock {
  position: fixed; left: 0; right: 0; top: 0; z-index: 80;
  display: grid; gap: 8px;
  padding: calc(10px + var(--top)) 14px 12px;
  background: var(--bar); border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}
.autolock .bar-fill { transition: width 1s linear; }
@media (min-width: 700px) {
  .autolock { left: 50%; right: auto; width: 520px; transform: translateX(-50%); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; }
}

/* ---------- List view ---------- */
.tile .meta { display: none; }
.grid.list { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.grid.list .tile {
  aspect-ratio: auto; height: 60px; flex-direction: row; justify-content: flex-start;
  gap: 12px; padding: 6px 12px 6px 6px; border-radius: 6px;
}
.grid.list .tile img.thumb { position: static; width: 46px; height: 46px; border-radius: 4px; flex: none; }
.grid.list .tile .glyph { width: 46px; flex: none; font-size: 1.7rem; text-align: center; }
.grid.list .tile .ext, .grid.list .tile .play { display: none; }
.grid.list .tile .label {
  position: static; flex: 1; min-width: 0; padding: 0; background: none;
  text-align: left; font-size: 0.95rem; color: var(--text);
}
.grid.list .tile .meta {
  display: block; flex: none; text-align: right; font-family: var(--mono);
  font-size: 0.75rem; color: var(--muted); line-height: 1.35; white-space: nowrap;
}
.grid:not(.list) .tile.media .label { display: none; }
.grid.list .tile.sel::after, .grid.list.selecting .tile:not(.sel)::after { left: auto; right: 10px; top: 50%; margin-top: -12px; }
.grid.list .tile.sel .meta, .grid.list.selecting .tile .meta { visibility: hidden; }

/* ---------- Text editor ---------- */
.editor { position: fixed; inset: 0; z-index: 45; background: var(--bg); display: flex; flex-direction: column; }
.editor-top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--top)) 12px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.ed-state { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.ed-state.dirty { color: #f0a040; }
.ed-state.saved { color: var(--accent); }
.editor-text {
  flex: 1; width: 100%; resize: none; border: 0; outline: none;
  padding: 14px 14px calc(14px + var(--bottom));
  background: var(--bg); color: var(--text);
  font-family: var(--mono); font-size: 16px; line-height: 1.5; tab-size: 4;
}
.editor-text:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--line-hi); }

/* ---------- Action sheet (pick) ---------- */
.pick { display: grid; gap: 10px; margin-bottom: 4px; }

/* ---------- Dialog ---------- */
.dialog {
  margin: auto; width: min(92vw, 440px); color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.dialog form { padding: 20px; }
.dialog h2 { font-size: 1.15rem; margin-bottom: 6px; }
.dialog .lead { color: var(--muted); font-size: 0.9rem; margin-bottom: 16px; line-height: 1.45; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 0.85rem; color: var(--text-2); }
.field input, .field select {
  width: 100%; min-height: 46px; padding: 0 12px; font-size: 1rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text);
}
.field input[type=password] { font-family: var(--mono); color: var(--accent); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 10px rgba(50, 205, 50, 0.3); }
.field small { color: var(--muted); font-size: 0.78rem; }
.dialog-actions { display: flex; gap: 10px; margin-top: 8px; }
.dialog-actions .tb { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: 90vw; padding: 10px 16px; border-radius: 6px;
  background: #2a3a2a; border: 1px solid #3a5a3a; color: #90d090; font-size: 0.9rem;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger-bg); border-color: var(--danger-line); color: #ff9090; }

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