/* ============================================================
   wukotec Filemanager - UI
   ============================================================ */

:root {
  /* WUKOTEC brand -------------------------------------------------- */
  --brand-navy: #152d60;
  --brand-mid: #12464c;
  --brand-green: #165345;
  --brand-lime: #73c01e;
  --brand-gradient: linear-gradient(100deg, var(--brand-navy) 0%, var(--brand-mid) 55%, var(--brand-green) 100%);

  /* Surfaces ------------------------------------------------------- */
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eceff5;
  --border: #e2e7f0;
  --border-strong: #ccd3e0;

  /* Text ----------------------------------------------------------- */
  --text: #0b1840;
  --text-dim: #5a648a;
  --text-mute: #7882a3;

  /* Interaction ---------------------------------------------------- */
  --accent: #1c6ef6;
  --accent-hover: #1558d0;
  --accent-soft: #e8f0ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fdeceb;
  --ok: #16a34a;
  --warn: #b45309;

  --shadow-sm: 0 1px 2px rgba(11, 24, 64, .06);
  --shadow: 0 6px 20px rgba(11, 24, 64, .10);
  --shadow-lg: 0 24px 56px rgba(11, 24, 64, .24);
  --radius: 12px;
  --radius-sm: 8px;
  --row-h: 42px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1020;
    --surface: #111a2e;
    --surface-2: #16203a;
    --surface-3: #1e2a45;
    --border: #253150;
    --border-strong: #35436a;
    --text: #e8ecf5;
    --text-dim: #a3adc7;
    --text-mute: #7682a0;
    --accent: #5b96ff;
    --accent-hover: #7aabff;
    --accent-soft: #16264a;
    --danger: #ef5350;
    --danger-hover: #f66c69;
    --danger-soft: #3a1b1d;
    --ok: #3ecf7f;
    --warn: #e0a23c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow: 0 6px 20px rgba(0, 0, 0, .5);
    --shadow-lg: 0 24px 56px rgba(0, 0, 0, .62);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a1020;
  --surface: #111a2e;
  --surface-2: #16203a;
  --surface-3: #1e2a45;
  --border: #253150;
  --border-strong: #35436a;
  --text: #e8ecf5;
  --text-dim: #a3adc7;
  --text-mute: #7682a0;
  --accent: #5b96ff;
  --accent-hover: #7aabff;
  --accent-soft: #16264a;
  --danger: #ef5350;
  --danger-hover: #f66c69;
  --danger-soft: #3a1b1d;
  --ok: #3ecf7f;
  --warn: #e0a23c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 6px 20px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, .62);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--text-dim); }
.spacer { flex: 1; }
img { max-width: 100%; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-mute); }

/* ---------------------------- buttons ---------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font: inherit; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-block { width: 100%; justify-content: center; }

/* Hover rules come last and all carry the same specificity, so a variant
   always wins over the neutral default instead of falling back to grey. */
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-strong); }
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover); border-color: var(--accent-hover); color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover); border-color: var(--danger-hover); color: #fff;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; color: var(--text); }
/* Keep the divider inside a split button visible while hovering. */
.split .btn:hover:not(:disabled) { border-left-color: rgba(255, 255, 255, .28); }
.split .btn:first-child:hover:not(:disabled) { border-left-color: var(--accent-hover); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid transparent;
  background: transparent; color: var(--text-dim);
  border-radius: var(--radius-sm);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }

.split { display: inline-flex; }
.split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; border-left-color: rgba(255,255,255,.28); }

select, input[type="text"], input[type="password"], input[type="search"], input[type="number"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}
select:focus-visible, input:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}


/* ------------------------------ icons ---------------------------- */

.ico { display: block; flex: 0 0 auto; }
.btn .ico, .ctx-item .ico { margin-right: -1px; }
.btn > span[data-icon], .ctx-icon { display: inline-flex; align-items: center; }
.icon-btn > svg { pointer-events: none; }
.caret { display: inline-flex; align-items: center; color: var(--text-mute); }

