:root {
  --bg: #0e1014;
  --bg-2: #151922;
  --bg-3: #1c2230;
  --line: #242b3a;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #7c9cf5;
  --accent-2: #4f74d6;
  --ok: #4ac08a;
  --warn: #e2b04a;
  --err: #e4675f;
  --radius: 14px;
}

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

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1 { font-size: 20px; margin: 0 0 8px; }
a { color: var(--accent); }

button { font: inherit; cursor: pointer; border: 0; background: var(--bg-3); color: var(--text); border-radius: 10px; padding: 9px 14px; }
button:hover { background: #232b3c; }
button.primary { background: var(--accent-2); }
button.primary:hover { background: var(--accent); color: #08101f; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.danger { color: var(--err); border-color: #4a2a2a; }

input, textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
input:focus { border-color: var(--accent-2); }

/* ---------- login ---------- */
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; }
.login-card h1 { margin: 0; font-size: 24px; }
.logo {
  width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08101f; font-weight: 700; font-size: 30px; display: grid; place-items: center;
}
.error-text { color: var(--err); font-size: 13px; min-height: 18px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 10px; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(14,16,20,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.search-wrap { flex: 1; }
.search-wrap input { padding: 8px 12px; background: var(--bg-3); border-color: transparent; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; font-size: 22px; line-height: 1;
  display: grid; place-items: center; background: var(--accent-2); color: #fff;
}

.view { padding: 14px 14px calc(40px + env(safe-area-inset-bottom)); max-width: 860px; margin: 0 auto; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed #2b3446; border-radius: var(--radius); padding: 22px 16px; text-align: center;
  color: var(--muted); margin-bottom: 16px; transition: .15s;
}
.dropzone.over { border-color: var(--accent); background: #131a2a; color: var(--text); }
.dropzone.compact { padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; justify-content: center; flex-wrap: wrap; }
.dropzone.compact .dz-title { font-size: 14px; }
.dropzone.compact .dz-sub { margin: 0; }
.dz-title { font-weight: 600; color: var(--text); }
.dz-sub { font-size: 12.5px; margin-top: 4px; }

/* ---------- list ---------- */
.list { display: grid; gap: 10px; }
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; display: grid; gap: 6px; cursor: pointer; transition: .15s;
}
.card:hover { border-color: #33405a; background: #171c27; }
.card-top { display: flex; gap: 10px; align-items: baseline; }
.card-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pill { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.pill.done { color: var(--ok); border-color: #24523c; }
.pill.error { color: var(--err); border-color: #4a2a2a; }
.pill.work { color: var(--warn); border-color: #4a4126; }
.bar { height: 4px; background: #1d2432; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .4s; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty-icon { font-size: 34px; margin-bottom: 8px; }

/* ---------- detail ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 10px; }
.back { background: transparent; padding: 6px 0; color: var(--muted); }
.back:hover { background: transparent; color: var(--text); }
.detail-title { font-size: 22px; line-height: 1.25; margin: 6px 0 6px; }
.status-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 14px 0; }
.status-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.player audio { width: 100%; }

.speakers { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.speaker-edit { display: flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px; }
.speaker-edit span { font-size: 12px; color: var(--muted); }
.speaker-edit input { width: 120px; padding: 4px 6px; font-size: 13px; background: transparent; border: 0; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.tab { background: transparent; color: var(--muted); border-radius: 8px 8px 0 0; padding: 9px 12px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-body { display: grid; gap: 14px; }
.summary-block h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.summary-block p { margin: 0; }
.summary-block ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.quote { border-left: 3px solid var(--accent-2); padding-left: 10px; color: #c9d3e6; font-style: italic; }

.task { display: flex; gap: 10px; align-items: flex-start; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.task input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.task-body { flex: 1; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.task.done .task-body { opacity: .45; text-decoration: line-through; }

.line { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 7px 6px; border-radius: 8px; cursor: pointer; }
.line:hover { background: var(--bg-2); }
.line .t { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.line .who { font-size: 11.5px; font-weight: 600; color: var(--accent); display: block; margin-bottom: 1px; }
.line .txt { font-size: 14.5px; display: inline; }
.line > div:last-child { max-width: 72ch; }
.line.active { background: #17203a; }

/* ---------- upload / toast ---------- */
.upload-panel {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,.45); display: grid; gap: 7px;
}
.up-head { display: flex; justify-content: space-between; font-size: 13px; gap: 10px; }
.up-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(24px + env(safe-area-inset-bottom)); background: #1f2839; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: .25s; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

mark { background: #3b4a1f; color: #f0f5c8; border-radius: 3px; padding: 0 2px; }

@media (min-width: 720px) {
  .detail-title { font-size: 26px; }
  .line { grid-template-columns: 60px 1fr; }
}
@media (max-width: 560px) {
  .brand { display: none; }
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; justify-content: center; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
  .search-wrap { flex: 1 1 120px; }
  .detail-actions button { padding: 9px 11px; font-size: 13.5px; }
}

/* ---------- запись ---------- */
.record-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.record-bar .muted { flex-basis: 100%; }
.rec-btn { background: #2b171c; color: var(--err); border: 1px solid #4a2a2a; }
.rec-btn:hover { background: #3a1d23; }
.rec-live { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid #4a2a2a; border-radius: 12px; padding: 6px 12px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--err); animation: recpulse 1.4s infinite; }
@keyframes recpulse { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 14px; }
.rec-level { width: 84px; height: 6px; background: #1d2432; border-radius: 99px; overflow: hidden; }
.rec-level > div { height: 100%; width: 0; background: var(--err); transition: width .08s linear; }
.ghost-icon { background: transparent; border: 1px solid var(--line); font-size: 17px; }
.line.playing { background: #16233a; }

/* ---------- чат по встрече ---------- */
.chat-log { display: grid; gap: 10px; min-height: 40px; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { justify-self: end; background: #23304d; border-bottom-right-radius: 4px; }
.msg.bot { justify-self: start; background: var(--bg-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--muted); font-style: italic; }
.ask-form { display: flex; gap: 8px; margin-top: 4px; }
.ask-form input { flex: 1; }
.ask-form button { padding: 10px 16px; }
.chat-empty { color: var(--muted); font-size: 13.5px; }

/* ---------- навигация и задачи ---------- */
.nav { display: flex; gap: 4px; }
.nav-link { font-size: 13.5px; color: var(--muted); text-decoration: none; padding: 6px 9px; border-radius: 8px; }
.nav-link.active { color: var(--text); background: var(--bg-3); }
.tasks-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.tasks-head h1 { margin: 0; font-size: 20px; }
.tasks-head label { display: flex; align-items: center; gap: 6px; }
.tasks-head input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.tasks-list { display: grid; gap: 8px; }
.task-row { display: flex; gap: 10px; align-items: flex-start; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.task-row input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.task-row .body { flex: 1; min-width: 0; }
.task-row .src { font-size: 12px; color: var(--muted); margin-top: 4px; }
.task-row .src a { color: var(--accent); text-decoration: none; }
.task-row.done .body { opacity: .45; }
.task-row.done .body > div:first-child { text-decoration: line-through; }

.footer-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; justify-content: space-between; }
.footer-actions button { font-size: 13px; padding: 7px 12px; }
