/* siftp web portal. One stylesheet, system fonts, no dependencies. */
:root {
  --bg: #f6f8f8;
  --surface: #ffffff;
  --surface-2: #f3f6f6;
  --fg: #111418;
  --muted: #59606b;
  --faint: #6f7681;
  --line: #e3e7ea;
  --line-strong: #cfd5da;
  --accent: #0b8462;
  --accent-fg: #ffffff;
  --accent-soft: #e6f3ee;
  --accent-text: #07694e;
  --ctx: #8b929c;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --info-soft: #eaf1fb;
  --info: #1d4f91;
  --code-bg: #f1f4f5;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 32, 0.18);
  --focus: #0b8462;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e11;
    --surface: #12161b;
    --surface-2: #171c22;
    --fg: #e6e9ec;
    --muted: #a0a8b3;
    --faint: #8a929d;
    --line: #222830;
    --line-strong: #323a44;
    --accent: #19aa70;
    --accent-fg: #04140d;
    --accent-soft: #10241c;
    --accent-text: #4fd1a1;
    --ctx: #5f6873;
    --danger: #ff8a7d;
    --danger-soft: #2a1512;
    --warn: #f0b94a;
    --warn-soft: #2a2110;
    --info-soft: #111c2c;
    --info: #8db8f2;
    --code-bg: #161b21;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
    --focus: #4fd1a1;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 16px; }
p { margin: 0 0 8px; }
a { color: var(--accent-text); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.boot { padding: 24px 16px; color: var(--muted); }
.icon { flex: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }

/* ------------------------------------------------------------ header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--fg); }
.brand-mark { width: 24px; height: 24px; display: block; }
.brand-mark.big { width: 32px; height: 32px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link { white-space: nowrap; padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--fg); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; margin-left: auto; }
.who-name { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { max-width: 1000px; margin: 0 auto; padding: 24px 16px 140px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; }
.page-titles { min-width: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13.5px; margin-bottom: 6px; flex-wrap: wrap; }
.crumb a { color: var(--muted); }
.crumb-here { color: var(--fg); font-weight: 500; overflow-wrap: anywhere; }

/* ---------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.solid-danger { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.btn.small { height: 32px; padding: 0 10px; font-size: 14px; }
.btn.big { height: 46px; padding: 0 22px; font-size: 16px; border-radius: 10px; width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }

.input, select.input {
  width: 100%; height: 40px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font: inherit;
}
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-weight: 500; font-size: 14px; }
.field-help { color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.radio-col { display: flex; flex-direction: column; gap: 8px; }
.radio-card { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin-top: 4px; accent-color: var(--accent); }
.check-t { font-weight: 500; display: block; }
.check-d { color: var(--muted); font-size: 13px; display: block; }

/* ------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }

/* ------------------------------------------------------------- files */
.sortbar { display: flex; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.sort { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 500; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.sort:hover { color: var(--fg); background: var(--line); }
.sort.on { color: var(--accent-text); background: var(--accent-soft); }
.files { list-style: none; margin: 0; padding: 0; }
.frow {
  display: grid; grid-template-columns: minmax(0, 1fr) 90px 170px auto; align-items: center; gap: 4px 12px;
  padding: 4px 8px 4px 16px; border-bottom: 1px solid var(--line); min-height: 48px;
}
.frow:last-child { border-bottom: 0; }
.frow:hover { background: var(--surface-2); }
.fname { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--fg); text-decoration: none; font-weight: 500; padding: 6px 0; }
.fname .icon { color: var(--ctx); }
.frow[data-type="dir"] .fname .icon { color: var(--accent); }
a.fname:hover .fname-text { text-decoration: underline; }
.fname-text { overflow-wrap: anywhere; }
.fsize, .fmod { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.fsize { text-align: right; }
.fact { display: flex; justify-content: flex-end; min-width: 36px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-title { font-weight: 600; color: var(--fg); margin-bottom: 4px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 40px 16px; border: 2px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); background: var(--surface);
}
.dz-title { font-weight: 600; color: var(--fg); font-size: 17px; }
body.dragging::after {
  content: "Drop to upload here"; position: fixed; inset: 8px; z-index: 50; display: grid; place-items: center;
  border: 3px dashed var(--accent); border-radius: 16px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  color: var(--accent-text); font-size: 20px; font-weight: 600; pointer-events: none;
}
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plain-list li { display: flex; align-items: center; gap: 10px; }
.plain-list .icon { color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list > li:last-child { border-bottom: 0; }
.li-main { flex: 1; min-width: 200px; }
.li-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.li-sub { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.li-actions { display: flex; gap: 8px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

.banner { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; align-items: flex-start; }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner .icon { margin-top: 2px; }
.banner-msg { font-weight: 500; overflow-wrap: anywhere; }
.banner-hint { opacity: 0.9; overflow-wrap: anywhere; }
.errors:empty { display: none; }

/* ------------------------------------------------------------ dialogs */
dialog.dialog {
  border: 1px solid var(--line-strong); border-radius: 14px; padding: 0; background: var(--surface); color: var(--fg);
  width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px);
}
dialog.dialog::backdrop { background: rgba(8, 12, 16, 0.55); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-text { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.secret { display: flex; gap: 8px; align-items: stretch; }
.secret-value {
  flex: 1; min-width: 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 8px; overflow-wrap: anywhere; word-break: break-all; user-select: all; font-size: 13px;
}

.toasts { position: fixed; left: 16px; right: 16px; top: 64px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 100; pointer-events: none; }
.toast { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500; max-width: 100%; }
.toast.error { background: var(--danger); color: var(--surface); }

/* ----------------------------------------------------- bare (sign-in) */
.bare-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.bare-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}
.bare-brand { display: flex; align-items: center; gap: 10px; }
.small-note { font-size: 13.5px; margin: 0; }

/* --------------------------------------------------------- transfers */
.tpanel {
  position: fixed; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); z-index: 40;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: 55vh; display: flex; flex-direction: column; overflow: hidden;
}
.tpanel[hidden] { display: none; }
.tpanel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 4px 4px; border-bottom: 1px solid var(--line); }
.tpanel.collapsed .tpanel-head { border-bottom: 0; }
.tpanel-toggle { display: flex; align-items: center; gap: 8px; flex: 1; background: none; border: 0; color: var(--fg); font: inherit; font-weight: 600; padding: 8px; cursor: pointer; text-align: left; border-radius: 8px; }
.tpanel-toggle .icon:last-child { margin-left: auto; }
.tpanel-toggle[aria-expanded="false"] .icon:last-child { transform: rotate(180deg); }
.tlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.trow { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.trow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.trow-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow-stat { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.trow[data-state="error"] .trow-stat { color: var(--danger); }
.trow[data-state="done"] .trow-stat { color: var(--accent-text); }
.trow-actions { display: flex; flex: none; }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.trow[data-state="paused"] .bar-fill { background: var(--ctx); }
.trow[data-state="error"] .bar-fill { background: var(--danger); }

/* ------------------------------------------------------------ narrow */
@media (max-width: 640px) {
  h1 { font-size: 20px; }
  .top { padding: 8px 12px; }
  .who-name { max-width: 110px; }
  .main { padding: 16px 12px 140px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .frow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "n a" "s a" "m a"; gap: 0 8px; padding: 6px 4px 6px 12px; }
  .fname { grid-area: n; }
  .fact { grid-area: a; }
  .fsize { grid-area: s; text-align: left; font-size: 13px; }
  .fmod { grid-area: m; font-size: 13px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .bare-card { padding: 24px 20px; }
  .btn { height: 42px; }
  .btn.small { height: 34px; }
  .tpanel { right: 8px; left: 8px; bottom: 8px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
