/* ========== Tokens ========== */
:root {
  --bg: #070b18;
  --bg-2: #0c1224;
  --surface: rgba(20, 28, 52, 0.72);
  --surface-solid: #121a31;
  --surface-2: rgba(255, 255, 255, 0.04);
  --surface-3: rgba(255, 255, 255, 0.07);
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #e8ecf6;
  --text-2: #b6bfd4;
  --muted: #7f8aa6;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --accent: #06b6d4;
  --danger: #f43f5e;
  --success: #10b981;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #06b6d4 120%);
  --ring: 0 0 0 4px rgba(99, 102, 241, 0.22);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 50px -24px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 272px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-2: #eef1f8;
  --surface: rgba(255, 255, 255, 0.85);
  --surface-solid: #ffffff;
  --surface-2: #f3f5fa;
  --surface-3: #e9edf5;
  --border: #e3e7f0;
  --border-strong: #cfd6e4;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -18px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 30px 70px -30px rgba(15, 23, 42, 0.35);
  color-scheme: light;
}

/* ========== Base ========== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ico { width: 18px; height: 18px; flex: none; }

[data-theme="dark"] .when-light, [data-theme="light"] .when-dark { display: none; }

::selection { background: rgba(99, 102, 241, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(6, 182, 212, 0.10), transparent 60%);
}
[data-theme="light"] .bg-glow { opacity: 0.6; }

/* ========== Buttons & inputs ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 11px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary {
  background: var(--grad); background-size: 140% 140%; color: #fff;
  box-shadow: 0 10px 24px -10px rgba(99, 102, 241, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:hover { background-position: 100% 0; box-shadow: 0 14px 30px -10px rgba(99, 102, 241, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 10px 24px -12px rgba(244, 63, 94, 0.8); }
.btn-danger:hover { filter: brightness(1.08); }
.btn.danger:hover { color: var(--danger); border-color: rgba(244, 63, 94, 0.4); background: rgba(244, 63, 94, 0.08); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm .ico { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(244, 63, 94, 0.4); background: rgba(244, 63, 94, 0.1); }
.icon-btn.active { background: rgba(99, 102, 241, 0.16); color: #a5b4fc; border-color: rgba(99, 102, 241, 0.4); }
[data-theme="light"] .icon-btn.active { color: var(--primary); }

.input {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); background: var(--surface-3); }
.input.sm { height: 36px; padding: 0 11px; font-size: 13.5px; border-radius: 9px; }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237f8aa6' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
select.input option { background: var(--surface-solid); }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .6; }
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon {
  display: inline-flex; align-items: center; padding: 0 12px;
  background: var(--surface-3); border: 1px solid var(--border); border-left: 0;
  border-radius: 0 11px 11px 0; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.input-group .input.sm + .input-addon { border-radius: 0 9px 9px 0; padding: 0 10px; font-size: 12px; }
.input-addon:empty { display: none; }
.input-group .input:has(+ .input-addon:empty) { border-radius: 9px; }
.btn-reveal { cursor: pointer; }
.btn-reveal:hover { color: var(--text); }

.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stack { display: grid; gap: 16px; }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 18px;
  border: 1px solid;
}
.alert .ico { margin-top: 1px; }
.alert-error { background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.35); color: #fda4af; }
.alert-success { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.35); color: #6ee7b7; }
[data-theme="light"] .alert-error { color: #be123c; }
[data-theme="light"] .alert-success { color: #047857; }

.link { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: #a5b4fc; }
.link .ico { width: 15px; height: 15px; transition: transform .2s; }
.link:hover .ico { transform: translateX(3px); }
[data-theme="light"] .link { color: var(--primary); }

/* ========== App shell ========== */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 16px;
  background: color-mix(in srgb, var(--bg-2) 80%, transparent);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  background: var(--grad); color: #fff; box-shadow: 0 10px 24px -8px rgba(99, 102, 241, 0.7);
}
.brand-mark .ico { width: 22px; height: 22px; fill: rgba(255, 255, 255, 0.25); }
.brand-text { display: grid; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand-text small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.nav { display: grid; gap: 4px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px; color: var(--text-2); font-weight: 600; font-size: 14.5px;
  transition: background .2s, color .2s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: linear-gradient(90deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.04)); color: var(--text); }
