/* Пульт — мобильный интерфейс мозга.
   Тёмная тема по умолчанию: пультом чаще пользуются вечером и на ходу.
   Всё считано под палец: цели нажатия не мельче 44 px, безопасные зоны айфона учтены. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #262b36;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #cdb98a;      /* приглушённое золото — акцент владельца */
  --ok: #4ea36b;
  --warn: #d8a34a;
  --bad: #d4685e;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f2; --panel: #fff; --panel-2: #f0efeb; --line: #e3e1db;
    --text: #1a1a1a; --muted: #6c6c6c; --accent: #9a7f45;
  }
}

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

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

/* ── Вход ───────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.gate-card { width: 100%; max-width: 340px; text-align: center; }
.logo { font-size: 44px; color: var(--accent); line-height: 1; }
.gate h1 { margin: 12px 0 4px; font-size: 26px; letter-spacing: -0.01em; }
.gate p { margin: 0 0 20px; font-size: 15px; }
.gate input {
  width: 100%; padding: 15px 16px; font-size: 17px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  margin-bottom: 12px;
}
.gate input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.primary {
  width: 100%; padding: 15px; font-size: 17px; font-weight: 600;
  border: 0; border-radius: var(--radius); background: var(--accent); color: #14161b;
  cursor: pointer;
}
.primary:active { transform: scale(0.985); }
.primary:disabled { opacity: .5; }

/* ── Каркас ─────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 22px; cursor: pointer;
}
.icon-btn:active { background: var(--panel-2); }

.view { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }

/* ── Списки ─────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer;
}
.card:active { background: var(--panel-2); }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; line-height: 1.35; }
.card .meta { display: flex; gap: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.card .path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

.empty { text-align: center; padding: 48px 24px; font-size: 15px; }

/* ── Тревоги ────────────────────────────────────────── */
.alert { border-left: 3px solid var(--warn); }
.alert.crit { border-left-color: var(--bad); }
.alert.done { border-left-color: var(--ok); opacity: .6; }
.alert .detail { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.alert .actions { display: flex; gap: 8px; margin-top: 12px; }
.alert button {
  flex: 1; padding: 11px; font-size: 15px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.alert button.fix { background: var(--accent); color: #14161b; border-color: transparent; font-weight: 600; }

/* ── Переписка ──────────────────────────────────────── */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.bubble {
  max-width: 88%; padding: 11px 14px; border-radius: 16px; font-size: 15px;
  white-space: pre-wrap; word-break: break-word;
}
.bubble.you { align-self: flex-end; background: var(--accent); color: #14161b; border-bottom-right-radius: 5px; }
.bubble.claude { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.pending { opacity: .65; font-style: italic; }

.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px; padding: 12px 14px; font-size: 16px;
  border-radius: 20px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-family: inherit;
}
.send {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  background: var(--accent); color: #14161b; font-size: 20px; cursor: pointer;
}
.send:disabled { opacity: .4; }

/* ── Новая задача ───────────────────────────────────── */
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field select, .field textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; font-family: inherit;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--text); resize: vertical;
}
.result {
  margin-top: 16px; padding: 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  font-size: 15px; white-space: pre-wrap;
}

/* ── Вкладки ────────────────────────────────────────── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; position: relative; padding: 9px 0 7px; border: 0; background: none;
  color: var(--muted); font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab span { font-size: 19px; line-height: 1; }
.tab.active { color: var(--accent); }
.badge {
  position: absolute; top: 4px; right: 50%; transform: translateX(22px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; font-style: normal;
  line-height: 17px; text-align: center;
}

/* ── Настройки ──────────────────────────────────────── */
.settings { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 16px; }
.settings summary { color: var(--muted); font-size: 15px; cursor: pointer; padding: 6px 0; }
.settings input {
  width: 100%; padding: 13px 14px; margin-top: 10px; font-size: 16px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}
.settings button {
  width: 100%; margin-top: 12px; padding: 13px; font-size: 16px; cursor: pointer;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
}

/* ── Метки происхождения задачи ─────────────────────── */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.tag.mac { background: #3a2f18; color: var(--accent); }
.tag.brain { background: #16302a; color: #6fc79a; }
@media (prefers-color-scheme: light) {
  .tag.mac { background: #f0e6cf; color: #7a6229; }
  .tag.brain { background: #dff0e6; color: #2f7a52; }
}

.chatbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.ghost {
  margin-left: auto; padding: 8px 14px; font-size: 14px; cursor: pointer;
  border-radius: 20px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}
.ghost:active { background: var(--panel-2); }
.ghost:disabled { opacity: .5; }

/* ── Блок уведомлений ───────────────────────────────── */
.pushbox {
  margin-top: 24px; padding: 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--accent);
}
.pushbox p { margin: 0 0 8px; font-size: 15px; }
.pushbox .primary { margin-top: 8px; }

/* ── Переписка занимает весь экран ──────────────────────
   Панель вкладок и поле ввода оба прижаты к низу и перекрывали друг друга —
   поле ввода оказывалось под вкладками, и написать было нечем.
   В переписке вкладки убираем: наверху есть кнопка «назад». */
body.chatting .tabs { display: none; }
body.chatting #viewChat { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* Запас снизу под панель Safari, когда приложение открыто вкладкой,
   а не с экрана «Домой» */
@supports (-webkit-touch-callout: none) {
  .composer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}
