:root {
  --ink: #0c1113;
  --panel: #121a1d;
  --panel-2: #172125;
  --line: #223034;
  --line-soft: #1a2529;
  --text: #e9edea;
  --muted: #a3b4b0;
  --dim: #6f817d;
  --accent: #5cc4a2;
  --accent-ink: #0b1512;
  --danger: #d9705f;
  --kind-image: #7fb6d9;
  --kind-video: #c99ad1;
  --kind-audio: #d9b97f;
  --kind-pdf: #d98a7f;
  --kind-text: #9fc48f;
  --kind-archive: #b8a98e;
  --kind-other: #8b9c98;
  --radius: 10px;
  --sans: "Instrument Sans", "Avenir Next", system-ui, sans-serif;
  --disp: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  font-family: var(--sans);
  background: var(--ink);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; }
::selection { background: rgba(92, 196, 162, .25); }

/* ---------- wordmark ---------- */
.wordmark {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.wordmark-tide {
  width: 22px; height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 118%, var(--accent) 0 46%, transparent 47%),
    linear-gradient(180deg, transparent 52%, rgba(92,196,162,.35) 53% 60%, transparent 61%),
    var(--panel-2);
  border: 1px solid var(--line);
  display: inline-block;
}

/* ---------- shell ---------- */
#app { display: flex; min-height: 100vh; }
.rail {
  width: 228px;
  flex: 0 0 228px;
  border-right: 1px solid var(--line-soft);
  background: var(--panel);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-align: left;
  font-weight: 500;
}
.rail-link:hover { color: var(--text); background: var(--panel-2); }
.rail-link.active { color: var(--text); background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.rail-sep { height: 1px; background: var(--line-soft); margin: 10px 6px; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.rail-logout { width: 100%; }

.meter { padding: 0 6px; font-size: 12.5px; color: var(--muted); }
.meter-line { display: flex; justify-content: space-between; margin-bottom: 6px; }
.meter-bar { height: 4px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .4s; }
.meter-free { margin-top: 6px; color: var(--dim); font-size: 11.5px; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 26px 12px;
  flex-wrap: wrap;
}
.crumbs { font-family: var(--mono); font-size: 13px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-height: 32px; }
.crumb { padding: 3px 6px; border-radius: 6px; color: var(--muted); }
.crumb:hover { color: var(--text); background: var(--panel-2); }
.crumb.here { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--dim); }
.crumbs .view-title { font-family: var(--disp); font-size: 19px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }

.topbar-tools { display: flex; align-items: center; gap: 8px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--dim);
}
.search:focus-within { border-color: var(--accent); color: var(--accent); }
.search input {
  background: none; border: 0; outline: 0; color: var(--text);
  width: 170px; font-size: 13.5px;
}
.search input::placeholder { color: var(--dim); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid transparent;
  text-decoration: none;
  justify-content: center;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--dim); }
.btn-danger { border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: rgba(217, 112, 95, .12); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; margin-top: 6px; }
.btn-x { color: var(--dim); font-size: 18px; line-height: 1; padding: 2px 6px; }
.btn-x:hover { color: var(--text); }

.ico { width: 17px; height: 17px; flex: 0 0 auto; }
.ico-big { width: 40px; height: 40px; }

/* ---------- selection bar ---------- */
.selbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 26px 10px;
  padding: 8px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted);
}
.selbar-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- content ---------- */
.content { padding: 4px 26px 60px; flex: 1; }

.empty {
  color: var(--dim);
  padding: 70px 0;
  text-align: center;
  font-size: 14px;
}
.empty .mono { display: block; margin-top: 8px; font-size: 12.5px; }

/* list view */
table.flist { width: 100%; border-collapse: collapse; }
.flist th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--dim); font-weight: 600; padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.flist td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
.flist tr.row { cursor: default; }
.flist tr.row:hover { background: var(--panel); }
.flist tr.row.sel { background: rgba(92, 196, 162, .09); }
.flist .cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.flist tr.row .fname { cursor: pointer; }
.fname:hover { color: var(--accent); }
.cell-size, .cell-mtime { color: var(--muted); font-size: 13px; white-space: nowrap; }
.cell-check { width: 30px; }
.rowcheck {
  width: 15px; height: 15px;
  appearance: none;
  border: 1.4px solid var(--dim);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: -2px;
}
.rowcheck:checked { background: var(--accent); border-color: var(--accent); }

/* grid view */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  position: relative;
  min-width: 0;
}
.tile:hover { border-color: var(--line); background: var(--panel-2); }
.tile.sel { border-color: var(--accent); background: rgba(92, 196, 162, .08); }
.tile-thumb {
  height: 92px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  background: var(--ink);
  margin-bottom: 9px;
  overflow: hidden;
}
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile-thumb .ico { width: 30px; height: 30px; }
.tile-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.tile .rowcheck { position: absolute; top: 8px; left: 8px; opacity: 0; }
.tile:hover .rowcheck, .tile.sel .rowcheck, .fgrid.selecting .rowcheck { opacity: 1; }

.kind-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.k-dir { color: var(--accent); }
.k-image { color: var(--kind-image); }
.k-video { color: var(--kind-video); }
.k-audio { color: var(--kind-audio); }
.k-pdf { color: var(--kind-pdf); }
.k-text { color: var(--kind-text); }
.k-doc { color: var(--kind-image); }
.k-archive { color: var(--kind-archive); }
.k-other { color: var(--kind-other); }

