/* qast.one — дизайн по токенам handoff (design-tokens.md).
   Тема: атрибут data-theme на <html> (light/dark), ставится скриптом
   в <head> из localStorage или prefers-color-scheme — без вспышки.
   Шрифты: MiSans (интерфейс), JetBrains Mono (URL). */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400&display=swap');

@font-face {
  font-family: "MiSans";
  src: url("https://statics.kimi.ai/neo-design-static/p-font/MiSans.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg-page: #F3F5F7;
  --surface-card: #FFFFFF;
  --surface-subtle: #EEF1F5;
  --border: #E2E7ED;
  --text-primary: #10151D;
  --text-secondary: #5A6575;
  --text-tertiary: #8B95A5;
  --accent: #2563EB;
  --accent-emphasis: #1D4ED8;
  --accent-soft: #E3EEFF;
  --on-accent: #FFFFFF;
  --wait: #D97706;
  --wait-soft: #FDF0DB;
  --wait-text: #9A5B07;
  --track: #E4E9EF;
  --danger: #DC2626;
  --shadow-card: 0 10px 30px rgba(16, 21, 29, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #0D1117;
  --surface-card: #171D29;
  --surface-subtle: #202836;
  --border: #2A3342;
  --text-primary: #EDF1F7;
  --text-secondary: #98A3B4;
  --text-tertiary: #6C7789;
  --accent: #60A5FA;
  --accent-emphasis: #60A5FA;
  --accent-soft: #16263F;
  --on-accent: #0B1220;
  --wait: #FBBF24;
  --wait-soft: #382A10;
  --wait-text: #FCD34D;
  --track: #2A3342;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: "MiSans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  transition: background 0.2s ease;
}

/* ---------- Бренд ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .wordmark {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  text-decoration: none; /* логотип — ссылка на главную */
}

.brand .wordmark .one { color: var(--accent); }

/* ---------- Каркас ---------- */

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 36px 64px 32px;
}

.screen > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.screen > main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 64px;
  padding: 24px 0;
}

.foot-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-tertiary);
}
.foot-note svg { width: 12px; height: 12px; fill: var(--text-tertiary); }

/* ---------- Анимации ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes swap {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  0%   { opacity: 0; transform: scale(0.6); }
  70%  { transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.anim-load { animation: rise 0.34s ease both; }
.anim-load-1 { animation-delay: 0.05s; }
.anim-load-2 { animation-delay: 0.12s; }
.anim-load-3 { animation-delay: 0.19s; }
.anim-swap { animation: swap 0.22s ease; }

/* ---------- Инфопанель (ПК) ---------- */

.info { max-width: 430px; display: flex; flex-direction: column; gap: 28px; }

.info h2 {
  margin: 0 0 12px;
  font-size: 34px;
  font-weight: 700;
  line-height: 40px;
}

.info .subtitle {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  color: var(--text-secondary);
}

.info ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info ol li { display: flex; align-items: center; gap: 12px; font-size: 15px; line-height: 22px; }

.step-num {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-emphasis);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Карточка ---------- */

.card {
  width: 520px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
}

.card .caption { font-size: 15px; line-height: 22px; color: var(--text-secondary); }

/* ---------- Чип статуса ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--wait-soft);
  color: var(--wait-text);
  width: fit-content;
  transition: background 0.24s ease, color 0.24s ease;
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--wait);
  transition: background 0.24s ease;
}
.chip.active { background: var(--accent-soft); color: var(--accent-emphasis); }
.chip.active .dot { background: var(--accent); }

/* ---------- QR (плашка всегда белая, в обеих темах) ---------- */

