/* Cloud Storage - app styles */
[hidden] { display: none !important; }

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --line: #e3e7ee;
  --line-2: #d6dce7;
  --text: #131a26;
  --muted: #64708a;
  --accent: #2f6bff;
  --accent-2: #1b4fd8;
  --accent-soft: #e8f0ff;
  --danger: #d8382c;
  --danger-soft: #fdecea;
  --star: #f0b429;
  --sh-1: 0 1px 2px rgba(19, 26, 38, .06), 0 1px 3px rgba(19, 26, 38, .06);
  --sh-2: 0 8px 24px rgba(19, 26, 38, .12), 0 2px 6px rgba(19, 26, 38, .07);
  --radius: 12px;
  --top-h: 56px;
}

:root[data-theme="dark"] {
  --bg: #10141c;
  --surface: #171d28;
  --surface-2: #1e2531;
  --line: #262f3d;
  --line-2: #33405a;
  --text: #e8ecf4;
  --muted: #96a2b8;
  --accent: #5b8cff;
  --accent-2: #7ba3ff;
  --accent-soft: #1c2740;
  --danger: #ff6b5e;
  --danger-soft: #341b1b;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 10px 30px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

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

button, input { font: inherit; color: inherit; }

.i {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- top bar ---------- */
.topbar {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -.01em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-name { white-space: nowrap; }

.search-wrap {
  flex: 1;
  max-width: 620px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap .search-i {
  position: absolute;
  left: 11px;
  color: var(--muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

#search {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  outline: none;
}

#search:focus { border-color: var(--accent); background: var(--surface); }
.search-clear { position: absolute; right: 4px; }

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .5; cursor: default; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: 12.5px;
  letter-spacing: .02em;
  cursor: pointer;
}

.avatar .i { width: 19px; height: 19px; stroke-width: 1.8; }

.acct { position: relative; }

/* ---------- menus ---------- */
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--sh-2);
  padding: 6px;
  z-index: 90;
}

.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-name { font-weight: 600; }
.menu-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.checked::after { content: "\2713"; margin-left: auto; color: var(--accent); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.ctx { position: fixed; top: 0; left: 0; }

/* ---------- layout ---------- */
.shell {
  display: flex;
  height: calc(100% - var(--top-h));
  min-height: 0;
}

.sidebar {
  width: 244px;
  flex: none;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  position: relative;
}

.upload-cta { width: 100%; }
/* Anchored under the Upload button; .menu supplies the surface and shadow. */
.upload-menu { top: 54px; left: 12px; right: 12px; min-width: 0; }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); }
.nav-item.active .i { color: var(--accent-2); }
.nav-item .i { color: var(--muted); width: 19px; height: 19px; }

.tree-wrap { flex: 1; min-height: 0; overflow-y: auto; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 4px 10px; }

.side-tree { display: flex; flex-direction: column; gap: 1px; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
  cursor: pointer;
  padding: 5px 8px 5px 0;
  color: var(--text);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
}

.tree-row:hover { background: var(--surface-2); }
.tree-row.active { background: var(--accent-soft); color: var(--accent-2); }
.tree-row.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-caret { width: 18px; height: 18px; color: var(--muted); flex: none; transition: transform .12s ease; }
.tree-caret.open { transform: rotate(90deg); }
.tree-spacer { width: 18px; flex: none; }
.tree-row .i { width: 17px; height: 17px; color: var(--muted); }

.storage { border-top: 1px solid var(--line); padding-top: 12px; }
.storage-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.meter { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.meter-fill.warn { background: #e5a13a; }
.meter-fill.full { background: var(--danger); }
.storage-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.storage-scope { margin-top: 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.linkish { border: 0; background: transparent; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 0;
  overflow: hidden;
  position: relative;
}

/* ---------- breadcrumbs / tools ---------- */
.crumbs-row { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 19px; font-weight: 650; letter-spacing: -.01em; min-width: 0; }

.crumb {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 3px 6px;
  border-radius: 7px;
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb:hover { background: var(--surface-2); }
.crumb.current { cursor: default; }
.crumb.current:hover { background: transparent; }
.crumb.drop-target { outline: 2px solid var(--accent); }
.crumb-sep { color: var(--muted); font-weight: 400; }

.view-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.filter { position: relative; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 10px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}

.pill:hover { background: var(--surface-2); }
.pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.pill .caret { width: 16px; height: 16px; opacity: .7; }
.filter .menu { min-width: 190px; }

/* ---------- date group headers ---------- */
.group-head {
  padding: 14px 8px 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.rows.grid .group-head { grid-column: 1 / -1; padding-top: 6px; }
.seg { display: flex; background: var(--surface-2); border-radius: 9px; padding: 2px; position: relative; }

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 550;
  font-size: 13px;
}

.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }
.seg-btn .i { width: 18px; height: 18px; }

/* ---------- bars ---------- */
.bulkbar, .trashbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 550;
}

/* Floats over the list so selecting never shifts the rows under the cursor. */
.bulkbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  margin: 0;
  z-index: 50;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--sh-2);
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}

.trashbar { background: var(--surface-2); color: var(--muted); }
.bulk-count { margin-right: 4px; }
.bulkbar .btn, .trashbar .btn { margin-left: 0; }
.trashbar .btn { margin-left: auto; }

/* ---------- list ---------- */
.list-head {
  background: var(--bg);
  display: grid;
  grid-template-columns: 38px 1fr 150px 92px 112px;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 8px;
  margin-top: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.hcell {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}

.hcell:hover { color: var(--text); }
.hcell.sorted::after { content: " \25B4"; }
.hcell.sorted.desc::after { content: " \25BE"; }
.hsize, .hmod { text-align: right; }

.rows { flex: 1; overflow-y: auto; padding-bottom: 80px; min-height: 0; }
/* With no rows the list must not claim half the height, or the empty-state
   upload panel ends up floating below the centre of the page. */
.rows:empty { flex: 0 0 auto; padding: 0; min-height: 0; }

.row {
  display: grid;
  grid-template-columns: 38px 1fr 150px 92px 112px;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}

.row:hover { background: var(--surface-2); }
.row.selected { background: var(--accent-soft); }
.row.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; }
.row.dragging { opacity: .45; }
.row.just-added { animation: flash 1.6s ease; }

@keyframes flash {
  0%, 55% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* Rubber-band selection box (drag on empty list/grid space). */
.marquee {
  position: fixed;
  z-index: 45;
  border: 1px solid var(--accent);
  background: rgba(47, 107, 255, .12);
  border-radius: 2px;
  pointer-events: none;
}

.chk-cell { display: flex; align-items: center; justify-content: center; }
.chk-cell input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

.namecell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fname { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; cursor: pointer; vertical-align: middle; }
.fname:hover { text-decoration: underline; }
.meta-line { display: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.rows.grid .meta-line { display: block; }
.fpath { color: var(--muted); font-size: 12px; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ficon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--surface-2); }
.ficon .i { width: 18px; height: 18px; }
.ficon.folder { background: var(--accent-soft); color: var(--accent); }
.ficon.image { background: #eaf7ee; color: #2e9e57; }
.ficon.video { background: #fdeeea; color: #d1603d; }
.ficon.audio { background: #f2ecfd; color: #7a4fd6; }
.ficon.pdf { background: #fdeaea; color: #cc3b3b; }
.ficon.doc { background: #e9f0fe; color: #3a6fd8; }
.ficon.sheet { background: #e9f7ee; color: #2f8f52; }
.ficon.slide { background: #fdf1e6; color: #cf7a2a; }
.ficon.zip { background: #f4f0e6; color: #97803a; }
.ficon.code { background: #eaf0f6; color: #4b6b8f; }
.ficon.text { background: var(--surface-2); color: var(--muted); }

:root[data-theme="dark"] .ficon.image { background: #16281d; }
:root[data-theme="dark"] .ficon.video { background: #2a1a16; }
:root[data-theme="dark"] .ficon.audio { background: #221a33; }
:root[data-theme="dark"] .ficon.pdf { background: #2c1717; }
:root[data-theme="dark"] .ficon.doc { background: #16203a; }
:root[data-theme="dark"] .ficon.sheet { background: #14261b; }
:root[data-theme="dark"] .ficon.slide { background: #2a2013; }
:root[data-theme="dark"] .ficon.zip { background: #262214; }
:root[data-theme="dark"] .ficon.code { background: #182029; }

.thumb { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }

.namewrap { min-width: 0; flex: 1; }
.name-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.star-btn { border: 0; background: transparent; cursor: pointer; color: var(--line-2); padding: 2px; border-radius: 6px; display: inline-flex; opacity: 0; transition: opacity .1s ease; }
.row:hover .star-btn, .star-btn:focus-visible { opacity: 1; }
.star-btn.on { opacity: 1; }
.star-btn:hover { color: var(--star); }
.star-btn.on { color: var(--star); }
.star-btn.on .i { fill: var(--star); }
.star-btn .i { width: 16px; height: 16px; }

.cell-mod, .cell-size { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.row-menu { display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.quick { display: flex; gap: 2px; opacity: 0; pointer-events: none; transition: opacity .1s ease; }
.row:hover .quick, .row.selected .quick, .quick:focus-within { opacity: 1; pointer-events: auto; }
.quick-btn { width: 30px; height: 30px; }
.quick-btn .i { width: 17px; height: 17px; }
.rows.grid .quick { display: none; }
.rename-input { width: 100%; height: 28px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--accent); background: var(--surface); outline: none; }

/* ---------- grid view ---------- */
.rows.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; align-content: start; padding-top: 12px; }
.rows.grid .row { display: block; padding: 10px; border: 1px solid var(--line); background: var(--surface); position: relative; }
.rows.grid .row:hover { border-color: var(--line-2); box-shadow: var(--sh-1); }
.rows.grid .row.selected { border-color: var(--accent); background: var(--accent-soft); }
.rows.grid .chk-cell { position: absolute; top: 8px; left: 8px; z-index: 2; }
.rows.grid .row-menu { position: absolute; top: 6px; right: 6px; z-index: 2; }
.rows.grid .cell-mod, .rows.grid .cell-size { display: none; }
.rows.grid .cell-size { display: none; }
.rows.grid .namecell { flex-direction: column; align-items: stretch; gap: 8px; min-width: 0; overflow: hidden; }
.rows.grid .namewrap { width: 100%; min-width: 0; }
.rows.grid .name-line { width: 100%; min-width: 0; }
.rows.grid .ficon, .rows.grid .thumb { width: 100%; height: 96px; border-radius: 10px; }
.rows.grid .ficon .i { width: 34px; height: 34px; }
.rows.grid .fname { display: block; max-width: 100%; width: 100%; }
.grid-star { position: absolute; bottom: 10px; right: 8px; }
.list-head.hidden-head { display: none; }

/* ---------- empty / loading ---------- */
.empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); padding: 12px 0 60px; }

.empty-drop {
  width: min(560px, 100%);
  border: 2px dashed var(--line-2);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface);
}

.empty-drop.plain { border: 0; background: transparent; padding-top: 20px; }
.empty-drop.plain .empty-i { stroke: var(--muted); opacity: .8; }
.empty-icon { display: block; }
.empty-i { width: 44px; height: 44px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
.empty-title { font-size: 17px; font-weight: 650; color: var(--text); }
.empty-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.loading { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- details ---------- */
.details { width: 300px; flex: none; border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
.details-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.details-body { padding: 14px; overflow-y: auto; }
.det-preview { width: 100%; height: 150px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 12px; }
.det-preview img { width: 100%; height: 100%; object-fit: cover; }
.det-preview .i { width: 40px; height: 40px; color: var(--muted); }
.det-name { font-weight: 600; word-break: break-word; margin-bottom: 10px; }
.det-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.det-row span:first-child { color: var(--muted); }
.det-row span:last-child { text-align: right; word-break: break-word; }
.det-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- sign-in gate ---------- */
.gate {
  position: fixed;
  inset: var(--top-h) 0 0;
  z-index: 150;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.gate-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--sh-2);
  padding: 34px 32px 28px;
  text-align: center;
}

.gate-mark {
  width: 46px;
  height: 46px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gate-title { font-size: 23px; line-height: 1.25; margin: 14px 0 8px; letter-spacing: -.02em; }
.gate-sub { color: var(--muted); margin: 0 0 20px; }
.gate-btn { width: 100%; height: 42px; }
.gate-note { margin-top: 10px; font-size: 13px; color: var(--muted); }

.gate-list {
  list-style: none;
  margin: 22px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
  text-align: left;
  color: var(--muted);
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate-list li { display: flex; gap: 9px; align-items: flex-start; }
.gate-list li::before { content: "\2713"; color: var(--accent); font-weight: 700; }

/* ---------- dropzone ---------- */
.dropzone { position: fixed; inset: 0; z-index: 120; background: rgba(47, 107, 255, .12); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.dz-inner { background: var(--surface); border: 2px dashed var(--accent); border-radius: 18px; padding: 34px 48px; text-align: center; box-shadow: var(--sh-2); }
.dz-i { width: 46px; height: 46px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dz-title { font-size: 18px; font-weight: 650; margin-top: 8px; }
.dz-sub { color: var(--muted); margin-top: 2px; }

/* ---------- uploads panel ---------- */
.uploads { position: fixed; right: 18px; bottom: 18px; transition: bottom .15s ease, max-height .2s ease; width: 330px; max-height: 46vh; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-2); z-index: 110; display: flex; flex-direction: column; overflow: hidden; }
.uploads-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.uploads-list { overflow-y: auto; padding: 8px; }
/* Finished transfers collapse to the header line before the card disappears. */
.uploads.done { max-height: 46px; }
.uploads.done .uploads-list { overflow: hidden; }
.up-item { padding: 7px 6px; }
.up-top { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.up-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.up-state.err { color: var(--danger); }
.up-state.ok { color: #2e9e57; }
.up-bar { height: 4px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.up-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
.up-fill.done { background: #2e9e57; }
.up-fill.err { background: var(--danger); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(11, 16, 26, .45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border-radius: 14px; box-shadow: var(--sh-2); overflow: hidden; display: flex; flex-direction: column; max-height: 82vh; }
.modal-head { padding: 16px 18px 6px; font-size: 17px; font-weight: 650; }
.modal-body { padding: 6px 18px 12px; overflow-y: auto; }
.modal-foot { padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px; }
.modal p { color: var(--muted); margin: 4px 0 10px; }
.field { width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); outline: none; }
.field:focus { border-color: var(--accent); }
.link-box { display: flex; gap: 8px; margin-top: 8px; }
.link-box .field { font-size: 12px; }

.picker-tree { border: 1px solid var(--line); border-radius: 10px; padding: 6px; max-height: 260px; overflow-y: auto; }
.picker-row { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 7px 8px; border-radius: 8px; cursor: pointer; text-align: left; color: var(--text); }
.picker-row:hover { background: var(--surface-2); }
.picker-row.sel { background: var(--accent-soft); color: var(--accent-2); }
.picker-row .i { width: 17px; height: 17px; color: var(--muted); }
.picker-row.sel .i { color: var(--accent-2); }
.picker-row:disabled { opacity: .4; cursor: default; }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 300; background: #0b0f17; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #eef2f8; background: rgba(255, 255, 255, .04); border-bottom: 1px solid rgba(255, 255, 255, .08); }
.viewer-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.viewer-edit { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); color: #eef2f8; }
.viewer-edit:hover { background: rgba(255, 255, 255, .2); }
.viewer-actions .icon-btn { color: #c8d2e2; }
.viewer-actions .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.viewer-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 20px 24px; min-height: 0; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; background: #fff; }
.viewer-body audio { width: min(560px, 100%); }
.viewer-text { width: min(900px, 100%); height: 100%; overflow: auto; background: var(--surface); color: var(--text); border-radius: 10px; padding: 20px 24px; }
.viewer-text pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.viewer-md h1, .viewer-md h2, .viewer-md h3 { margin: 1em 0 .4em; line-height: 1.25; }
.viewer-md p { color: inherit; }
.viewer-md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 92%; }
.viewer-md pre { background: var(--surface-2); padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.viewer-md table { border-collapse: collapse; width: 100%; font-size: 13px; }
.viewer-md th, .viewer-md td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.viewer-md th { background: var(--surface-2); }
.viewer-note { color: #c8d2e2; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---------- rich document previews ---------- */
.viewer-doc { max-width: 900px; }
.viewer-doc h1, .viewer-doc h2, .viewer-doc h3, .viewer-doc h4 { margin: 1.1em 0 .4em; line-height: 1.25; }
.viewer-doc h1:first-child, .viewer-doc h2:first-child { margin-top: 0; }
.viewer-doc p { margin: .55em 0; color: inherit; }
.viewer-doc ul, .viewer-doc ol { margin: .5em 0 .5em 1.2em; padding: 0; }
.viewer-doc li { margin: .2em 0; }
.viewer-doc blockquote { margin: .6em 0; padding: .2em 0 .2em 12px; border-left: 3px solid var(--line-2); color: var(--muted); }
.viewer-doc img { max-width: 100%; height: auto; border-radius: 6px; margin: .5em 0; }
.viewer-doc u { text-underline-offset: 2px; }

.doc-page { padding: 4px 2px; }
.doc-note { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.doc-empty { color: var(--muted); }

.doc-table, .sheet-table { border-collapse: collapse; width: 100%; font-size: 13px; margin: .6em 0; }
.doc-table td, .doc-table th, .sheet-table td, .sheet-table th {
  border: 1px solid var(--line);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
}
.sheet-table th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
.sheet-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-table .rowhead { background: var(--surface-2); color: var(--muted); text-align: right; font-weight: 500; width: 46px; }
.sheet-pane { overflow-x: auto; }

.sheet-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.sheet-tab {
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.sheet-tab:hover { background: var(--surface-2); color: var(--text); }
.sheet-tab.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }

.slide-card, .pdf-page {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
  background: var(--surface);
}
.slide-num { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.slide-card h2 { margin: 0 0 8px; font-size: 18px; }
.pdf-page p { margin: .3em 0; }
.slide-img { display: block; width: 100%; height: auto; border-radius: 8px; margin-top: 10px; border: 1px solid var(--line); }
.viewer-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #c8d2e2; }
.slow-hint { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; font-size: 13px; }
.slow-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- Word document rendering (mirrors the office-word-editor look) ---------- */
.doc-sheet {
  margin: 0 auto;
  background: #fff;
  color: #202124;
  font-family: Calibri, Carlito, "Segoe UI", system-ui, sans-serif;
  font-size: 11pt;
  line-height: 1.5;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}

.doc-sheet p, .doc-sheet li { margin: 0 0 8pt; color: inherit; }
.doc-sheet .doc-blank { margin: 0 0 8pt; }
.doc-sheet a { color: #0563C1; }
.doc-sheet .doc-tab { display: inline-block; width: 36pt; }

.doc-sheet .ds-Title {
  font-size: 28pt; font-weight: 400; line-height: 1.15;
  margin: 0 0 4pt; border-bottom: 1px solid #4472C4; padding-bottom: 4pt;
}
.doc-sheet .ds-Heading1 { font-size: 16pt; font-weight: 400; color: #2F5496; margin: 16pt 0 4pt; }
.doc-sheet .ds-Heading2 { font-size: 13pt; font-weight: 400; color: #2F5496; margin: 14pt 0 4pt; }
.doc-sheet .ds-Heading3 { font-size: 12pt; font-weight: 400; color: #1F3763; margin: 12pt 0 4pt; }
.doc-sheet .ds-Heading4, .doc-sheet .ds-Heading5, .doc-sheet .ds-Heading6 {
  font-size: 11pt; font-style: italic; color: #2F5496; margin: 10pt 0 4pt;
}
.doc-sheet .ds-Quote {
  margin: 10pt 24pt; font-style: italic; color: #404040;
  border-left: 3px solid #d0d0d0; padding-left: 12pt;
}

.doc-sheet .doc-list { margin: 0 0 8pt 24pt; padding: 0; }
.doc-sheet .doc-list .doc-list { margin-bottom: 0; }
.doc-sheet .doc-list li { margin: 0 0 4pt; }

.doc-sheet .doc-figure { margin: 10pt 0; }
.doc-sheet .doc-figure img { max-width: 100%; height: auto; }

.doc-sheet .doc-table {
  border-collapse: collapse; width: 100%; margin: 10pt 0; font-size: inherit;
}
.doc-sheet .doc-table td, .doc-sheet .doc-table th {
  border: 1px solid #bfbfbf; padding: 4pt 6pt; vertical-align: top; text-align: left;
}
.doc-sheet .doc-table th { background: #f2f2f2; font-weight: 600; }
.doc-sheet .doc-table p:last-child { margin-bottom: 0; }

.doc-sheet .doc-pagebreak { border: 0; border-top: 1px dashed #bbb; margin: 18pt 0; }
.doc-sheet .doc-ins { color: #2E74B5; text-decoration: underline; }
.doc-sheet .doc-del { color: #C00000; text-decoration: line-through; }

.doc-comments {
  max-width: 900px; margin: 16px auto 0; padding: 14px 16px;
  background: var(--surface-2); border-radius: 10px; font-size: 13px;
}
.doc-comments h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.doc-comments p { margin: 4px 0; }

/* the sheet supplies its own paper surface, so the wrapper steps back */
.viewer-text.viewer-paper { background: transparent; padding: 0; box-shadow: none; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 400; align-items: center; }
.toast { background: #11161f; color: #f2f5fa; padding: 10px 16px; border-radius: 10px; box-shadow: var(--sh-2); display: flex; align-items: center; gap: 12px; max-width: 92vw; }
.toast.err { background: var(--danger); }
.toast .t-act { border: 0; background: transparent; color: #8fb4ff; font-weight: 600; cursor: pointer; padding: 0; }
.toast.err .t-act { color: #fff; text-decoration: underline; }

/* ---------- responsive ---------- */
.nav-toggle { display: none; }

@media (max-width: 900px) {
  .details { position: fixed; right: 0; top: var(--top-h); bottom: 0; z-index: 60; box-shadow: var(--sh-2); }
  .list-head, .row { grid-template-columns: 34px 1fr 92px 40px; }
  .cell-mod, .hmod { display: none; }
  .quick { display: none; }
  .brand-name { display: none; }
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: var(--top-h); bottom: 0; z-index: 70; transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--sh-2); }
  .sidebar.open { transform: none; }
  .content { padding: 12px 12px 0; }
  .search-wrap { max-width: none; }
  .uploads { right: 10px; left: 10px; width: auto; max-height: 34vh; }
  #infoBtn { display: none; }

  /* Stack the title above the tools so neither gets squeezed. */
  .list-head, .row { grid-template-columns: 34px 1fr 40px; }
  .cell-size, .hsize { display: none; }
  .meta-line { display: block; }
  .crumbs-row { flex-wrap: wrap; align-items: flex-start; gap: 8px; }
  .crumbs { width: 100%; font-size: 18px; }
  .view-tools { margin-left: 0; width: 100%; justify-content: flex-start; }
  .bulkbar { left: 10px; right: 10px; transform: none; justify-content: center; }
  .bulkbar .btn { flex: 0 0 auto; }
  .bulk-count { width: 100%; text-align: center; margin: 0; }
}

/* ---------- focus visibility ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.row:focus-visible { outline-offset: -2px; }

/* Breadcrumbs collapse from the middle when a path gets deep. */
.crumb.ellipsis { color: var(--muted); padding: 3px 4px; }

/* ---------- Shared Drive (cross-app SkillSafe Drive) ---------- */

.drive-panel { padding: 20px 26px 40px; overflow-y: auto; }
.drive-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.drive-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.drive-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; max-width: 640px; }
.drive-head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.drive-connect { display: flex; justify-content: center; padding: 48px 0; }
.drive-connect-card {
  max-width: 420px; text-align: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 26px; box-shadow: var(--sh-1);
}
.drive-connect-card h2 { font-size: 16px; margin: 0 0 8px; }
.drive-connect-card p { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.drive-connect-err { color: var(--danger); }

.drive-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 14px; }
.drive-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.drive-chip:hover { background: var(--surface-2); }
.drive-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }

.drive-rows { display: flex; flex-direction: column; }
.drive-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.drive-row:last-child { border-bottom: none; }
.drive-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drive-row-name { font-size: 13.5px; font-weight: 550; word-break: break-all; }
.drive-row-sub { color: var(--muted); font-size: 12px; }
.drive-row-acts { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.drive-act { font-size: 12px; padding: 4px 10px; }
.drive-empty { color: var(--muted); font-size: 13px; padding: 28px 0; text-align: center; }
.drive-more { margin: 14px auto 0; display: block; }

.drive-picker {
  position: fixed; inset: 0; background: rgba(10, 14, 22, .45);
  display: flex; align-items: center; justify-content: center; z-index: 60;
}
.drive-picker-card {
  width: min(480px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 64px));
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sh-2); padding: 14px;
}
.drive-picker-head { display: flex; align-items: center; justify-content: space-between; font-weight: 650; font-size: 14px; margin-bottom: 10px; }
.drive-picker-search {
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg);
  color: var(--text); padding: 8px 10px; font-size: 13px; font-family: inherit; margin-bottom: 8px;
}
.drive-picker-list { overflow-y: auto; display: flex; flex-direction: column; }
.drive-pick-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: none; background: none; text-align: left; padding: 8px 6px; font-size: 13px;
  color: var(--text); cursor: pointer; border-radius: 8px; font-family: inherit;
}
.drive-pick-row:hover { background: var(--surface-2); }

@media (max-width: 768px) {
  .drive-panel { padding: 14px 14px 32px; }
  .drive-row { flex-direction: column; align-items: flex-start; }
  .drive-row-acts { justify-content: flex-start; }
}

.drive-group-head {
  font-family: var(--mono, monospace);
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  text-transform: none;
  letter-spacing: .02em;
  padding: 12px 4px 4px;
  border-bottom: 1px solid var(--line);
}

.drive-chip-share { border-style: dashed; color: var(--accent-2); }
