:root {
  color-scheme: dark;
  --bg: #111514;
  --panel: #171d1b;
  --panel-2: #1d2522;
  --line: #2a3631;
  --text: #edf1ef;
  --muted: #98a69f;
  --accent: #557966;
  --accent-2: #6f9b82;
  --danger: #b96a6a;
  --shadow: 0 14px 40px rgba(0,0,0,.25);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }

.shell { min-height: 100vh; }
.topbar {
  height: 66px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(17,21,20,.94);
  position: sticky; top: 0; z-index: 30; backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; border: 1px solid #405249; background: linear-gradient(145deg,#2f4b3c,#18221e); display: grid; place-items: center; color: #b9d2c4; font-weight: 800; }
.brand small { display: block; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-top: 1px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.button, button.button {
  border: 1px solid var(--line); background: var(--panel-2); padding: 9px 13px; border-radius: 9px;
  cursor: pointer; transition: .15s ease; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.button:hover { border-color: #43564d; background: #23302b; }
.button.primary { background: #355443; border-color: #496e5a; }
.button.primary:hover { background: #3e604e; }
.button.danger { color: #efc0c0; border-color: #5b3939; background: #2a1d1d; }
.button.subtle { background: transparent; }

.layout { display: grid; grid-template-columns: 245px minmax(0,1fr); max-width: 1480px; margin: 0 auto; }
.sidebar { min-height: calc(100vh - 66px); border-right: 1px solid var(--line); padding: 26px 18px; }
.sidebar-label { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; margin: 0 10px 9px; }
.folder-nav { display: grid; gap: 3px; }
.folder-link { padding: 9px 10px; border-radius: 8px; color: #ccd5d1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-link:hover, .folder-link.active { background: #202a26; color: white; }
.folder-link.depth-1 { padding-left: 26px; }
.folder-link.depth-2 { padding-left: 42px; }
.folder-link.depth-3 { padding-left: 58px; }

.main { padding: 32px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 27px; letter-spacing: -.025em; }
.page-head p { margin: 0; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumbs { display: flex; gap: 7px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.breadcrumbs a:hover { color: var(--text); }

.upload-zone { border: 1px dashed #405049; border-radius: var(--radius); background: #151b19; padding: 24px; text-align: center; color: var(--muted); margin-bottom: 25px; transition: .15s ease; }
.upload-zone.drag { border-color: var(--accent-2); background: #19221e; color: #dce8e1; }
.upload-zone strong { color: var(--text); }
.upload-zone input { display: none; }
.upload-progress { margin-top: 12px; font-size: 13px; min-height: 18px; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { font-size: 13px; color: #cbd5d0; text-transform: uppercase; letter-spacing: .11em; margin: 0; }
.count { color: var(--muted); font-size: 12px; }

.folder-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(190px,1fr)); gap: 12px; }
.folder-card { border: 1px solid var(--line); border-radius: 11px; background: var(--panel); padding: 15px; min-height: 86px; display: flex; flex-direction: column; justify-content: space-between; }
.folder-card:hover { border-color: #3b4e45; background: #1a221f; }
.folder-card strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-card span { color: var(--muted); font-size: 12px; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 16px; }
.file-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.preview { aspect-ratio: 1/1; background: #0b0e0d; display: grid; place-items: center; overflow: hidden; position: relative; }
.preview img { width: 100%; height: 100%; object-fit: contain; background-image: linear-gradient(45deg,#171b19 25%,transparent 25%),linear-gradient(-45deg,#171b19 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#171b19 75%),linear-gradient(-45deg,transparent 75%,#171b19 75%); background-size: 18px 18px; background-position: 0 0,0 9px,9px -9px,-9px 0px; }
.preview .file-ext { font-size: 22px; color: var(--muted); border: 1px solid var(--line); padding: 11px 13px; border-radius: 10px; text-transform: uppercase; }
.file-info { padding: 13px; }
.file-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.file-meta { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 10px; }
.file-actions { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 11px; }
.file-actions .button { padding: 8px 10px; }

.empty { border: 1px solid var(--line); border-radius: var(--radius); padding: 35px; text-align: center; color: var(--muted); background: var(--panel); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-backdrop.show { display: flex; }
.modal { width: min(440px,100%); border: 1px solid var(--line); border-radius: 14px; background: #171d1b; box-shadow: 0 24px 80px rgba(0,0,0,.48); padding: 22px; }
.modal h3 { margin: 0 0 15px; }
.modal label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.modal input { width: 100%; border: 1px solid var(--line); background: #101513; color: var(--text); padding: 10px 11px; border-radius: 8px; outline: none; }
.modal input:focus { border-color: var(--accent-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(390px,100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 7px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card label { display: grid; gap: 7px; margin: 12px 0; color: #c8d2cd; }
.login-card input { border: 1px solid var(--line); background: #101513; color: var(--text); padding: 11px; border-radius: 9px; }
.login-card .button { width: 100%; margin-top: 8px; }
.error { background: #2a1d1d; border: 1px solid #553434; color: #f0bcbc; padding: 9px 11px; border-radius: 8px; margin-bottom: 12px; }

.toast { position: fixed; right: 24px; bottom: 24px; background: #223029; border: 1px solid #466052; padding: 11px 14px; border-radius: 9px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; z-index: 90; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 800px) {
  .topbar { padding: 0 16px; }
  .layout { display: block; }
  .sidebar { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .folder-nav { display: flex; overflow-x: auto; }
  .folder-link, .folder-link.depth-1, .folder-link.depth-2, .folder-link.depth-3 { padding: 8px 10px; }
  .main { padding: 22px 16px; }
  .page-head { display: block; }
  .head-actions { margin-top: 14px; }
  .file-grid { grid-template-columns: repeat(auto-fill,minmax(165px,1fr)); gap: 10px; }
}
