/* jhsimpl — no build step, no flex-gap, no :has(), Safari 14 safe */

:root {
  --bg: #0e0f13;
  --bg2: #15171d;
  --card: #171a21;
  --line: #262b36;
  --fg: #e8eaf0;
  --mut: #8b94a7;
  --acc: #5b8cff;
  --acc-fg: #ffffff;
  --ok: #35c07f;
  --bad: #f0575f;
  --r: 12px;
  --sh: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fa; --bg2: #ffffff; --card: #ffffff; --line: #e3e6ee;
    --fg: #14161c; --mut: #6b7488; --acc: #2f6bff;
    --sh: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--mut); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- boot ---------- */
.boot {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: center; justify-content: center;
  color: var(--mut); letter-spacing: .12em; text-transform: lowercase;
  background: var(--bg); z-index: 60;
}

/* ---------- top bar ---------- */
.top {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  /* standalone on iOS draws under the status bar (black-translucent) */
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
}
/* honour the notch on the sides in landscape */
.wrap {
  padding-left: calc(16px + constant(safe-area-inset-left));
  padding-right: calc(16px + constant(safe-area-inset-right));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}
.top-in {
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  height: 54px;
}
.brand { font-weight: 700; letter-spacing: -.02em; margin: 0; }
.brand-sm { font-size: 16px; color: var(--fg); margin-right: 18px; }
.brand-sm:hover { text-decoration: none; }

.nav {
  -webkit-box-flex: 1; flex: 1;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.nav a {
  display: inline-block;
  color: var(--mut);
  padding: 6px 10px;
  margin-right: 2px;
  border-radius: 8px;
  font-size: 14px;
}
.nav a:hover { color: var(--fg); text-decoration: none; background: var(--bg2); }
.nav a.on { color: var(--fg); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }

.foot {
  display: -webkit-box; display: flex;
  -webkit-box-pack: justify; justify-content: space-between;
  padding-top: 24px; padding-bottom: 24px;
}

/* ---------- primitives ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--sh);
}

.btn {
  -webkit-appearance: none; appearance: none;
  font: inherit; font-size: 14px;
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:active { -webkit-transform: translateY(1px); transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-pri { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); font-weight: 600; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-full { width: 100%; margin-top: 14px; padding: 11px; }
.btn-bad { color: var(--bad); }

.in {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%;
  font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  margin-bottom: 12px;
}
.in:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px rgba(91,140,255,.22); }
select.in {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b94a7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 30px;
}
.lbl { display: block; font-size: 12.5px; color: var(--mut); margin-bottom: 5px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

.row-between {
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: justify; justify-content: space-between;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.section-head {
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: justify; justify-content: space-between;
  margin: 26px 0 12px;
}
.section-head h2 { font-size: 17px; margin: 0; letter-spacing: -.01em; }

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: center; justify-content: center;
  padding: 24px 16px;
}
.login-card { width: 100%; max-width: 370px; }
.login-card .brand { font-size: 22px; }
.login-card .small { margin: 2px 0 16px; }

.tabs { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  -webkit-appearance: none; appearance: none;
  font: inherit; font-size: 13.5px;
  background: none; border: 0; color: var(--mut);
  padding: 8px 2px; margin-right: 18px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab.active { color: var(--fg); border-bottom-color: var(--acc); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 12px; margin-top: 20px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; }
.stat b { display: block; font-size: 21px; letter-spacing: -.02em; font-weight: 650; }
.stat span { font-size: 12px; color: var(--mut); }

/* ---------- file grid ---------- */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-gap: 12px; }
.file {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden;
  position: relative;
}
.thumb {
  display: block;
  width: 100%; height: 118px;
  background: var(--bg2);
  position: relative;
  overflow: hidden;
}
.thumb img, .thumb video {
  width: 100%; height: 100%;
  -o-object-fit: cover; object-fit: cover;
  display: block;
  background: var(--bg2);
}
.thumb .ext {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: center; justify-content: center;
  color: var(--mut); font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
}
.file-meta { padding: 8px 10px; }
.file-meta .n { font-size: 12.5px; }
.file-acts { padding: 0 10px 10px; }
.file-acts .btn { margin-right: 5px; }
.fav { position: absolute; top: 6px; right: 6px; font-size: 13px; }

/* ---------- list rows ---------- */
.rows { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); }
.rw {
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.rw:last-child { border-bottom: 0; }
.rw-main { -webkit-box-flex: 1; flex: 1; min-width: 0; margin-right: 10px; }
.rw-main .sub { margin-top: 2px; }
.rw .btn { margin-left: 6px; }

.toolbar {
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  margin-bottom: 12px;
}
.toolbar .in { margin-bottom: 0; margin-right: 8px; -webkit-box-flex: 1; flex: 1; }
.toolbar .in.w-auto { -webkit-box-flex: 0; flex: 0 0 auto; width: auto; }

.pager { text-align: center; padding: 18px 0; }
.pager .btn { margin: 0 4px; }

.empty { text-align: center; color: var(--mut); padding: 42px 16px; font-size: 14px; }

/* ---------- upload sheet ---------- */
.sheet { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 40; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-bg { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); }
.sheet-card { position: relative; max-width: 520px; margin: 8vh auto 24px; }
.sheet-card .row-between { margin-bottom: 14px; }

.dropzone {
  display: block; text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: var(--r);
  padding: 26px 12px;
  margin-bottom: 14px;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--acc); }
.dropzone span { display: block; }
.dropzone span:first-child { font-weight: 600; margin-bottom: 3px; }

.queue { list-style: none; margin: 6px 0 0; padding: 0; }
.queue li { padding: 9px 0; border-top: 1px solid var(--line); }
.bar { height: 4px; background: var(--bg2); border-radius: 3px; overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; width: 0; background: var(--acc); -webkit-transition: width .15s linear; transition: width .15s linear; }
.bar.done i { background: var(--ok); }
.bar.fail i { background: var(--bad); width: 100% !important; }

.drop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(14,15,19,.82);
  color: #fff;
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: center; justify-content: center;
  font-size: 20px; font-weight: 600;
  pointer-events: none;
}

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: 16px; z-index: 70; text-align: center; pointer-events: none; }
.toast {
  display: inline-block;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 15px; margin-top: 8px;
  box-shadow: var(--sh);
  font-size: 13.5px;
  max-width: 88%;
}
.toast.bad { border-color: var(--bad); color: var(--bad); }
