/* Тёмная тема: диктофоном чаще пользуются в переговорке и в машине, светлый экран там бьёт по глазам. */
:root {
  --bg: #0f1319;
  --surface: #171d26;
  --surface-2: #1e2632;
  --line: #2a3441;
  --text: #e8edf4;
  --muted: #8d9bb0;
  --accent: #4c8dff;
  --rec: #ff4d5e;
  --ok: #34c98a;
  --warn: #f0b429;
  --radius: 14px;
  --pad: 16px;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать наши display. Без этой строки кнопка с display:
   inline-flex остаётся видимой, потому что стили автора важнее браузерных. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.muted { color: var(--muted); }
.error { color: var(--rec); font-size: 14px; margin: 10px 0 0; }

.screen { display: none; padding: var(--pad); max-width: 720px; margin: 0 auto; }
.screen.active { display: block; }

/* ─── вход ─── */
.login-box { max-width: 380px; margin: 12vh auto 0; }
.brand { text-align: center; margin-bottom: 28px; }
.brand-mark {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), #7b4cff);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 14px; height: 22px; border-radius: 7px; background: #fff;
  box-shadow: 0 16px 0 -6px rgba(255, 255, 255, .85);
}
.brand h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
.brand p { margin: 0; font-size: 14px; }

form label {
  display: block; font-size: 13px; color: var(--muted);
  margin: 14px 0 6px;
}
input[type=text], input[type=password], textarea {
  width: 100%; padding: 13px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 16px; /* 16px — иначе мобильный Safari зумит поле при фокусе */
  font-family: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 14px 18px; margin-top: 18px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 16px; font-weight: 550; font-family: inherit;
  cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; margin-top: 0; font-size: 14px; padding: 11px 14px; }

.hint { font-size: 13px; margin-top: 20px; text-align: center; line-height: 1.45; }

/* ─── шапка ─── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; font-weight: 650; }
.icon-btn {
  background: none; border: none; color: var(--muted);
  font-size: 22px; padding: 6px 10px; cursor: pointer; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
#back-btn { font-size: 30px; }

/* ─── панель записи ─── */
.recorder-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px; margin-bottom: 22px;
}
.rec-state { display: flex; align-items: center; gap: 14px; }
.rec-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--line); flex: none;
}
.recording .rec-dot { background: var(--rec); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .recording .rec-dot { animation: none; } }

.rec-info { flex: 1; min-width: 0; }
.rec-timer { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.rec-sub { font-size: 13px; margin-top: 2px; }
/* Полоска уровня: видно, что микрофон действительно слышит, а не пишет тишину. */
.level {
  height: 4px; margin-top: 14px; border-radius: 2px;
  background: var(--surface-2); overflow: hidden;
}
.level-bar {
  height: 100%; width: 0; border-radius: 2px;
  background: var(--ok); transition: width .12s linear;
}
.silent .level-bar { background: var(--warn); }
.silent .rec-sub { color: var(--warn); }

.btn-record { background: var(--accent); border-color: var(--accent); color: #fff; }
.recording .btn-record { background: var(--rec); border-color: var(--rec); }
.rec-warn { font-size: 13px; margin: 12px 0 0; line-height: 1.45; }

/* ─── список ─── */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card:active { background: var(--surface-2); }
.card-top { display: flex; align-items: baseline; gap: 10px; }
.card-title { font-weight: 600; flex: 1; min-width: 0; }
.card-time { font-size: 12px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.card-sub { font-size: 14px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 999px; margin-top: 9px; font-weight: 550;
}
.badge.processing { background: rgba(240, 180, 41, .15); color: var(--warn); }
.badge.recording  { background: rgba(255, 77, 94, .15);  color: var(--rec); }
.badge.interrupted{ background: rgba(141, 155, 176, .15); color: var(--muted); }
.badge.error      { background: rgba(255, 77, 94, .15);  color: var(--rec); }
.badge.note       { background: rgba(76, 141, 255, .15); color: var(--accent); margin-left: 6px; }
.empty { text-align: center; padding: 36px 12px; font-size: 14px; }

/* ─── карточка разговора ─── */
.detail-meta { font-size: 13px; margin-bottom: 16px; }
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 16px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 10px 12px; font-size: 14px; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.pane { display: none; white-space: pre-wrap; word-wrap: break-word; line-height: 1.6; }
.pane.active { display: block; }
#pane-transcript { font-size: 15px; color: #cfd8e6; }
/* Реплики: имя говорящего отдельной строкой, чтобы разговор читался сверху вниз. */
.reply { margin-bottom: 14px; }
.reply-who {
  font-size: 12px; font-weight: 650; color: var(--accent);
  letter-spacing: .02em; margin-bottom: 2px;
}
.transcript-note { font-size: 13px; margin: 0 0 14px; line-height: 1.45; }
#note-input { min-height: 190px; resize: vertical; white-space: pre-wrap; }
.note-actions { display: flex; align-items: center; gap: 12px; }
.note-actions .btn { width: auto; margin-top: 14px; }
.note-actions .muted { font-size: 13px; margin-top: 14px; }

.detail-actions { display: flex; gap: 10px; margin-top: 26px; }
.detail-actions .btn { flex: 1; }
#resummarize-btn, #speakers-btn { margin-top: 10px; }

/* ─── баннер установки и обновления ─── */
.banner {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 16px; z-index: 60;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
  max-width: 520px; margin: 0 auto;
}
.banner-text { font-size: 14px; line-height: 1.45; }
.banner-actions { display: flex; gap: 8px; margin-top: 12px; }
.banner-btn {
  flex: 1; padding: 10px 14px; border-radius: 10px;
  background: var(--accent); border: 1px solid var(--accent); color: #fff;
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
}
.banner-btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }

/* ─── всплывающее сообщение ─── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 11px 18px; border-radius: 999px; font-size: 14px;
  max-width: min(90vw, 460px); text-align: center; z-index: 50;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
}