/* Colour-coded file kinds, using the portal's tile palette. */
:root {
  --ic-dir: #f0a413;
  --ic-image: #16a34a;
  --ic-video: #7076f4;
  --ic-audio: #f05ca7;
  --ic-archive: #c2740a;
  --ic-pdf: #dc2626;
  --ic-code: #1c6ef6;
  --ic-style: #a855f7;
  --ic-html: #ea580c;
  --ic-data: #12a99a;
  --ic-text: #7882a3;
  --ic-font: #7076f4;
  --ic-exe: #5a648a;
  --ic-lock: #b98600;
  --ic-db: #0f766e;
  --ic-file: #98a2b8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ic-dir: #f5bd4a;
    --ic-image: #4ade80;
    --ic-video: #9ba3ff;
    --ic-audio: #f77fbd;
    --ic-archive: #e0a355;
    --ic-pdf: #f87171;
    --ic-code: #6ba4ff;
    --ic-style: #c98cfb;
    --ic-html: #fb923c;
    --ic-data: #2dd4bf;
    --ic-text: #94a3b8;
    --ic-font: #9ba3ff;
    --ic-exe: #8b96b5;
    --ic-lock: #e3bb4d;
    --ic-db: #2dd4bf;
    --ic-file: #8b96b5;
  }
}
:root[data-theme="dark"] {
  --ic-dir: #f5bd4a;
  --ic-image: #4ade80;
  --ic-video: #9ba3ff;
  --ic-audio: #f77fbd;
  --ic-archive: #e0a355;
  --ic-pdf: #f87171;
  --ic-code: #6ba4ff;
  --ic-style: #c98cfb;
  --ic-html: #fb923c;
  --ic-data: #2dd4bf;
  --ic-text: #94a3b8;
  --ic-font: #9ba3ff;
  --ic-exe: #8b96b5;
  --ic-lock: #e3bb4d;
  --ic-db: #2dd4bf;
  --ic-file: #8b96b5;
}

.ico-dir { color: var(--ic-dir); }
.ico-image { color: var(--ic-image); }
.ico-video { color: var(--ic-video); }
.ico-audio { color: var(--ic-audio); }
.ico-archive { color: var(--ic-archive); }
.ico-pdf { color: var(--ic-pdf); }
.ico-code { color: var(--ic-code); }
.ico-style { color: var(--ic-style); }
.ico-html { color: var(--ic-html); }
.ico-data { color: var(--ic-data); }
.ico-text { color: var(--ic-text); }
.ico-font { color: var(--ic-font); }
.ico-exe { color: var(--ic-exe); }
.ico-lock { color: var(--ic-lock); }
.ico-db { color: var(--ic-db); }
.ico-file { color: var(--ic-file); }

/* ----------------------------- login ----------------------------- */

.login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: var(--brand-gradient);
  position: relative; overflow: hidden;
}
/* Soft light bloom, echoing the portal's photographic header. */
.login-view::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(900px 500px at 82% 12%, rgba(115, 192, 30, .20), transparent 62%),
    radial-gradient(700px 420px at 12% 88%, rgba(28, 110, 246, .22), transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: 100%; max-width: 408px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 32px 30px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-brand { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.login-brand .logo { height: 24px; width: auto; margin-bottom: 12px; }
.login-brand h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.login-brand p { margin: 0; font-size: 13px; }

/* Show the logo variant that suits the card background. */
.logo-on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block; }
}
:root[data-theme="dark"] .logo-on-light { display: none; }
:root[data-theme="dark"] .logo-on-dark { display: block; }
:root[data-theme="light"] .logo-on-light { display: block; }
:root[data-theme="light"] .logo-on-dark { display: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: .01em; }
.field input { width: 100%; padding: 11px 12px; }
.pw-wrap { position: relative; display: block; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--text-dim);
  font: inherit; font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }
