/* Значения цветов, шрифтов и отступов сняты с Google Диска (Material 3) */
:root {
  --bg: #f8fafd;
  --surface: #ffffff;
  --text: #1f1f1f;
  --text-2: #444746;
  --outline: #747775;
  --divider: #c7c7c7;
  --primary: #0b57d0;
  --primary-container: #c2e7ff;
  --on-primary-container: #004a77;
  --selected-text: #001d35;
  --search-bg: #e9eef6;
  --card-bg: #f0f4f9;
  --card-hover: #e1e5ea;
  --state-hover: rgba(68, 71, 70, .08);
  --state-press: rgba(68, 71, 70, .12);
  --inverse: #303030;
  --inverse-text: #f2f2f2;
  --inverse-primary: #a8c7fa;
  --danger: #b3261e;
  --on-primary: #ffffff;
  --primary-hover: rgba(11, 87, 208, .08);
  --primary-press: rgba(11, 87, 208, .12);
  --search-focus: #ffffff;
  --search-focus-shadow: 0 1px 1px 0 rgba(65, 69, 73, .3), 0 1px 3px 1px rgba(65, 69, 73, .15);
  --create-bg: #ffffff;
  --create-hover: #edf2fa;
  --create-press: #e1e8f3;
  --create-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --create-shadow-hover: 0 1px 3px 0 rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --track: #e1e3e1;
  --chip-hover: #f2f2f2;
  --menu-bg: #ffffff;
  --sep: #e3e3e3;
  --panel-bg: #ffffff;
  --panel-head: #f8fafd;
  --dialog-bg: #ffffff;
  --inverse-hover: rgba(242, 242, 242, .08);
  --icon-gray: #5f6368;
  --success-icon: #1e8e3e;
  --thumb-bg: #e9eef6;

  --font: "Google Sans Text", "Google Sans", Roboto, Arial, sans-serif;
  --font-display: "Google Sans", Roboto, Arial, sans-serif;

  --shadow-1: 0 1px 2px 0 rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
  --shadow-2: 0 1px 2px 0 rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
  --shadow-3: 0 4px 8px 3px rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .3);
  --ease: cubic-bezier(.2, 0, 0, 1);

  --sidebar-w: 256px;
  --header-h: 64px;
  color-scheme: light;
}

/* Тёмная тема: палитра Google Диска (gm3-sys-color, dark) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1b1b;
  --surface: #131314;
  --text: #e3e3e3;
  --text-2: #c4c7c5;
  --outline: #8e918f;
  --divider: #444746;
  --primary: #a8c7fa;
  --on-primary: #062e6f;
  --primary-container: #004a77;
  --on-primary-container: #c2e7ff;
  --selected-text: #c2e7ff;
  --search-bg: #282a2c;
  --search-focus: #333537;
  --search-focus-shadow: 0 1px 3px 1px rgba(0, 0, 0, .3), 0 1px 2px 0 rgba(0, 0, 0, .3);
  --card-bg: #1e1f20;
  --card-hover: #282a2c;
  --state-hover: rgba(227, 227, 227, .08);
  --state-press: rgba(227, 227, 227, .12);
  --inverse: #e3e3e3;
  --inverse-text: #303030;
  --inverse-primary: #0b57d0;
  --inverse-hover: rgba(48, 48, 48, .08);
  --danger: #f2b8b5;
  --primary-hover: rgba(168, 199, 250, .08);
  --primary-press: rgba(168, 199, 250, .12);
  --create-bg: #37393b;
  --create-hover: #3d4043;
  --create-press: #45474a;
  --create-shadow: 0 1px 2px 0 rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
  --create-shadow-hover: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 4px 8px 3px rgba(0, 0, 0, .15);
  --track: #444746;
  --chip-hover: #232425;
  --menu-bg: #282a2c;
  --sep: #444746;
  --panel-bg: #1e1f20;
  --panel-head: #282a2c;
  --dialog-bg: #282a2c;
  --icon-gray: #c4c7c5;
  --success-icon: #6dd58c;
  --thumb-bg: #282a2c;
  --shadow-2: 0 1px 2px 0 rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
  --shadow-3: 0 4px 8px 3px rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .3);
}
[data-theme="dark"] .empty-art { opacity: .8; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.ms {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
  flex-shrink: 0;
}
.ms.fill { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

/* ---------- кнопки-иконки ---------- */
.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
  transition: background-color .15s var(--ease);
}
.icon-btn:hover { background: var(--state-hover); }
.icon-btn:active { background: var(--state-press); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.text-btn {
  height: 40px; padding: 0 12px;
  border-radius: 20px;
  color: var(--primary);
  font: 500 14px/20px var(--font);
  transition: background-color .15s var(--ease);
}
.text-btn:hover { background: var(--primary-hover); }
.text-btn:active { background: var(--primary-press); }

/* ---------- шапка ---------- */
.topbar {
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 8px;
  background: var(--bg);
}
.menu-btn { display: none; margin-right: 4px; }
.brand {
  display: flex; align-items: center;
  width: calc(var(--sidebar-w) - 8px);
  padding-left: 8px;
  flex-shrink: 0;
}
.brand img { display: block; }
.brand-text {
  padding-left: 8px;
  font: 400 22px/48px var(--font-display);
  color: var(--text);
  white-space: nowrap;
}
.search {
  flex: 0 1 722px;
  min-width: 0;
  height: 48px;
  display: flex; align-items: center;
  background: var(--search-bg);
  border: 1px solid transparent;
  border-radius: 24px;
  padding: 0 4px 0 16px;
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease);
}
.search:focus-within {
  background: var(--search-focus);
  box-shadow: var(--search-focus-shadow);
}
.search-icon { color: var(--text-2); margin-right: 16px; }
.search input {
  flex: 1; min-width: 0;
  height: 100%;
  border: 0; outline: 0; background: transparent;
  font: 400 16px/20px var(--font-display);
  color: var(--text);
}
.search input::placeholder { color: var(--text-2); }
.search-clear { visibility: hidden; }
.search.has-value .search-clear { visibility: visible; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; padding-right: 8px; }

