/* Sign-in gate, account panel, file explorer and viewer. Colors come from the tokens in index.html. */
[hidden] { display: none !important; }
body.locked header nav, body.locked main, body.locked #acct-open { visibility: hidden; }
body.noscroll { overflow: hidden; }

.btn { font: inherit; font-weight: 550; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.iconbtn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; text-decoration: none; }
.iconbtn:hover { background: var(--hover); }
.iconbtn svg { width: 18px; height: 18px; }

/* ---------- gate ---------- */
#gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.gate-card .logo { width: 56px; height: 56px; margin: 0 auto 14px; }
.gate-card h1 { font-size: 22px; margin: 0 0 6px; }
.gate-msg { color: var(--muted); margin: 0 0 18px; }
.gate-input { width: 100%; padding: 12px; font-size: 22px; letter-spacing: .12em; text-align: center; text-transform: uppercase;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); margin-bottom: 12px; outline: none; }
.gate-input:focus { border-color: var(--accent); }
#gate .btn { width: 100%; padding: 12px; font-size: 15px; }
#gate-err, #acct-err { color: var(--bad); min-height: 20px; margin-top: 12px; font-size: 13px; }

/* ---------- account dialog ---------- */
#account { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 70px 16px 16px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 460px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.sheet h2 { font-size: 16px; margin: 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
#acct-keys { list-style: none; padding: 0; margin: 0 0 14px; }
#acct-keys li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
#acct-keys li:first-child { border-top: 0; }
.sheet .row { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet .row .btn { flex: 1; }

/* ---------- explorer ---------- */
.ftools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
#f-crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow-x: auto; white-space: nowrap; scrollbar-width: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; height: 36px; }
#f-crumbs::-webkit-scrollbar { display: none; }
#f-crumbs a { color: var(--text); text-decoration: none; padding: 3px 4px; border-radius: 5px; }
#f-crumbs a:last-child { font-weight: 600; }
#f-crumbs a:hover { background: var(--hover); }
#f-crumbs .sep { color: var(--muted); }
.ftools2 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.ftools2 input[type=search] { max-width: none; }
select { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
#f-err { color: var(--bad); margin: 0 0 10px; }
#f-err:empty { display: none; }
#f-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
#f-list li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto 12px; align-items: center; gap: 12px; padding: 10px 14px;
  border-top: 1px solid var(--line); cursor: pointer; }
#f-list li:first-child { border-top: 0; }
#f-list li:hover { background: var(--hover); }
#f-list li.dim { opacity: .6; }
#f-list li.empty { display: block; cursor: default; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmeta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.chev { color: var(--muted); font-size: 18px; line-height: 1; }
.ficon { color: var(--muted); }
.ficon.k-dir { color: var(--accent); }
.ficon.k-image { color: var(--ok); }
.ficon.k-video { color: var(--mem); }
.ficon.k-audio { color: var(--temp); }
.ficon.k-pdf { color: var(--bad); }

/* ---------- view switch ---------- */
.seg { display: inline-flex; background: var(--track); padding: 3px; border-radius: 9px; gap: 2px; }
.seg button { font: inherit; font-size: 12.5px; font-weight: 600; min-width: 32px; height: 28px; padding: 0 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.seg button svg { width: 16px; height: 16px; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* ---------- thumbnail grid ---------- */
#f-list.grid { display: grid; gap: 10px; background: none; border: 0; border-radius: 0; overflow: visible;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); }
#f-list.grid.sz-s { --tile: 96px; gap: 8px; }
#f-list.grid.sz-m { --tile: 150px; }
#f-list.grid.sz-l { --tile: 240px; gap: 14px; }
#f-list.grid li.tile { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); min-width: 0; }
#f-list.grid li.tile:hover { background: var(--hover); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
#f-list.grid li.empty { grid-column: 1 / -1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 30px; text-align: center; }
.thumb { position: relative; flex: none; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--track);
  display: flex; align-items: center; justify-content: center; }
.thumb .ficon { width: 42%; height: 42%; }
.thumb.has-img { background: color-mix(in srgb, var(--track) 60%, transparent); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.thumb img.cover { object-fit: cover; }
.thumb img.contain { object-fit: contain; padding: 6%; }
.thumb .play { position: absolute; right: 6px; bottom: 6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55);
  color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; padding-left: 2px; }
.tname { width: 100%; max-width: 100%; min-width: 0; font-size: 12.5px; line-height: 1.3; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; word-break: break-word; padding: 0 2px; }
.tmeta { font-size: 11px; color: var(--muted); text-align: center; margin-top: -3px; }
.tmeta:empty { display: none; }
#f-list.grid.sz-s .tmeta { display: none; }
#f-list.grid.sz-s .tname { font-size: 11.5px; -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; display: block; }
#f-list.grid.sz-s li.tile { padding: 4px; gap: 4px; border-radius: 10px; }
#f-list.grid.sz-s .thumb { border-radius: 7px; }
#f-list.grid.sz-l .tname { font-size: 13.5px; }

@media (max-width: 640px) {
  #f-list.grid.sz-s { --tile: 72px; gap: 6px; }
  #f-list.grid.sz-m { --tile: 100px; gap: 8px; }
  #f-list.grid.sz-l { --tile: 150px; gap: 10px; }
  .ftools2 .count { width: 100%; text-align: right; margin-top: -4px; }
}

/* ---------- viewer ---------- */
#viewer { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; }
.v-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  padding-top: max(10px, env(safe-area-inset-top)); }
.v-title { flex: 1; min-width: 0; }
#v-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#v-meta { color: var(--muted); font-size: 12px; }
.v-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.v-body.center { display: flex; align-items: center; justify-content: center; padding: 12px; }
.v-body img, .v-body video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #000; }
.v-body img { background: transparent; }
.v-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.audio-card { text-align: center; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.audio-card .ficon { width: 72px; height: 72px; }
.audio-card audio { width: 100%; }
.audio-card .row { display: flex; gap: 8px; }
.textview { display: grid; grid-template-columns: auto minmax(0, 1fr); font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, monospace; min-height: 100%; }
.textview .ln { white-space: pre; text-align: right; color: var(--muted); padding: 12px 10px 12px 14px; border-right: 1px solid var(--line); user-select: none; opacity: .7; }
.textview pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.textview.wrap pre { white-space: pre-wrap; word-break: break-word; }
.textview.wrap .ln { display: none; }
.textview.wrap { grid-template-columns: minmax(0, 1fr); }
.v-note { position: sticky; bottom: 0; padding: 8px 14px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.v-nav { display: flex; gap: 6px; }

@media (max-width: 640px) {
  #f-list li { padding: 11px 12px; gap: 10px; grid-template-columns: 24px minmax(0, 1fr) 12px; }
  #f-list li .fmeta { grid-column: 2; grid-row: 2; margin-top: -2px; }
  #f-list li .chev { grid-column: 3; grid-row: 1 / 3; }
  #f-list li .ficon { grid-row: 1 / 3; }
  .ftools2 input[type=search] { min-width: 0; flex-basis: 100%; }
  .v-body.center { padding: 0; }
  .v-body video, .v-body img { border-radius: 0; }
  #v-open { display: none; }
}
