:root {
  --topbar: #2a2a2e;
  --bg: #323236;
  --sidebar: #3a3a3f;
  --sidebar-active: #303035;
  --panel: #3a3a3f;
  --input: #46464b;
  --row-hover: #3d3d43;
  --border: #4b4b52;
  --border-soft: #414147;
  --text: #e8e8ea;
  --text-strong: #ffffff;
  --muted: #b3b3b9;
  --link: #4fa3ec;
  --primary: #4b9ee6;
  --primary-hover: #64adec;
  --danger: #e0584f;
  --warn: #e6a23c;
  --success: #3fb67b;
  --folder: #9fb6cc;
  --radius: 2px;
  --sidebar-w: 214px;
  --topbar-h: 54px;
  font-family: "Nunito Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; flex: none; }
code { background: var(--topbar); padding: 1px 6px; border-radius: 2px; font-size: 13px; }
[hidden] { display: none !important; }
.link { color: var(--link); }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 16px 0 10px;
  background: var(--topbar); border-bottom: 1px solid #1f1f22;
}
.brand { display: flex; align-items: center; gap: 4px; color: var(--text-strong); flex: none; width: 104px; }
.logo-mark { width: 30px; height: 30px; }
.logo-text { font-weight: 800; font-size: 19px; letter-spacing: -.4px; font-style: italic; }
.brand-lg .logo-mark { width: 40px; height: 40px; }
.brand-lg .logo-text { font-size: 26px; }
.search {
  flex: 1; max-width: 756px; height: 32px; display: flex; align-items: center; gap: 8px;
  background: var(--input); border: 1px solid #55555b; border-radius: var(--radius); padding: 0 10px;
}
.search svg { width: 18px; height: 18px; color: var(--muted); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 14.5px; }
.search input::placeholder { color: #a5a5ab; font-style: italic; }
.search:focus-within { border-color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px;
  background: none; border: 0; border-radius: 50%; color: #d9d9dc;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.icon-btn svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--primary); color: #fff; font-size: 10px; font-weight: 800; line-height: 16px;
}
.menu-btn, .search-toggle { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius); background: var(--input); font-weight: 600; font-size: 14px;
  white-space: nowrap; transition: background .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { background: none; border-color: var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,.05); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-create { height: 32px; padding: 0 16px; }

.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; z-index: 40;
  background: var(--sidebar); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 16px; background: none; border: 0; text-align: left;
}
.dropdown-menu button:hover { background: var(--sidebar-active); color: var(--link); }
.dropdown-menu svg { width: 18px; height: 18px; }

