:root {
  --bg: #0b0e14;
  --bg-soft: #121722;
  --panel: #151b28;
  --panel-2: #1b2231;
  --border: #263144;
  --border-2: #313d54;
  --text: #e6ecf7;
  --muted: #8b97ad;
  --accent: #7c8cff;
  --accent-2: #a855f7;
  --ok: #34d399;
  --err: #f87171;
  --rec: #ff4d6d;
  --radius: 16px;
  --gap: 22px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

/* Служебный [hidden] должен побеждать любые display: ниже.
   Без !important авторский `.details { display: grid }` перебивает его,
   и заблокированный элемент остаётся видимым (был реальный баг). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 620px at 10% -12%, rgba(124, 140, 255, .18), transparent 60%),
    radial-gradient(900px 520px at 108% -4%, rgba(168, 85, 247, .14), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: min(100% - 32px, 1180px);
  margin-inline: auto;
  padding-block: clamp(18px, 3vw, 30px) 72px;
}

/* ── topbar ── */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: var(--gap);
}
.brand { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.logo {
  width: 11px; height: 11px; border-radius: 50%; align-self: center; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(124, 140, 255, .8);
}
.name { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.sub { color: var(--muted); font-size: 12.5px; }

/* индикатор записи аудио для eval-набора */
.capflag {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--warn); border: 1px solid rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .08);
}

.chips { margin-left: auto; display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border); color: var(--muted); background: var(--bg-soft);
  display: inline-flex; align-items: center; gap: 5px;
}
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--err); }
.chip.on { color: var(--text); border-color: rgba(52, 211, 153, .4); }
.chip.on::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ── layout: одна колонка → две на широком ── */
.layout {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.col-main, .col-side { min-width: 0; }

@media (min-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 344px; }
  .col-side { position: sticky; top: 24px; }
}

/* ── stage ── */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(20px, 4vw, 40px) clamp(12px, 3vw, 26px);
  background: linear-gradient(180deg, rgba(21, 27, 40, .75), rgba(18, 23, 34, .35));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
}

.rec {
  position: relative;
  width: clamp(132px, 30vw, 176px);
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  color: var(--text);
  display: grid;
  place-content: center;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: transform .12s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.rec:hover { transform: translateY(-2px); }
.rec:active { transform: scale(.985); }
.rec:disabled { cursor: default; }
.rec .ring {
  position: absolute; inset: -10px; border-radius: 50%;
  border: 2px solid transparent;
}
.mic {
  width: clamp(34px, 8vw, 44px); aspect-ratio: 1;
  justify-self: center; position: relative;
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: background .2s;
}
.mic::after {
  content: ""; position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%);
  width: 3px; height: 11px; border-radius: 2px; background: currentColor; opacity: .5;
}
.rec-label { font-size: 13px; color: var(--muted); }
.rec-timer { font-variant-numeric: tabular-nums; font-size: 21px; font-weight: 700; letter-spacing: .5px; }

