/* 文件仓库 — dark console styling for the storage server */

:root {
  --ink-900: #0a1014;
  --ink-850: #0c1419;
  --ink-800: #101920;
  --ink-750: #131f27;
  --ink-700: #16232c;
  --line: #22323d;
  --line-soft: #1a2831;
  --text: #e9eff3;
  --text-dim: #9cb0bc;
  --text-faint: #6c8290;
  --amber: #f0a03c;
  --amber-bright: #ffbd63;
  --amber-soft: rgba(240, 160, 60, 0.13);
  --ok: #6ac9a6;
  --danger: #e57068;
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background-color: var(--ink-900);
  background-image:
    radial-gradient(1100px 420px at 12% -12%, rgba(240, 160, 60, 0.075), transparent 68%),
    radial-gradient(900px 500px at 100% 0%, rgba(106, 201, 166, 0.05), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

/* The upload button is a transparent file input stretched over the button:
   the tap lands directly on the input, which is the most widely supported
   way to open a file chooser (no programmatic click, no label forwarding). */
.upload-trigger {
  position: relative;
  overflow: hidden;
}

.file-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 0;
  cursor: pointer;
}

.upload-trigger:focus-within,
.upload-trigger:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* Visitors always see the upload and new-folder buttons; tapping them asks for
   the admin login instead of silently doing nothing. */
body.is-visitor #btnNewFolder,
body.is-visitor .upload-trigger {
  opacity: 0.62;
}

body.is-visitor .file-overlay {
  pointer-events: none;
}

.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

body.is-visitor .admin-only,
body.is-admin .visitor-only {
  display: none !important;
}

/* ---------- top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 clamp(16px, 4vw, 36px);
  height: 62px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 20, 0.9);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--amber);
  stroke-width: 1.5;
}

.brand-text {
  color: var(--text);
}

.bar-meta {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink-800);
}

.who .i {
  width: 15px;
  height: 15px;
  color: var(--ok);
}

.who-name {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
}

.role-chip {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber-bright);
  letter-spacing: 0.02em;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1;
  padding: 9px 13px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.btn .i {
  width: 16px;
  height: 16px;
}

.btn:hover {
  color: var(--text);
}

.btn-primary {
  background: var(--amber);
  color: #1b1206;
  font-weight: 600;
  border-color: var(--amber);
}

.btn-primary:hover {
  background: var(--amber-bright);
  border-color: var(--amber-bright);
  color: #1b1206;
}

.btn-quiet {
  border-color: var(--line);
  background: var(--ink-800);
  color: var(--text-dim);
}

.btn-quiet:hover {
  border-color: #2c4150;
  background: var(--ink-750);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--ink-800);
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
  color: var(--text-faint);
  border-color: transparent;
}

.btn-icon:hover {
  color: var(--text);
  background: var(--ink-700);
}

/* ---------- layout ---------- */

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px clamp(14px, 4vw, 36px) 60px;
  flex: 1;
}

.instruments {
  display: flex;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.readout {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 20px;
  border-right: 1px solid var(--line-soft);
  min-width: 124px;
}

.readout:last-child {
  border-right: none;
}

.readout-wide {
  flex: 1;
  min-width: 200px;
}

.readout-k {
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.readout-v {
  font-size: 19px;
  color: var(--text);
}

.readout-note {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.4;
  padding-top: 2px;
}

/* ---------- panel ---------- */

.panel {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.014), transparent);
}

.crumbs-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 260px;
}

.crumbs {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-dim);
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}

.crumbs::-webkit-scrollbar {
  display: none;
}

.crumb {
  padding: 3px 5px;
  border-radius: 5px;
  color: var(--text-dim);
  transition: color 0.15s ease, background-color 0.15s ease;
}

button.crumb {
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
}

.crumb:hover {
  color: var(--amber-bright);
  background: var(--amber-soft);
}

.crumb-current {
  color: var(--text);
  font-weight: 500;
}