.login-error {
  margin: 0; padding: 9px 12px;
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm); font-size: 13px;
}
.login-card .btn-primary { padding: 11px; font-size: 15px; margin-top: 2px; }
.login-note { margin: 0; font-size: 11.5px; line-height: 1.5; }

/* ------------------------------ app ------------------------------ */

.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  height: 58px; flex: 0 0 58px;
  padding: 0 14px;
  background: var(--brand-gradient);
  color: #fff;
  padding-top: env(safe-area-inset-top, 0px);
  box-shadow: 0 1px 0 rgba(11, 24, 64, .18);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo { height: 19px; width: auto; display: block; }
.brand-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .28); flex: 0 0 1px; }
.brand-name {
  white-space: nowrap; font-weight: 500; font-size: 14.5px;
  color: rgba(255, 255, 255, .92); letter-spacing: .01em;
}

/* Controls sitting on the dark header need their own light treatment. */
.topbar .icon-btn { color: rgba(255, 255, 255, .78); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; border-color: transparent; }
.topbar .icon-btn:focus-visible, .topbar .user-btn:focus-visible, .topbar input:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .85); outline-offset: 1px;
}

.search-wrap { flex: 1; max-width: 460px; margin-left: auto; position: relative; display: flex; align-items: center; }
.search-wrap input {
  width: 100%; padding-left: 32px; padding-right: 34px;
  background: rgba(255, 255, 255, .13);
  border-color: rgba(255, 255, 255, .22);
  color: #fff;
}
.search-wrap input::placeholder { color: rgba(255, 255, 255, .6); }
.search-wrap input:hover { background: rgba(255, 255, 255, .18); }
.search-ico {
  position: absolute; left: 9px; display: flex; align-items: center;
  color: rgba(255, 255, 255, .65); pointer-events: none;
}
.search-wrap .icon-btn { position: absolute; right: 2px; width: 28px; height: 28px; }
.topbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid transparent; color: #fff;
  font: inherit; cursor: pointer; padding: 4px 8px 4px 5px; border-radius: 999px;
}
.user-btn:hover { background: rgba(255, 255, 255, .14); border-color: transparent; }
.user-btn .caret { color: rgba(255, 255, 255, .7); }
.avatar {
  width: 27px; height: 27px; border-radius: 8px;
  background: var(--brand-lime); color: #0b2b04;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 246px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px; overflow: hidden; color: var(--text);
}
.dropdown-head { padding: 9px 10px 11px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.dropdown-head .mono { word-break: break-all; font-size: 11px; }
.dropdown-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: transparent; color: var(--text);
  font: inherit; cursor: pointer; border-radius: var(--radius-sm);
}
.dropdown-item:hover { background: var(--surface-3); }
.dropdown-item.danger { color: var(--danger); }

.body { display: flex; flex: 1; min-height: 0; background: var(--bg); }

/* ---------------------------- sidebar ---------------------------- */

.sidebar {
  width: 250px; flex: 0 0 250px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-section { flex: 1; overflow: auto; padding: 10px 8px; min-height: 0; }
.sidebar-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mute); font-weight: 700; padding: 4px 8px 9px;
}
.sidebar-foot { padding: 8px; border-top: 1px solid var(--border); }

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 13px; border-left: 1px solid var(--border); padding-left: 4px; }
.tree-row {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 6px; border-radius: var(--radius-sm);
  cursor: pointer; user-select: none; font-size: 13.5px;
  white-space: nowrap;
}
.tree-row:hover { background: var(--surface-3); }
.tree-row.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-row.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.tree-caret {
  width: 16px; height: 16px; flex: 0 0 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mute);
  transition: transform .12s;
}
.tree-caret.open { transform: rotate(90deg); }
.tree-caret.leaf { visibility: hidden; }
.tree-label { overflow: hidden; text-overflow: ellipsis; }

/* ----------------------------- main ------------------------------ */

