@import url("player.css");
:root {
  --bg: #14161a;
  --panel: #1b1e24;
  --panel2: #22262e;
  --line: #2e3440;
  --text: #dfe3ea;
  --dim: #8b94a3;
  --accent: #6aa9ff;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

/* A class that sets `display` outbids the UA rule for the hidden attribute, so
   .drop and .actions rendered even while marked hidden. Settle it once here
   rather than per-selector. */
[hidden] { display: none !important; }

.linkrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px 0;
  border-top: 1px solid #23272e;
  align-items: center;
}
.linkrow b { overflow-wrap: anywhere; }
.linkrow input {
  grid-column: 1;
  width: 100%;
  background: #14171c;
  color: var(--dim);
  border: 1px solid #2a2f37;
  border-radius: 5px;
  padding: 4px 6px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.linkrow button { grid-column: 2; grid-row: 1 / span 3; }
.linkmeta { grid-column: 1; color: var(--dim); font-size: 12px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { font-weight: 600; letter-spacing: .04em; }
.spacer { flex: 1; }

.crumbs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.crumbs a { color: var(--accent); text-decoration: none; cursor: pointer; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span.sep { color: var(--dim); }

.tools { display: flex; align-items: center; gap: 8px; }
.who { color: var(--dim); }
.sortwrap { color: var(--dim); display: flex; gap: 4px; align-items: center; }

button, select, input[type=text], input:not([type]) {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  font: inherit;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.danger { border-color: #5c2b2b; color: var(--danger); }

.layout { display: flex; align-items: flex-start; }
.nav-toggle { display: none; }
.navscrim { display: none; }
body.nav-open { overflow: hidden; }

nav {
  width: 210px;
  flex: none;
  padding: 12px;
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 48px);
}
nav .share {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  padding: 7px 9px;
  border-radius: 6px;
  margin-bottom: 3px;
}
nav .share.active { background: var(--panel2); border-color: var(--line); }
nav .share .mode { display: block; color: var(--dim); font-size: 12px; }

main { flex: 1; padding: 12px 14px 60px; min-width: 0; }

.actions { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.hint { color: var(--dim); }

.entries.list { display: flex; flex-direction: column; gap: 1px; }
.entries.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--panel);
}
.row:hover { background: var(--panel2); }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.row .size, .row .when { color: var(--dim); width: 150px; text-align: right; flex: none; }
.row .icon { width: 20px; text-align: center; flex: none; }
.row .ops { display: flex; gap: 6px; flex: none; visibility: hidden; }
.row:hover .ops { visibility: visible; }
.row .ops button { padding: 2px 7px; font-size: 12px; }
.row.item .ops { visibility: visible; }
.row.item .size { width: auto; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .where { display: block; color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
nav .share.special .mode { font-style: italic; }
nav .share.special:nth-child(2) { margin-bottom: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.card:hover { border-color: var(--accent); }
.card .thumb {
  position: relative;
  height: 108px;
  background: #0e1013 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--dim);
}
.card .meta { padding: 6px 8px; }
.card .meta .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta .s { color: var(--dim); font-size: 12px; }

.empty { color: var(--dim); padding: 30px 4px; }

.uploads { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.uploads .up { background: var(--panel); border-radius: 6px; padding: 5px 9px; color: var(--dim); }
.uploads .up progress { width: 160px; vertical-align: middle; margin-left: 8px; }

.drop {
  position: fixed;
  inset: 0;
  /* Belt and braces: if this ever gets stranded visible it must not eat
     clicks for the entire page. */
  pointer-events: none;
  background: rgba(20, 22, 26, .85);
  border: 3px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  z-index: 20;
}

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  max-width: 90vw;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 10px; font-size: 16px; }
dialog h3 { margin: 16px 0 6px; font-size: 14px; color: var(--dim); }
dialog table { width: 100%; border-collapse: collapse; }
dialog td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
dialog form { display: grid; gap: 8px; max-width: 460px; }
dialog form label { display: grid; gap: 3px; color: var(--dim); }
dialog form label.check { display: flex; gap: 6px; align-items: center; }
.dlgbar { margin-top: 14px; text-align: right; }
.note { color: var(--dim); font-size: 12px; }

#player {
  padding: 0;
  border: none;
  border-radius: 0;
  background: #000;
  margin: 0;
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
  inset: 0;
}
#playerShell { width: 100%; height: 100%; }
#player::backdrop { background: #000; }

.watched {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, .55);
}
.watched i { display: block; height: 100%; background: #e0483d; }
.watched.done i { background: #6ee7a8; }

.login {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 20px;
}
.loginbox {
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
}
.loginbox h1 { font-size: 18px; margin: 0 0 10px; }
.loginbox p { color: var(--dim); }
.loginbox ol { color: var(--dim); padding-left: 20px; }
.loginbox b { color: var(--text); }
.loginbox .code {
  font: 600 30px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: .18em;
  text-align: center;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 10px 0 6px;
  user-select: all;
}
.loginbox .err { color: var(--danger); }

@media (max-width: 840px) {
  header {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
  }
  .brand { font-size: 15px; }
  .spacer { display: none; }
  .crumbs {
    order: 3;
    flex: 1 0 100%;
    font-size: 13px;
  }
  .tools {
    margin-left: auto;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .who { display: none; }
  .sortwrap { font-size: 12px; }
  .hint { display: none; }

  .layout { display: block; }
  nav {
    position: fixed;
    z-index: 25;
    top: var(--header-h, 48px);
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    min-height: 0;
    background: var(--panel);
    border-right: 1px solid var(--line);
    transform: translateX(-105%);
    transition: transform .2s ease;
    overflow: auto;
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
  }
  body.nav-open nav { transform: translateX(0); }
  nav .share { padding: 10px 12px; }
  .navscrim {
    display: block;
    position: fixed;
    z-index: 24;
    top: var(--header-h, 48px);
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, .5);
  }

  main { padding: 10px 10px calc(80px + env(safe-area-inset-bottom)); }
  .actions { flex-wrap: wrap; }
  .row { padding: 10px 8px; }
  .row .when { display: none; }
  .row .size { width: auto; max-width: 72px; font-size: 12px; }
  .row .ops { visibility: visible; }
  .row .ops button { padding: 6px 8px; }
  .entries.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .card .thumb { height: 96px; }

  .login { padding: 12px; align-items: start; }
  .loginbox { padding: 16px; }
  .loginbox .code { font-size: 22px; letter-spacing: .12em; }

  dialog {
    width: calc(100vw - 24px);
    max-width: none;
  }
  #player {
    width: 100vw;
    height: 100dvh;
  }
}

dialog form textarea {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: 13px/1.4 ui-monospace, Consolas, monospace;
  resize: vertical;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 16px;
  z-index: 30;
}
.toast.bad { border-color: var(--danger); color: var(--danger); }