.rec.recording { border-color: rgba(255, 77, 109, .6); }
.rec.recording .mic { background: linear-gradient(135deg, var(--rec), #ff8fa3); }
.rec.recording .ring { border-color: rgba(255, 77, 109, .5); animation: pulse 1.5s ease-out infinite; }
.rec.recording .rec-label { color: var(--rec); }
/* transform — не создаёт overflow, в отличие от анимации inset */
@keyframes pulse {
  0% { transform: scale(1); opacity: .85; }
  100% { transform: scale(1.18); opacity: 0; }
}

.rec.busy { border-color: rgba(124, 140, 255, .45); }
.rec.busy .mic { background: linear-gradient(135deg, #4b5570, #39415a); }
.rec.busy .ring {
  border-color: transparent;
  background: conic-gradient(from 0deg, transparent 0 70%, var(--accent) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.meter { display: flex; align-items: flex-end; gap: 4px; height: 30px; margin-top: 22px; }
.meter span {
  width: 5px; height: 4px; border-radius: 3px; background: var(--border);
  transition: height .08s linear, background .2s;
}
.meter.active span { background: linear-gradient(180deg, var(--accent), var(--accent-2)); }

.hint { color: var(--muted); font-size: 12.5px; margin: 16px 0 0; max-width: 46ch; }
kbd {
  font: inherit; font-size: 11px; padding: 1px 6px; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 6px; background: var(--bg-soft); color: var(--text);
  white-space: nowrap;
}

/* ── result ── */
.result {
  margin-top: var(--gap);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(14px, 2.4vw, 18px);
  box-shadow: var(--shadow);
  animation: rise .22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.result-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.badge {
  font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: rgba(124, 140, 255, .16); color: #c3caff; border: 1px solid rgba(124, 140, 255, .3);
}
.meta { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.spacer { flex: 1 1 auto; min-width: 0; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }

#resultText {
  width: 100%; min-height: clamp(148px, 26vh, 260px); resize: vertical;
  padding: 13px 14px; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font: 15px/1.65 inherit; outline: none;
}
#resultText:focus { border-color: var(--accent); }

.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font: inherit; font-size: 13.5px; cursor: pointer;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; font-weight: 600; color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.tiny { padding: 3px 9px; font-size: 12px; border-radius: 8px; }
.btn.danger { color: var(--err); border-color: rgba(248, 113, 113, .45); background: transparent; }
.btn.danger:hover { border-color: var(--err); background: rgba(248, 113, 113, .08); }
/* эталон стоит — видно сразу, и понятно, что кнопка теперь снимает */
.btn.starred { color: var(--ok); border-color: rgba(52, 211, 153, .5); background: rgba(52, 211, 153, .07); }
/* Копирование не прошло автоматически и ждёт жеста: подсвечиваем кнопку, чтобы
   человеку было куда нажать, вместо бесполезного «не удалось скопировать». */
.btn.attention { border-color: var(--warn); animation: attn 1.7s ease-in-out infinite; }
@keyframes attn {
  0%, 100% { box-shadow: 0 0 0 2px rgba(251, 191, 36, .10); }
  50%      { box-shadow: 0 0 0 6px rgba(251, 191, 36, .22); }
}
.cancel { margin-top: 18px; }
/* стрелка-дисклоуз: состояние видно, надпись не «прыгает» */
.btn .caret { display: inline-block; font-size: 10px; margin-right: 2px; transition: transform .15s; }
.btn[aria-expanded="true"] .caret { transform: rotate(90deg); }

/* ── details: транскрипты; costbar — стоимость (видна всегда) ── */
.details { margin-top: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.costbar { margin-top: 12px; }

/* ── отказ в доступе: не тост на 5 секунд, а постоянная плашка ── */
.accessbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 18px; padding: 10px 13px; border-radius: 10px;
  background: rgba(248, 113, 113, .07); border: 1px solid rgba(248, 113, 113, .45);
  color: var(--err); font-size: 12.5px; max-width: 52ch;
}
.accessbar span { color: var(--muted); }

/* ── лимит и расход: видно ДО того, как жать запись ── */
.budget {
  padding: 10px 13px; border-radius: 12px; margin-bottom: 16px;
  background: var(--bg-soft); border: 1px solid var(--border);
}
.budget-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; margin-bottom: 8px;
}
.b-who { color: var(--text); font-weight: 600; }
.b-nums { color: var(--muted); margin-left: auto; }
.b-nums b { color: var(--text); }
.budget-track {
  height: 5px; border-radius: 3px; overflow: hidden; background: rgba(255, 255, 255, .07);
}
.budget-fill {
  height: 100%; width: 0%; border-radius: 3px; background: var(--accent, #6ea8fe);
  transition: width .3s ease;
}
.budget.warn .budget-fill { background: var(--warn); }
.budget.over { border-color: rgba(248, 113, 113, .5); }
.budget.over .budget-fill { background: var(--err); width: 100% !important; }
.budget.over .b-nums { color: var(--err); }
.rec:disabled { opacity: .5; cursor: not-allowed; }

/* ── вердикт ревьюера ── */
.reviewbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding: 9px 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--border); font-size: 12.5px;
}
.reviewbar.ok { border-color: rgba(52, 211, 153, .4); }
.reviewbar.warn { border-color: rgba(251, 191, 36, .45); }
.rv-chip { font-weight: 600; color: var(--muted); }
.reviewbar.ok .rv-chip { color: var(--ok); }
.reviewbar.warn .rv-chip { color: var(--warn); }
.rv-text { color: var(--muted); }
.rv-text b { color: var(--text); font-weight: 600; }
.tcard.review.ok { border-color: rgba(52, 211, 153, .4); }
.tcard.review.warn { border-color: rgba(251, 191, 36, .4); }
.issue { font-size: 12.5px; padding: 4px 0; border-top: 1px solid var(--border); }
.issue:first-of-type { border-top: 0; }
.issue .rule { color: #c3caff; font-weight: 600; margin-right: 6px; }
.issue .sev { font-size: 10.5px; color: var(--warn); border: 1px solid rgba(251,191,36,.4); border-radius: 999px; padding: 0 6px; margin-right: 6px; }
.issue q { color: var(--text); }
.issue .fix { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.tcard .notes { color: var(--muted); font-size: 12px; font-style: italic; margin-top: 6px; }
.tcard { min-width: 0; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tcard h4 { margin: 0 0 5px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.tcard h4 b { color: var(--text); font-weight: 600; }
.tcard h4 .t { margin-left: auto; font-variant-numeric: tabular-nums; }
.tcard p { margin: 0; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tcard.err p { color: var(--err); }
.tcard.merge { border-color: rgba(52, 211, 153, .35); }

.costcard { min-width: 0; background: var(--bg-soft); border: 1px solid rgba(52, 211, 153, .35); border-radius: 10px; padding: 11px 13px; }
.costcard h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.costcard h4 b { color: var(--text); font-weight: 600; }
.costcard h4 .tariff { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); }
.costcard h4 .tariff.offpeak { color: var(--ok); border-color: rgba(52, 211, 153, .45); }
.cost-row { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12.5px; padding: 2.5px 0; font-variant-numeric: tabular-nums; min-width: 0; }
.cost-row .k { flex: none; min-width: 68px; }
.cost-row .d { color: var(--muted); font-size: 11.5px; min-width: 0; overflow-wrap: anywhere; }
.cost-row .v { margin-left: auto; flex: none; }
.cost-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 7px; font-weight: 600; }
.cost-row.total .v { color: var(--ok); }

/* ── history ── */
.history {
  background: linear-gradient(180deg, rgba(21, 27, 40, .6), rgba(18, 23, 34, .25));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.hist-head { display: flex; align-items: center; gap: 10px; }
.history h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0; }
.hist-head .btn { margin-left: auto; }
.hist-stats { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.hist-stats b { color: var(--ok); font-weight: 600; }
.hist-list { display: grid; gap: 8px; margin-top: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.hitem { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; transition: .15s; }
.hitem:hover { border-color: var(--accent); background: var(--panel); }
.hitem .h-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.hitem .h-meta .m { color: #c3caff; }
.hitem .h-meta .cost { margin-left: auto; color: var(--ok); }
.hitem p { margin: 0; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* ── toast ── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .25s; max-width: min(90vw, 460px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(248, 113, 113, .5); }

@media (max-width: 460px) {
  .sub { display: none; }
  .chips { margin-left: 0; width: 100%; }
  .hint { font-size: 12px; }
}