/* ---------- layout ---------- */
.shell { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 20;
  background: var(--sidebar); overflow-y: auto; padding: 6px 0 44px; transition: transform .22s ease;
}
.nav-head {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 44px; padding: 0 12px 0 8px;
  background: none; border: 0; text-transform: uppercase; font-weight: 800; font-size: 12.5px; letter-spacing: .2px; color: #f0f0f2;
}
.nav-head span { flex: 1; text-align: left; }
.nav-ico { width: 20px; height: 20px; }
.chev { width: 16px; height: 16px; color: #c8c8cc; transition: transform .2s; }
.nav-group.open .chev { transform: rotate(180deg); }
.nav-items { display: none; padding-bottom: 6px; }
.nav-group.open .nav-items { display: block; }
.nav-items a { display: block; padding: 6px 12px 6px 40px; font-size: 14px; color: #ececee; }
.nav-items a:hover { color: var(--link); }
.nav-items a.active { background: var(--sidebar-active); color: var(--link); font-weight: 600; }
.sidebar-foot { position: fixed; bottom: 0; left: 0; width: var(--sidebar-w); padding: 8px 14px; display: flex; justify-content: flex-end; color: var(--muted); background: var(--sidebar); }
.sidebar-foot svg { width: 16px; height: 16px; }
.scrim { display: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); }
.main > section { flex: 1; }
.page-head { padding: 26px 24px 0; }
.page-head h1 { margin: 0 0 18px; font-size: 16px; font-weight: 800; color: var(--text-strong); }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 6px 15px 12px; color: var(--link); font-size: 14.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:first-child { padding-left: 0; }
.tabs a.active { color: var(--text-strong); border-bottom-color: var(--primary); font-weight: 700; }

.panel { background: var(--panel); }
.summary { margin: 16px 0 0; padding: 18px 24px 20px; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.summary h2 { margin: 0; font-size: 16px; font-weight: 800; color: var(--text-strong); }
.summary p { margin: 8px 0 0; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 10px; font-size: 14px; }
.crumbs a { color: var(--link); padding: 2px 4px; border-radius: 2px; }
.crumbs a:hover { background: rgba(255,255,255,.05); }
.crumbs span.cur { color: var(--text); padding: 2px 4px; font-weight: 600; }
.crumbs svg { width: 14px; height: 14px; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.select-wrap { position: relative; width: 100%; max-width: 522px; }
.select-wrap select {
  appearance: none; width: 100%; height: 32px; padding: 0 36px 0 12px; background: var(--bg); border: 1px solid #5a5a60;
  border-radius: var(--radius); font-style: italic; color: #c4c4c9;
}
.select-wrap select:focus { outline: 1px solid var(--primary); }
.select-wrap svg { position: absolute; right: 10px; top: 7px; width: 18px; height: 18px; pointer-events: none; }
.bulk { display: flex; align-items: center; gap: 12px; color: var(--muted); }

.notice { margin: 16px 24px 0; padding: 12px 16px; border-left: 4px solid var(--warn); background: rgba(230,162,60,.1); }
.notice-error { border-color: var(--danger); background: rgba(224,88,79,.12); margin: 0 0 16px; }

/* ---------- file table ---------- */
.table-wrap { padding: 8px 24px 0; }
.ftable { width: 100%; border-collapse: collapse; }
.ftable th {
  text-align: left; font-weight: 700; font-size: 13px; color: var(--muted); padding: 12px 10px; border-bottom: 1px solid var(--border);
}
.ftable td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.ftable tbody tr:hover { background: var(--row-hover); }
.ftable tbody tr.sel { background: rgba(75,158,230,.12); }
.c-check { width: 36px; }
.c-size { width: 120px; }
.c-date { width: 170px; }
.c-act { width: 150px; text-align: right; }
.c-size, .c-date { color: var(--muted); white-space: nowrap; }
.ftable input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.fname { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fname .ico { width: 22px; height: 22px; display: grid; place-items: center; flex: none; }
.fname .ico img { width: 16px; height: 16px; }
.fname .ico svg { width: 20px; height: 20px; }
.fname .ico.folder { color: var(--folder); }
.fname a, .fname .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname a { color: var(--link); font-weight: 600; }
.fname a:hover { text-decoration: underline; }
.fname .txt { min-width: 0; display: flex; flex-direction: column; }
.fname .meta { display: none; font-size: 12px; color: var(--muted); }
.acts { display: inline-flex; gap: 2px; justify-content: flex-end; }
.acts .icon-btn { width: 30px; height: 30px; border-radius: 2px; color: var(--muted); }
.acts .icon-btn:hover { color: var(--link); }
.acts .icon-btn.del:hover { color: var(--danger); }
.acts svg { width: 18px; height: 18px; }

.empty, .loading { text-align: center; padding: 64px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.spinner { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.more-wrap { text-align: center; padding: 16px 0 0; }
.hint { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 32px; margin: 0; }

/* ---------- uploads ---------- */
.up-list { padding: 8px 24px 24px; }
.up-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-stat { color: var(--muted); font-size: 13px; white-space: nowrap; }
.up-bar { grid-column: 1 / -1; height: 4px; background: var(--border-soft); overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.up-item.done .up-bar i { background: var(--success); }
.up-item.error .up-bar i { background: var(--danger); }
.up-item.error .up-stat { color: var(--danger); }
.up-ctl { display: flex; gap: 6px; align-items: center; }

/* ---------- account ---------- */
.account-box { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.account-box img { width: 48px; height: 48px; border-radius: 50%; }
.account-box .av { width: 48px; height: 48px; border-radius: 50%; background: var(--input); display: grid; place-items: center; }
.account-box b { display: block; font-size: 15px; color: var(--text-strong); }
.center-stat { text-align: center; padding: 120px 16px 80px; }
.center-stat .meter { max-width: 420px; height: 8px; margin: 14px auto 6px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.center-stat .meter i { display: block; height: 100%; background: var(--primary); }

/* ---------- footer ---------- */
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 24px; margin-top: auto;
  border-top: 1px solid var(--border); color: #d2d2d6; font-size: 14px;
}

/* ---------- overlays ---------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: none; place-items: center; background: rgba(28,28,31,.82);
  border: 3px dashed var(--primary);
}
.drop-overlay.show { display: grid; }
.drop-overlay div { text-align: center; color: var(--text-strong); font-size: 18px; font-weight: 700; }
.drop-overlay svg { width: 56px; height: 56px; color: var(--primary); }

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.55); }
.modal-card { width: 100%; max-width: 460px; background: var(--sidebar); border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-body { padding: 20px; }
.modal-body p { margin: 0; word-break: break-word; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 700; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.field input, .modal-body input {
  width: 100%; height: 36px; padding: 0 12px; background: var(--bg); border: 1px solid #5a5a60; border-radius: var(--radius); outline: 0;
}
.field input:focus, .modal-body input:focus { border-color: var(--primary); }

.viewer { position: fixed; inset: 0; z-index: 65; display: flex; flex-direction: column; background: rgba(18,18,20,.96); }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 54px; padding: 0 12px 0 20px; background: var(--topbar); }
.viewer-head span { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-head > div { display: flex; gap: 6px; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-body audio { width: min(520px, 100%); }
.viewer-body .empty { padding: 0; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { min-width: 240px; max-width: 380px; padding: 12px 16px; background: var(--sidebar); border-left: 4px solid var(--primary); box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: tin .2s ease; }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--success); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- auth pages ---------- */
.auth-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); padding: 32px 28px; border-top: 3px solid var(--primary); }
.auth-card .brand { width: auto; margin-bottom: 20px; }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.auth-card .muted { margin: 0 0 20px; }
.auth-foot { margin-top: 20px; color: var(--muted); font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .c-date { width: 140px; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-grid; }
  .brand { width: auto; }
  .sidebar { transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.4); }
  .sidebar-foot { display: none; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 15; background: rgba(0,0,0,.45); }
  .main { margin-left: 0; }
  .c-date { display: none; }
}
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 8px 0 4px; }
  .search-toggle { display: inline-grid; }
  .search { display: none; position: absolute; left: 8px; right: 8px; top: 11px; max-width: none; }
  body.search-open .search { display: flex; }
  body.search-open .brand, body.search-open .topbar-right, body.search-open .menu-btn { visibility: hidden; }
  .hide-sm { display: none; }
  .btn-create { padding: 0 10px; }
  .btn-create span { display: none; }
  .topbar-right { gap: 4px; }
  .page-head { padding: 18px 16px 0; }
  .summary { padding: 16px; }
  .table-wrap, .up-list { padding-left: 16px; padding-right: 16px; }
  .notice { margin: 16px 16px 0; }
  .c-size { display: none; }
  .c-act { width: auto; }
  .ftable td { padding: 9px 6px; }
  .fname { align-items: flex-start; }
  .fname .meta { display: block; }
  .acts .hide-sm { display: none; }
  .foot { padding: 12px 16px; }
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-form { max-width: 420px; margin-top: 18px; }
#passwordPanel { margin-bottom: 24px; }
