/* Мобильный интерфейс: тёмный, крупный, под большой палец.
   Расчёт на чтение в дороге - контраст выше обычного, шрифт не мельче 15px. */

:root {
  --bg: #191917;
  --panel: #21211f;
  --panel-2: #2a2a27;
  --line: #3a3a36;
  --text: #f0efea;
  --dim: #9c9a92;
  --accent: #d97757;
  --accent-dim: #7a4433;
  --ok: #6cae75;
  --danger: #d9605c;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── Вход ─────────────────────────────────────────── */
.login { align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; }
.brand { font-size: 20px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.hint { color: var(--dim); font-size: 14px; margin: 0 0 20px; }
.pw-row { display: flex; gap: 8px; margin-bottom: 12px; }
.pw-row input {
  flex: 1; padding: 15px 14px; font-size: 17px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.eye {
  width: 52px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); font-size: 20px; cursor: pointer;
}
.primary {
  width: 100%; padding: 15px; font-size: 17px; font-weight: 600; border: 0;
  border-radius: 12px; background: var(--accent); color: #1a1008; cursor: pointer;
}
.primary:active { transform: scale(0.99); }
.err { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* ── Шапка ────────────────────────────────────────── */
.top {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line); background: var(--panel); flex: 0 0 auto;
}
.top .title { flex: 1; font-weight: 600; font-size: 17px; min-width: 0; }
.top .title > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: 12px; color: var(--dim); font-weight: 400; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  padding: 9px 13px; border-radius: 10px; font-size: 15px; cursor: pointer;
}
.ghost.danger { border-color: var(--danger); color: var(--danger); }
#back-btn { font-size: 22px; line-height: 1; padding: 6px 14px; }

/* ── Выбор проекта ────────────────────────────────── */
.picker { padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.picker select {
  width: 100%; padding: 12px; font-size: 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}

/* ── Список диалогов ──────────────────────────────── */
.sessions { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--safe-b); }
.item { padding: 15px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:active { background: var(--panel); }
.item .t { font-size: 15px; margin-bottom: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .m { font-size: 12px; color: var(--dim); }
.empty { padding: 40px 20px; text-align: center; color: var(--dim); }

/* ── Лента чата ───────────────────────────────────── */
.feed { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px; }
.msg { margin-bottom: 14px; max-width: 92%; }
.msg.user { margin-left: auto; background: var(--accent-dim); border-radius: 14px 14px 4px 14px; padding: 11px 13px; }
.msg.assistant { background: var(--panel); border-radius: 14px 14px 14px 4px; padding: 11px 13px; }
.msg.system { text-align: center; color: var(--dim); font-size: 12px; max-width: 100%; }
.msg pre {
  background: #131311; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; overflow-x: auto; font-size: 13px; margin: 8px 0;
}
.msg code { background: #131311; padding: 1px 5px; border-radius: 4px; font-size: 13.5px; }
.msg pre code { background: none; padding: 0; }
.msg p { margin: 6px 0; }
.msg p:first-child { margin-top: 0; }
.msg p:last-child { margin-bottom: 0; }

/* Вызов инструмента - служебная строка, не мешает читать разговор */
.tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  color: var(--dim); padding: 7px 10px; margin-bottom: 8px;
  background: var(--panel); border-left: 2px solid var(--line); border-radius: 0 6px 6px 0;
  white-space: pre-wrap; word-break: break-all;
}
.tool b { color: var(--accent); font-weight: 600; }
/* ── Индикатор работы ─────────────────────────────
   Задача - доказать, что процесс жив: пульс и бегущие точки идут всё время,
   пока Claude работает. Статичный текст этого не доказывает. */
.act {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 10px;
  background: var(--panel); border-radius: 12px;
  border-left: 2px solid var(--accent);
}
.act .pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  flex: 0 0 auto; animation: pulse 1.3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 119, 87, 0.5); }
  50% { opacity: 0.65; transform: scale(0.82); box-shadow: 0 0 0 7px rgba(217, 119, 87, 0); }
}
.act .what { flex: 1; font-size: 14px; color: var(--text); min-width: 0; }
.act .dots::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}
.act .timer { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.act.long .timer { color: var(--accent); }

/* Отметка о завершении - чтобы «закончил» читалось однозначно */
.done { font-size: 12px; color: var(--dim); padding: 2px 2px 10px; }
.done b { color: var(--ok); }

/* ── Кнопки разрешений ────────────────────────────── */
.perms { flex: 0 0 auto; }
.perm {
  margin: 10px 14px; padding: 13px; background: var(--panel-2);
  border: 1px solid var(--accent); border-radius: 12px;
}
.perm .why { font-size: 14px; margin-bottom: 6px; }
.perm .cmd {
  font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--dim);
  background: #131311; padding: 8px; border-radius: 6px; margin-bottom: 10px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
.perm .btns { display: flex; gap: 8px; }
.perm button { flex: 1; padding: 13px; border-radius: 10px; border: 0; font-size: 15px; font-weight: 600; cursor: pointer; }
.perm .yes { background: var(--ok); color: #0e1a10; }
.perm .no { background: var(--panel); color: var(--danger); border: 1px solid var(--danger); }

/* ── Ввод ─────────────────────────────────────────── */
.composer {
  flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--panel);
  padding: 10px 10px calc(10px + var(--safe-b));
}
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.icon-btn {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 12px; font-size: 19px; cursor: pointer; flex: 0 0 auto;
}
#input {
  flex: 1; resize: none; max-height: 140px; padding: 12px;
  font: inherit; font-size: 16px; /* меньше 16px -> iOS зумит страницу при фокусе */
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
}
.send {
  width: 44px; height: 44px; border: 0; border-radius: 12px; flex: 0 0 auto;
  background: var(--accent); color: #1a1008; font-size: 20px; font-weight: 700; cursor: pointer;
}
.send:disabled { opacity: 0.4; }

.attached { display: flex; gap: 8px; padding-bottom: 8px; overflow-x: auto; }
.attached .th { position: relative; flex: 0 0 auto; }
.attached img { height: 62px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.attached .x {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 0; font-size: 13px; line-height: 22px; cursor: pointer;
}

/* ── Подсказка слэш-команд ────────────────────────── */
.slash { max-height: 190px; overflow-y: auto; margin-top: 8px; border-top: 1px solid var(--line); }
.slash div { padding: 11px 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.slash div:active { background: var(--panel-2); }
.slash b { color: var(--accent); }
.slash span { color: var(--dim); font-size: 12.5px; }
