/* Ray AI — интерфейс для Ray-Ban Meta Display (≈600×600).
   Чёрный фон на дисплее очков выглядит прозрачным, поэтому основа — чёрная,
   элементы — контрастные, фокус — яркий жёлтый. */
:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #101016;
  --key: #1d1e26;
  --line: #3a3b47;
  --text: #fff;
  --muted: #a5a6b2;
  --accent: #3d8bff;
  --focus: #ffd60a;
  --ok: #34c759;
  --err: #ff6b6b;
  --ans-size: 24px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; user-select: none; }

#app {
  position: relative;
  width: 100%; max-width: 640px;
  height: 100dvh; max-height: 640px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px;
}

button {
  font: inherit; font-weight: 650; color: var(--text);
  background: var(--key); border: 2px solid var(--line); border-radius: 14px;
  cursor: pointer; padding: 0 10px; min-height: 48px;
  transition: transform .08s, background .08s;
}
button:disabled { opacity: .35; cursor: default; }
button:focus { outline: none; }
button.is-focused {
  background: var(--focus); color: #000; border-color: #fff;
  /* масштаб и точку роста у края экрана подбирает fitFocus() в app.js */
  transform: scale(var(--focus-scale, 1.05)); transform-origin: var(--focus-origin, center); position: relative; z-index: 2;
  box-shadow: 0 0 0 3px rgba(255, 214, 10, .45);
}
.dim { opacity: .4; }
[hidden] { display: none !important; }
/* Свайпы обрабатывает приложение; прокручивается только текст ответа. */
.bar, .inputrow, .kbd, .controls, .photo-body, .settings { touch-action: none; }

/* Верхняя панель */
.bar { display: flex; align-items: center; gap: 8px; height: 48px; flex: none; border-radius: 12px; }
.brand { font-size: 22px; font-weight: 800; letter-spacing: .02em; }
.chip { font-size: 16px; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; }
.chip-photo { color: var(--ok); border-color: var(--ok); }
button.chip { min-height: 0; height: 40px; padding: 0 14px; font-size: 16px; font-weight: 600; border-radius: 999px; }
.chip-net.on { color: var(--ok); }
.chip-net.off { color: var(--err); border-color: var(--err); }
.chip-net.is-focused { color: #000; border-color: #fff; }
.spacer { flex: 1; }
.icon { width: 52px; font-size: 26px; padding: 0; }

/* Экраны */
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; gap: 8px; }
.screen.active { display: flex; }

