:root {
  --bg: #0b0d12;
  --bg-soft: #11151d;
  --bg-raise: #171d27;
  --line: #232b38;
  --text: #e8eef7;
  --muted: #8fa0b8;
  --accent: #5ef2c7;
  --accent-2: #4a8dff;
  --danger: #ff6b6b;
  --warn: #ffcc66;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 20% -10%, #16202c 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent-2); text-decoration: none; }
code { background: #0d1117; border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; font-size: 0.9em; }
.hidden, [hidden] { display: none !important; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; letter-spacing: 0.2px; }
.brand-name { font-weight: 700; }
.brand-sub { color: var(--muted); font-weight: 500; }
.brand-lg { gap: 14px; margin-bottom: 26px; }
.brand-lg .brand-name { font-size: 24px; }
.brand-lg .brand-sub { font-size: 14px; letter-spacing: 2px; text-transform: uppercase; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(400px, 100%);
  background: linear-gradient(180deg, rgba(23, 29, 39, 0.96), rgba(13, 17, 23, 0.98));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 7px; }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #0d1117;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { border-color: #35618f; box-shadow: 0 0 0 3px rgba(74, 141, 255, 0.16); }
button { font: inherit; cursor: pointer; border-radius: 11px; border: 1px solid var(--line); background: var(--bg-raise); color: var(--text); padding: 9px 15px; transition: background 0.15s, border-color 0.15s, opacity 0.15s; }
button:hover:not(:disabled) { background: #1e2633; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--accent), #34c9ff); border: 0; color: #05231c; font-weight: 700; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); }
.wide { width: 100%; padding: 12px; }
.form-error { color: var(--danger); font-size: 13.5px; margin: 0 0 14px; }
.login-note { color: var(--muted); font-size: 12.5px; margin: 18px 0 0; text-align: center; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 22px;
  background: rgba(11, 13, 18, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.storage { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.storage .bar { width: 120px; height: 5px; border-radius: 99px; background: #1b2230; overflow: hidden; margin-top: 5px; }
.storage .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.account { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow); z-index: 30;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 11px; border-radius: 8px; }
.menu button:hover { background: #232c3b; }
.caret { color: var(--muted); font-size: 11px; }

/* ---------- layout ---------- */
.layout { max-width: 1180px; margin: 0 auto; padding: 22px; display: grid; gap: 18px; }
.card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 16px; letter-spacing: 0.3px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--muted); min-width: 0; }
.breadcrumb button { border: 0; background: transparent; padding: 3px 6px; border-radius: 7px; color: var(--muted); }
.breadcrumb button:hover { color: var(--text); background: #1b2230; }
.breadcrumb .sep { opacity: 0.45; }
.breadcrumb .current { color: var(--text); font-weight: 600; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tools input[type="search"] { width: 190px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(35, 43, 56, 0.7); font-size: 14px; }
th { font-size: 11.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr:hover { background: rgba(30, 38, 51, 0.55); }
tbody tr:last-child td { border-bottom: 0; }
.col-check { width: 40px; }
.col-size { width: 110px; white-space: nowrap; }
.col-date { width: 190px; white-space: nowrap; }
.col-actions { width: 210px; text-align: right; white-space: nowrap; }
.file-name { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.file-name .icon { width: 20px; height: 20px; flex: 0 0 20px; opacity: 0.85; }
.file-name a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.file-name a:hover { color: var(--accent); }
.muted { color: var(--muted); }
tr.is-selected { background: rgba(74, 141, 255, 0.12); }
.row-actions button { padding: 5px 9px; font-size: 12.5px; border-radius: 8px; margin-left: 5px; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }

.banner { padding: 11px 16px; font-size: 13.5px; background: rgba(255, 204, 102, 0.1); color: var(--warn); border-bottom: 1px solid rgba(255, 204, 102, 0.25); }

/* ---------- drop ---------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(6, 9, 14, 0.78); backdrop-filter: blur(3px);
}
.drop-overlay div { border: 2px dashed var(--accent); border-radius: 22px; padding: 46px 62px; font-size: 20px; font-weight: 600; color: var(--accent); }

/* ---------- transfers ---------- */
.transfers .card-head { padding: 14px 16px; }
#transfer-list { display: grid; gap: 10px; padding: 14px 16px; }
.transfer { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; background: #0f141b; }
.transfer-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.transfer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.progress { height: 6px; border-radius: 99px; background: #1b2230; overflow: hidden; margin-top: 9px; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s; }
.transfer.error .progress > i { background: var(--danger); }
.transfer-actions { display: flex; gap: 6px; }
.transfer-actions button { padding: 3px 8px; font-size: 12px; }

/* ---------- admin ---------- */
.admin { border-color: rgba(94, 242, 199, 0.25); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding: 14px 16px; }
.stat { background: #0f141b; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 650; margin-top: 3px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 6px; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 170px; }
.inline-form button { flex: 0 0 auto; }
.hint { color: var(--muted); font-size: 12.5px; padding: 0 16px 12px; margin: 0; }
.admin-table td, .admin-table th { font-size: 13px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--accent); border-color: rgba(94, 242, 199, 0.3); }
.pill.off { color: var(--danger); border-color: rgba(255, 107, 107, 0.3); }
.pill.admin { color: var(--accent-2); border-color: rgba(74, 141, 255, 0.35); }

/* ---------- dialog + toasts ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--bg-raise); color: var(--text); padding: 24px; width: min(420px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5, 8, 12, 0.72); }
dialog h2 { margin: 0 0 16px; font-size: 17px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 18px 0 0; padding: 0; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 9px; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--bg-raise); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 13px; font-size: 13.5px; box-shadow: var(--shadow); animation: pop 0.16s ease-out; }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .layout { padding: 14px; }
  .storage { display: none; }
  .col-date { display: none; }
  .col-actions { width: auto; }
  .row-actions button span { display: none; }
  .row-actions .play-action { display: none; }
  .row-actions .action-link { margin-left: 4px; padding: 5px 8px; }
  .tools input[type="search"] { width: 100%; }
  .tools { width: 100%; }
  .file-name a { max-width: 28ch; }
  .col-size { width: 76px; }
}

/* ---------- sign-up, media player, folder drop ---------- */
.login-note a { color: var(--accent-2); }
.file-open { border: 0; background: transparent; padding: 0; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.action-link { padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; color: var(--text); margin-left: 5px; }
.file-open:hover { color: var(--accent-2); text-decoration: underline; }
.folder-row.drop-target { outline: 2px dashed var(--accent); outline-offset: -3px; background: rgba(94, 242, 199, 0.07); }
.media-dialog { width: min(920px, 96vw); padding: 14px; }
.media-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.media-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-body { background: #05070b; border-radius: 10px; overflow: hidden; display: grid; place-items: center; min-height: 160px; }
.media-body video, .media-body img { max-width: 100%; max-height: 62vh; display: block; }
.media-body audio { width: 100%; padding: 16px; }
.media-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 12.5px; }
@media (max-width: 720px) {
  .media-dialog { padding: 10px; width: 96vw; }
  .media-body img, .media-body video { max-height: 50vh; }
}