/* shares / people / activity tables reuse flist */
.pill {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill-on { color: var(--accent); border-color: rgba(92,196,162,.4); }
.pill-off { color: var(--danger); border-color: rgba(217,112,95,.35); }
.linkish { color: var(--accent); cursor: pointer; text-decoration: none; }
.linkish:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- drop veil ---------- */
.dropveil {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 17, 19, .82);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.dropveil-inner {
  border: 1.5px dashed var(--accent);
  border-radius: 14px;
  padding: 46px 64px;
  text-align: center;
  color: var(--text);
  font-family: var(--disp);
  font-size: 17px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.dropveil .ico-big { color: var(--accent); }

/* ---------- uploader panel ---------- */
.uploader {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  width: 330px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  overflow: hidden;
}
.uploader-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  font-weight: 600; font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}
.uploader-items { max-height: 260px; overflow-y: auto; padding: 6px 0; }
.up-item { padding: 6px 14px; font-size: 12.5px; }
.up-item-line { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.up-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-item-pct { color: var(--muted); flex: 0 0 auto; }
.up-bar { height: 3px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.up-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.up-item.done .up-fill { background: var(--accent); }
.up-item.err .up-fill { background: var(--danger); }
.up-item.err .up-item-pct { color: var(--danger); }

/* ---------- modal ---------- */
.modal-veil {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(8, 12, 13, .7);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow: auto;
}
.modal.modal-wide { max-width: 860px; }
.modal h2 { font-family: var(--disp); font-size: 17px; font-weight: 600; margin-bottom: 14px; letter-spacing: -0.01em; }
.modal .hint { color: var(--dim); font-size: 12.5px; margin-top: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field input, .field select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 11px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.form-error { color: var(--danger); font-size: 13px; margin: 4px 0 10px; }

.copyrow { display: flex; gap: 8px; margin-top: 4px; }
.copyrow input { flex: 1; }

/* preview inside modal */
.preview-stage { display: flex; align-items: center; justify-content: center; background: var(--ink); border-radius: 8px; min-height: 200px; max-height: 64vh; overflow: hidden; }
.preview-stage img, .preview-stage video { max-width: 100%; max-height: 64vh; object-fit: contain; }
.preview-stage iframe { width: 100%; height: 64vh; border: 0; background: #fff; }
.preview-stage pre {
  width: 100%; max-height: 64vh; overflow: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  padding: 16px; color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.preview-stage audio { width: 90%; }
.preview-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.preview-title .fname { max-width: none; font-weight: 600; }

/* move dialog tree */
.movelist { max-height: 300px; overflow: auto; border: 1px solid var(--line-soft); border-radius: 8px; }
.movelist button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left; padding: 7px 12px;
  color: var(--muted); font-size: 13px;
}
.movelist button:hover { background: var(--panel); color: var(--text); }
.movelist button.chosen { color: var(--accent); background: rgba(92,196,162,.08); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 9px;
  font-size: 13.5px;
  z-index: 80;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}
.toast.err { border-color: rgba(217, 112, 95, .5); color: var(--danger); }

/* ---------- login & share pages ---------- */
.login-body { background: radial-gradient(1200px 600px at 70% -10%, #14211f 0%, var(--ink) 55%); min-height: 100vh; display: flex; }
.login-wrap { margin: auto; width: 100%; max-width: 380px; padding: 28px 20px; }
.share-wrap { max-width: 520px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 28px;
}
.login-card .wordmark { margin-bottom: 6px; }
.login-sub { color: var(--dim); font-size: 13.5px; margin-bottom: 22px; }
.login-foot { text-align: center; color: var(--dim); font-size: 12px; margin-top: 18px; }

.share-title { font-family: var(--disp); font-size: 19px; font-weight: 600; margin: 14px 0 4px; letter-spacing: -0.01em; }
.share-filename { word-break: break-all; }
.share-preview { width: 100%; border-radius: 9px; margin: 14px 0 6px; max-height: 420px; object-fit: contain; background: var(--ink); }
.share-pdf { height: 420px; border: 0; background: #fff; }
.share-audio { width: 100%; margin: 14px 0 6px; }
.share-list { list-style: none; margin: 6px 0 12px; border: 1px solid var(--line-soft); border-radius: 9px; overflow: hidden; }
.share-list li { display: flex; align-items: center; gap: 10px; padding: 8px 13px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.share-list li:last-child { border-bottom: 0; }
.share-item-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.share-item-meta { color: var(--dim); font-size: 12px; flex: 0 0 auto; }
.share-item-dl { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 12.5px; }
.share-item-dl:hover { text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .rail { position: fixed; left: 0; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; border-top: 1px solid var(--line); border-right: 0; z-index: 40; }
  .rail .wordmark, .rail-foot .meter { display: none; }
  .rail-nav { flex-direction: row; flex: 1; }
  .rail-link { padding: 8px; font-size: 0; gap: 0; }
  .rail-link .ico { width: 20px; height: 20px; }
  .rail-sep { display: none; }
  .rail-foot { margin: 0; }
  #app { padding-bottom: 54px; }
  .topbar { padding: 12px 14px 8px; }
  .content { padding: 4px 14px 60px; }
  .selbar { margin: 0 14px 10px; }
  .fname { max-width: 38vw; }
  .cell-mtime { display: none; }
  th.cell-mtime { display: none; }
}

.lightbox-nav { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 12px; }