.main {
  flex: 1; display: flex; flex-direction: column; gap: 11px;
  min-width: 0; min-height: 0; position: relative;
  padding: 12px 13px 13px;
}

/* Listing, selection bar and status line read as one card, like the
   portal's content panels. */
.panel {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-actions { margin-left: auto; gap: 6px; flex-wrap: wrap; }

.breadcrumb {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  min-width: 0; font-size: 13.5px;
}
.crumb {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 0; color: var(--text-dim);
  font: inherit; cursor: pointer; padding: 4px 7px; border-radius: var(--radius-sm);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb:hover { background: var(--surface-3); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb.drop-target { outline: 2px dashed var(--accent); background: var(--accent-soft); }
.crumb-sep { color: var(--text-mute); }

.selbar, .clipbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.clipbar { background: var(--surface-2); }
.selbar-count { font-weight: 600; margin-right: 6px; }

/* ---------------------------- listing ---------------------------- */

.listing { flex: 1; overflow: auto; min-height: 0; outline: none; position: relative; }

.rows { display: block; }
.row-head, .row {
  display: grid;
  grid-template-columns: 34px 28px minmax(0, 1fr) 110px 170px 120px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: var(--row-h);
}
.row-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .07em;
  min-height: 36px;
}
.row-head button {
  display: inline-flex; align-items: center; gap: 3px;
  background: transparent; border: 0; color: inherit; font: inherit; font-weight: 700;
  cursor: pointer; padding: 4px 2px; text-align: left; border-radius: 5px;
}
.row-head .sort-ind { color: var(--accent); }
.row-head .sort-ind.sort-asc { transform: rotate(180deg); }
.row-head button:hover { color: var(--text); }
.row {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  cursor: default; user-select: none;
}
.row:hover { background: var(--surface-2); }
.row.selected { background: var(--accent-soft); }
.row.cut { opacity: .5; }
.row.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.row.dragging { opacity: .4; }

.cell-check { display: grid; place-items: center; }
.cell-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.cell-icon { display: flex; align-items: center; justify-content: center; }
.cell-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.name-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.name-text:hover { text-decoration: underline; }
.row.is-dir .name-text { font-weight: 550; }
.badge {
  font-size: 10px; padding: 1px 5px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-dim); flex: 0 0 auto;
}
.cell-size, .cell-mtime, .cell-perm { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }
.cell-size { text-align: right; font-family: var(--mono); }
.cell-perm { font-family: var(--mono); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn { width: 26px; height: 26px; opacity: 0; }
.row:hover .row-actions .icon-btn, .row.selected .row-actions .icon-btn { opacity: 1; }

/* grid view */
.listing.grid-view .row-head { display: none; }
.listing.grid-view .rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; padding: 12px;
}
.listing.grid-view .row {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; padding: 15px 8px; min-height: 122px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2);
  transition: border-color .12s, box-shadow .12s;
}
.listing.grid-view .row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.listing.grid-view .cell-icon { padding: 4px 0 2px; }
.listing.grid-view .cell-name { justify-content: center; }
.listing.grid-view .name-text { white-space: normal; word-break: break-word; max-height: 2.9em; overflow: hidden; }
.listing.grid-view .cell-mtime, .listing.grid-view .cell-perm, .listing.grid-view .row-actions { display: none; }
.listing.grid-view .cell-check { position: absolute; }
.listing.grid-view .row { position: relative; }
.listing.grid-view .cell-check { top: 6px; left: 8px; }
.listing.grid-view .cell-size { text-align: center; }

.empty {
  display: grid; place-items: center; gap: 6px;
  padding: 60px 20px; color: var(--text-dim); text-align: center;
}
.empty strong { color: var(--text); font-size: 15px; }

.statusbar {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 13px; flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim); font-size: 12.5px;
}

/* --------------------------- dropzone ---------------------------- */

