:root {
  color-scheme: light dark;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #171a21;
  --muted: #626b7c;
  --border: #dfe3ea;
  --accent: #2f55d4;
  --accent-hover: #2445b3;
  --accent-soft: #e8edff;
  --on-accent: #ffffff;
  --danger: #c0271b;
  --danger-soft: #fdebe9;
  --ok: #0b7446;
  --ok-soft: #e2f5ea;
  --warn: #8a5100;
  --warn-soft: #fff2d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #171a21;
    --surface-2: #20242d;
    --text: #e8eaef;
    --muted: #9aa3b4;
    --border: #2b303b;
    --accent: #8ea2ff;
    --accent-hover: #a9b8ff;
    --accent-soft: #1e274d;
    --on-accent: #0e1015;
    --danger: #ff8479;
    --danger-soft: #3a1b19;
    --ok: #62d49d;
    --ok-soft: #132e20;
    --warn: #f0bd61;
    --warn-soft: #32260f;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1 { margin: 0; font-size: 1.6rem; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 28px; padding-bottom: 56px; display: grid; gap: 20px; align-content: start; }
main.center { flex: 1; align-content: center; justify-items: center; }

.muted { color: var(--muted); }
.small { font-size: .87rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.offscreen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* шапка */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 8px 20px; min-height: 56px; flex-wrap: wrap; }
.brand-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); margin-right: auto; }
.brand-name:hover { text-decoration: none; }
.logo { width: 26px; height: 26px; color: var(--accent); flex: none; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.note { margin-top: 6px; max-width: 70ch; white-space: pre-line; overflow-wrap: anywhere; }
.crumbs { margin-bottom: -8px; font-size: .9rem; }

/* карточки и формы */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-narrow { max-width: 480px; }

.field { display: grid; gap: 6px; font-weight: 500; font-size: .93rem; }
.field .muted { font-weight: 400; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-width: 0; padding: 9px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; font-weight: 400;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly], textarea[readonly] { background: var(--surface-2); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); flex: none; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 400; }
.copy-row { display: flex; gap: 8px; }
.copy-row > input, .copy-row > select { flex: 1; }
.copy-row.narrow { max-width: 320px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
  border: 1px solid transparent; border-radius: 8px; font-weight: 600; font-size: .93rem; line-height: 1.4;
  white-space: nowrap; cursor: pointer; background: none; transition: background-color .12s, border-color .12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn-block { width: 100%; padding-block: 10px; }
.link { color: var(--accent); cursor: pointer; font-weight: 600; }
.link:hover { text-decoration: underline; }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid transparent; font-size: .93rem; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }
.topbar + .container > .alert { margin-top: 16px; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chip-active { background: var(--ok-soft); color: var(--ok); }
.chip-expired { background: var(--warn-soft); color: var(--warn); }
.chip-disabled { background: var(--surface-2); color: var(--muted); }

/* вход */
.auth { width: 100%; max-width: 400px; display: grid; gap: 16px; padding: 28px; text-align: center; }
.auth form { text-align: left; }
.brand { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; background: var(--accent-soft); }
.brand .logo { width: 32px; height: 32px; }

/* таблицы */
.card.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 14px; text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.col-check { width: 1%; padding-right: 0 !important; }
.col-title { min-width: 180px; max-width: 420px; overflow-wrap: anywhere; }
.actions { width: 1%; white-space: nowrap; text-align: right; }
.actions form { display: inline; }
.actions .btn { padding: 5px 10px; font-size: .85rem; }
.title-input:not(:focus) { border-color: transparent !important; background: transparent !important; text-overflow: ellipsis; }
.title-input { margin-left: -8px; padding: 4px 8px !important; font-weight: 600 !important; cursor: text; }
.title-input:hover:not(:focus) { border-color: var(--border) !important; }
.file-name { padding-left: 1px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: -8px; }

/* загрузка */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 20px; text-align: center; background: var(--surface); transition: border-color .12s, background-color .12s; }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 2px; }
.upload-list { list-style: none; margin: 0; padding: 0; text-align: left; display: grid; gap: 10px; }
.upload-list:not(:empty) { margin-top: 20px; }
.upload-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: .9rem; }
.upload-item .upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.upload-item progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--accent); }
.upload-item.is-done .upload-status { color: var(--ok); }
.upload-item.is-error .upload-status { color: var(--danger); }