.nav-link.active::before { content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); }
.nav-link.active .ico { color: #a5b4fc; }
[data-theme="light"] .nav-link.active .ico { color: var(--primary); }

.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.storage-card { padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.storage-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; margin-bottom: 10px; }
.storage-head .ico { width: 16px; height: 16px; color: var(--accent); }
.storage-card p { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.storage-card strong { color: var(--text); }
.meter { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--grad); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); }
.avatar {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 11px;
  background: linear-gradient(135deg, #f472b6, #8b5cf6); color: #fff; font-weight: 700; font-size: 14px;
}
.user-meta { display: grid; min-width: 0; flex: 1; }
.user-meta strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .icon-btn { width: 34px; height: 34px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 20px 36px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.page-head { flex: 1; min-width: 0; }
.page-head h1 { font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 28px 36px 48px; display: grid; gap: 24px; align-content: start; max-width: 1400px; width: 100%; }
.only-mobile { display: none; }
.scrim { display: none; }

/* ========== Panels ========== */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel-head p { margin-top: 4px; }

/* ========== Dashboard ========== */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--kc) 30%, transparent), transparent 70%);
}
.stat-icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; flex: none;
  color: var(--kc); background: color-mix(in srgb, var(--kc) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--kc) 28%, transparent);
}
.stat-icon .ico { width: 21px; height: 21px; }
.stat small { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat strong { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }

.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.action-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 18px;
  padding: 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: transform .25s ease, border-color .25s, box-shadow .25s;
}
.action-card::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: radial-gradient(600px 200px at 0% 0%, color-mix(in srgb, var(--kc) 18%, transparent), transparent 70%);
}
.action-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--kc) 45%, transparent); box-shadow: var(--shadow-lg); }
.action-card:hover::before { opacity: 1; }
.action-card > * { position: relative; }
.action-icon {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 16px; flex: none; color: #fff;
  background: linear-gradient(135deg, var(--kc), color-mix(in srgb, var(--kc) 60%, #000));
  box-shadow: 0 14px 28px -12px var(--kc);
}
.action-icon .ico { width: 26px; height: 26px; }
.action-card h3 { font-size: 17px; font-weight: 700; }
.action-card p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.action-go {
  margin-left: auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); transition: transform .25s, background .25s, color .25s;
}
.action-card:hover .action-go { transform: translateX(4px); background: var(--kc); color: #fff; border-color: transparent; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }

.stackbar { display: flex; gap: 3px; height: 12px; border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.stackbar span { height: 100%; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.legend a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 11px; transition: background .2s; }
.legend a:hover { background: var(--surface-2); }
.legend-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--kc); background: color-mix(in srgb, var(--kc) 14%, transparent); flex: none; }
.legend-icon .ico { width: 17px; height: 17px; }
.legend-name { flex: 1; display: grid; font-weight: 600; font-size: 14px; }
.legend-name small { color: var(--muted); font-weight: 500; font-size: 12px; }
.legend-size { font-size: 13px; font-weight: 600; color: var(--text-2); }

/* ========== File cards ========== */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.file-grid.compact { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.fcard {
  position: relative; display: flex; flex-direction: column;
  border-radius: 14px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform .2s ease, border-color .2s, box-shadow .2s, opacity .3s;
  animation: rise .35s ease both;
}
.fcard:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--kc) 45%, transparent); box-shadow: var(--shadow-lg); }
.fcard.removing { opacity: 0; transform: scale(.96); }
.fcard-thumb {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; overflow: hidden;
  background:
    radial-gradient(120px 80px at 50% 40%, color-mix(in srgb, var(--kc) 22%, transparent), transparent 70%),
    color-mix(in srgb, var(--kc) 7%, var(--surface-2));
  border-bottom: 1px solid var(--border);
}
.fcard-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.fcard:hover .fcard-thumb img { transform: scale(1.05); }
.kind-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; color: var(--kc);
  background: color-mix(in srgb, var(--kc) 16%, var(--surface-solid));
  border: 1px solid color-mix(in srgb, var(--kc) 30%, transparent);
  box-shadow: 0 12px 26px -14px var(--kc);
}
.kind-icon .ico { width: 26px; height: 26px; }
.ext-badge {
  position: absolute; left: 10px; top: 10px; padding: 3px 8px; border-radius: 7px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .05em; color: #fff;
  background: var(--kc); box-shadow: 0 4px 10px -4px var(--kc);
}
.fcard-body { padding: 12px 14px 14px; display: grid; gap: 5px; min-width: 0; }
.fcard-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcard-name:hover { color: #a5b4fc; }
[data-theme="light"] .fcard-name:hover { color: var(--primary); }
.fcard-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 7px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.gr-chip {
  justify-self: start; display: inline-flex; align-items: center; gap: 4px; margin-top: 2px;
  padding: 2px 8px 2px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  color: #a5b4fc; background: rgba(99, 102, 241, 0.13); border: 1px solid rgba(99, 102, 241, 0.25);
}
[data-theme="light"] .gr-chip { color: #4f46e5; }
.gr-chip .ico { width: 12px; height: 12px; }
.fcard-actions {
  position: absolute; right: 8px; top: 8px; display: flex; gap: 6px;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s;
}
.fcard-actions .icon-btn { background: color-mix(in srgb, var(--surface-solid) 85%, transparent); backdrop-filter: blur(8px); }
.fcard:hover .fcard-actions, .fcard:focus-within .fcard-actions { opacity: 1; transform: none; }
@media (hover: none) {
  .fcard-actions { position: static; opacity: 1; transform: none; padding: 0 14px 12px; }
  .fcard-actions .icon-btn { background: var(--surface-2); }
}

/* list view */
.file-grid.list { grid-template-columns: 1fr; gap: 8px; }
.file-grid.list .fcard { flex-direction: row; align-items: center; padding: 8px; gap: 14px; }
.file-grid.list .fcard:hover { transform: none; }
.file-grid.list .fcard-thumb { width: 54px; height: 54px; aspect-ratio: auto; border-radius: 11px; border: 0; flex: none; }
.file-grid.list .kind-icon { width: 34px; height: 34px; border-radius: 10px; box-shadow: none; }
.file-grid.list .kind-icon .ico { width: 18px; height: 18px; }
.file-grid.list .ext-badge { display: none; }
.file-grid.list .fcard-body { flex: 1; padding: 0; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px; }
.file-grid.list .gr-chip { margin: 0; }
.file-grid.list .fcard-actions { position: static; opacity: 1; transform: none; padding-right: 4px; }
.file-grid.list .fcard-actions .icon-btn { background: var(--surface-2); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ========== Empty state ========== */
.empty { text-align: center; padding: 48px 20px; display: grid; justify-items: center; gap: 8px; }
.empty-icon {
  display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; margin-bottom: 8px;
  color: #a5b4fc; background: rgba(99, 102, 241, 0.12); border: 1px solid rgba(99, 102, 241, 0.25);
}
.empty-icon .ico { width: 32px; height: 32px; }
.empty h3 { font-size: 18px; }
.empty p { color: var(--muted); margin-bottom: 10px; }

/* ========== Upload ========== */
.dropzone {
  position: relative; border-radius: 20px; padding: 48px 24px; text-align: center; cursor: pointer;
  background:
    radial-gradient(500px 220px at 50% 0%, rgba(99, 102, 241, 0.14), transparent 70%),
    var(--surface);
  border: 2px dashed var(--border-strong);
  transition: border-color .25s, background .25s, transform .25s;
}
.dropzone:hover { border-color: rgba(99, 102, 241, 0.6); }
.dropzone.drag { border-color: var(--primary); background: radial-gradient(500px 260px at 50% 30%, rgba(99, 102, 241, 0.25), transparent 70%), var(--surface); transform: scale(1.005); }
.dz-inner { display: grid; justify-items: center; gap: 10px; }
.dz-icon {
  display: grid; place-items: center; width: 84px; height: 84px; border-radius: 24px; margin-bottom: 6px; color: #fff;
  background: var(--grad); box-shadow: 0 20px 40px -16px rgba(99, 102, 241, 0.8);
  animation: float 3.5s ease-in-out infinite;
}
.dz-icon .ico { width: 38px; height: 38px; }
.dropzone h2 { font-size: 22px; font-weight: 800; }
@keyframes float { 50% { transform: translateY(-6px); } }

.count-pill { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--grad); color: #fff; }
.bulk { display: flex; gap: 8px; flex-wrap: wrap; }
.bulk .input { width: 150px; }

.queue-list { display: grid; gap: 10px; }
.qitem {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px;
  border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
  animation: rise .3s ease both;
}
.qicon .kind-icon { width: 44px; height: 44px; border-radius: 12px; box-shadow: none; }
.qicon .kind-icon .ico { width: 20px; height: 20px; }
.qicon img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; display: block; }
.qmain { flex: 1; min-width: 0; display: grid; gap: 10px; }
.qtop { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.qorig { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qfields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 160px; gap: 8px; }
.queue { scroll-margin-top: 100px; }
.qprogress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: none; }
.qprogress span { display: block; height: 100%; width: 0; background: var(--grad); transition: width .15s; }
.qstatus:empty { display: none; }
.qitem.uploading .qprogress, .qitem.done .qprogress { display: block; }
.qitem.uploading .qfields, .qitem.done .qfields { opacity: .55; pointer-events: none; }
.qitem.done { border-color: rgba(16, 185, 129, 0.4); }
.qitem.done .qprogress span { background: var(--success); }
.qitem.done .qstatus { color: var(--success); }
.qitem.error { border-color: rgba(244, 63, 94, 0.45); }
.qitem.error .qstatus { color: var(--danger); }
.queue-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ========== Find files ========== */
.toolbar { display: grid; gap: 14px; padding: 16px; position: sticky; top: 90px; z-index: 10; }
.search { position: relative; display: flex; align-items: center; }
.search > .ico { position: absolute; left: 16px; color: var(--muted); width: 20px; height: 20px; pointer-events: none; }
.search input {
  width: 100%; height: 54px; padding: 0 56px 0 48px; border-radius: 14px; font-size: 16px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); transition: border-color .2s, box-shadow .2s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.search kbd {
  position: absolute; right: 14px; padding: 2px 8px; border-radius: 6px; font: 600 12px/1.4 inherit;
  color: var(--muted); background: var(--surface-3); border: 1px solid var(--border);
}
.toolbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mini-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mini-field .ico { width: 16px; height: 16px; }
.mini-field .input { width: auto; }
.view-toggle { margin-left: auto; display: flex; gap: 6px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  --kc: var(--primary);
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 13px; font-weight: 600; color: var(--text-2); transition: all .2s;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--kc); }
.chip span { font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--muted); }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { color: var(--text); border-color: color-mix(in srgb, var(--kc) 55%, transparent); background: color-mix(in srgb, var(--kc) 16%, transparent); }
.chip.active span { background: var(--kc); color: #fff; }
.result-summary { margin-bottom: 14px; }
.result-summary strong { color: var(--text); }
[data-results] { transition: opacity .2s; }
[data-results].loading { opacity: .5; }

/* ========== Viewer ========== */
.back-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--muted); justify-self: start; }
.back-link:hover { color: var(--text); }
.viewer-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.viewer { padding: 0; overflow: hidden; min-height: 460px; display: grid; }
.viewer-media { display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--kc) 5%, transparent); }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: 72vh; border-radius: 12px; box-shadow: var(--shadow-lg); }
.viewer-media video { width: 100%; background: #000; }
.checker { background-color: var(--surface-2); background-image: conic-gradient(var(--surface-3) 25%, transparent 0 50%, var(--surface-3) 0 75%, transparent 0); background-size: 24px 24px; }
.viewer-pdf { width: 100%; height: 78vh; border: 0; background: #fff; }
.viewer-audio, .viewer-none { display: grid; place-items: center; align-content: center; gap: 14px; padding: 48px 24px; text-align: center; }
.viewer-audio audio { width: min(520px, 100%); }
.viewer-none p { max-width: 420px; }
.big-icon {
  display: grid; place-items: center; width: 96px; height: 96px; border-radius: 28px; color: var(--kc);
  background: color-mix(in srgb, var(--kc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--kc) 30%, transparent);
  box-shadow: 0 24px 50px -24px var(--kc);
}
.big-icon .ico { width: 42px; height: 42px; }
.viewer-code { margin: 0; padding: 22px; overflow: auto; max-height: 78vh; font: 13.5px/1.65 ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text-2); white-space: pre; tab-size: 4; }
.viewer-table { overflow: auto; max-height: 78vh; }
.viewer-table table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.viewer-table th, .viewer-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.viewer-table th { position: sticky; top: 0; background: var(--surface-solid); font-weight: 700; }
.viewer-table tr:hover td { background: var(--surface-2); }

.details { position: sticky; top: 110px; display: grid; gap: 20px; }
.details-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.details-head > div { min-width: 0; }
.details-head .kind-icon { width: 50px; height: 50px; flex: none; }
.details-head h2 { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.props { margin: 0; display: grid; gap: 2px; border-top: 1px solid var(--border); padding-top: 14px; }
.props > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.props > div:last-child { border-bottom: 0; }
.props dt { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; flex: none; }
.props dt .ico { width: 15px; height: 15px; }
.props dd { margin: 0; font-weight: 600; font-size: 13.5px; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-actions { display: grid; gap: 10px; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ========== Modal & toast ========== */
.modal {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(3, 6, 15, 0.6); backdrop-filter: blur(6px);
  animation: fade .2s ease;
}
.modal-card {
  width: min(500px, 100%); padding: 24px; border-radius: 20px; display: grid; gap: 16px;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: pop .25s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-sm { width: min(420px, 100%); text-align: center; justify-items: center; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-card h3 { font-size: 18px; font-weight: 700; }
.modal-card strong { color: var(--text); word-break: break-word; }
.modal-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; }
.modal-icon.danger { color: var(--danger); background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.3); }
.modal-icon .ico { width: 26px; height: 26px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; width: 100%; margin-top: 4px; }
.modal-sm .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px;
  padding: 13px 16px; border-radius: 13px; font-size: 14px; font-weight: 500;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: pop .25s ease;
}
.toast .ico { color: var(--success); }
.toast.error .ico { color: var(--danger); }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .3s; }

/* ========== Auth ========== */
.auth-body { overflow-x: hidden; }
.auth-blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.auth-blobs span { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; animation: drift 18s ease-in-out infinite alternate; }
.auth-blobs span:nth-child(1) { width: 520px; height: 520px; background: #6366f1; left: -120px; top: -140px; }
.auth-blobs span:nth-child(2) { width: 420px; height: 420px; background: #06b6d4; right: -100px; bottom: -120px; animation-delay: -6s; opacity: .35; }
.auth-blobs span:nth-child(3) { width: 300px; height: 300px; background: #ec4899; left: 40%; top: 55%; animation-delay: -12s; opacity: .25; }
[data-theme="light"] .auth-blobs span { opacity: .25; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.1); } }

.theme-float { position: fixed; top: 20px; right: 20px; z-index: 5; }
.auth {
  position: relative; z-index: 1; min-height: 100vh;
  display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 48px;
  max-width: 1160px; margin: 0 auto; padding: 48px 32px;
}
.hero-mark {
  display: grid; place-items: center; width: 76px; height: 76px; border-radius: 22px; color: #fff; margin-bottom: 26px;
  background: var(--grad); box-shadow: 0 24px 50px -18px rgba(99, 102, 241, 0.9);
}
.hero-mark .ico { width: 38px; height: 38px; fill: rgba(255, 255, 255, 0.25); }
.auth-hero h1 {
  font-size: clamp(40px, 5.5vw, 64px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.02;
  background: linear-gradient(120deg, var(--text) 30%, #a5b4fc 70%, #67e8f9);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: 18px; color: var(--text-2); margin-top: 16px; max-width: 460px; }
.hero-points { list-style: none; padding: 0; margin: 34px 0 0; display: grid; gap: 16px; }
.hero-points li { display: flex; gap: 14px; align-items: flex-start; }
.hero-points li > span {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--surface); border: 1px solid var(--border); color: #a5b4fc;
}
[data-theme="light"] .hero-points li > span { color: var(--primary); }
.hero-points strong { display: block; font-size: 15px; }
.hero-points small { color: var(--muted); font-size: 13.5px; }

.auth-card {
  padding: 34px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}
.auth-card-head { margin-bottom: 24px; }
.auth-card-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.auth-card-head p { margin-top: 6px; }
.auth-card .btn-lg { margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--muted); font-size: 14px; }
.auth-switch a { color: #a5b4fc; font-weight: 700; }
[data-theme="light"] .auth-switch a { color: var(--primary); }
.auth-switch a:hover { text-decoration: underline; }
.auth-note {
  display: flex; gap: 12px; margin-top: 24px; padding: 14px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.auth-note .ico { color: #f59e0b; margin-top: 2px; }
.auth-note strong { display: block; font-size: 13.5px; }
.auth-note small { color: var(--muted); font-size: 13px; }

/* ========== Responsive ========== */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .viewer-grid { grid-template-columns: 1fr; }
  .details { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: var(--sidebar-w);
    background: var(--surface-solid); transform: translateX(-100%); transition: transform .3s ease;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .sidebar.open + .scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 14px 16px; }
  .page-head h1 { font-size: 19px; }
  .page-head p { display: none; }
  .content { padding: 18px 16px 40px; gap: 18px; }
  .actions-grid { grid-template-columns: 1fr; }
  .toolbar { top: 70px; }
  .auth { grid-template-columns: 1fr; gap: 28px; padding: 72px 16px 32px; }
  .hero-points { display: none; }
  .hero-mark { width: 60px; height: 60px; margin-bottom: 16px; }
  .auth-card { padding: 24px; }
}
@media (max-width: 600px) {
  .hide-sm { display: none !important; }
  .panel { padding: 16px; }
  .fcard-body { padding: 10px 12px 12px; }
  .fcard-actions { padding: 0 12px 12px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat strong { font-size: 19px; }
  .field-row { grid-template-columns: 1fr; }
  .qfields { grid-template-columns: 1fr 1fr; }
  .qfields .input-group { grid-column: 1 / -1; }
  .bulk { width: 100%; }
  .bulk .input { flex: 1; width: auto; min-width: 0; }
  .file-grid, .file-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .file-grid.list { grid-template-columns: 1fr; }
  .file-grid.list .fcard-body { grid-template-columns: 1fr; gap: 3px; }
  .toolbar { position: static; }
  .mini-field { flex: 1 1 140px; }
  .mini-field .input { flex: 1; min-width: 0; }
  .view-toggle { margin-left: 0; }
  .dropzone { padding: 32px 16px; }
  .toasts { left: 16px; right: 16px; }
  .toast { min-width: 0; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
