/* HiDrive — один файл стилей. Мобильный экран первичен: сервисом чаще всего
   пользуются с телефона одной рукой. */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #17181c;
  --muted: #6b7280;
  --line: #e4e6eb;
  --line-strong: #c9cdd6;
  --accent: #2f6df6;
  --accent-soft: rgba(47, 109, 246, 0.10);
  --danger: #d64545;
  --ok: #2c9a5b;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.04), 0 6px 20px rgba(20, 24, 40, 0.06);
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --text: #e7e9ee;
    --muted: #8a93a5;
    --line: #262b36;
    --line-strong: #353c4a;
    --accent: #5b8cff;
    --accent-soft: rgba(91, 140, 255, 0.14);
    --danger: #ef6b6b;
    --ok: #4fc57f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
svg { width: 22px; height: 22px; flex: none; }
/* Спрайт иконок: только <symbol>, сам ничего не рисует и места не занимает.
   Класс, а не style="…": CSP страницы запрещает inline-стили. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* --- шапка ---------------------------------------------------------------- */
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px 6px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 650; font-size: 18px; letter-spacing: -0.01em;
  text-decoration: none; color: var(--text);
}
.brand .logo { width: 26px; height: 26px; color: var(--accent); }
.session-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.session-actions form { margin: 0; }
.session-actions .ghost { padding: 7px 11px; font-size: 14px; }
.subline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 760px; margin: 0 auto; padding: 0 16px 6px;
  font-size: 12.5px; color: var(--muted);
}
.session { white-space: nowrap; }
.session.guest { border: 1px dashed var(--line-strong); border-radius: 999px; padding: 2px 9px; }
.usage { display: flex; align-items: center; gap: 10px; min-width: 0; }
.usage-bar {
  width: 88px; height: 6px; border-radius: 4px;
  background: var(--line); overflow: hidden;
}
/* Заполнение — через transform, а не width: не трогает layout, анимируется на композиторе. */
.usage-bar i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: var(--accent); transition: transform .4s ease; }
.usage-bar i.warn { background: var(--danger); }
.usage-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .usage-bar { display: none; } .session-actions .ghost svg { display: none; } }

/* --- общие элементы ------------------------------------------------------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; display: grid; gap: 16px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted);
  text-decoration: none; transition: background .15s, color .15s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.icon-btn.danger:hover, .icon-btn.danger:focus-visible { background: rgba(214, 69, 69, 0.12); color: var(--danger); }
.primary {
  border: 0; border-radius: 10px; padding: 10px 18px;
  background: var(--accent); color: #fff; font-weight: 600;
  transition: filter .15s, transform .05s;
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .6; cursor: default; }
.ghost {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px;
  background: transparent; color: var(--text);
}
.ghost svg { width: 18px; height: 18px; color: var(--muted); }
.ghost[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* --- зона загрузки -------------------------------------------------------- */
.drop {
  position: relative;
  display: grid; justify-items: center; gap: 4px;
  padding: 26px 16px 22px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-within, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-ico { width: 34px; height: 34px; color: var(--accent); margin-bottom: 4px; }
.drop-title { font-weight: 600; font-size: 16px; }
.drop-hint { font-size: 12.5px; color: var(--muted); }
@media (hover: none) { .drop-hint { display: none; } .drop { padding: 22px 16px 20px; } }

.options { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.opt { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.opt select {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 10px;
  background: var(--card); color: var(--text);
}

.text-form { display: grid; gap: 10px; }
.text-form textarea {
  width: 100%; resize: vertical; min-height: 84px;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px;
  background: var(--bg); color: var(--text);
}
.text-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.text-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.text-hint { font-size: 12.5px; color: var(--muted); }

/* --- очередь загрузок ------------------------------------------------------ */
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.queue:empty { display: none; }
.qrow { display: grid; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.q-head { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.q-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.q-status { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.qrow.error .q-status { color: var(--danger); }
.q-cancel { width: 30px; height: 30px; }
.q-cancel svg { width: 16px; height: 16px; }
.q-bar { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; }
.q-bar i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: var(--accent); transition: transform .2s linear; }
.qrow.error .q-bar i { background: var(--danger); }

/* --- список ---------------------------------------------------------------- */
.files { display: grid; gap: 8px; }
.empty { margin: 30px 0; text-align: center; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 8px 10px 14px;
  box-shadow: var(--shadow);
}
.row.fresh { animation: pop .35s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.row-ico { width: 26px; height: 26px; color: var(--muted); }
.row.kind-text .row-ico, .row.cat-image .row-ico { color: var(--accent); }
.row-body { min-width: 0; display: grid; gap: 3px; }
.row-name {
  font-weight: 550; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-name[href]:hover { text-decoration: underline; }
.row-rename {
  width: 100%; padding: 4px 8px; font-weight: 550;
  border: 1px solid var(--accent); border-radius: 8px;
  background: var(--bg); color: var(--text); outline: none;
}
.row-text {
  margin: 0; padding: 8px 10px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg); border-radius: 8px;
  white-space: pre-wrap; word-break: break-word;
  max-height: 7.5em; overflow: auto;
}
.row-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-meta .soon { color: var(--danger); }
.row-actions { display: flex; align-items: center; }
@media (max-width: 520px) {
  .row { grid-template-columns: auto 1fr; padding: 12px 12px 6px 14px; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: -2px; }
}

/* --- уведомление ------------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 10;
  animation: rise .2s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* --- вход ----------------------------------------------------------------- */
.login-body { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 340px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 28px 24px 24px;
  display: grid; gap: 18px;
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; font-size: 20px; }
.login-brand .logo { width: 28px; height: 28px; color: var(--accent); }
.login-card form { display: grid; gap: 10px; }
.login-label { font-size: 13px; color: var(--muted); }
.login-input {
  width: 100%; padding: 12px 14px; font-size: 20px; letter-spacing: .12em; text-align: center;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--text);
}
.login-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-input[aria-invalid="true"] { border-color: var(--danger); }
.login-guest { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; margin-top: 2px; }
.login-guest input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.login-guest small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.4; color: var(--muted); }
.login-error { margin: 0; font-size: 13.5px; color: var(--danger); text-align: center; }
.login-notice { margin: 0; font-size: 13.5px; color: var(--ok); text-align: center; }
.login-btn { padding: 12px 18px; margin-top: 4px; }
