:root {
  --bg: #ffffff;
  --soft: #f6f7f9;
  --line: #e4e7ec;
  --text: #111827;
  --muted: #6b7280;
  --on: #16a34a;
  --on-bg: #f0fdf4;
  --on-line: #bbf7d0;
  --accent: #2563eb;
  --danger: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- кнопки ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .55; cursor: default; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

/* ---------- вход ---------- */
.login {
  width: 280px;
  margin: 18vh auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login input { border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; }
.err { color: var(--danger); min-height: 1.4em; font-size: 14px; }

/* ---------- каркас ---------- */
.app { height: 100vh; display: flex; flex-direction: column; }
.offline { background: #fef2f2; color: var(--danger); text-align: center; padding: 4px; font-size: 14px; }

/* запись */
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.rec {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 6px 14px 6px 12px;
  font-weight: 600;
  cursor: pointer;
}
.rec::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.rec:hover { background: var(--soft); }
.rec.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.rec.on::before { background: #fff; border-radius: 2px; }
.rec.on .t { font-variant-numeric: tabular-nums; }
.capture { font-size: 13px; color: var(--muted); }
.capture.ok::before { content: "● "; color: var(--on); }
.capture:not(.ok)::before { content: "● "; color: var(--danger); }

/* верх: транскрипт колонками по спикерам */
.speakers {
  flex: 1.25;
  min-height: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
.spk { position: relative; display: flex; flex-direction: column; min-height: 0; }
.spk + .spk { border-left: 1px solid var(--line); }
.spk.off .spk-head { opacity: .45; }

.spk-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  column-gap: 6px;
  row-gap: 4px;
  padding: 8px 12px 6px;
}
.spk-head .src { font-size: 12px; color: var(--muted); white-space: nowrap; }
.spk-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.spk.speaking .spk-head .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); }
.spk.err .spk-head .name { color: var(--danger); }
.spk-head input.name {
  border: 0;
  border-bottom: 1px dashed #c4c9d2;
  outline: 0;
  padding: 1px 0;
  min-width: 0;
  width: 100%;
  font-weight: 600;
  background: transparent;
}
.spk-head input.name::placeholder { color: var(--accent); font-weight: 500; }
.spk-head input.name:hover { border-bottom-color: var(--muted); }
.spk-head input.name:focus { border-bottom: 1px solid var(--accent); }
.spk-head .meter { grid-column: 1 / -1; height: 3px; background: var(--soft); border-radius: 2px; overflow: hidden; }
.spk-head .meter i { display: block; height: 100%; width: 0; background: var(--c); transition: width .12s linear; }

.switch { position: relative; width: 28px; height: 16px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 8px; transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--on); }
.switch input:checked + span::after { transform: translateX(12px); }

.empty { color: var(--muted); padding: 24px; margin: auto; }

/* низ: тезисы | вопросы */
.bottom { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.col { position: relative; display: flex; flex-direction: column; min-height: 0; }
.col + .col { border-left: 1px solid var(--line); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 46px; }
.col-head .label { font-weight: 600; }
.col-head .count { color: var(--muted); font-size: 13px; flex: 1; }

.list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 12px; }

/* ---------- карточки ---------- */
.card {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.card.on { background: var(--on-bg); border-color: var(--on-line); border-left-color: var(--on); }
.card.sel { outline: 2px solid var(--accent); outline-offset: -1px; }
.card.live .text { color: var(--muted); }

.tick {
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border: 1.5px solid #c4c9d2;
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  color: transparent;
  font-size: 15px;
  line-height: 1;
}
.tick:hover { border-color: var(--on); }
.card.on .tick { background: var(--on); border-color: var(--on); color: #fff; }
.tick:disabled { opacity: .35; cursor: default; }

.meta { font-size: 12px; color: var(--muted); margin-bottom: 1px; }
.meta .who { color: var(--c); font-weight: 600; }
.meta:empty { display: none; }
.text { white-space: pre-wrap; word-break: break-word; cursor: text; border-radius: 4px; }
.text[contenteditable="true"] { outline: 2px solid var(--accent); background: #fff; padding: 2px 4px; margin: -2px -4px; cursor: auto; }

.del {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 16px;
  line-height: 1;
  visibility: hidden;
}
.card:hover .del { visibility: visible; }
.del:hover { color: var(--danger); }

.jump {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.add { padding: 0 12px 8px; }
.add input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; }

.prompt { border-top: 1px solid var(--line); padding: 8px 12px; }
.prompt summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.prompt textarea { width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; font-size: 13px; resize: vertical; }
.row { display: flex; gap: 6px; margin-top: 6px; }

.toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; max-width: 420px; }
.toast { background: var(--text); color: #fff; padding: 8px 12px; border-radius: var(--radius); font-size: 14px; }
.toast.error { background: var(--danger); }

@media (max-width: 800px) {
  .bottom { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .col + .col { border-left: 0; border-top: 1px solid var(--line); }
}