.crumb-sep {
  color: #3a4d59;
  padding: 0 1px;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.search {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-750);
  color: var(--text-faint);
}

.search:focus-within {
  border-color: #3d5464;
  color: var(--amber);
}

.search .i {
  width: 15px;
  height: 15px;
}

.search input {
  width: 150px;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  padding: 0;
}

.search input::placeholder {
  color: var(--text-faint);
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.sortwrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-750);
  padding-right: 2px;
}

.sortwrap select {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 4px 8px 10px;
  cursor: pointer;
  outline: none;
}

.sortwrap select option {
  background: var(--ink-800);
  color: var(--text);
}

.sortwrap .btn-icon {
  width: 26px;
  height: 26px;
  color: var(--text-dim);
}

/* ---------- listing ---------- */

.thead,
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 142px 158px;
  align-items: center;
  gap: 10px;
}

.thead {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

.th-size {
  text-align: right;
}

.th-actions {
  text-align: right;
}

.rows {
  display: flex;
  flex-direction: column;
}

.row {
  position: relative;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  transition: background-color 0.13s ease;
}

.row:last-child {
  border-bottom: none;
}

.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background-color 0.13s ease;
}

.row:hover {
  background: var(--ink-750);
}

.row:hover::before {
  background: var(--amber);
}

.row-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: default;
}

.row-folder .row-name {
  cursor: pointer;
}

.glyph {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text-dim);
  background: var(--ink-700);
}

.glyph .i {
  width: 16px;
  height: 16px;
}

.row-folder .glyph {
  color: var(--amber);
  border-color: rgba(240, 160, 60, 0.28);
  background: var(--amber-soft);
}

.name-stack {
  min-width: 0;
}