.qr-box {
  width: 340px;
  aspect-ratio: 1; /* на мобильном ширина меньше 340 — высота следует за ней */
  max-width: 100%;
  align-self: center;
  position: relative;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

/* два слоя для перекрёстного растворения при смене кода */
.qr-layer {
  position: absolute;
  inset: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.qr-layer.show { opacity: 1; }

/* width сжимается на узком экране, height следует за ней через aspect-ratio —
   иначе код растягивался по высоте */
.qr-layer img, .qr-layer canvas {
  width: 300px;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  aspect-ratio: 1;
}
.qr-layer canvas { display: block; image-rendering: pixelated; }

/* подключено: QR превращается в мозаику (даунскейл канваса в host.js) */
.qr-box.paired .qr-layer { opacity: 0.55; }

/* спиннер по центру, пока ждём подключения */
.qr-spin {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-box.paired .qr-spin { display: none; }
/* спиннер — только пока код не отрисован; после загрузки скрываем */
.qr-box.qr-loaded .qr-spin { display: none; }
.qr-spin::after {
  content: "";
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 2px 12px rgba(16, 21, 29, 0.12);
  position: absolute;
}
.qr-spin::before {
  content: "";
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  z-index: 1;
}

.qr-badge {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: var(--accent-soft);
  display: none;
  align-items: center;
  justify-content: center;
}
.qr-box.paired .qr-badge { display: flex; animation: pop 0.28s ease; }
.qr-badge svg { width: 26px; height: 26px; stroke: var(--accent-emphasis); }

/* ---------- Таймер до смены QR ---------- */

.qr-timer {
  text-align: center;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
  min-height: 16px; /* чтобы не прыгал layout при появлении текста */
}

/* ---------- Строка URL ---------- */

.urlbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  background: var(--surface-subtle);
  border-radius: 12px;
}

.urlbar .url {
  flex: 1;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-btn {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.copy-btn:hover { background: var(--surface-card); }
.copy-btn svg { width: 15px; height: 15px; fill: currentColor; }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Кнопки ---------- */

.btn {
  height: 48px;
  border-radius: 12px;
  border: 0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn.secondary { background: var(--surface-subtle); color: var(--text-primary); }
.btn.ghost { background: transparent; color: var(--accent-emphasis); }
.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); }

.actions { display: flex; gap: 12px; }
.actions[hidden] { display: none; }
.actions .btn { flex: 1; }

/* ---------- Строка файла ---------- */

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.file-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface-subtle);
  border-radius: 14px;
}

.file-item .top { display: flex; align-items: center; gap: 12px; }

.file-item .tile {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-item .tile svg { width: 15px; height: 15px; fill: var(--accent-emphasis); }

.file-item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.file-item .name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item .size { font-size: 13px; color: var(--text-secondary); }

.file-item .status-wrap { display: flex; align-items: center; gap: 6px; flex: none; }

.file-item .status { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.file-item.done .status { color: var(--accent-emphasis); }
.file-item.failed .status { color: var(--danger); }

.file-item .status-icon { display: none; width: 13px; height: 13px; stroke: var(--accent-emphasis); }
.file-item.done .status-icon { display: block; }

.file-item .track { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.file-item .bar { height: 6px; width: 0; border-radius: 3px; background: var(--accent); transition: width 0.2s ease; }

.file-item .remove {
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 18px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}
.file-item .remove:hover { background: var(--surface-card); color: var(--text-primary); }

/* ---------- Мобильная страница ---------- */

.screen-mobile {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 20px 24px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.screen-mobile > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.screen-mobile .content { flex: 1; display: flex; flex-direction: column; gap: 14px; justify-content: center; }

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.status-tile {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 999px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-tile svg { width: 15px; height: 15px; stroke: var(--accent-emphasis); }

.status-text { font-size: 15px; line-height: 22px; }

.pick-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.pick-card.dimmed { opacity: 0.5; pointer-events: none; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 26px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone svg { width: 22px; height: 22px; fill: var(--accent-emphasis); }
.dropzone .dz-title { font-size: 15px; font-weight: 600; }
.dropzone .dz-caption { font-size: 13px; color: var(--text-tertiary); }

/* ---------- Переключатель языка ---------- */

.lang-toggle {
  display: inline-flex;
  align-items: center;
  height: 34px; /* как у theme-toggle */
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
}
.lang-toggle:hover { color: var(--text-primary); }

/* переключатель темы: солнце/луна меняются по data-theme на <html> */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Версия сборки: еле заметная, по центру внизу ---------- */

.version-badge {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  line-height: 1;
  color: var(--text-tertiary); /* подстраивается под тему */
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
  z-index: 5;
}

/* ---------- Иконка статуса (мобильная страница) ---------- */

.status-tile svg { display: none; }
.status-card[data-icon="link"] .status-tile .i-link { display: block; }
.status-card[data-icon="up"] .status-tile .i-up { display: block; }
.status-card[data-icon="check"] .status-tile .i-check { display: block; }
.status-card[data-icon="warn"] .status-tile .i-warn { display: block; }

.divider { height: 1px; background: var(--border); }

/* ---------- Адаптив ---------- */

@media (max-width: 960px) {
  .screen { padding: 24px 20px; }
  .screen > main { flex-direction: column; gap: 28px; align-items: stretch; }
  .info { max-width: 100%; }
  .info h2 { font-size: 26px; line-height: 32px; }
  .card { width: 100%; }
  .foot-note.side { justify-content: flex-start; }
}
