:root {
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f0f4f9;
  --hover: #e9eef6;
  --selected: #c2e7ff;
  --selected-soft: #d3e3fd;
  --primary: #0b57d0;
  --primary-hover: #0842a0;
  --text: #1f1f1f;
  --text-2: #444746;
  --text-3: #747775;
  --border: #e0e3e7;
  --danger: #b3261e;
  --shadow: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --radius: 16px;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.hidden { display: none !important; }

.material-symbols-outlined {
  font-size: 20px;
  vertical-align: middle;
  user-select: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 24px; border-radius: 20px; border: 1px solid transparent;
  background: transparent; color: var(--primary); font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: rgba(11, 87, 208, .08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.btn.outline { border-color: #747775; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.tonal { background: var(--selected); color: #001d35; }
.btn.tonal:hover { background: #b3dcf5; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  color: var(--text-2); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: rgba(68, 71, 70, .08); }
.icon-btn.active { background: var(--selected); color: #001d35; }
.icon-btn.sm { width: 32px; height: 32px; }

.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 6px; border: 1px solid #747775;
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
select.input { padding-right: 8px; }

/* ---------- avatar ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 500; font-size: 14px;
  text-transform: uppercase; user-select: none;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.lg { width: 40px; height: 40px; font-size: 18px; }

/* ---------- app layout ---------- */
.app { display: grid; grid-template-columns: 256px 1fr; grid-template-rows: 64px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 8px; width: 232px; text-decoration: none; color: var(--text-2); font-size: 22px; }
.brand img { width: 40px; height: 40px; }
.search {
  flex: 1; max-width: 720px; display: flex; align-items: center; gap: 4px; height: 48px;
  padding: 0 8px; border-radius: 24px; background: #e9eef6; transition: background .15s, box-shadow .15s;
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; }
.topbar .spacer { flex: 1; }

.sidebar { padding: 8px 16px 16px 8px; overflow-y: auto; display: flex; flex-direction: column; }
.new-btn {
  display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 0 16px;
  margin: 0 0 16px 8px; border-radius: 16px; border: 0; background: var(--surface);
  box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  font-weight: 500; cursor: pointer; align-self: flex-start;
}
.new-btn:hover { box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15); background: #f6f9fe; }
.new-btn .material-symbols-outlined { font-size: 24px; }
.nav a {
  display: flex; align-items: center; gap: 16px; height: 32px; padding: 0 16px 0 20px;
  border-radius: 16px; color: var(--text); text-decoration: none; margin-bottom: 2px;
}
.nav a:hover { background: var(--hover); }
.nav a.active { background: var(--selected); font-weight: 600; color: #001d35; }
.nav a.drop-target { background: var(--selected-soft); outline: 2px solid var(--primary); }
.nav .sep { height: 12px; }
.storage { margin: 16px 0 0 20px; color: var(--text-2); font-size: 13px; }
.storage .bar { height: 4px; border-radius: 2px; background: #e3e3e3; margin: 8px 0; overflow: hidden; }
.storage .bar div { height: 100%; background: var(--primary); }
.storage .bar.warn div { background: var(--danger); }

.main {
  background: var(--surface); border-radius: var(--radius); margin: 0 16px 16px 0;
  display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative;
}
.main-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 4px 24px; min-height: 64px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; font-size: 22px; flex: 1; min-width: 0; }
.crumbs a, .crumbs span.cur {
  padding: 4px 12px; border-radius: 20px; color: var(--text); text-decoration: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 260px;
}
.crumbs a { color: var(--text-2); }
.crumbs a:hover, .crumbs a.drop-target { background: var(--hover); }
.crumbs .chev { color: var(--text-3); }
.crumbs .cur { display: inline-flex; align-items: center; gap: 4px; }
.crumbs .cur.clickable { cursor: pointer; }
.crumbs .cur.clickable:hover { background: var(--hover); }

.selbar {
  display: flex; align-items: center; gap: 4px; margin: 4px 16px 0 16px; padding: 0 8px;
  height: 48px; border-radius: 24px; background: var(--surface-2);
}
.selbar .count { margin: 0 12px 0 4px; font-weight: 500; }
.filters { display: flex; align-items: center; gap: 8px; padding: 4px 24px 8px; min-height: 48px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid #747775; background: transparent; cursor: pointer; font-weight: 500; color: var(--text-2);
}
.chip:hover { background: var(--hover); }
.chip.on { background: var(--selected-soft); border-color: transparent; color: #001d35; }

.content-wrap { flex: 1; display: flex; min-height: 0; }
.content { flex: 1; overflow-y: auto; padding: 0 16px 24px 24px; position: relative; outline: none; }
.section-title { font-weight: 500; color: var(--text); margin: 16px 0 12px; display: flex; align-items: center; gap: 8px; }

/* grid view */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.folder-card {
  display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 4px 0 16px; border-radius: 12px;
  background: var(--surface-2); cursor: default; user-select: none; min-width: 0;
}
.folder-card .name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.file-card {
  border-radius: 12px; background: var(--surface-2); padding: 0 4px 8px; cursor: default; user-select: none;
  display: flex; flex-direction: column; min-width: 0;
}
.file-card .head { display: flex; align-items: center; gap: 12px; height: 48px; padding-left: 12px; }
.file-card .head .name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .thumb {
  height: 170px; margin: 0 4px; border-radius: 8px; background: var(--surface); display: flex;
  align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.file-card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface); }
.file-card .thumb .material-symbols-outlined { font-size: 72px; }
.file-card .meta { display: flex; align-items: center; gap: 8px; padding: 10px 8px 0; color: var(--text-2); font-size: 12px; }
.folder-card:hover, .file-card:hover { background: #e1e5ea; }
.folder-card.sel, .file-card.sel { background: var(--selected); }
.folder-card.drop-target { background: var(--selected-soft); outline: 2px solid var(--primary); }
.cut { opacity: .5; }

/* list view */
.list { width: 100%; border-collapse: collapse; table-layout: fixed; }
.list th {
  position: sticky; top: 0; background: var(--surface); z-index: 1; text-align: left; font-weight: 500;
  color: var(--text-2); height: 48px; border-bottom: 1px solid var(--border); padding: 0 8px; user-select: none;
}
.list th.sortable { cursor: pointer; }
.list th.sortable:hover { color: var(--text); }
.list td { height: 48px; border-bottom: 1px solid var(--border); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.list tr.row { cursor: default; user-select: none; }
.list tr.row:hover td { background: #f0f4f9; }
.list tr.row.sel td { background: var(--selected); }
.list tr.row.drop-target td { background: var(--selected-soft); }
.list td.name { color: var(--text); font-weight: 500; }
.list td.name .inner { display: flex; align-items: center; gap: 16px; overflow: hidden; }
.list td.name .inner span.txt { overflow: hidden; text-overflow: ellipsis; }
.list .owner { display: inline-flex; align-items: center; gap: 8px; }
.list .actions { text-align: right; }
.list .actions .icon-btn { visibility: hidden; }
.list tr.row:hover .actions .icon-btn, .list tr.row.sel .actions .icon-btn { visibility: visible; }
.badge-icons { display: inline-flex; gap: 4px; color: var(--text-3); }
.badge-icons .material-symbols-outlined { font-size: 16px; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 16px; color: var(--text-2); text-align: center; }
.empty .material-symbols-outlined { font-size: 120px; color: #c4c7c5; margin-bottom: 16px; }
.empty h2 { font-weight: 400; color: var(--text); margin: 0 0 8px; font-size: 22px; }

/* drag & drop upload */
.dropzone {
  position: absolute; inset: 0; border: 2px solid var(--primary); border-radius: var(--radius);
  background: rgba(194, 231, 255, .35); z-index: 20; pointer-events: none;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 40px;
}
.dropzone div { background: var(--primary); color: #fff; padding: 12px 24px; border-radius: 24px; font-weight: 500; display: flex; gap: 8px; align-items: center; }

/* details panel */
.details { width: 340px; border-left: 1px solid var(--border); overflow-y: auto; padding: 8px 16px 24px; flex-shrink: 0; }
.details .dhead { display: flex; align-items: center; gap: 12px; padding: 8px 0 16px; }
.details .dhead .name { flex: 1; font-size: 18px; overflow: hidden; text-overflow: ellipsis; }
.details .preview { height: 180px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 16px; }
.details .preview img { max-width: 100%; max-height: 100%; }
.details .preview .material-symbols-outlined { font-size: 80px; }
.details h3 { font-size: 16px; font-weight: 500; margin: 24px 0 12px; }
.details dl { margin: 0; }
.details dt { font-size: 12px; color: var(--text-2); font-weight: 500; margin-top: 16px; }
.details dd { margin: 4px 0 0; }
.details .access { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- menus ---------- */
.menu {
  position: fixed; z-index: 1000; min-width: 220px; max-width: 320px; padding: 8px 0; border-radius: 8px;
  background: var(--surface); box-shadow: var(--shadow); max-height: calc(100vh - 16px); overflow-y: auto;
}
.menu button, .menu a {
  display: flex; align-items: center; gap: 16px; width: 100%; height: 36px; padding: 0 16px; border: 0;
  background: transparent; cursor: pointer; text-align: left; color: var(--text); text-decoration: none; white-space: nowrap;
}
.menu button:hover, .menu a:hover { background: var(--hover); }
.menu button:disabled { opacity: .4; cursor: default; background: transparent; }
.menu button .material-symbols-outlined { color: var(--text-2); }
.menu button .hint { margin-left: auto; color: var(--text-3); font-size: 12px; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.menu .label { padding: 8px 16px; color: var(--text-2); font-size: 12px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 900; display: flex;
  align-items: center; justify-content: center; padding: 16px; animation: fade .12s;
}
.modal {
  background: var(--surface); border-radius: 28px; box-shadow: var(--shadow); width: 100%; max-width: 420px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { max-width: 560px; }
.modal h2 { margin: 0; padding: 24px 24px 16px; font-size: 22px; font-weight: 400; }
.modal .body { padding: 0 24px; overflow-y: auto; }
.modal .footer { display: flex; justify-content: flex-end; gap: 8px; padding: 20px 24px 20px; }
@keyframes fade { from { opacity: 0; } }

/* share dialog */
.share-add { display: flex; gap: 8px; margin-bottom: 16px; }
.share-add .input { flex: 1; }
.share-add select { width: 150px; flex: 0 0 auto; }
.people { list-style: none; margin: 0 0 16px; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.people .who { flex: 1; min-width: 0; }
.people .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .who .email { color: var(--text-2); font-size: 12px; }
.people select { border: 0; background: transparent; padding: 6px; border-radius: 4px; cursor: pointer; }
.people select:hover { background: var(--hover); }
.people .role { color: var(--text-3); }
.general { display: flex; align-items: center; gap: 12px; padding: 8px 0 4px; }
.general .circle { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.general.on .circle { background: #c4eed0; color: #0d652d; }
.general select { border: 0; background: transparent; font-weight: 500; padding: 4px; border-radius: 4px; cursor: pointer; }
.general .sub { color: var(--text-2); font-size: 12px; padding-left: 4px; }

/* move dialog */
.move-list { border: 1px solid var(--border); border-radius: 8px; height: 300px; overflow-y: auto; }
.move-list .row { display: flex; align-items: center; gap: 12px; padding: 0 12px; height: 40px; cursor: pointer; }
.move-list .row:hover { background: var(--hover); }
.move-list .row.sel { background: var(--selected); }
.move-list .row .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-path { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; min-height: 32px; flex-wrap: wrap; }
.move-path a { cursor: pointer; text-decoration: none; padding: 4px 8px; border-radius: 4px; }
.move-path a:hover { background: var(--hover); }

/* ---------- toast & uploads ---------- */
.toasts { position: fixed; left: 24px; bottom: 24px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #303030; color: #f2f2f2; padding: 14px 16px; border-radius: 4px; min-width: 280px; max-width: 560px;
  display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); animation: fade .15s;
}
.toast button { background: none; border: 0; color: #a8c7fa; font-weight: 500; cursor: pointer; margin-left: auto; }

.uploads {
  position: fixed; right: 24px; bottom: 0; width: 360px; z-index: 800; background: var(--surface);
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow); overflow: hidden;
}
.uploads .uhead { display: flex; align-items: center; gap: 4px; background: var(--surface-2); padding: 4px 8px 4px 20px; height: 54px; font-weight: 500; }
.uploads .uhead span.t { flex: 1; }
.uploads ul { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.uploads li { display: flex; align-items: center; gap: 12px; padding: 10px 20px; }
.uploads li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploads .ring { width: 24px; height: 24px; }

/* ---------- preview ---------- */
.viewer { position: fixed; inset: 0; z-index: 950; background: rgba(0,0,0,.88); display: flex; flex-direction: column; color: #fff; }
.viewer .vhead { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 16px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.viewer .vhead .name { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer .vbody { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 72px 24px; position: relative; }
.viewer .vbody img, .viewer .vbody video { max-width: 100%; max-height: 100%; }
.viewer .vbody iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 4px; }
.viewer .vbody pre { background: #fff; color: #202124; width: 100%; max-width: 960px; height: 100%; overflow: auto; margin: 0; padding: 24px; border-radius: 4px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.viewer .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.4); }
.viewer .nav-btn.prev { left: 16px; }
.viewer .nav-btn.next { right: 16px; }
.viewer .noprev { background: #3c4043; padding: 32px 48px; border-radius: 8px; text-align: center; }
.viewer .noprev .material-symbols-outlined { font-size: 64px; display: block; margin: 0 auto 12px; }

/* ---------- auth page ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 24px; background: var(--surface-2); }
.auth-card { background: var(--surface); border-radius: 28px; padding: 36px 40px; width: 100%; max-width: 960px; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.auth-card h1 { font-size: 36px; font-weight: 400; margin: 16px 0 12px; }
.auth-card p { color: var(--text-2); font-size: 16px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; padding-top: 24px; }
.auth-card .actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.auth-card .error { color: var(--danger); min-height: 20px; }
@media (max-width: 760px) { .auth-card { grid-template-columns: 1fr; padding: 24px; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; top: 64px; left: 0; bottom: 0; width: 280px; background: var(--bg); z-index: 500; box-shadow: var(--shadow); }
  .main { margin: 0 8px 8px; }
  .brand span.t { display: none; }
  .brand { width: auto; }
  .details { position: absolute; right: 0; top: 0; bottom: 0; background: var(--surface); z-index: 5; }
  .list .col-owner, .list .col-size { display: none; }
}
@media (min-width: 901px) { .menu-toggle { display: none !important; } }