/* Ввод */
.inputrow { display: flex; gap: 8px; height: 76px; flex: none; border-radius: 14px; }
.field {
  flex: 1; min-width: 0; overflow: hidden;
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
  padding: 6px 12px; font-size: 24px; line-height: 30px;
  white-space: pre-wrap; word-break: break-word;
}
.placeholder { color: var(--muted); }
.caret { display: inline-block; width: 3px; height: 26px; margin-left: 1px; vertical-align: -5px; background: var(--focus); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.side { flex: none; min-width: 86px; font-size: 19px; }
#btnPhoto.attached { border-color: var(--ok); color: var(--ok); }
#btnPhoto.attached.is-focused { color: #000; }
.counter { flex: none; text-align: right; font-size: 15px; color: var(--muted); margin-top: -4px; }
.counter.warn { color: var(--err); }

.kbd { flex: 1; min-height: 0; display: grid; grid-auto-rows: 1fr; gap: 6px; }
.krow { display: flex; gap: 5px; min-height: 0; border-radius: 12px; }
.key { flex: 1 1 0; min-width: 0; min-height: 0; padding: 0; font-size: 26px; font-weight: 600; }
.kbd.shift .k-char { text-transform: uppercase; }
.ctrl .key { font-size: 19px; flex-grow: 1.25; }
.ctrl .k-space, .ctrl .k-send { flex-grow: 2.6; }
.ctrl .k-bs { font-size: 26px; }
.k-send { background: var(--accent); border-color: var(--accent); }
.kbd.shift .k-shift { border-color: var(--focus); color: var(--focus); }
.kbd.shift .k-shift.is-focused { color: #000; }

/* Ответ */
.question { flex: none; font-size: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.answer-wrap { position: relative; flex: 1; min-height: 0; display: flex; gap: 6px; }
.answer {
  flex: 1; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain;
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 16px; font-size: var(--ans-size); line-height: 1.45;
  white-space: pre-wrap; word-break: break-word; user-select: text;
}
.answer::-webkit-scrollbar { display: none; }
.answer.loading { color: var(--muted); }
.answer.error { color: var(--err); }
.track { width: 8px; border-radius: 4px; background: #24252e; position: relative; }
.thumb { position: absolute; left: 0; right: 0; top: 0; height: 100%; border-radius: 4px; background: var(--accent); }
.more { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); font-size: 16px; padding: 3px 12px; border-radius: 999px; background: var(--accent); pointer-events: none; }

.controls { display: flex; gap: 8px; height: 76px; flex: none; border-radius: 14px; }
.controls button { flex: 1; font-size: 22px; }
.controls button.wide { flex: 2; }
.controls button.retry { flex: 2; background: var(--accent); border-color: var(--accent); }
.controls button.retry.is-focused { background: var(--focus); border-color: #fff; }

/* Фото */
.photo-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.pair { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.hint { font-size: 20px; color: var(--muted); }
.url { font-size: 22px; font-weight: 700; color: var(--accent); word-break: break-all; }
.pcode { font: 800 64px/1 ui-monospace, Consolas, monospace; letter-spacing: .08em; margin-top: 4px; white-space: nowrap; } /* 8 символов + дефис */
.pstatus { font-size: 18px; color: var(--ok); }
.pstatus.off { color: var(--err); }
.pstatus.wait { color: var(--muted); }
.pcode.off { opacity: .35; }
.photo-body.with-photo .pstatus { font-size: 16px; }
.have { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 0; }
.have img { max-width: 100%; max-height: 150px; border-radius: 12px; border: 2px solid var(--ok); }
.pinfo { font-size: 18px; color: var(--ok); }
.photo-body.with-photo .pcode { font-size: 40px; }
.photo-body.with-photo .hint, .photo-body.with-photo .url { font-size: 17px; }

/* Настройки */
.settings { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.srow { display: flex; align-items: center; gap: 10px; font-size: 21px; padding: 4px 6px; border-radius: 14px; }
.srow > span { flex: 1; }
.srow button { min-width: 170px; height: 62px; font-size: 21px; }
.srow button.small { min-width: 84px; }
.help { margin: 4px 6px 0; font-size: 17px; line-height: 1.4; color: var(--muted); }

/* Вход */
.login-title { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.lcode { font-size: 80px; letter-spacing: .08em; }
.keyfield { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .06em; line-height: 60px; }
.keyfield .placeholder { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 400; letter-spacing: 0; }

/* Автосканирование: подсветка группы */
.scan-group { outline: 4px solid var(--accent); outline-offset: 3px; }
body.scan-on #app::after {
  content: "АВТО"; position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 800; padding: 2px 8px; border-radius: 6px; background: var(--accent);
}

/* Уведомления — поверх верхней панели (высота 48px), чтобы не закрывать первую строку экрана.
   width: max-content — короткий текст в одну строку (left: 50% иначе сужал блок вдвое). */
.toast {
  position: absolute; left: 50%; top: 10px; transform: translate(-50%, -12px);
  width: max-content; max-width: 92%; padding: 8px 18px; border-radius: 14px; line-height: 1.2;
  background: #fff; color: #000; font-size: 20px; font-weight: 650; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Очень маленькая высота */
@media (max-height: 480px) {
  .inputrow, .controls { height: 60px; }
  .key { font-size: 21px; }
  .field { font-size: 20px; line-height: 24px; }
  .pcode { font-size: 52px; }
}
