/* Tube Cloud — веб-панель */
:root {
  --bg: #0B1426; --bg2: #0F1C33; --card: #13223D; --card2: #182A4A; --line: #22385C;
  --text: #E2E8F0; --muted: #8DA2BF; --faint: #5B7091;
  --accent: #7DD3FC; --accent2: #38BDF8; --ink: #0F172A;
  --ok: #4ADE80; --warn: #FBBF24; --err: #F87171;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F4F8FC; --bg2: #EAF2FA; --card: #FFFFFF; --card2: #F1F6FB; --line: #D7E3F0;
    --text: #0F172A; --muted: #50637E; --faint: #8A9BB3; --accent: #0284C7; --accent2: #0EA5E9; --ink: #FFFFFF;
    --shadow: 0 10px 30px rgba(15,23,42,.10); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #F4F8FC; --bg2: #EAF2FA; --card: #FFFFFF; --card2: #F1F6FB; --line: #D7E3F0;
  --text: #0F172A; --muted: #50637E; --faint: #8A9BB3; --accent: #0284C7; --accent2: #0EA5E9; --ink: #FFFFFF;
  --shadow: 0 10px 30px rgba(15,23,42,.10); color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pixel { image-rendering: pixelated; }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card2);
  border-radius: 11px; padding: 8px 14px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--err); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card2); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 0;
  background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--card2); color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], input[type=url],