/* ---------- раскладка ---------- */
.layout {
  display: flex;
  height: calc(100% - var(--header-h));
}

/* ---------- боковое меню ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow-y: auto;
}
.drawer-brand { display: none; }
.create-wrap { padding: 8px 16px 16px; }
.create-btn {
  height: 56px;
  display: inline-flex; align-items: center; gap: 12px;
  padding: 18px 20px 18px 16px;
  border-radius: 16px;
  background: var(--create-bg);
  color: var(--text);
  font: 500 14px/20px var(--font);
  box-shadow: var(--create-shadow);
  transition: box-shadow .28s var(--ease), background-color .15s var(--ease);
}
.create-btn:hover { background: var(--create-hover); box-shadow: var(--create-shadow-hover); }
.create-btn:active { background: var(--create-press); }
.create-btn .ms { font-size: 24px; color: var(--text); }

.nav { list-style: none; margin: 0; padding: 0 16px 0 16px; }
.nav-gap { height: 16px; }
.nav-item {
  height: 32px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 12px 0 18px;
  border-radius: 100px;
  color: var(--text);
  font: 400 14px/20px var(--font);
  white-space: nowrap;
  transition: background-color .15s var(--ease);
}
.nav-item .ms { font-size: 20px; }
.nav-item:hover { background: var(--state-hover); }
.nav-item.active { background: var(--primary-container); color: var(--on-primary-container); font-weight: 500; }
.nav-item.active .ms { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 20; }

.storage { padding: 8px 16px 16px 34px; margin-right: 16px; }
.storage-bar {
  height: 4px; border-radius: 2px;
  background: var(--track);
  overflow: hidden;
  margin: 4px 0 8px;
}
.storage-fill { height: 100%; width: 0; background: var(--primary); border-radius: 2px; transition: width .4s var(--ease); }
.storage-text { color: var(--text-2); font-size: 14px; line-height: 20px; }
.storage-note {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 16px;
  color: var(--text-2);
  font-size: 12px; line-height: 16px;
}
.storage-note .ms { font-size: 18px; color: var(--primary); }

/* ---------- основная область ---------- */
.main {
  position: relative;
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  margin: 0 16px 16px 0;
  overflow: hidden;
}
.main-head {
  display: flex; align-items: center;
  padding: 14px 16px 6px 4px;
  min-height: 64px;
}
.title-btn {
  display: inline-flex; align-items: center;
  height: 40px;
  padding: 4px 12px 4px 16px;
  margin: 2px 0 2px 4px;
  border-radius: 100px;
  transition: background-color .15s var(--ease);
  min-width: 0;
}
.title-btn:hover { background: var(--state-hover); }
.title-btn h1 {
  margin: 0;
  font: 400 24px/32px var(--font-display);
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.title-btn .ms { margin-left: 4px; color: var(--text); }

.view-toggle {
  margin-left: auto;
  display: flex;
  border: 1px solid var(--outline);
  border-radius: 100px;
  overflow: hidden;
  height: 32px;
}
.vt-btn {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 100%;
  color: var(--text-2);
  transition: background-color .15s var(--ease), width .2s var(--ease);
}
.vt-btn + .vt-btn { border-left: 1px solid var(--outline); }
.vt-btn .ms { font-size: 18px; }
.vt-btn .vt-check { width: 0; overflow: hidden; transition: width .2s var(--ease); }
.vt-btn:hover { background: var(--state-hover); }
.vt-btn.active { background: var(--primary-container); color: var(--selected-text); }
.vt-btn.active .vt-check { width: 18px; }

.toolbar { padding: 0 16px 0 16px; min-height: 48px; display: flex; align-items: center; }
.chips { display: flex; flex-wrap: wrap; align-items: center; }
.chip {
  height: 32px;
  display: inline-flex; align-items: center;
  padding: 0 4px 0 12px;
  margin: 4px 8px 4px 4px;
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  font: 500 14px/16px var(--font);
  white-space: nowrap;
  transition: background-color .15s var(--ease);
}
.chip:hover { background: var(--chip-hover); }
.chip .ms { font-size: 18px; margin-left: 4px; }
.chip.on { background: var(--primary-container); border-color: transparent; color: var(--selected-text); padding-left: 8px; }
.chip.on::before {
  content: "check";
  font-family: "Material Symbols Outlined"; font-size: 18px; margin-right: 6px;
}

.selbar {
  display: flex; align-items: center; gap: 4px;
  height: 40px;
  margin: 4px 4px;
  padding: 0 4px;
  border-radius: 100px;
  background: var(--search-bg);
  animation: fade-in .15s var(--ease);
}
.selbar .icon-btn { width: 32px; height: 32px; }
.selbar .icon-btn .ms { font-size: 20px; }
.selbar-count { font: 500 14px/20px var(--font); padding: 0 12px 0 4px; white-space: nowrap; }

.content { position: relative; flex: 1; overflow-y: auto; padding: 0 16px 16px 20px; }

/* ---------- список ---------- */
.list-head, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px 150px 48px;
  align-items: center;
}
.list-head {
  position: sticky; top: 0; z-index: 2;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  color: var(--text);
  font: 500 14px/48px var(--font);
}
.col {
  display: flex; align-items: center; gap: 4px;
  height: 100%; min-width: 0;
  padding: 0 8px 0 6px;
  text-align: left;
  white-space: nowrap;
}
.col > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.sortable { cursor: pointer; border-radius: 8px 8px 0 0; }
.sortable:hover { background: var(--state-hover); }
.sort-arrow {
  font-size: 18px;
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex !important; align-items: center; justify-content: center;
  visibility: hidden;
}
.sortable.sorted .sort-arrow { visibility: visible; background: var(--primary-container); color: var(--selected-text); }
.sortable.desc .sort-arrow { transform: rotate(180deg); }