.dropzone-overlay {
  position: absolute; inset: 12px 13px 13px; z-index: 40;
  border-radius: var(--radius);
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  backdrop-filter: blur(1.5px);
  pointer-events: none;
}
.dropzone-inner {
  background: var(--surface);
  border: 2.5px dashed var(--accent);
  border-radius: 16px;
  padding: 30px 46px;
  text-align: center;
  box-shadow: var(--shadow);
}
.dz-icon { color: var(--accent); display: flex; justify-content: center; }
.dz-title { font-size: 16px; font-weight: 600; margin-top: 6px; }
.dz-sub { color: var(--text-dim); margin-top: 4px; }

/* ---------------------------- uploads ---------------------------- */

.uploads {
  position: fixed; right: 16px; bottom: 16px; z-index: 70;
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.uploads-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.uploads-head strong { flex: 1; font-size: 13.5px; }
.uploads-head-actions { display: flex; gap: 2px; }
.uploads-total { padding: 10px 12px 6px; display: flex; flex-direction: column; gap: 5px; }
.uploads-total-text { color: var(--text-dim); font-size: 11.5px; }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .15s linear; }
.bar-fill.error { background: var(--danger); }
.bar-fill.done { background: var(--ok); }
.uploads-list { list-style: none; margin: 0; padding: 0 0 4px; max-height: 260px; overflow: auto; }
.uploads.collapsed .uploads-list, .uploads.collapsed .uploads-foot { display: none; }
.up-item { padding: 6px 12px; display: flex; flex-direction: column; gap: 4px; }
.up-item-top { display: flex; align-items: center; gap: 8px; }
.up-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.up-state { font-size: 11px; color: var(--text-dim); font-family: var(--mono); white-space: nowrap; }
.up-item.error .up-state { color: var(--danger); }
.up-item.done .up-state { color: var(--ok); }
.up-cancel {
  border: 0; background: transparent; color: var(--text-mute); cursor: pointer;
  padding: 0 2px; display: inline-flex; align-items: center;
}
.up-cancel:hover { color: var(--danger); }
.uploads-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.uploads-foot .inline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; flex: 1; }
.uploads-foot select { padding: 3px 6px; font-size: 12.5px; }

/* -------------------------- context menu ------------------------- */

.context-menu {
  position: fixed; z-index: 90; min-width: 212px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 5px; font-size: 13.5px;
}
.ctx-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 10px; border: 0; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius-sm);
}
.ctx-item:hover:not(:disabled) { background: var(--surface-3); }
.ctx-item:disabled { opacity: .4; cursor: not-allowed; }
.ctx-item .ctx-icon { width: 17px; flex: 0 0 17px; justify-content: center; color: var(--text-dim); }
.ctx-item .ctx-key { margin-left: auto; color: var(--text-mute); font-size: 11px; font-family: var(--mono); }
.ctx-item.danger, .ctx-item.danger .ctx-icon { color: var(--danger); }
.ctx-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ----------------------------- modals ---------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 13, 18, .55);
  display: grid; place-items: center;
  padding: 20px;
  overflow: auto;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 40px);
}
.modal.wide { max-width: 1100px; }
.modal.full { max-width: min(1400px, 100%); height: calc(100vh - 40px); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px; overflow: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.modal-body.tight { gap: 10px; }
.modal-body.flush { padding: 0; }
.modal-foot {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 0 13px 13px;
  flex-wrap: wrap;
}
.modal-foot .spacer { flex: 1; }
.modal-msg { margin: 0; line-height: 1.55; }
.modal-msg strong { word-break: break-all; }
.modal-list {
  margin: 0; padding: 8px 12px; max-height: 190px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 12px; list-style: none;
}
.modal-list li { padding: 1px 0; word-break: break-all; }

.props { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.props dt { color: var(--text-dim); }
.props dd { margin: 0; word-break: break-all; font-family: var(--mono); font-size: 12.5px; }

/* permission matrix */
.perm-grid { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 6px 10px; align-items: center; }
.perm-grid .ph { font-size: 12px; color: var(--text-dim); font-weight: 600; text-align: center; }
.perm-grid .pl { font-size: 13px; color: var(--text-dim); }
.perm-grid label { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12.5px; }
.perm-grid input { accent-color: var(--accent); }
.perm-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.perm-octal { width: 88px; font-family: var(--mono); text-align: center; font-size: 15px; letter-spacing: .08em; }
.perm-presets { display: flex; gap: 5px; flex-wrap: wrap; }
.check-inline { display: flex; align-items: center; gap: 7px; font-size: 13.5px; }

/* ----------------------------- editor ---------------------------- */

.editor-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  font-size: 12.5px;
}
.editor-bar select, .editor-bar input[type="number"] { padding: 3px 7px; font-size: 12.5px; }
.editor-bar .dirty-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); flex: 0 0 8px;
}
.editor-host { flex: 1; min-height: 0; position: relative; }
.CodeMirror { height: 100% !important; font-family: var(--mono); font-size: 13px; }
.editor-host textarea.fallback {
  width: 100%; height: 100%; border: 0; resize: none; padding: 12px;
  font-family: var(--mono); font-size: 13px; background: var(--surface); color: var(--text);
}

