:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #e6ebf2;
  --text: #172238;
  --muted: #718096;
  --blue: #2868f2;
  --blue-dark: #174dcc;
  --blue-soft: #edf3ff;
  --danger: #dc3d4d;
  --shadow: 0 18px 60px rgba(35, 55, 92, .13);
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .16em; }

.brand-mark {
  display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 24px;
  color: #fff; font-size: 23px; font-weight: 800; border-radius: 19px;
  background: linear-gradient(145deg, #4d88ff, #1555e5); box-shadow: 0 14px 32px rgba(40, 104, 242, .3);
}
.brand-mark.small { width: 42px; height: 42px; margin: 0; border-radius: 14px; font-size: 17px; }

.login-screen, .setup-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 18% 18%, rgba(83, 135, 255, .16), transparent 30%),
    radial-gradient(circle at 85% 80%, rgba(55, 191, 225, .12), transparent 32%),
    #f6f8fc;
}
.login-card, .setup-card {
  width: min(420px, 100%); padding: 42px; text-align: center; background: rgba(255, 255, 255, .95);
  border: 1px solid rgba(230, 235, 242, .9); border-radius: 28px; box-shadow: var(--shadow);
}
.login-card h1, .setup-card h1 { margin: 0 0 10px; font-size: 29px; }
.login-card form, .setup-card form { display: grid; gap: 12px; margin-top: 28px; text-align: left; }
label { color: #46536b; font-size: 13px; font-weight: 700; }
input {
  width: 100%; min-height: 44px; padding: 0 14px; color: var(--text); background: #fff;
  border: 1px solid #d9e0eb; border-radius: 11px; outline: none; transition: .16s ease;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(40, 104, 242, .12); }
.password-row { display: flex; gap: 8px; }
.password-row .icon-button { min-width: 58px; }
.form-message { min-height: 22px; margin: 16px 0 0; color: var(--danger); font-size: 13px; }
.secure-note { margin: 20px 0 0; color: #8b96a9; font-size: 12px; }
.secure-note::before { content: "●"; margin-right: 7px; color: #31a66a; }

.primary, .secondary, .danger, .icon-button, .text-button {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; font-weight: 700;
}
.primary { color: #fff; background: var(--blue); box-shadow: 0 7px 18px rgba(40, 104, 242, .2); }
.primary:hover { background: var(--blue-dark); }
.secondary { color: #3b4a65; background: #f5f7fb; border: 1px solid #e3e8f1; }
.secondary:hover { background: #edf1f7; }
.danger { color: #fff; background: var(--danger); }
.wide { width: 100%; min-height: 46px; }
.link-button { display: grid; place-items: center; margin-top: 18px; text-decoration: none; }
.icon-button { padding: 0 10px; color: #66758d; background: transparent; }
.icon-button:hover { color: var(--blue); background: var(--blue-soft); }
.text-button { min-height: 32px; padding: 0 8px; color: #42516b; background: transparent; }
.text-button:hover { color: var(--blue); background: var(--blue-soft); }
.danger-text { color: var(--danger); }

.app-shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; width: 244px;
  padding: 24px 16px; background: #fff; border-right: 1px solid var(--line);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: 2px; color: #8a96a9; font-size: 11px; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 14px;
  color: #5b6980; background: transparent; border: 0; border-radius: 11px; text-align: left; font-weight: 650;
}
.nav-item span { width: 20px; text-align: center; font-size: 17px; }
.nav-item:hover, .nav-item.active { color: var(--blue); background: var(--blue-soft); }
.logout { margin-top: 14px; }
.storage-card { margin-top: auto; padding: 16px; background: #f7f9fc; border: 1px solid #edf0f5; border-radius: 14px; }
.storage-title { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; }
.storage-card progress { width: 100%; height: 7px; margin: 12px 0 5px; accent-color: var(--blue); }
.storage-card p { margin: 0; color: var(--muted); font-size: 11px; }

.workspace { grid-column: 2; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  min-height: 76px; padding: 0 34px; background: rgba(244, 247, 251, .9); border-bottom: 1px solid rgba(230, 235, 242, .8); backdrop-filter: blur(16px);
}
.search-box { display: flex; align-items: center; gap: 9px; width: min(440px, 52vw); padding: 0 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.search-box input { min-height: 42px; padding: 0; border: 0; box-shadow: none; }
.connection-pill { display: flex; align-items: center; gap: 7px; color: #5e6d84; font-size: 12px; font-weight: 700; }
.connection-pill i { width: 8px; height: 8px; background: #35b674; border-radius: 50%; box-shadow: 0 0 0 4px rgba(53, 182, 116, .12); }
.mobile-only { display: none; }

.content { padding: 30px 34px 46px; }
.content-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.content-heading h2 { margin: 0; font-size: 26px; }
.button-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.button-row.compact { gap: 3px; }
.file-panel { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 28px rgba(38, 59, 94, .045); }
.pathbar { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.breadcrumbs { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: auto; white-space: nowrap; }
.breadcrumbs button { padding: 5px 7px; color: #68768b; background: transparent; border: 0; border-radius: 7px; }
.breadcrumbs button:hover { color: var(--blue); background: var(--blue-soft); }
.breadcrumbs button:last-child { color: var(--text); font-weight: 750; }
.breadcrumbs span { color: #b1b9c6; }
.selection-bar { display: flex; align-items: center; min-height: 48px; padding: 0 18px; background: #f4f7ff; border-bottom: 1px solid #dfe8ff; }
.selection-bar > span { margin-right: 16px; color: var(--blue); font-size: 13px; font-weight: 750; }
.selection-bar > .icon-button { margin-left: auto; }
.table-wrap { position: relative; min-height: 330px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 44px; color: #8b96a7; font-size: 11px; font-weight: 750; text-align: left; background: #fbfcfe; border-bottom: 1px solid var(--line); }
td { height: 58px; padding: 0 8px; color: #526079; font-size: 13px; border-bottom: 1px solid #f0f2f6; }
tbody tr { transition: background .12s; }
tbody tr:hover, tbody tr.selected { background: #f6f9ff; }
.check-cell { width: 48px; padding-left: 18px; }
.check-cell input { width: 15px; min-height: 15px; accent-color: var(--blue); }
.name-cell { display: flex; align-items: center; gap: 11px; min-width: 0; color: #26334a; font-weight: 650; }
.name-cell button { min-width: 0; padding: 0; overflow: hidden; color: inherit; background: none; border: 0; font-weight: inherit; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.file-icon { display: grid; place-items: center; flex: 0 0 35px; height: 35px; border-radius: 10px; background: #f1f5fc; font-size: 19px; }
.folder-icon { color: #e9a532; background: #fff7de; }
.path-column { width: 23%; }
.size-column { width: 105px; }
.date-column { width: 160px; }
.action-cell { width: 55px; }
.more-button { min-width: 34px; }
.empty-state, .loading-state { position: absolute; inset: 44px 0 0; display: grid; place-content: center; text-align: center; }
.empty-state div { color: #b5c2d5; font-size: 54px; }
.empty-state h3 { margin: 10px 0 5px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.loading-state { gap: 10px; color: var(--muted); font-size: 13px; }
.loading-state span { width: 24px; height: 24px; margin: auto; border: 3px solid #dce5f4; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.drop-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 30px; background: rgba(27, 45, 77, .55); backdrop-filter: blur(4px); }
.drop-overlay div { display: grid; gap: 8px; width: min(520px, 90vw); padding: 54px; color: #fff; text-align: center; border: 2px dashed rgba(255,255,255,.8); border-radius: 24px; }
.drop-overlay strong { font-size: 26px; }
.drop-overlay span { opacity: .8; }
.upload-queue { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: min(380px, calc(100vw - 30px)); max-height: 55vh; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.queue-header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 0 14px; background: #fff; border-bottom: 1px solid var(--line); }
.queue-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #f0f2f6; }
.queue-item strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.queue-item span { color: var(--muted); font-size: 11px; }
.queue-item progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--blue); }

.dialog { width: min(440px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 18px; box-shadow: var(--shadow); }
.dialog::backdrop, .preview-dialog::backdrop { background: rgba(22, 34, 55, .48); backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 14px; padding: 25px; }
.dialog h3 { margin: 0; }
.dialog p { margin: 0; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 8px; }
.move-dialog { width: min(520px, calc(100vw - 30px)); }
.folder-picker { min-height: 230px; max-height: 42vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.folder-picker button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 13px; background: #fff; border: 0; border-bottom: 1px solid #f0f2f6; text-align: left; }
.folder-picker button:hover { color: var(--blue); background: var(--blue-soft); }
.picker-empty { padding: 0 14px; }
.preview-dialog { width: min(1000px, calc(100vw - 36px)); height: min(760px, calc(100vh - 36px)); padding: 0; overflow: hidden; border: 0; border-radius: 18px; box-shadow: var(--shadow); }
.preview-dialog header { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--line); }
.preview-body { display: grid; place-items: center; height: calc(100% - 54px); padding: 18px; overflow: auto; background: #f1f3f7; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
.preview-body audio { width: min(620px, 100%); }
.preview-body iframe { width: 100%; height: 100%; background: #fff; border: 0; border-radius: 8px; }
.toast-region { position: fixed; top: 20px; right: 22px; z-index: 200; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 12px 15px; color: #fff; background: #26364f; border-radius: 10px; box-shadow: 0 10px 28px rgba(20, 31, 49, .24); font-size: 13px; animation: toast-in .18s ease-out; }
.toast.error { background: #b93444; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .workspace { grid-column: 1; }
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { padding: 0 18px; gap: 10px; }
  .search-box { width: min(100%, 440px); }
  .connection-pill { display: none; }
  .content { padding: 22px 18px 38px; }
  .content-heading { align-items: flex-start; flex-direction: column; }
  .path-column { display: none; }
}

@media (max-width: 620px) {
  .login-card, .setup-card { padding: 32px 24px; border-radius: 22px; }
  .content-heading .button-row { width: 100%; }
  .content-heading .button-row button { flex: 1 1 auto; }
  .date-column { display: none; }
  .size-column { width: 82px; }
  .selection-bar { align-items: flex-start; flex-wrap: wrap; padding: 8px 12px; }
  .selection-bar > .icon-button { position: absolute; right: 12px; }
  .selection-bar > .button-row { width: 100%; order: 2; }
  .file-panel { border-radius: 14px; }
  .check-cell { width: 38px; padding-left: 12px; }
  .size-column { font-size: 0; }
  .action-cell { display: none; }
  .preview-body { padding: 8px; }
}
