:root {
  --bg: #0b0f15;
  --bg-glow: #13203a;
  --panel: #111823;
  --panel-2: #16202e;
  --panel-3: #1b2738;
  --line: #233247;
  --line-soft: #1a2637;
  --text: #e8eef7;
  --muted: #8ea2ba;
  --faint: #647892;
  --accent: #5b8cff;
  --accent-strong: #7aa4ff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --danger: #f07373;
  --danger-soft: rgba(240, 115, 115, 0.14);
  --success: #58d3a5;
  --radius: 14px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(900px 500px at 15% -10%, var(--bg-glow), transparent 60%),
    radial-gradient(700px 450px at 100% 0%, rgba(38, 74, 130, 0.35), transparent 55%),
    var(--bg);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

::selection {
  background: rgba(91, 140, 255, 0.35);
}

.app {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  max-width: 1120px;
  height: 100dvh;
  margin: 0 auto;
  padding: 18px max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
  stroke-width: 1.7;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: var(--panel-3);
  border-color: #31465f;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn-primary {
  border-color: rgba(91, 140, 255, 0.5);
  background: linear-gradient(180deg, #5f90ff, #4778e8);
  color: #fff;
  box-shadow: 0 8px 24px rgba(58, 110, 235, 0.28);
}

.btn-primary:hover {
  border-color: rgba(122, 164, 255, 0.8);
  background: linear-gradient(180deg, #6d9aff, #5283f2);
}

.btn-danger {
  border-color: rgba(240, 115, 115, 0.4);
  background: var(--danger-soft);
  color: #ffb3b3;
}

.btn-danger:hover {
  border-color: rgba(240, 115, 115, 0.65);
  background: rgba(240, 115, 115, 0.22);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.icon-btn.danger:hover {
  border-color: rgba(240, 115, 115, 0.35);
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scrollbar-width: none;
}

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

.crumbs a,
.crumbs span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.crumbs a:hover {
  background: var(--panel-2);
  color: var(--text);
}

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

.crumbs .sep {
  padding: 0;
  color: var(--faint);
  font-size: 12px;
  user-select: none;
}

.crumbs .home-icon {
  padding: 5px 7px;
}

.crumbs .home-icon svg {
  width: 15px;
  height: 15px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(380px, 100%);
}

.search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--faint);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

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

.search input:focus {
  border-color: rgba(91, 140, 255, 0.6);
  background: var(--panel-2);
}

.summary {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 24, 35, 0.82);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
}

.list-head,
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 170px 108px;
  gap: 12px;
  align-items: center;
}

.list-head {
  flex: none;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.listing {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.listing::-webkit-scrollbar,
.preview-body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.listing::-webkit-scrollbar-thumb,
.preview-body::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #2c3c52;
  background-clip: padding-box;
}

.row {
  min-height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.12s ease;
}

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

.row:hover {
  background: rgba(30, 44, 64, 0.55);
}

.name-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  background: none;
  text-align: left;
}

.name {
  overflow: hidden;
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
}

.badge svg {
  width: 18px;
  height: 18px;
}

.badge.dir {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge.link {
  color: #c69bff;
}

.badge.image {
  background: rgba(88, 211, 165, 0.12);
  color: var(--success);
}

.cell {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell.size {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

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

.spacer {
  width: 32px;
  height: 32px;
}

.empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  min-height: 180px;
  padding: 30px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.empty[hidden] {
  display: none;
}

.empty strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.empty span {
  color: var(--faint);
  font-size: 12.5px;
}

.drop-hint {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed rgba(91, 140, 255, 0.65);
  border-radius: var(--radius);
  background: rgba(11, 15, 21, 0.86);
  color: var(--accent-strong);
  font-size: 14px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.drop-hint svg {
  width: 44px;
  height: 44px;
  stroke-width: 1.5;
}

.drop-hint p {
  margin: 0;
}

.panel.dragging .drop-hint {
  display: flex;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
  padding: 0 3px;
  color: var(--faint);
  font-size: 11.5px;
}

#uploadStatus {
  overflow: hidden;
  max-width: 60%;
  color: var(--accent-strong);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(4, 7, 12, 0.72);
  backdrop-filter: blur(3px);
}

.dialog h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.1px;
}

.dialog .hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.dialog input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.dialog input:focus {
  border-color: rgba(91, 140, 255, 0.65);
}

.dialog input:invalid {
  border-color: rgba(240, 115, 115, 0.65);
}

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

.preview-dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: min(86dvh, 900px);
}

.preview-dialog[open] {
  display: flex;
  flex-direction: column;
}

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

.preview-head h2 {
  overflow: hidden;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 140px;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #090d13;
}

.preview-text {
  width: 100%;
  margin: 0;
  color: #c6d4e6;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: 62dvh;
  border-radius: 8px;
  object-fit: contain;
}

.preview-note {
  align-self: stretch;
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
}

.preview-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.preview-info .badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.preview-info .badge svg {
  width: 26px;
  height: 26px;
}

.preview-info strong {
  color: var(--text);
  font-size: 15px;
}

.preview-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}

.preview-foot:empty {
  display: none;
}

.preview-meta {
  color: var(--muted);
  font-size: 12.5px;
}

.preview-foot .btn {
  text-decoration: none;
}

.error {
  margin: 0;
  padding: 18px;
  color: #ffb3b3;
  font-size: 13.5px;
  text-align: center;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 40px auto;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toasts {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: rgba(22, 32, 46, 0.97);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  overflow-wrap: anywhere;
  animation: toast-in 0.2s ease both;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.out {
  animation: toast-out 0.2s ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

:focus-visible {
  outline: 2px solid rgba(122, 164, 255, 0.7);
  outline-offset: 2px;
}

.profile-dialog {
  width: min(460px, calc(100vw - 32px));
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #5f90ff, #3f6fdc);
  color: #fff;
  font-size: 19px;
  font-weight: 650;
  text-transform: uppercase;
  box-shadow: 0 8px 22px rgba(58, 110, 235, 0.3);
}

.profile-id {
  flex: 1;
  min-width: 0;
}

.profile-id h2 {
  overflow: hidden;
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-id .hint {
  margin: 0;
  font-size: 12px;
}

.profile-dialog h3 {
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.profile-dialog .auth-field {
  margin-bottom: 12px;
}

.profile-hint {
  margin: 2px 0 12px;
  font-size: 12px;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  overflow: auto;
}

.auth-card {
  width: min(400px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(17, 24, 35, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-logo {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 18px;
  border: 1px solid rgba(91, 140, 255, 0.28);
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.auth-logo svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.6;
}

.auth-card h1 {
  margin: 0 0 7px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.2px;
}

.auth-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-card form {
  margin-top: 24px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.auth-field span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
}

.auth-field input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.auth-field input:focus {
  border-color: rgba(91, 140, 255, 0.65);
  background: #0e141d;
}

.auth-error {
  margin: 4px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(240, 115, 115, 0.28);
  border-radius: 9px;
  background: var(--danger-soft);
  color: #ffb3b3;
  font-size: 12.5px;
  line-height: 1.4;
}

.auth-error[hidden] {
  display: none;
}

.auth-submit {
  width: 100%;
  height: 42px;
  margin-top: 18px;
}

.auth-submit:disabled {
  cursor: default;
  opacity: 0.65;
}

.auth-note {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 11.5px;
  text-align: center;
}

@media (max-width: 760px) {
  .app {
    gap: 9px;
    padding: 12px;
  }

  .auth-page {
    padding: 16px;
  }

  .auth-card {
    padding: 24px;
  }

  .brand span {
    display: none;
  }

  .list-head,
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .list-head .col-size,
  .list-head .col-date,
  .row .cell.size,
  .row .cell.date {
    display: none;
  }

  .list-head {
    padding: 9px 12px;
  }

  .row {
    min-height: 56px;
    padding: 0 12px;
  }

  .row-actions {
    opacity: 1;
  }

  .bar {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .search {
    width: 100%;
  }

  .summary {
    display: none;
  }

  .preview-dialog {
    width: calc(100vw - 16px);
    max-height: 92dvh;
    padding: 14px;
  }

  .toasts {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }
}

@media (max-width: 560px) {
  .btn-label {
    display: none;
  }

  .btn {
    padding: 8px 10px;
  }

  .tools {
    gap: 6px;
  }
}

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

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