.row {
  position: relative;
  height: 48px;
  border-bottom: 1px solid var(--divider);
  color: var(--text-2);
  cursor: default;
  user-select: none;
  transition: opacity .2s var(--ease);
}
.row::before {
  content: ""; position: absolute; inset: 0 0 -1px 0;
  border-radius: 0;
  pointer-events: none;
  transition: background-color .1s var(--ease);
}
.row:hover::before { background: var(--state-hover); }
.row.selected { border-bottom-color: transparent; }
.row.selected::before { background: var(--primary-container); border-radius: 8px; }
.row.selected .r-name, .row.selected .r-cell { color: var(--selected-text); }

.r-name {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
  padding: 0 8px 0 22px;
  color: var(--text);
  position: relative;
}
.r-name .ft { font-size: 24px; }
.r-title { min-width: 0; display: flex; flex-direction: column; }
.r-title strong {
  font: 500 14px/20px var(--font);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.r-meta { display: none; font-size: 12px; line-height: 16px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-cell { padding: 0 8px 0 6px; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-more { display: flex; justify-content: center; position: relative; }

.r-actions {
  position: absolute; right: 4px; top: 0; bottom: 0;
  display: none; align-items: center; gap: 2px;
  padding-left: 8px;
}
.row:hover .r-actions, .row.selected .r-actions { display: flex; }
.row:hover .r-name, .row.selected .r-name { padding-right: 112px; }
.r-actions .icon-btn, .r-more .icon-btn { width: 32px; height: 32px; }
.r-actions .icon-btn .ms, .r-more .icon-btn .ms { font-size: 20px; }

.row.busy { opacity: .55; }
.busy-label { display: none; color: var(--primary); font-size: 12px; margin-left: 8px; white-space: nowrap; }
.row.busy .busy-label, .card.busy .busy-label { display: inline; }
.row.leaving, .card.leaving { animation: leave .3s var(--ease) forwards; }
.row.entering, .card.entering { animation: enter .35s var(--ease); }

/* ---------- миниатюры ---------- */
.r-thumb {
  position: relative;
  width: 32px; height: 32px;
  margin: 0 -4px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--thumb-bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.r-thumb .ft { font-size: 20px; }
.r-thumb img, .card-thumb img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.card-thumb img.top { object-position: top; }
.play-mini {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.play-mini .ms { font-size: 14px; }
.play-badge {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s var(--ease), background-color .2s var(--ease);
}
.play-badge .ms { font-size: 30px; }
.card:hover .play-badge { transform: translate(-50%, -50%) scale(1.08); background: rgba(0, 0, 0, .7); }
.dur {
  position: absolute; right: 8px; bottom: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font: 500 12px/16px var(--font);
}
.broken img, .broken .play-mini, .broken .play-badge, .broken .dur { display: none; }

/* ---------- значки типов ---------- */
.ft.image { color: #d93025; }
.ft.video { color: #d93025; }
.ft.audio { color: #d93025; }
.ft.pdf { color: #d93025; }
.ft.doc { color: #4285f4; }
.ft.sheet { color: #0f9d58; }
.ft.slides { color: #f4b400; }
.ft.archive { color: var(--icon-gray); }
.ft.apk { color: #34a853; }
.ft.code { color: var(--icon-gray); }
.ft.text { color: #4285f4; }
.ft.other { color: var(--icon-gray); }

/* ---------- сетка ---------- */
.grid {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding-top: 8px;
}
.content.grid-mode .list { display: none; }
.content.grid-mode .grid { display: grid; }
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 0 4px 4px;
  user-select: none;
  transition: background-color .1s var(--ease), opacity .2s var(--ease);
}
.card:hover { background: var(--card-hover); }
.card.selected { background: var(--primary-container); }
.card.busy { opacity: .55; }
.card-top {
  display: flex; align-items: center; gap: 12px;
  height: 48px;
  padding: 0 0 0 12px;
  min-width: 0;
}
.card-top .ft { font-size: 20px; }
.card-name { flex: 1; min-width: 0; font: 500 14px/20px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-top .icon-btn { width: 32px; height: 32px; }
.card-top .icon-btn .ms { font-size: 20px; }
.card-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb .ft { font-size: 64px; }
.card-meta { padding: 8px 8px 4px; font-size: 12px; line-height: 16px; color: var(--text-2); display: flex; gap: 4px; }

/* ---------- пусто ---------- */
.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.empty-art { width: 240px; height: 180px; margin-bottom: 24px; }
.empty-title { font: 400 22px/28px var(--font-display); color: var(--text); }
.empty-sub { margin-top: 8px; color: var(--text-2); font-size: 14px; }

/* ---------- перетаскивание ---------- */
.drop-overlay {
  position: absolute; inset: 0;
  z-index: 10;
  border: 2px solid var(--primary);
  border-radius: 16px;
  background: var(--primary-hover);
  display: none;
  align-items: flex-end; justify-content: center;
  pointer-events: none;
}
body.dragging .drop-overlay { display: flex; }
.drop-hint {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
  padding: 12px 24px 12px 16px;
  border-radius: 100px;
  background: var(--primary);
  color: var(--on-primary);
  font: 500 14px/20px var(--font);
  box-shadow: var(--shadow-2);
  animation: rise .25s var(--ease);
}

/* ---------- меню ---------- */
.menu {
  position: fixed; z-index: 160;
  min-width: 200px;
  max-width: calc(100vw - 16px);
  padding: 8px 0;
  background: var(--menu-bg);
  border-radius: 4px;
  box-shadow: var(--shadow-2);
  transform-origin: top left;
  animation: menu-in .12s var(--ease);
}
.menu-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  height: 32px;
  padding: 0 16px 0 12px;
  font: 400 14px/20px var(--font);
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--state-hover); outline: 0; }
.menu-item .ms { font-size: 20px; color: var(--text-2); }
.menu-item.danger .ms, .menu-item.danger { color: var(--danger); }
.menu-item .check { margin-left: auto; color: var(--text-2); visibility: hidden; }
.menu-item.checked .check { visibility: visible; }
.menu-sep { height: 1px; background: var(--sep); margin: 8px 0; }

/* ---------- панель загрузок ---------- */
.uploads {
  position: fixed; z-index: 50;
  right: 24px; bottom: 0;
  width: 360px;
  background: var(--panel-bg);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: rise .25s var(--ease);
}
.uploads-head {
  display: flex; align-items: center;
  height: 56px;
  padding: 0 8px 0 24px;
  background: var(--panel-head);
}
.uploads-title { flex: 1; font: 500 16px/24px var(--font-display); color: var(--text); }
.uploads-sub {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px;
  padding: 0 12px 0 24px;
  background: var(--card-bg);
  color: var(--text-2);
}
.uploads-list { list-style: none; margin: 0; padding: 0; max-height: 264px; overflow-y: auto; transition: max-height .2s var(--ease); }
.uploads.collapsed .uploads-list, .uploads.collapsed .uploads-sub { display: none; }
.uploads.collapsed #uploadsToggle .ms { transform: rotate(180deg); }
.up-item {
  display: flex; align-items: center; gap: 16px;
  height: 48px;
  padding: 0 16px 0 24px;
}
.up-item:hover { background: var(--state-hover); }
.up-item .ft { font-size: 20px; }
.up-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.up-status { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; position: relative; }
.up-status .ring { width: 24px; height: 24px; transform: rotate(-90deg); }
.up-status .ring circle { fill: none; stroke-width: 3; }
.up-status .ring .track { stroke: var(--sep); }
.up-status .ring .bar { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.up-status .done { color: var(--success-icon); }
.up-status .err { color: var(--danger); }
.up-status .cancel-btn { position: absolute; inset: 0; width: 32px; height: 32px; display: none; }
.up-item.running:hover .ring { display: none; }
.up-item.running:hover .cancel-btn { display: inline-flex; }

/* ---------- снэкбар ---------- */
.snackbar {
  position: fixed; z-index: 170;
  left: 24px; bottom: 24px;
  min-height: 48px;
  max-width: 560px;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 4px 4px 16px;
  border-radius: 4px;
  background: var(--inverse);
  color: var(--inverse-text);
  box-shadow: var(--shadow-3);
  font: 400 14px/20px var(--font);
  transform: translateY(24px);
  opacity: 0;
  visibility: hidden;
  transition: transform .25s var(--ease), opacity .2s var(--ease), visibility 0s .25s;
}
.snackbar.show { transform: none; opacity: 1; visibility: visible; transition: transform .25s var(--ease), opacity .2s var(--ease); }
.snackbar-text { flex: 1; padding: 10px 8px 10px 0; }
.snackbar-action {
  height: 40px; padding: 0 12px; border-radius: 20px;
  color: var(--inverse-primary);
  font: 500 14px/20px var(--font);
  white-space: nowrap;
}
.snackbar-action:hover { background: var(--inverse-hover); }
.snackbar-close { color: var(--inverse-text); }
.snackbar-close:hover { background: var(--inverse-hover); }

/* ---------- диалог ---------- */
.dialog-scrim {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .32);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade-in .15s var(--ease);
}
.dialog {
  width: 100%; max-width: 480px;
  background: var(--dialog-bg);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow-3);
  animation: menu-in .2s var(--ease);
}
.dialog h2 { margin: 0 0 16px; font: 400 24px/32px var(--font-display); }
.help-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; color: var(--text-2); }
.help-list li { display: flex; gap: 16px; align-items: flex-start; }
.help-list .ms { color: var(--primary); }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 24px; }

/* ---------- подсказки ---------- */
.tooltip {
  position: fixed; z-index: 300;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--inverse);
  color: var(--inverse-text);
  font: 500 12px/16px var(--font);
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s;
  white-space: nowrap;
}
.tooltip.show { opacity: .92; }

/* ---------- FAB и мобильное меню ---------- */
.fab {
  display: none;
  position: fixed; z-index: 40;
  right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--primary-container);
  color: var(--selected-text);
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-3);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.fab:active { transform: scale(.96); }
.scrim { display: none; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes menu-in { from { opacity: 0; transform: scale(.92); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes enter { from { opacity: 0; background: var(--primary-press); } }
@keyframes leave { to { opacity: 0; transform: translateX(16px); } }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .list-head, .row { grid-template-columns: minmax(0, 1fr) 140px 120px 48px; }
}

@media (max-width: 768px) {
  body { background: var(--surface); }
  .topbar { background: var(--surface); padding: 8px 8px 8px 4px; }
  .menu-btn { display: inline-flex; }
  .brand { display: none; }
  .search { flex: 1; height: 48px; }
  .topbar-actions { padding-right: 0; }

  .sidebar {
    position: fixed; z-index: 90;
    top: 0; bottom: 0; left: 0;
    width: 300px; max-width: 85vw;
    background: var(--surface);
    border-radius: 0 16px 16px 0;
    padding-top: 12px;
    transform: translateX(-105%);
    transition: transform .3s var(--ease);
    box-shadow: var(--shadow-3);
  }
  body.nav-open .sidebar { transform: none; }
  .scrim {
    display: block;
    position: fixed; inset: 0; z-index: 80;
    background: rgba(0, 0, 0, .32);
    opacity: 0; pointer-events: none;
    transition: opacity .3s var(--ease);
  }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .create-wrap { display: none; }
  .drawer-brand { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 8px; font: 400 22px/28px var(--font-display); }

  .main { margin: 0; border-radius: 0; }
  .main-head { padding: 4px 8px 0 0; min-height: 52px; }
  .title-btn h1 { font-size: 22px; line-height: 28px; }
  .toolbar { padding: 0 12px; }
  .content { padding: 0 0 96px; }

  .list-head { display: none; }
  .list-head, .row { grid-template-columns: minmax(0, 1fr) 48px; }
  .row { height: 64px; border-bottom: 0; }
  .row::before { inset: 0; }
  .row .r-cell, .row .r-actions { display: none !important; }
  .r-name { padding-left: 20px; gap: 20px; }
  .r-thumb { width: 40px; height: 40px; margin: 0 -8px; border-radius: 8px; }
  .r-meta { display: block; }
  .row.selected::before { border-radius: 0; }

  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 8px 12px 0; }
  .card-top { padding-left: 10px; gap: 8px; }

  .fab { display: inline-flex; }
  .uploads { right: 0; left: 0; width: auto; }
  .snackbar { left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
  .empty-art { width: 200px; height: 150px; }
}

@media (hover: none) {
  .row:hover::before { background: none; }
  .row:active::before { background: var(--state-press); }
  .card:hover { background: var(--card-bg); }
}

/* ---------- просмотр файла (как в Google Диске — всегда тёмный) ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 150;
  display: flex; flex-direction: column;
  background: rgba(0, 0, 0, .92);
  color: #e3e3e3;
  animation: fade-in .2s var(--ease);
  overscroll-behavior: contain;
}
.v-head {
  flex-shrink: 0;
  height: 64px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 8px 12px;
}
.v-btn { color: #c4c7c5; }
.v-btn:hover { background: rgba(227, 227, 227, .08); }
.v-btn:active { background: rgba(227, 227, 227, .12); }
.v-icon { display: flex; margin: 0 4px; }
.v-icon .ft { font-size: 24px; }
.v-titles { flex: 1; min-width: 0; }
.v-title {
  font: 400 18px/24px var(--font-display);
  color: #e3e3e3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.v-sub { font-size: 12px; line-height: 16px; color: #c4c7c5; }
.v-actions { display: flex; align-items: center; gap: 8px; }
.v-download {
  height: 40px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 24px 0 16px;
  border-radius: 100px;
  background: #004a77;
  color: #c2e7ff;
  font: 500 14px/20px var(--font);
  transition: background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.v-download .ms { font-size: 20px; }
.v-download:hover { background: #0b5785; box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15); }
.v-download:active { background: #166294; }

.v-body {
  position: relative;
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.v-stage {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 88px 88px;
  overflow: hidden;
  touch-action: none;
}
.v-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  user-select: none; -webkit-user-drag: none;
  transition: transform .18s var(--ease), opacity .2s;
  cursor: zoom-in;
  transform-origin: center;
}
.v-stage.zoomed .v-img { cursor: grab; }
.v-stage.panning .v-img { cursor: grabbing; transition: none; }
.v-img.loading { filter: blur(6px); }
.v-video {
  max-width: calc(100% - 176px); max-height: calc(100% - 32px);
  background: #000;
  outline: 0;
}
.v-audio {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  padding: 40px 32px;
  border-radius: 16px;
  background: #1e1f20;
  width: min(440px, calc(100% - 32px));
}
.v-audio .ft { font-size: 72px; }
.v-audio audio { width: 100%; }
.v-pdf {
  width: 100%; height: 100%;
  overflow: auto;
  padding: 8px 16px 96px;
}
.v-page {
  position: relative;
  margin: 0 auto 16px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.v-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.v-text {
  width: min(960px, calc(100% - 176px)); height: calc(100% - 24px);
  margin: 0 0 24px;
  overflow: auto;
  padding: 24px 28px;
  border-radius: 8px;
  background: #1e1f20;
  color: #e3e3e3;
  font: 13px/20px ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  white-space: pre-wrap; word-break: break-word;
  tab-size: 4;
}
.v-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(420px, calc(100% - 32px));
  padding: 40px 32px 32px;
  border-radius: 16px;
  background: #1e1f20;
  text-align: center;
}
.v-card .ft { font-size: 72px; margin-bottom: 8px; }
.v-card-title { font: 400 22px/28px var(--font-display); color: #e3e3e3; word-break: break-word; }
.v-card-text { color: #c4c7c5; margin-bottom: 16px; }
.v-spinner {
  position: absolute; left: 50%; top: 50%;
  width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%;
  border: 4px solid rgba(168, 199, 250, .25);
  border-top-color: #a8c7fa;
  animation: spin .9s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.v-nav {
  position: absolute; top: 50%; z-index: 2;
  width: 48px; height: 48px; margin-top: -8px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30, 31, 32, .9);
  color: #e3e3e3;
  transition: background-color .15s var(--ease), opacity .15s;
}
.v-nav:hover { background: #333537; }
.v-nav .ms { font-size: 28px; }
.v-prev { left: 24px; }
.v-next { right: 24px; }
.v-nav[disabled] { opacity: 0; pointer-events: none; }

.v-zoom {
  position: absolute; left: 50%; bottom: 24px; z-index: 2;
  transform: translateX(-50%);
  height: 48px;
  display: flex; align-items: center; gap: 2px;
  padding: 0 4px;
  border-radius: 100px;
  background: #333537;
  box-shadow: 0 1px 3px 1px rgba(0, 0, 0, .3);
}
.v-zoom .v-btn { color: #e3e3e3; }
.v-zoom-label { min-width: 52px; text-align: center; font: 500 14px/20px var(--font); }
.v-pages { padding: 0 16px 0 12px; border-left: 1px solid #5e5e5e; margin-left: 4px; font: 500 14px/20px var(--font); white-space: nowrap; color: #c4c7c5; }

@media (max-width: 768px) {
  .v-head { padding: 8px 8px 8px 4px; gap: 4px; }
  .v-icon { display: none; }
  .v-title { font-size: 16px; }
  .v-download { width: 40px; padding: 0; justify-content: center; background: transparent; color: #c4c7c5; }
  .v-download:hover { background: rgba(227, 227, 227, .08); box-shadow: none; }
  .v-download .ms { font-size: 24px; }
  .v-download-label { display: none; }
  .v-card .v-card-btn { width: auto; padding: 0 24px 0 16px; background: #004a77; color: #c2e7ff; }
  .v-card .v-card-btn .ms { font-size: 20px; }
  .v-actions { gap: 0; }
  .v-stage { padding: 0; }
  .v-video { max-width: 100%; max-height: 100%; }
  .v-text { width: 100%; height: 100%; margin: 0; border-radius: 0; padding: 16px; }
  .v-pdf { padding: 8px 8px 96px; }
  .v-nav { display: none; }
  .v-zoom { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ---------- хлебные крошки ---------- */
.crumbs {
  display: flex; align-items: center;
  min-width: 0; flex: 1;
  margin-left: 4px;
}
.crumb {
  flex-shrink: 1; min-width: 0; max-width: 220px;
  height: 40px;
  padding: 4px 12px 4px 16px;
  border-radius: 100px;
  font: 400 24px/32px var(--font-display);
  color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background-color .15s var(--ease);
}
.crumb:hover { background: var(--state-hover); color: var(--text); }
.crumb-more { flex-shrink: 0; padding: 4px 12px; }
.crumb-sep { color: var(--text-2); margin: 0 -4px; flex-shrink: 0; }
.crumbs .title-btn { margin-left: 0; flex-shrink: 1; }
.crumb-back { display: none; margin-right: 4px; }
.crumb.drop-target, .title-btn.drop-target { background: var(--primary-container); color: var(--selected-text); outline: 2px solid var(--primary); }

/* ---------- папки ---------- */
.ft.folder { color: var(--text-2); }
.grid-label {
  grid-column: 1 / -1;
  font: 500 14px/20px var(--font);
  color: var(--text);
  padding: 8px 0 0 4px;
}
.grid-label + .grid-label { display: none; }
.folder-card { padding: 0 4px; }
.folder-card .card-top { height: 48px; }
.folder-card .card-top .ft { font-size: 24px; }
.row.drop-target::before, .card.drop-target { background: var(--primary-container) !important; }
.row.drop-target, .card.drop-target { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 8px; }
.row.drop-target .r-name, .card.drop-target .card-name { color: var(--selected-text); }

.drag-chip {
  position: fixed; left: -1000px; top: -1000px;
  display: inline-flex; align-items: center; gap: 12px;
  height: 40px; max-width: 280px;
  padding: 0 16px 0 12px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
  font: 500 14px/20px var(--font);
  white-space: nowrap; overflow: hidden;
}
.drag-chip .ms { font-size: 20px; color: var(--text-2); }
.drag-chip span:last-child { overflow: hidden; text-overflow: ellipsis; }

/* ---------- сортировка ---------- */
.sortable:not(.sorted):hover .sort-arrow { visibility: visible; opacity: .55; }
.col-more { justify-content: center; padding: 0; }
.col-more .icon-btn { width: 32px; height: 32px; }
.col-more .icon-btn .ms { font-size: 20px; }
.sortbar { display: none; align-items: center; justify-content: flex-end; gap: 2px; height: 40px; padding-top: 4px; }
.content.grid-mode .sortbar { display: flex; }
.content.grid-mode.grid-labels .sortbar { position: relative; z-index: 1; margin-bottom: -40px; margin-left: auto; width: max-content; }
.content.grid-mode .grid { padding-top: 0; }
.sort-field {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font: 500 14px/20px var(--font);
  color: var(--text);
  transition: background-color .15s var(--ease);
}
.sort-field:hover { background: var(--state-hover); }
.sort-dir { width: 32px; height: 32px; }
.sort-dir .ms { font-size: 18px; }

/* ---------- меню: подсказки сочетаний клавиш ---------- */
.menu-hint {
  margin-left: auto;
  padding-left: 32px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ---------- диалоги: поле ввода, «Переместить» ---------- */
.prompt-dialog { max-width: 400px; }
.text-field {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 400 16px/24px var(--font);
  outline: 0;
}
.text-field:focus { border: 2px solid var(--primary); padding: 0 14px; }
.filled-btn {
  height: 40px;
  padding: 0 24px;
  border-radius: 20px;
  background: var(--primary);
  color: var(--on-primary);
  font: 500 14px/20px var(--font);
  transition: box-shadow .15s var(--ease), opacity .15s;
}
.filled-btn:hover { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15); }
.filled-btn:disabled { opacity: .38; box-shadow: none; cursor: default; }
.dialog-actions { gap: 8px; align-items: center; }
.dialog-actions .spacer { flex: 1; }
#moveNewFolder { width: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
#moveNewFolder .ms { font-size: 22px; }
.move-dialog { max-width: 440px; padding-bottom: 20px; }
.move-head { display: flex; align-items: center; gap: 4px; height: 48px; margin: 0 0 4px -8px; }
.move-where { font: 500 14px/20px var(--font); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.move-list {
  height: 280px;
  overflow-y: auto;
  border-top: 1px solid var(--sep);
  border-bottom: 1px solid var(--sep);
  padding: 4px 0;
  margin: 0 -24px;
}
.move-item {
  display: flex; align-items: center; gap: 16px;
  width: 100%; height: 48px;
  padding: 0 16px 0 24px;
  text-align: left;
  color: var(--text);
}
.move-item span:nth-child(2) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.move-item:hover:not(:disabled) { background: var(--state-hover); }
.move-item:disabled { opacity: .45; cursor: default; }
.move-item .ms:last-child { color: var(--text-2); font-size: 20px; }
.move-empty { padding: 24px; text-align: center; color: var(--text-2); }

@media (max-width: 768px) {
  .crumbs { margin-left: 0; }
  .crumb, .crumb-sep, .crumb-more { display: none; }
  .crumb-back { display: inline-flex; }
  .crumbs .title-btn { padding-left: 8px; }
  .sortbar { display: flex; justify-content: flex-start; padding: 0 8px 0 12px; }
  .move-list { height: 50vh; }
}

/* ---------- загрузка с телефона ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0; opacity: 0;
}
.empty-btn {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 24px;
  padding: 0 24px 0 16px;
}
.empty-btn .ms { font-size: 20px; }
@supports (height: 100dvh) {
  body { height: 100dvh; }
}