/* страница витрины в админке */
.share { display: grid; gap: 16px; }
.reveal { display: grid; gap: 8px; padding: 14px; border-radius: 8px; background: var(--accent-soft); justify-items: start; }
.reveal textarea { font-family: ui-monospace, Consolas, monospace; font-size: .88rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; margin: 0; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.facts dd .muted { font-weight: 400; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.picker-head input { max-width: 240px; }
.pick-list { list-style: none; margin: 0; padding: 4px; max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pick-list .check { padding: 8px 10px; border-radius: 6px; }
.pick-list .check:hover { background: var(--surface-2); }
.pick-text { display: grid; min-width: 0; overflow-wrap: anywhere; }

/* витрина для посетителя */
.shelf { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.file-card { display: grid; gap: 14px; align-content: space-between; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.file-info { min-width: 0; display: grid; gap: 4px; overflow-wrap: anywhere; }
.ext { justify-self: start; padding: 4px 9px; border-radius: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .04em; color: #fff; background: #6b7280; }
.ext-doc { background: #2b62d9; }
.ext-pdf { background: #c8332a; }
.ext-sheet { background: #15803d; }
.ext-slides { background: #c2570c; }
.ext-image { background: #8544c9; }
.ext-video { background: #be2f7a; }
.ext-audio { background: #0d7f86; }
.ext-archive { background: #8a6410; }

/* ── проводник ───────────────────────────────────────── */
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 0; font-size: 1.6rem; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
.path a { color: var(--muted); padding: 0 4px; margin: 0 -4px; border-radius: 6px; }
.path a:hover { color: var(--accent); text-decoration: none; }
.path .sep { color: var(--muted); font-weight: 400; }
.path [aria-current] { overflow-wrap: anywhere; }
.is-drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft) !important; }

.explorer-bar { position: sticky; top: 0; z-index: 6; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 0; margin: -10px 0 -12px; background: var(--bg); }
.view-controls select { width: auto; padding: 7px 10px; }
.icon-btn { min-width: 38px; padding-inline: 8px; }
.selection-bar { position: sticky; top: 58px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); margin-bottom: -10px; }
.selection-bar[hidden] { display: none; }
.selection-bar strong { margin-right: 6px; color: var(--accent); }
.btn-delete { background: var(--danger); color: #fff; }
.btn-delete:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }

.explorer { position: relative; min-height: 260px; display: grid; gap: 12px; align-content: start; border-radius: var(--radius); }
.explorer.is-over::after {
  content: "Отпустите, чтобы загрузить сюда"; position: absolute; inset: -6px; z-index: 4; display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  color: var(--accent); font-weight: 700; font-size: 1.1rem; pointer-events: none;
}
.upload-panel { display: grid; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.upload-panel[hidden] { display: none; }
.upload-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.upload-panel > progress { width: 100%; height: 8px; accent-color: var(--accent); }
.upload-summary .btn { margin-left: auto; padding: 4px 12px; font-size: .85rem; }
.upload-summary .btn[hidden] { display: none; }
.explorer .upload-list { max-height: 40vh; overflow-y: auto; }
.explorer .upload-list:not(:empty) { margin: 6px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.explorer .empty { border: 2px dashed var(--border); border-radius: var(--radius); }

.items { list-style: none; margin: 0; padding: 0; }
.item { position: relative; border-radius: 10px; transition: background-color .1s; }
.item:hover { background: var(--surface-2); }
.item.is-selected { background: var(--accent-soft); }
.item-main { display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.item-main:hover { text-decoration: none; }
.item-visual { position: relative; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 6px; }
.item-visual .thumb { width: 100%; height: 100%; object-fit: cover; }
.item-visual .thumb + .ext { display: none; }
.item-visual .ext { justify-self: center; }
.item-text { display: grid; min-width: 0; gap: 2px; }
.item-name { font-weight: 500; overflow-wrap: anywhere; }
.item-sub { color: var(--muted); font-size: .8rem; }
.item-size, .item-date, .item-shared, .items-head { display: none; }
.item .pick { flex: none; }
.item-menu { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.item-menu:hover, .item-menu:focus-visible { background: var(--surface); color: var(--text); }
.icon-folder { width: 100%; height: 100%; }
.icon-folder .folder-back { fill: #e0a526; }
.icon-folder .folder-front { fill: #f5c044; }

/* Таблица */
.view-details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.view-details .items-head, .view-details .item {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) 110px 170px 100px 32px; align-items: center; gap: 0 14px;
  padding: 7px 14px; border-radius: 0; border-bottom: 1px solid var(--border);
}
.view-details .item:last-child { border-bottom: 0; }
.view-details .items-head { font-size: .8rem; font-weight: 600; color: var(--muted); }
.view-details .item-visual { width: 30px; height: 30px; }
.view-details .ext { font-size: .55rem; padding: 2px 3px; letter-spacing: 0; }
.view-details .item-sub { display: none; }
.view-details .item-size, .view-details .item-date, .view-details .item-shared { display: block; font-size: .9rem; white-space: nowrap; }
.view-details .item-size { text-align: right; }

/* Список и мелкие значки — компактные строки */
.view-list, .view-s { display: grid; gap: 2px 14px; }
.view-list { grid-template-columns: minmax(0, 1fr); }
.view-s { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.view-list .item, .view-s .item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.view-list .item-visual, .view-s .item-visual { width: 22px; height: 22px; }
.view-list .ext, .view-s .ext { font-size: .45rem; padding: 1px 2px; letter-spacing: 0; }
.view-s .item-sub { display: none; }
.view-list .item-text { display: flex; justify-content: space-between; gap: 12px; flex: 1; }
.view-list .item-name, .view-s .item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-list .item-sub { white-space: nowrap; }
.view-list .item-menu, .view-s .item-menu { width: 26px; height: 26px; }

/* Значки: обычные, крупные, огромные */
.view-m, .view-l, .view-xl { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); }
.view-m { --tile: 128px; --visual: 76px; --ext: .8rem; }
.view-l { --tile: 176px; --visual: 132px; --ext: 1rem; }
.view-xl { --tile: 280px; --visual: 230px; --ext: 1.3rem; }
.view-m .item, .view-l .item, .view-xl .item { padding: 12px 8px 10px; }
.view-m .item-main, .view-l .item-main, .view-xl .item-main { flex-direction: column; gap: 8px; text-align: center; }
.view-m .item-visual, .view-l .item-visual, .view-xl .item-visual { width: var(--visual); height: var(--visual); }
.view-m .item-visual .thumb, .view-l .item-visual .thumb, .view-xl .item-visual .thumb { object-fit: contain; }
.view-m .ext, .view-l .ext, .view-xl .ext { font-size: var(--ext); padding: .45em .7em; }
.view-m .item-text, .view-l .item-text, .view-xl .item-text { justify-items: center; width: 100%; }
.view-m .item-name, .view-l .item-name, .view-xl .item-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.view-m .pick, .view-l .pick, .view-xl .pick, .view-tiles .pick { position: absolute; top: 8px; left: 8px; z-index: 2; opacity: 0; }
.view-m .item-menu, .view-l .item-menu, .view-xl .item-menu { position: absolute; top: 4px; right: 4px; opacity: 0; }
.view-m .item:hover :is(.pick, .item-menu), .view-l .item:hover :is(.pick, .item-menu), .view-xl .item:hover :is(.pick, .item-menu),
.view-tiles .item:hover .pick, .item .pick:checked, .item .pick:focus-visible, .item .item-menu:focus-visible { opacity: 1; }

/* Плитка */
.view-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.view-tiles .item { display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 12px; border: 1px solid var(--border); background: var(--surface); }
.view-tiles .item.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.view-tiles .item-visual { width: 60px; height: 60px; }
.view-tiles .item-visual .thumb { object-fit: contain; }
.view-tiles .ext { font-size: .7rem; }

@media (hover: none) {
  .item .pick, .item .item-menu { opacity: 1 !important; }
}

/* Меню, уведомление, диалоги */
.menu { position: fixed; z-index: 60; display: grid; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(10, 14, 24, .2); }
.menu[hidden] { display: none; }
.menu > * { padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.menu > *:hover, .menu > *:focus-visible { background: var(--surface-2); text-decoration: none; outline: none; }
.menu > [hidden] { display: none; }
.menu .danger { color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast[hidden] { display: none; }

.dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(10, 14, 24, .3); }
.dialog::backdrop { background: rgba(10, 12, 18, .5); }
.dialog h2 { font-size: 1.15rem; overflow-wrap: anywhere; }
.tree { max-height: 320px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 8px; }
.tree label { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px calc(8px + var(--depth, 0) * 20px); border-radius: 6px; cursor: pointer; }
.tree label:hover { background: var(--surface-2); }
.tree .icon-folder { width: 20px; height: 17px; flex: none; }
.tree input:disabled ~ span { color: var(--muted); }
.tree label:has(input:disabled) { cursor: not-allowed; }
.dialog code, .dialog input[readonly] { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* Просмотр файла */
.viewer { width: min(1180px, calc(100vw - 24px)); height: min(88vh, 940px); max-width: none; max-height: none; padding: 0; border: 0; border-radius: var(--radius); background: #0d0f13; color: #eceef2; overflow: hidden; }
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.viewer::backdrop { background: rgba(6, 8, 12, .78); }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #171a20; }
.viewer-title { flex: 1; min-width: 0; display: grid; }
.viewer-title strong, .viewer-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title span { color: #9aa3b4; }
.viewer .btn-ghost { background: transparent; color: #eceef2; border-color: #333a46; }
.viewer .btn-ghost:hover { background: #232832; }
.viewer-nav { font-size: 1.3rem; padding-block: 4px; }
.viewer-nav[hidden] { display: none; }
.viewer-body { min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 14px; overflow: auto; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body video { width: 100%; height: 100%; background: #000; border-radius: 6px; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; border-radius: 6px; background: #fff; }
.viewer-body audio { width: min(560px, 100%); }
.viewer-body pre { align-self: stretch; justify-self: stretch; margin: 0; padding: 16px 18px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 8px; background: #171a20; color: #e3e6ec; font: .86rem/1.55 ui-monospace, Consolas, monospace; }
.viewer-empty { display: grid; justify-items: center; gap: 14px; text-align: center; color: #9aa3b4; }
.viewer-empty .ext { font-size: 1.6rem; padding: .5em .8em; }

/* Витрина: превью на карточке */
.file-card { padding-top: 0; overflow: hidden; }
.card-visual { position: relative; display: grid; place-items: center; height: 168px; margin: 0 -18px; padding: 0; border: 0; border-bottom: 1px solid var(--border); background: var(--surface-2); cursor: pointer; overflow: hidden; }
.card-visual .thumb { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.card-visual:hover .thumb { transform: scale(1.03); }
.card-visual .thumb + .ext { display: none; }
.card-visual .ext { justify-self: center; font-size: 1rem; padding: .5em .8em; }
.card-actions { display: flex; gap: 8px; }
.card-actions .btn { flex: 1; }

@media (max-width: 900px) {
  .hide-md { display: none; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .hide-sm { display: none; }
  /* на телефоне строка таблицы — карточка: название и размер сверху, кнопки снизу */
  .card.table-wrap { overflow-x: visible; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table, .table tbody { display: block; }
  .table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { padding: 0 !important; border: 0; width: auto; }
  .table .col-title { flex: 1; min-width: 0; }
  .table .actions { flex-basis: 100%; text-align: left; white-space: normal; display: flex; flex-wrap: wrap; gap: 6px; }
  .nav { order: 3; width: 100%; padding-bottom: 8px; }
  .card { padding: 16px; }
  .share .copy-row { flex-wrap: wrap; }
  .share .copy-row > input { flex-basis: 100%; }
  /* проводник на телефоне: в таблице остаются имя и размер */
  .path { font-size: 1.3rem; }
  .explorer-bar { position: static; margin: 0; padding: 0; }
  .selection-bar { top: 0; }
  .view-details .items-head, .view-details .item { grid-template-columns: 24px minmax(0, 1fr) auto 32px; gap: 0 10px; padding: 7px 10px; }
  .view-details .item-date, .view-details .item-shared,
  .view-details .items-head span:nth-child(4), .view-details .items-head span:nth-child(5) { display: none; }
  .view-xl { --tile: 100%; }
  .card-visual { height: 140px; }
}

/* ---------- прошивка STM32 (static/flasher.js) ---------- */
.viewer-bar .btn[hidden] { display: none; }
.card-actions { flex-wrap: wrap; }
.flasher { width: min(560px, calc(100vw - 32px)); }
.flasher fieldset { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.flasher legend { margin-bottom: 8px; padding: 0; font-weight: 600; }
.flasher .check { align-items: flex-start; }
.flasher .check input { margin-top: 3px; flex: none; }
.flasher [hidden] { display: none; }
.flasher-checks { display: grid; gap: 6px; }
.flasher-status { display: grid; gap: 8px; }
.flasher-status progress { width: 100%; height: 8px; accent-color: var(--accent); }
#flasher-stage { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
#flasher-stage.is-ok { color: var(--ok); }
#flasher-stage.is-error { color: var(--danger); }
#flasher-log { max-height: 150px; margin: 0; padding: 10px 12px; overflow: auto; border-radius: 8px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; font: .8rem/1.5 ui-monospace, Consolas, monospace; }
#flasher-log:empty { display: none; }
.flasher-help summary { color: var(--muted); cursor: pointer; }
.flasher-help p { margin: 6px 0 0; color: var(--muted); }