select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent2); }
label.f { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
.check { display: flex; gap: 10px; align-items: center; margin: 8px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent2); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

/* вход */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, #1a3a66 0%, transparent 60%), var(--bg); }
.login .card { width: 100%; max-width: 380px; text-align: center; }
.login canvas { width: 220px; height: auto; display: block; margin: 0 auto 4px; }
.login h1 { margin: 6px 0 2px; font-size: 24px; letter-spacing: .5px; }
.login form { text-align: left; margin-top: 18px; }
.login .err { color: var(--err); min-height: 22px; margin-top: 10px; font-size: 14px; text-align: center; }
.code-input { font-size: 26px !important; letter-spacing: 10px; text-align: center; font-family: var(--mono); }

/* каркас */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand canvas { width: 54px; }
.brand b { font-size: 17px; letter-spacing: .3px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; color: var(--muted);
  text-decoration: none; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.on { background: var(--card2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.nav .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--faint); padding: 6px 12px 2px; }
.side .foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.quota { height: 6px; background: var(--card2); border-radius: 4px; overflow: hidden; margin: 6px 0 4px; }
.quota i { display: block; height: 100%; background: var(--accent2); }
.net { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }
main { min-width: 0; padding: 20px 28px 80px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.top h2 { margin: 0; font-size: 22px; }
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; padding: 2px 6px; border-radius: 7px; }
.crumbs a:hover { background: var(--card); color: var(--text); }
.crumbs b { color: var(--text); padding: 2px 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.stat b { display: block; font-size: 24px; margin-top: 4px; }
h3 { margin: 22px 0 10px; font-size: 16px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; }
.section-title h3 { margin: 0; }

/* список файлов */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.files { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.frow { display: grid; grid-template-columns: 34px 44px 1fr 110px 150px 40px; gap: 10px; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.frow:last-child { border-bottom: 0; }
.frow:hover { background: var(--card2); }
.frow.sel { background: color-mix(in srgb, var(--accent2) 14%, transparent); }
.frow .th { width: 40px; height: 40px; border-radius: 9px; background: var(--card2); display: grid; place-items: center;
  overflow: hidden; color: var(--accent); }
.frow .th img { width: 100%; height: 100%; object-fit: cover; }
.frow .name { min-width: 0; }
.frow .name div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.frow .size, .frow .date { color: var(--muted); font-size: 13px; text-align: right; }
.frow.head { cursor: default; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  background: var(--bg2); }
.frow.head:hover { background: var(--bg2); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 20px;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted); }
.chip.person { color: #C4B5FD; border-color: #4C3E80; }
.chip.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty canvas { width: 150px; margin: 0 auto 8px; display: block; }
.drop { outline: 2px dashed var(--accent2); outline-offset: -8px; }

/* фото */
.month { margin: 20px 0 8px; font-weight: 600; color: var(--muted); text-transform: capitalize; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.tile { position: relative; aspect-ratio: 1; background: var(--card2); border-radius: 10px; overflow: hidden; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.tile:hover img { transform: scale(1.04); }
.tile .badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px;
  padding: 1px 7px; border-radius: 8px; }

/* окна */
.modal-bg { position: fixed; inset: 0; background: rgba(3,8,20,.66); display: grid; place-items: center; z-index: 50;
  padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal.wide { max-width: 1100px; }
.modal h3 { margin: 0 0 12px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.viewer { display: grid; grid-template-columns: 1fr 300px; gap: 18px; }
.viewer .stage { background: #050a14; border-radius: 12px; min-height: 300px; display: grid; place-items: center;
  overflow: hidden; position: relative; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 72vh; display: block; }
.viewer .stage iframe { width: 100%; height: 72vh; border: 0; background: #fff; }
.viewer .stage pre { width: 100%; max-height: 72vh; overflow: auto; margin: 0; padding: 14px; color: #e2e8f0;
  font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.viewer .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.45); color: #fff;
  border: 0; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 20px; }
.viewer .nav-btn.prev { left: 10px; } .viewer .nav-btn.next { right: 10px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.tree { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.tree div { padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.tree div:hover { background: var(--card2); } .tree div.on { background: var(--accent); color: var(--ink); }

/* меню */
.menu { position: fixed; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; min-width: 200px; }
.menu button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--card2); }
.menu button.danger { color: var(--err); }

/* загрузки */
.uploads { position: fixed; right: 16px; bottom: 16px; width: 360px; max-width: calc(100vw - 32px); z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.uploads .uh { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--card2); font-weight: 600; }
.uploads .ul { max-height: 280px; overflow: auto; }
.uitem { padding: 9px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.bar { height: 5px; background: var(--bg2); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--accent2); transition: width .2s; }
.bar.big { height: 10px; border-radius: 6px; }
.bar.warn i { background: var(--warn); } .bar.err i { background: var(--err); }

/* тосты */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--accent2); border-radius: 12px;
  padding: 10px 14px; box-shadow: var(--shadow); max-width: 360px; animation: slide .25s ease; }
.toast.err { border-left-color: var(--err); } .toast.ok { border-left-color: var(--ok); } .toast.warn { border-left-color: var(--warn); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* таблицы */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--faint); font-weight: 500; font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 20px; background: var(--card2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.err { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.alert { border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent);
  padding: 10px 14px; border-radius: 12px; margin-bottom: 8px; }
.qr { background: #fff; padding: 14px; border-radius: 14px; display: inline-block; }
.qr img, .qr canvas { display: block; width: 100%; max-width: 240px; height: auto; image-rendering: pixelated; }
.spark { width: 100%; height: 120px; }
.term { background: #0B1426; border-radius: 14px; padding: 8px; height: calc(100vh - 210px); min-height: 320px; border: 1px solid var(--line); }

/* мобильные */
.mobile-top { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 45; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line);
    background: var(--bg2); position: sticky; top: 0; z-index: 30; }
  .mobile-top canvas { width: 40px; }
  main { padding: 16px 16px 90px; }
  .frow { grid-template-columns: 30px 40px 1fr 40px; }
  .frow .size, .frow .date { display: none; }
  .viewer { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 4px; }
  .kv { grid-template-columns: 100px 1fr; }
}

/* ───────── 4.0.1 ───────── */
.btn.big { padding: 12px 18px; font-size: 16px; min-height: 46px; }
.err-text { color: var(--err); font-size: 14px; margin-top: 6px; }
.warn-text { color: var(--warn); }
.dim { opacity: .6; }
mark { background: color-mix(in srgb, var(--warn) 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
code { font-family: var(--mono); font-size: 13px; background: var(--bg2); padding: 1px 5px; border-radius: 6px; }
details summary { cursor: pointer; }
pre.changelog { white-space: pre-wrap; font: 13px/1.45 var(--mono); background: var(--bg2); padding: 10px; border-radius: 10px; max-height: 220px; overflow: auto; }

/* значок «идут задачи» */
.task-badge { margin-left: auto; min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent); color: var(--ink);
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; padding: 0 6px; }

/* плитка файлов */
.files.as-grid { background: transparent; border: 0; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.ftile { cursor: pointer; font-size: 13px; min-width: 0; }
.ftile .tile { margin-bottom: 6px; display: grid; place-items: center; color: var(--accent); }
.ftile .tile .empty { padding: 0; display: grid; place-items: center; height: 100%; }
.ftile.sel .tile { outline: 3px solid var(--accent2); outline-offset: -3px; }
.tile-cb { position: absolute; left: 6px; top: 6px; width: 20px; height: 20px; accent-color: var(--accent2); opacity: 0; transition: opacity .15s; }
.ftile:hover .tile-cb, .ftile.sel .tile-cb, .fgrid:has(.sel) .tile-cb { opacity: 1; }
.bulkbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }

/* просмотр: картинка не вылезает за окно, масштаб жестом/колесом */
.zoombox { width: 100%; height: 72vh; display: grid; place-items: center; overflow: hidden; touch-action: pan-x pan-y; cursor: zoom-in; }
.zoombox.zoomed { cursor: grab; touch-action: none; }
.zoombox img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; transition: transform .08s; user-select: none; -webkit-user-drag: none; }

/* экран «сервер перезагружается / обновляется» */
.busy-overlay { position: fixed; inset: 0; z-index: 90; background: color-mix(in srgb, var(--bg) 92%, transparent); display: grid; place-items: center;
  padding: 16px; backdrop-filter: blur(4px); text-align: center; }
.busy-overlay .card { max-width: 420px; }
.busy-overlay canvas { width: 160px; margin: 0 auto; display: block; }

/* задачи */
.cards.tasks { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.task .row b { font-size: 15px; }

/* конвертация / архивы */
.big-chip { padding: 7px 12px; font-size: 14px; cursor: pointer; background: var(--card2); }
.big-chip.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.share-card .row { gap: 8px; }

/* помощник */
.chat { min-height: 280px; max-height: 58vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 0; }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .bubble { white-space: pre-wrap; padding: 10px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.msg.me .bubble { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0; }
.chat-form textarea { resize: none; }
.chat-form .btn { height: 46px; }

/* журнал по дням */
details.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
details.day > summary { list-style: none; display: flex; gap: 8px; align-items: center; padding: 12px 14px; }
details.day > summary::-webkit-details-marker { display: none; }
details.day[open] > summary { border-bottom: 1px solid var(--line); background: var(--card2); }
.day-items { overflow-x: auto; }
tr.lvl-error td:first-child { box-shadow: inset 3px 0 0 var(--err); }
tr.lvl-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* настройки */
.settings-card { display: grid; gap: 4px; max-width: 760px; }
.setting { padding: 4px 0; }
.tg-wizard .steps { display: grid; gap: 12px; }
.tg-wizard .step { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.tg-wizard .step.done { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.card.vault { margin-bottom: 14px; border-color: color-mix(in srgb, var(--accent2) 40%, var(--line)); }

/* нижняя навигация — только на телефоне */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--bg2); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--muted); text-decoration: none;
    font-size: 11px; min-height: 48px; position: relative; border-radius: 10px; }
  .bottom-nav a.on { color: var(--accent); }
  .bottom-nav .task-badge { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; min-width: 16px; height: 16px; font-size: 10px; }
  main { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  .uploads { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  .frow { padding: 10px 12px; }
  .check input { width: 22px; height: 22px; }
  input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], input[type=url], select, textarea { font-size: 16px; }
  .fgrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .modal { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .modal-bg { align-items: end; padding: 0; }
  .modal { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; }
  .zoombox { height: 60vh; }
  .chat { max-height: 52vh; }
  #toasts { left: 16px; right: 16px; top: calc(10px + env(safe-area-inset-top)); }
  .toast { max-width: none; }
  .mobile-top { padding-top: calc(10px + env(safe-area-inset-top)); }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs a { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* телефон: ничего не вылезает по ширине */
.shell > div { min-width: 0; }
@media (max-width: 860px) {
  main { overflow-x: hidden; }
  .top { gap: 8px; }
  .top .right { margin-left: 0; flex-wrap: wrap; }
  .top h2 { font-size: 20px; flex: 1 1 auto; }
  .mobile-top .net { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; justify-content: flex-end; }
  .mobile-top b { white-space: nowrap; }
  .toolbar > * { max-width: 100%; }
  .toolbar select, .toolbar input[type=date] { flex: 1 1 140px; width: auto; }
  .cards { grid-template-columns: 1fr; }
  .cards.tasks { grid-template-columns: 1fr; }
  .stat b { font-size: 21px; overflow-wrap: anywhere; }
  .kv { grid-template-columns: 96px minmax(0, 1fr); }
  .tbl-wrap, .day-items { max-width: 100%; }
  details.day > summary { flex-wrap: wrap; }
  .crumbs { min-width: 0; }
  .row.wrap > .btn { flex: 0 1 auto; }
}
@media (max-width: 860px) { .toolbar .grow { flex: 1 1 100%; } }

/* 4.0.2: причина недоступности носителя */
.stor-problem{display:flex;flex-direction:column;gap:6px;margin:10px 0 2px;padding:10px 12px;border-radius:10px;background:rgba(251,191,36,.08);border:1px solid rgba(251,191,36,.25);font-size:14px}
.stor-problem .btn{align-self:flex-start}

/* ───────── 4.0.2 ───────── */
/* тумблеры: строка-карточка ≥ 56 px, подпись слева, переключатель 52×32 справа, вся строка кликабельна */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px;
  padding: 10px 14px; background: var(--card2); border-radius: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.toggle-row.small { min-height: 48px; padding: 8px 12px; }
.toggle-row.disabled { cursor: default; opacity: .62; }
.toggle-row:focus-within { outline: 2px solid var(--accent2); outline-offset: 2px; }
.tr-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tr-label { overflow-wrap: anywhere; }
.tr-hint { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.tr-badge { margin-left: 6px; font-size: 11px; vertical-align: 1px; }
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; margin: 0; border-radius: 16px;
  border: 2px solid #64748B; background: #1E293B; position: relative; cursor: pointer; transition: background .15s, border-color .15s; }
input.switch::before { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #94A3B8; transition: left .15s, background .15s; }
input.switch:checked { background: #16A34A; border-color: #16A34A; }
input.switch:checked::before { left: 23px; background: #fff; }
input.switch:checked::after { content: ""; position: absolute; left: 9px; top: 8px; width: 8px; height: 5px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg); }
input.switch:disabled { cursor: default; }
input.switch:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
:root[data-theme="light"] input.switch:not(:checked) { background: #E2E8F0; border-color: #64748B; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) input.switch:not(:checked) { background: #E2E8F0; border-color: #64748B; } }
.toggle-group { display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; }
.toggle-group > .toggle-row { border-radius: 0; }
.toggle-group > .toggle-row + .toggle-row { border-top: 1px solid var(--line); }
.settings-card .setting + .setting { margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { input.switch, input.switch::before { transition: none; } }

/* фото: ячейка строго квадратная; превью не меняет высоту; нажатие — по всей ячейке и только по ней */
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px; }
.ph-cell { position: relative; display: block; width: 100%; aspect-ratio: 1; min-height: 0; padding: 0; border: 0; margin: 0;
  overflow: hidden; border-radius: 8px; background: var(--card2); cursor: pointer; contain: layout paint; -webkit-tap-highlight-color: transparent; }
.ph-cell > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; display: block; }
.ph-cell > .ph-icon { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); pointer-events: none; }
.ph-cell > .badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 1px 7px;
  border-radius: 8px; pointer-events: none; }
.ph-cell:focus-visible { outline: 3px solid var(--accent2); outline-offset: -3px; }
@media (hover: hover) { .ph-cell:hover > img { transform: scale(1.03); transition: transform .2s; } }
@media (max-width: 600px) { .ph-grid { grid-template-columns: repeat(3, 1fr); gap: 2px; } .ph-cell { border-radius: 0; } }

/* профиль */
.profile-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-avatar { width: 112px; flex: none; }
.quota-ring { display: grid; justify-items: center; gap: 4px; }
.ring svg { display: block; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent2); stroke-width: 10; stroke-linecap: round; }
.ring-fg.warn { stroke: var(--warn); } .ring-fg.err { stroke: var(--err); }
.ring-t { fill: var(--text); font-size: 18px; font-weight: 700; }
.mascot-card { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.mascot-preview { width: 220px; max-width: 100%; border-radius: 12px; background: linear-gradient(#0B1426, #122B4D); flex: none; }
.mascot-card .fld { margin-bottom: 10px; }
.perm-list li { padding: 3px 0; }
.ok-text { color: var(--ok); font-weight: 700; }

/* обзор и защита */
.hero-status { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0; }
.hero-status canvas { width: 110px; flex: none; }
.hero-toggle { min-width: 260px; flex: 1 1 260px; }
.err-alert { border-color: rgba(248,113,113,.45) !important; background: rgba(248,113,113,.1) !important; }
.guard-card { display: grid; gap: 6px; margin: 12px 0; }
.g-row { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-top: 1px solid var(--line); }
.warn-text { color: var(--warn); }

/* пользователи */
.bulk-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; margin: 8px 0;
  background: var(--card); border: 1px solid var(--accent2); border-radius: 12px; }
.row-cb { width: 20px; height: 20px; accent-color: var(--accent2); }
.users-t td:first-child { width: 32px; }
.perm-group { margin: 12px 0; }
.perm-group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.perms-editor { max-height: 65vh; overflow: auto; }
.profile-card { display: grid; gap: 4px; }
.invite-code { font-size: 30px; letter-spacing: 4px; margin: 6px 0 12px; }
.token-box { white-space: pre-wrap; word-break: break-all; background: var(--bg2); padding: 10px 12px; border-radius: 10px; user-select: all; }
tr.dim td { opacity: .55; }
.ring-t.small { font-size: 26px; }
.profile-hero > .grow { flex: 1 1 200px; min-width: 0; }
.quota-ring { flex: 0 0 auto; margin-left: auto; max-width: 160px; }
@media (max-width: 600px) { .profile-avatar { width: 88px; } .quota-ring { margin: 0 auto; } }

/* 4.0.2: аватарки */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; background: var(--card, #13223d); }
.avatar-letter { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; line-height: 1; }
.avatar-wrap { position: relative; flex: none; }
.avatar-wrap img.profile-avatar { width: 112px; height: 112px; border-radius: 28px; }
.avatar-edit { position: absolute; right: -6px; bottom: -6px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent, #38bdf8); color: #0b1426; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.avatar-edit .i { width: 20px; height: 20px; }
.foot-avatar { display: inline-flex; margin-right: 10px; }
.avatar-crop { display: grid; gap: 8px; }
.avatar-crop-box { width: min(280px, 70vw); aspect-ratio: 1; margin: 0 auto 8px; border-radius: 50%; overflow: hidden; background: #0b1426; }
.avatar-crop-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-pick { max-height: 60vh; overflow: auto; }
.avatar-pick .ph-cell { border: 0; padding: 0; cursor: pointer; }
@media (max-width: 600px) { .avatar-wrap img.profile-avatar { width: 88px; height: 88px; border-radius: 22px; } }

/* 4.0.2: обновления в 3 шага, модули */
.how-it-works { display: grid; gap: 4px; font-size: 14px; }
.upd-steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 14px 0; }
.upd-step .step-n { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent, #38bdf8); color: #0b1426; font-weight: 700; margin-right: 10px; flex: none; }
.upd-item { border-top: 1px solid var(--line, #22385c); padding: 10px 0; display: grid; gap: 6px; }
.upd-item:first-child { border-top: 0; }
.dropzone { margin-top: 10px; border: 2px dashed var(--line, #22385c); border-radius: 14px; padding: 18px; display: grid; justify-items: center;
  gap: 4px; text-align: center; cursor: pointer; }
.dropzone.over, .dropzone:hover, .dropzone:focus-visible { border-color: var(--accent, #38bdf8); background: rgba(56, 189, 248, .06); }
.upd-steps { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.upd-steps li { display: flex; align-items: center; gap: 10px; color: var(--muted, #8da2bf); }
.upd-steps li .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; flex: none; }
.upd-steps li.ok { color: var(--ok, #4ade80); } .upd-steps li.ok .dot { background: currentColor; }
.upd-steps li.now { color: var(--fg, #e2e8f0); font-weight: 600; } .upd-steps li.now .dot { border-color: var(--accent, #38bdf8); animation: pulse 1s infinite; }
.upd-steps.static li { color: var(--fg, #e2e8f0); }
.upd-flow { display: grid; justify-items: center; gap: 8px; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .upd-steps li.now .dot { animation: none; } }
.module-cards .card .toggle-row { flex: 1 1 160px; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent, #38bdf8);
  color: #0b1426; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* 4.0.2 §14: здоровье данных */
.wide-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.wide-cards .card p { margin: 6px 0; }
.row.wrap { flex-wrap: wrap; }
.kv.kv-wide { grid-template-columns: minmax(0, 190px) minmax(0, 1fr); }
.bar.good i { background: var(--ok); }
.issue-list { display: grid; gap: 8px; margin-top: 10px; }
.issue { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 12px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--err, #F87171) 45%, transparent); background: color-mix(in srgb, var(--err, #F87171) 8%, transparent); }
.weekly-pre { white-space: pre-wrap; font: 13px/1.5 var(--mono, ui-monospace, monospace); background: var(--bg2, rgba(127,127,127,.08)); padding: 10px 12px; border-radius: 10px; margin-top: 10px; max-height: 360px; overflow: auto; }

/* 4.0.3: лимиты, общие папки, семья, профили */
.limits-ed { display: grid; gap: 10px; }
.limit-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.limit-row select { max-width: 100%; }
.chips-pick .chip { cursor: pointer; padding: 4px 12px; font-size: 13px; min-height: 32px; }
.chips-pick .chip.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.perms-editor h4 { margin: 18px 0 6px; }
.profile-card.is-hidden { opacity: .65; }
.space-card { display: grid; gap: 4px; text-decoration: none; color: inherit; }
.space-card:hover { border-color: var(--accent2); }
.frow.sp { grid-template-columns: 44px 1fr 110px 150px 40px; }
.family-card { display: grid; gap: 6px; }
.fam-member { display: flex; gap: 10px; align-items: center; }
.kid-card .btn.small { min-height: 36px; }
details.card summary { cursor: pointer; display: flex; gap: 6px; align-items: center; min-height: 32px; }
@media (max-width: 860px) {
  .frow.sp { grid-template-columns: 44px 1fr 40px; }
  .frow.sp .size, .frow.sp .date { display: none; }
}
.cards.wide-cards { grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
.cards.kids { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
