:root {
  --bg1: #1a2340;
  --bg2: #0d1220;
  --panel: rgba(30, 38, 56, 0.95);
  --accent: #4f8cff;
  --text: #e8ecf5;
  --dim: #aab3c7;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

body {
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(1200px 800px at 30% 20%, var(--bg1), var(--bg2));
}

button {
  font: inherit;
  color: var(--text);
  background: #ffffff14;
  border: 1px solid #ffffff22;
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
}
button:hover { background: #ffffff28; }

/* top bar */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  z-index: 10;
}
#crumbs a { color: var(--text); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
#crumbs a:hover { background: #ffffff22; }
#crumbs .sep { color: var(--dim); }
#topright { display: flex; align-items: center; gap: 10px; }
#whoami { color: var(--dim); }

/* desktop */
#desktop {
  position: absolute;
  inset: 44px 0 0 0;
  padding: 18px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  overflow-y: auto;
}
#desktop.drop { outline: 3px dashed var(--accent); outline-offset: -8px; }

.icon {
  width: 104px;
  padding: 10px 4px;
  text-align: center;
  border-radius: 10px;
  cursor: default;
  user-select: none;
  position: relative;
}
.icon:hover { background: #ffffff14; }
.icon.sel { background: rgba(79, 140, 255, 0.3); outline: 1px solid rgba(79, 140, 255, 0.55); }
.icon .em { font-size: 42px; line-height: 1.25; display: block; }
.icon .nm {
  font-size: 13px; margin-top: 8px; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.icon .sz { font-size: 11px; color: #a8a8b3; margin-top: 4px; }
.icon .dt { display: none; }
.icon .pin { position: absolute; bottom: -4px; right: -8px; font-size: 18px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }

/* Views */
#desktop.view-list { flex-direction: column; flex-wrap: nowrap; gap: 2px; }
#desktop.view-list .icon { width: 100%; display: flex; align-items: center; padding: 6px 12px; text-align: left; }
#desktop.view-list .icon .em { font-size: 24px; margin-right: 12px; }
#desktop.view-list .icon .nm { margin-top: 0; flex-grow: 1; -webkit-line-clamp: 1; white-space: nowrap; }
#desktop.view-list .icon .sz { margin-top: 0; min-width: 80px; text-align: right; }
#desktop.view-list .icon .pin { bottom: 6px; right: 8px; font-size: 14px; }

#desktop.view-details { flex-direction: column; flex-wrap: nowrap; gap: 2px; }
#desktop.view-details .icon { width: 100%; display: grid; grid-template-columns: 32px 1fr 100px 140px; align-items: center; padding: 6px 12px; text-align: left; }
#desktop.view-details .icon .em { font-size: 20px; }
#desktop.view-details .icon .nm { margin-top: 0; -webkit-line-clamp: 1; white-space: nowrap; }
#desktop.view-details .icon .sz { margin-top: 0; }
#desktop.view-details .icon .dt { display: block; font-size: 12px; color: var(--dim); }
#desktop.view-details .icon .pin { bottom: 6px; right: 8px; font-size: 14px; }

.thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; margin: 0 auto 8px auto; display: block; background: #000; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }

/* context menu */
#ctxmenu {
  position: fixed;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid #ffffff22;
  border-radius: 10px;
  padding: 6px;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
#ctxmenu .mi { padding: 7px 12px; border-radius: 6px; cursor: pointer; }
#ctxmenu .mi:hover { background: var(--accent); }
#ctxmenu hr { border: none; border-top: 1px solid #ffffff22; margin: 5px 4px; }

/* transfers panel */
#uploads {
  position: fixed;
  right: 16px; bottom: 16px;
  width: 360px;
  max-height: 45vh;
  background: var(--panel);
  border: 1px solid #ffffff22;
  border-radius: 12px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
#uploadsHead {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #ffffff22;
  font-weight: 600;
}
#uploadsHead button { padding: 1px 8px; }
#uploadsList { overflow-y: auto; padding: 8px 12px; }
.uprow { margin-bottom: 10px; }
.uprow .nm { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uprow .bar { height: 6px; background: #ffffff18; border-radius: 3px; margin: 4px 0; overflow: hidden; }
.uprow .fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.uprow.err .fill { background: #e05555; }
.uprow.ok .fill { background: #4fc26e; }
.uprow .st { font-size: 11px; color: var(--dim); }

/* toast */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #333; padding: 12px 24px; border-radius: 6px; font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5); z-index: 100;
}

#jobOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.job-card {
  background: #1e1e1e; padding: 32px; border-radius: 12px; width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}
.job-card h3 { margin: 0; font-size: 16px; }

/* login */
#login {
  position: fixed;
  inset: 0;
  background: radial-gradient(1200px 800px at 30% 20%, var(--bg1), var(--bg2));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
#login form {
  background: var(--panel);
  border: 1px solid #ffffff22;
  padding: 34px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  text-align: center;
}
#login h1 { font-size: 20px; margin-bottom: 6px; }
#login input {
  font: inherit;
  color: var(--text);
  background: #ffffff10;
  border: 1px solid #ffffff28;
  border-radius: 8px;
  padding: 8px 12px;
}
#login button { background: var(--accent); border: none; padding: 9px; }
#loginErr { color: #e05555; font-size: 12px; min-height: 1em; }

/* Mobile Optimization */
@media (max-width: 850px) {
  #topbar {
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  #topbar::-webkit-scrollbar {
    display: none;
  }
  #topbar > * {
    flex-shrink: 0;
  }
  #topright {
    margin-left: 15px;
    padding-right: 14px;
  }
  #topright > * {
    flex-shrink: 0;
  }
  .job-card {
    max-width: 95vw !important;
    overflow-x: auto;
  }
  #uploads {
    width: 95vw !important;
    right: 2.5vw !important;
    bottom: 16px !important;
  }
}
