/* Обменник. Шрифт системный — без загрузки веб-гарнитуры, как и в планере.
   Все цвета — в переменных; тёмная тема включается по настройке системы. */

:root {
  --canvas: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --ink: #14171c;
  --ink-2: #555d69;
  --ink-3: #868d98;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #e7eefd;
  --accent-ring: rgba(37, 99, 235, 0.18);
  --danger: #d23b3b;
  --danger-soft: #fdeaea;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 6px rgba(16, 24, 40, 0.04);
  --radius: 14px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  --k-doc: #2b6cd9;
  --k-xls: #1d8a4b;
  --k-pdf: #d03a3a;
  --k-ppt: #d6612a;
  --k-zip: #a8730f;
  --k-media: #7c4ddb;
  --k-img: #0d8f87;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0f1115;
    --surface: #171a20;
    --surface-2: #20242c;
    --ink: #e9ebef;
    --ink-2: #a5acb7;
    --ink-3: #737b87;
    --line: #272c35;
    --accent: #5b8cff;
    --accent-ink: #0b1020;
    --accent-soft: #1b2643;
    --accent-ring: rgba(91, 140, 255, 0.25);
    --danger: #f06a6a;
    --danger-soft: #3a1b1d;
    --ok: #3ccf7a;
    --shadow: none;

    --k-doc: #6d9eff;
    --k-xls: #4cc584;
    --k-pdf: #ff7a7a;
    --k-ppt: #ff9a63;
    --k-zip: #e0b04b;
    --k-media: #b195ff;
    --k-img: #42c9c0;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
svg { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.ink { color: var(--ink); font-weight: 600; }
.err { color: var(--danger); font-size: 13.5px; min-height: 1.2em; margin: 10px 0 0; }
.err:empty { margin: 0; min-height: 0; }

/* ── Кнопки и поля ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px;
  border: 1px solid transparent; background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 550; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: var(--line); }
.btn.danger-ghost.confirm { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 18px; height: 44px; font-size: 15px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.input {
  display: block; width: 100%; height: 44px; padding: 0 12px; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--canvas); color: var(--ink);
  font: inherit; font-size: 16px; /* 16px — иначе iPhone приближает страницу при фокусе */
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.chip {
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: 13.5px; white-space: nowrap; cursor: pointer;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip b { font-weight: 500; opacity: 0.6; margin-left: 5px; }
.chip b:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ── Вход ────────────────────────────────────────────────────────────────── */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(390px, 100%); padding: 28px 24px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.login-card .muted { margin: 6px 0 4px; font-size: 14px; }
.login-card .muted.small { margin-top: 16px; font-size: 12.5px; }
.card-title { margin: 18px 0 0; font-size: 20px; letter-spacing: -0.01em; }
.input[readonly] { color: var(--ink-2); }
.field { display: block; margin-top: 16px; font-size: 13.5px; color: var(--ink-2); }

.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--accent) url("icon-arrows.svg") center / 18px no-repeat;
}

/* ── Шапка, поле ввода, очередь ──────────────────────────────────────────── */

.wrap { max-width: 760px; margin: 0 auto; padding: 14px 16px 96px; }
.top { display: flex; align-items: center; gap: 10px; padding: 4px 0 14px; }
.me { margin-left: auto; color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offline {
  margin-left: auto; padding: 3px 9px; border-radius: 999px;
  background: var(--danger-soft); color: var(--danger); font-size: 12.5px; font-weight: 550;
}
.offline:not([hidden]) + .me { margin-left: 0; }

.composer {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.composer textarea {
  display: block; width: 100%; min-height: 64px; max-height: 45vh; padding: 14px 14px 6px;
  border: 0; outline: none; resize: none; background: transparent; color: inherit;
  font: inherit; font-size: 15.5px; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--ink-3); }
.cbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; }
.hint { flex: 1; min-width: 0; color: var(--ink-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd { font: inherit; font-size: 11.5px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink-2); }

.queue { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.queue:empty { display: none; }
.job {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 9px 6px 11px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  animation: enter .25s var(--ease-out);
}
.job-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.job-stat { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.job .icon-btn { width: 30px; height: 30px; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-2); }
.bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .25s linear; }
.job[data-state="done"] .bar i { background: var(--ok); }
.job[data-state="done"] .job-stat { color: var(--ok); }
.job[data-state="error"] { border-color: var(--danger-soft); }
.job[data-state="error"] .job-stat { color: var(--danger); white-space: normal; text-align: right; }
.job[data-state="error"] .bar { display: none; }

/* ── Фильтры и лента ─────────────────────────────────────────────────────── */

.toolbar { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.filters { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.zip { flex: none; color: var(--accent); }
.zip .short { display: none; }
.filters::-webkit-scrollbar { display: none; }

.feed { display: flex; flex-direction: column; gap: 8px; }
.day { margin: 18px 4px 0; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.empty { margin: 48px 16px; text-align: center; color: var(--ink-3); line-height: 1.6; }

.card {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.enter { animation: enter .3s var(--ease-out); }
.card.fresh::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  border: 2px solid var(--accent); opacity: 0; animation: fresh 2.6s ease-out;
}
@keyframes enter { from { opacity: 0; transform: translateY(-6px); } }
@keyframes fresh { 0%, 30% { opacity: 1; } 100% { opacity: 0; } }

.card.file, .card.image { display: flex; align-items: center; gap: 12px; padding: 9px 8px 9px 9px; }
.thumb {
  flex: none; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); cursor: pointer;
  text-decoration: none;
}
.card.image .thumb { width: 84px; height: 84px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ext { font-size: 11px; font-weight: 750; letter-spacing: 0.03em; color: var(--ink-2); }
.ext.k-doc { color: var(--k-doc); }
.ext.k-xls { color: var(--k-xls); }
.ext.k-pdf { color: var(--k-pdf); }
.ext.k-ppt { color: var(--k-ppt); }
.ext.k-zip { color: var(--k-zip); }
.ext.k-media { color: var(--k-media); }
.ext.k-img { color: var(--k-img); }

.info { flex: 1; min-width: 0; }
.name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; gap: 0 6px; min-width: 0; margin-top: 2px; color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.meta > span { flex: none; }
.meta > span + span::before { content: "·"; margin-right: 6px; }
/* Длинное имя устройства сокращается, а время и размер остаются на виду. */
.meta > .dev { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dev.other { color: var(--accent); }
.ttl.soon { color: var(--danger); }

.actions { display: flex; gap: 2px; flex: none; }
.act {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13.5px; font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.act:hover { background: var(--surface-2); color: var(--ink); }
.act.primary { background: var(--accent-soft); color: var(--accent); }
.act.primary:hover { background: var(--accent-soft); color: var(--accent); filter: brightness(0.97); }
.act.done { color: var(--ok); }
.act.del span { display: none; }
.act.del.confirm { background: var(--danger-soft); color: var(--danger); }
.act.del.confirm span { display: inline; }

.card.note { padding: 12px 8px 6px 14px; }
.note-body {
  padding-right: 6px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 15px; line-height: 1.5;
}
.note-body.clamped {
  max-height: 12em; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 65%, transparent);
  mask-image: linear-gradient(#000 65%, transparent);
}
.more { border: 0; background: none; padding: 4px 0; color: var(--accent); font: inherit; font-size: 13.5px; cursor: pointer; }
.foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.foot .meta { flex: 1; margin: 0; }

/* ── Перетаскивание ──────────────────────────────────────────────────────── */

.dropzone {
  position: fixed; inset: 0; z-index: 50; padding: 16px;
  background: color-mix(in srgb, var(--canvas) 85%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.dropzone > div {
  pointer-events: none; height: 100%; display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: 20px;
  color: var(--accent); font-size: 20px; font-weight: 600;
}

/* ── Просмотр фото ───────────────────────────────────────────────────────── */

.viewer {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: transparent; color: #fff; overflow: hidden;
}
.viewer::backdrop { background: rgba(5, 6, 8, 0.9); }
.viewer .stage { position: absolute; inset: 0 0 68px; display: grid; place-items: center; padding: 16px 64px; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.vbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 68px;
  display: flex; align-items: center; gap: 8px; padding: 0 16px calc(env(safe-area-inset-bottom) / 2);
}
.vname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; opacity: 0.85; }
.btn.on-dark { color: rgba(255, 255, 255, 0.85); }
.btn.on-dark:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.vnav {
  position: absolute; top: calc(50% - 56px); width: 44px; height: 44px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.12); color: #fff; cursor: pointer;
}
.vnav:hover { background: rgba(255, 255, 255, 0.22); }
.vnav:disabled { opacity: 0; pointer-events: none; }
.vnav.prev { left: 12px; }
.vnav.next { right: 12px; }

/* ── Настройки ───────────────────────────────────────────────────────────── */

.sheet {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0;
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.sheet[open] { animation: enter .22s var(--ease-out); }
.sheet::backdrop { background: rgba(10, 12, 16, 0.45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 4px 20px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sec { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.sec h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.sec p { margin: 0 0 10px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { margin: 0; }
.inline-form .btn { height: 44px; }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.stack .input { margin: 0; }
.stack .btn { align-self: flex-start; }
.stack .err { margin: 0; }
.stack p.small { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list:empty { display: none; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.list li + li { border-top: 1px solid var(--line); }
#invites { margin-top: 10px; }
.s-info { flex: 1; min-width: 0; }
.s-name { font-weight: 550; overflow-wrap: anywhere; }
.s-sub { color: var(--ink-3); font-size: 12.5px; }
.row-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.tag { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tag.soft { background: var(--surface-2); color: var(--ink-2); }

.disc { margin-top: 6px; }
.disc summary { width: fit-content; padding: 4px 0; color: var(--accent); font-size: 14px; cursor: pointer; }
.disc form { margin: 8px 0 6px; }

.linkbox { margin-top: 12px; }
.linkrow { display: flex; gap: 8px; }
.linkrow .input { margin: 0; height: 40px; font-size: 13.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.linkrow .btn { height: 40px; }
.linkbox p { margin: 6px 0 0; }

.notice { width: min(420px, calc(100vw - 24px)); }
.notice-body { padding: 26px 24px 22px; text-align: center; }
.notice-body h2 { margin: 12px 0 8px; font-size: 19px; }
.notice-body p { margin: 0 0 8px; line-height: 1.5; }
.notice-icon {
  width: 48px; height: 48px; margin: 0 auto; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
}
.notice-icon::before {
  content: ""; width: 24px; height: 24px; background: currentColor;
  -webkit-mask: url("icon-clock.svg") center / contain no-repeat; mask: url("icon-clock.svg") center / contain no-repeat;
}
.sheet-foot { padding: 12px 14px 14px; }

/* ── Уведомление ─────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 60;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--canvas); font-size: 14px;
  opacity: 0; transform: translate(-50%, 14px); pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Узкие экраны ────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .hint { display: none; }
  .meta .tm { display: none; }
  .zip .long { display: none; }
  .zip .short { display: inline; }
  .zip { padding: 0 10px; }
  .list li { flex-wrap: wrap; }
  .row-actions { flex-direction: row; }
  .cbar { justify-content: space-between; }
  .act span { display: none; }
  .act { width: 38px; justify-content: center; padding: 0; }
  .act.del.confirm { width: auto; padding: 0 10px; }
  .card.image .thumb { width: 64px; height: 64px; }
  .viewer .stage { padding: 12px; }
  .vnav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