/* ---------------------------- preview ---------------------------- */

.preview-host {
  display: grid; place-items: center;
  background: var(--surface-3);
  min-height: 300px; flex: 1; padding: 12px; overflow: auto;
}
.preview-host img, .preview-host video { max-width: 100%; max-height: calc(100vh - 220px); border-radius: 6px; background: #fff; }
.preview-host iframe { width: 100%; height: calc(100vh - 210px); border: 0; background: #fff; border-radius: 6px; }
.preview-host audio { width: min(560px, 100%); }
.preview-text {
  width: 100%; margin: 0; padding: 14px;
  background: var(--surface); border-radius: 6px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: calc(100vh - 220px); overflow: auto; align-self: stretch;
}

/* ----------------------------- toasts ---------------------------- */

.toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
  width: min(560px, calc(100vw - 32px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 13px; font-size: 13.5px; max-width: 100%;
  animation: toast-in .16s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast-icon { display: flex; align-items: center; color: var(--accent); flex: 0 0 auto; padding-top: 1px; }
.toast.error .toast-icon { color: var(--danger); }
.toast.success .toast-icon { color: var(--ok); }
.toast.warn .toast-icon { color: var(--warn); }
.toast-text { flex: 1; min-width: 0; word-break: break-word; }
.toast-close {
  border: 0; background: transparent; color: var(--text-mute); cursor: pointer;
  display: inline-flex; align-items: center; padding: 2px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* search results header */
.result-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.result-head .path { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.cell-name .sub-path {
  font-size: 11px; color: var(--text-mute); font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%;
}

/* shortcuts table */
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; }
.keys kbd {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; white-space: nowrap;
}

/* --------------------------- responsive -------------------------- */

.only-mobile { display: none; }

@media (max-width: 960px) {
  .row-head, .row { grid-template-columns: 34px 28px minmax(0, 1fr) 90px 120px; }
  .cell-perm { display: none; }
  .row-head .h-perm { display: none; }
  .search-wrap { max-width: 220px; }
}

@media (max-width: 760px) {
  .only-mobile { display: inline-flex; }
  .brand-name, .hide-narrow { display: none; }
  .sidebar {
    position: fixed; left: 0; top: 58px; bottom: 0; z-index: 80;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .row-head, .row { grid-template-columns: 34px 26px minmax(0, 1fr) 78px; }
  .cell-mtime, .row-head .h-mtime, .row-actions { display: none; }
  .tb-actions { width: 100%; margin-left: 0; }
  .breadcrumb { order: 3; width: 100%; }
  .uploads { right: 8px; left: 8px; width: auto; }
  .main { padding: 9px; gap: 9px; }
  .dropzone-overlay { inset: 9px; }
  .modal-foot { justify-content: stretch; }
  .modal-foot .btn { flex: 1; justify-content: center; }
}