.name-text {
  display: block;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-folder .name-text {
  font-weight: 500;
}

.name-sub {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-size,
.row-date {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.row-size {
  text-align: right;
}

.row-date {
  color: var(--text-faint);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.13s ease;
}

.row:hover .row-actions,
.row:focus-within .row-actions {
  opacity: 1;
}

.act {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.13s ease, background-color 0.13s ease;
}

.act .i {
  width: 15.5px;
  height: 15.5px;
}

.act:hover {
  color: var(--text);
  background: var(--ink-600, #1d2c36);
}

.act-danger:hover {
  color: var(--danger);
  background: rgba(229, 112, 104, 0.12);
}

/* ---------- empty state ---------- */

.empty {
  margin: 16px;
  padding: 44px 20px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-glyph {
  width: 34px;
  height: 34px;
  color: #33474f;
  margin-bottom: 4px;
}

.empty-title {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.empty-copy {
  margin: 0 0 6px;
  font-size: 13.5px;
  color: var(--text-faint);
  max-width: 40ch;
}

/* ---------- footer / hint ---------- */

.hint {
  margin: 14px 2px 0;
  font-size: 11.5px;
  color: #556c78;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 18px clamp(14px, 4vw, 36px) 30px;
  font-size: 12.5px;
  color: var(--text-faint);
  border-top: 1px solid var(--line-soft);
}

.foot a:hover {
  color: var(--amber-bright);
}

.build {
  color: #4f6673;
  font-size: 11.5px;
}

/* Shown only when the page script never started. */
.boot-alert {
  margin: 12px clamp(14px, 4vw, 36px) 0;
  padding: 11px 14px;
  border: 1px solid rgba(229, 112, 104, 0.45);
  border-radius: 10px;
  background: rgba(229, 112, 104, 0.12);
  color: #ffb3ac;
  font-size: 13.5px;
  line-height: 1.55;
}

.boot-alert b {
  color: #ffd7d2;
}

/* ---------- upload tray ---------- */

.tray {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(340px, calc(100vw - 32px));
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  z-index: 50;
  overflow: hidden;
}

.tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text-dim);
}

.tray-items {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 0;
}

.tray-item {
  padding: 8px 14px;
}

.tray-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.tray-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tray-pct {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  flex: none;
}

.bar-track {
  height: 3px;
  border-radius: 3px;
  background: var(--ink-700);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--amber);
  transition: width 0.15s linear;
}

.tray-item.is-done .bar-fill {
  background: var(--ok);
}

.tray-item.is-error .bar-fill {
  background: var(--danger);
}

.tray-item.is-error .tray-pct {
  color: var(--danger);
}

/* ---------- drop overlay ---------- */

.dropveil {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(7, 12, 16, 0.82);
  backdrop-filter: blur(2px);
}

.dropframe {
  border: 2px dashed var(--amber);
  border-radius: 16px;
  padding: 46px 62px;
  text-align: center;
  color: var(--amber);
  background: rgba(240, 160, 60, 0.05);
}

.dropframe .i {
  width: 30px;
  height: 30px;
}

.dropframe p {
  margin: 12px 0 4px;
  font-size: 17px;
  color: var(--text);
}

.dropframe span {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- modal ---------- */

.veil {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 9, 12, 0.72);
}

.modal {
  width: min(440px, 100%);
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-lead {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.6;
}

.field {
  margin-bottom: 13px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-750);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.input:focus,
.field select:focus {
  border-color: #3d5464;
  box-shadow: 0 0 0 3px rgba(240, 160, 60, 0.1);
}

.field select option {
  background: var(--ink-800);
}

.modal-error {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--danger);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions .btn {
  min-width: 84px;
}

.modal-danger {
  color: var(--danger);
  border-color: rgba(229, 112, 104, 0.4);
}

.modal-danger:hover {
  background: rgba(229, 112, 104, 0.12);
  color: #ff9d96;
}

.share-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-box .input {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.admin-list {
  margin: 0 0 16px;
  border-top: 1px solid var(--line-soft);
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}

.admin-row-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.admin-user {
  font-family: var(--mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-ops {
  display: flex;
  gap: 4px;
  flex: none;
}

.admin-subhead {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 9px 15px;
  border-radius: 8px;
  background: var(--ink-750);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
  max-width: min(420px, calc(100vw - 32px));
}

.toast-error {
  border-color: rgba(229, 112, 104, 0.45);
  color: #ffb0a9;
}

.toast-ok {
  border-color: rgba(106, 201, 166, 0.4);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .thead,
  .row {
    grid-template-columns: minmax(0, 1fr) 90px 122px;
  }

  .th-date,
  .row-date {
    display: none;
  }

  .bar-meta {
    display: none;
  }
}

@media (max-width: 660px) {
  body {
    font-size: 14.5px;
  }

  .bar {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .bar-actions {
    gap: 6px;
  }

  .brand {
    font-size: 15px;
  }

  .wrap {
    padding-top: 16px;
  }

  .instruments {
    margin-bottom: 16px;
  }

  .readout {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
  }

  .readout-v {
    font-size: 16px;
  }

  .readout-wide {
    order: -1;
    flex-basis: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .tools {
    gap: 6px;
  }

  .search {
    flex: 1 1 100%;
  }

  .search input {
    width: 100%;
  }

  .sortwrap {
    flex: 1 1 auto;
  }

  .sortwrap select {
    flex: 1;
    width: 100%;
  }

  .thead {
    display: none;
  }

  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name actions"
      "meta actions";
    row-gap: 2px;
    padding: 11px 12px;
  }

  .row-name {
    grid-area: name;
  }

  .row-size {
    grid-area: meta;
    text-align: left;
    padding-left: 40px;
    font-size: 11.5px;
    color: var(--text-faint);
  }

  .row-actions {
    grid-area: actions;
    opacity: 1;
  }

  .act {
    width: 30px;
    height: 30px;
  }

  .hint {
    display: none;
  }

  .tray {
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
  }

  .foot {
    padding-bottom: 22px;
  }
}

@media (hover: none) {
  .row-actions {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
