/* camvault — диспетчерская.
 *
 * Тёмный мир выбран по сцене использования, а не по моде: кадр с камеры почти
 * всегда тёмный (улица, ночью инфракрасная съёмка), и светлый интерфейс рядом
 * с ним слепит и заставляет видео выглядеть грязным.
 *
 * Акцент ровно один — янтарный. Им красится только то, что означает «здесь
 * сейчас что-то происходит»: идущая запись, метка события, найденный объект.
 * Как только им начнут красить кнопки, он перестанет работать.
 */

/* Golos Text — кириллический гротеск, нарисованный под русский текст.
 * Взят вместо привычного Inter намеренно: тот стоит на каждой второй панели
 * и не даёт интерфейсу собственного голоса, а у Golos'а есть характер —
 * чуть суженные прописные и высокие строчные хорошо держат плотную вёрстку.
 * Два поднабора вместо одного файла: латиница вдвое тяжелее кириллицы,
 * и грузить её ради цифр и «×» на каждой странице незачем. */
@font-face {
  font-family: "Golos Text";
  src: url("/static/vendor/golos-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  src: url("/static/vendor/golos-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
                 U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;

  --bg:        #0a0c0f;
  --panel:     #12151a;
  --raised:    #1a1e26;
  --raised-hi: #222833;
  --line:      #262c36;
  --line-soft: #1c212a;

  --ink:   #e8ecf2;
  --dim:   #a3adbd;
  --faint: #7c8695;

  --accent:      #f5a524;
  --accent-ink:  #17120a;
  --accent-soft: rgba(245, 165, 36, 0.14);
  --accent-line: rgba(245, 165, 36, 0.42);

  --ok:  #57d38c;
  --bad: #f87171;

  --r-lg: 12px;
  --r-md: 9px;
  --r-sm: 6px;

  /* Тени с настоящим смещением и мягким размытием — не цветной ореол. */
  --shadow: 0 2px 6px rgba(0,0,0,.45), 0 10px 28px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5), 0 3px 10px rgba(0,0,0,.28);

  /* Экспоненциальное замедление: движение начинается быстро и мягко
   * останавливается — так оно читается как физическое, а не как анимация. */
  --ease: cubic-bezier(.16,1,.3,1);
  --ease-soft: cubic-bezier(.32,.72,0,1);
  --fast: 140ms;
  --base: 260ms;
  --slow: 420ms;

  --font: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

/* Поверхности, которые рисует браузер, тоже часть оформления. */
::selection { background: var(--accent-soft); color: var(--ink); }
:root { caret-color: var(--accent); accent-color: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 99px;
  border: 3px solid var(--bg); background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #333b47; background-clip: padding-box; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Время сравнивают глазами постоянно — цифры не должны прыгать по ширине. */
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "cv01" 1; }

button, input, select {
  font: inherit; color: inherit;
  background: none; border: none; margin: 0;
}
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { display: block; }

/* ─── каркас ─────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
}

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 54px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel);
}

.mark {
  display: flex; align-items: center; gap: 9px;
  font-weight: 620; letter-spacing: -.015em; font-size: 15px;
  color: var(--ink); text-decoration: none;
}
.mark svg { width: 19px; height: 19px; color: var(--accent); }

/* Переключатель эфир/архив: подложка едет за активным пунктом. */
.modes {
  position: relative; display: flex; gap: 2px;
  padding: 3px; border-radius: var(--r-md);
  background: var(--bg); border: 1px solid var(--line-soft);
}
.modes button {
  position: relative; z-index: 1;
  min-width: 74px;          /* равная ширина: подложке достаточно ездить */
  padding: 6px 14px; border-radius: var(--r-sm);
  color: var(--faint); font-weight: 540; font-size: 13px;
  transition: color var(--fast) var(--ease);
}
.modes button:hover { color: var(--dim); }
.modes button[aria-selected="true"] { color: var(--ink); }
.modes .slider {
  position: absolute; z-index: 0; top: 3px; bottom: 3px;
  border-radius: var(--r-sm); background: var(--raised-hi);
  box-shadow: var(--shadow-sm);
  transition: transform var(--base) var(--ease);
}

.status { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
.dot {
  width: 7px; height: 7px; border-radius: 99px; background: var(--faint);
  transition: background var(--base) var(--ease), box-shadow var(--base) var(--ease);
}
/* Без пульсации: состояние меняется раз в сутки, и мигание изображало бы
 * активность вместо того, чтобы её показывать. Рядом стоит текст, а живое
 * движение в этом интерфейсе принадлежит таймлайну. */
.dot.on { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.dot-wrap { position: relative; display: grid; place-items: center; }

.spacer { margin-left: auto; }

.ghost {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r-md);
  color: var(--dim); font-size: 13px; font-weight: 520;
  border: 1px solid transparent;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
              border-color var(--fast) var(--ease);
}
.ghost:hover { background: var(--raised); color: var(--ink); border-color: var(--line-soft); }
.ghost:active { transform: translateY(.5px); }
.ghost svg { width: 15px; height: 15px; }
.ghost[disabled] { opacity: .38; pointer-events: none; }

.solid {
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; border-color: transparent;
}
.solid:hover { background: #ffb63f; color: var(--accent-ink); border-color: transparent; }

/* ─── рабочая область ────────────────────────────────────────────────── */

.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  min-height: 0;
}

.stage {
  position: relative; min-height: 0;
  display: flex; flex-direction: column;
  background: #000;
}

.frame {
  position: relative; flex: 1; min-height: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 100% at 50% 0%, #0e1116 0%, #000 68%);
}
.frame video {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  display: block; background: #000;
}
.frame canvas.overlay {
  position: absolute; inset: 0; pointer-events: none;
  width: 100%; height: 100%;
}

.stage-note {
  position: absolute; inset: auto 0 0 0;
  display: flex; justify-content: center; padding: 14px;
  pointer-events: none;
}
.stage-note span {
  padding: 7px 13px; border-radius: 99px;
  background: rgba(10,12,15,.86); color: var(--dim);
  border: 1px solid var(--line); font-size: 12.5px;
  box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--base) var(--ease), transform var(--base) var(--ease);
}
.stage-note.show span { opacity: 1; transform: none; }

.live-badge {
  position: absolute; top: 14px; left: 14px;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 11px 6px 9px; border-radius: 99px;
  background: rgba(10,12,15,.78); border: 1px solid var(--accent-line);
  color: var(--accent); font-size: 11.5px; font-weight: 640;
  letter-spacing: .06em; text-transform: uppercase;
  box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(-6px) scale(.97);
  transition: opacity var(--base) var(--ease), transform var(--base) var(--ease);
}
.live-badge.show { opacity: 1; transform: none; }

/* ─── панель управления плеером ──────────────────────────────────────── */

.controls {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line-soft);
}
.controls .clock {
  margin: 0 6px; padding: 5px 10px;
  border-radius: var(--r-sm); background: var(--bg);
  border: 1px solid var(--line-soft);
  font-size: 15px; font-weight: 560; letter-spacing: .01em;
  min-width: 96px; text-align: center;
}
.controls .date { color: var(--faint); font-size: 12.5px; margin-left: 2px; }

.iconbtn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: var(--r-md);
  color: var(--dim);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
              transform var(--fast) var(--ease);
}
.iconbtn:hover { background: var(--raised); color: var(--ink); }
.iconbtn:active { transform: scale(.93); }
.iconbtn[disabled] { opacity: .35; pointer-events: none; }
.iconbtn svg { width: 17px; height: 17px; }
.iconbtn.primary { width: 40px; height: 40px; background: var(--raised); color: var(--ink); }
.iconbtn.primary:hover { background: var(--raised-hi); }
.iconbtn.primary svg { width: 19px; height: 19px; }

.rate {
  padding: 6px 9px; border-radius: var(--r-sm);
  color: var(--dim); font-size: 12.5px; font-weight: 560;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.rate:hover { background: var(--raised); color: var(--ink); }

/* ─── журнал событий ─────────────────────────────────────────────────── */

.side {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line-soft);
}
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px 11px;
  border-bottom: 1px solid var(--line-soft);
}
.side-head h2 {
  margin: 0; font-size: 12px; font-weight: 640;
  letter-spacing: .07em; text-transform: uppercase; color: var(--faint);
}
.count {
  margin-left: auto; padding: 2px 8px; border-radius: 99px;
  background: var(--raised); color: var(--dim);
  font-size: 11.5px; font-weight: 600;
}

.filters { display: flex; gap: 6px; padding: 11px 15px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 99px;
  background: var(--raised); color: var(--dim);
  font-size: 12px; font-weight: 540;
  border: 1px solid transparent;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
              border-color var(--fast) var(--ease);
}
.chip:hover { background: var(--raised-hi); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line);
}

.events { flex: 1; overflow-y: auto; padding: 4px 8px 16px; min-height: 0; }
.events li { list-style: none; }
.events ul { margin: 0; padding: 0; }

.event {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 11px; width: 100%; padding: 9px 10px;
  border-radius: var(--r-md); text-align: left;
  transition: background var(--fast) var(--ease);
}
.event:hover { background: var(--raised); }
.event[aria-current="true"] { background: var(--accent-soft); }
.event .tick {
  width: 3px; align-self: stretch; border-radius: 99px;
  background: var(--accent); opacity: .75;
}
.event .when { font-size: 13.5px; font-weight: 560; }
.event .what { color: var(--faint); font-size: 12px; margin-top: 1px; }
.event .len { color: var(--faint); font-size: 12px; }

.empty {
  padding: 34px 20px; text-align: center; color: var(--faint); font-size: 13px;
}
.empty svg { width: 26px; height: 26px; margin: 0 auto 10px; color: var(--line); }

/* ─── таймлайн ───────────────────────────────────────────────────────── */

.timeline-wrap {
  background: var(--panel);
  border-top: 1px solid var(--line-soft);
  padding: 10px 14px 12px;
}
.timeline-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 9px; flex-wrap: wrap;
}
.daypick { display: flex; align-items: center; gap: 3px; }
.daypick .label {
  min-width: 132px; text-align: center;
  font-size: 13px; font-weight: 560;
}
.zoomhint { color: var(--faint); font-size: 12px; }
.selinfo {
  display: none; align-items: center; gap: 9px;
  padding: 4px 6px 4px 11px; border-radius: 99px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent); font-size: 12.5px; font-weight: 560;
}
.selinfo.show { display: flex; }
.selinfo button { color: inherit; }

#timeline {
  display: block; width: 100%; height: 92px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  cursor: grab; touch-action: none;
}
#timeline.dragging { cursor: grabbing; }
#timeline.selecting { cursor: crosshair; }

.preview {
  position: fixed; z-index: 40; pointer-events: none;
  border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--line); background: var(--raised);
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(4px) scale(.98);
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.preview.show { opacity: 1; transform: none; }
.preview img { display: block; width: 232px; height: auto; background: #000; }
.preview .cap {
  padding: 5px 9px; font-size: 12px; color: var(--dim);
  border-top: 1px solid var(--line-soft);
}

/* ─── вход ───────────────────────────────────────────────────────────── */

.gate {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(90% 60% at 50% 0%, #11151c 0%, var(--bg) 62%);
}
.gate form {
  width: 100%; max-width: 344px;
  padding: 30px 28px 26px; border-radius: var(--r-lg);
  background: var(--panel); border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  animation: rise var(--slow) var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.gate .mark { margin-bottom: 22px; }
.gate h1 { margin: 0 0 4px; font-size: 19px; font-weight: 620; letter-spacing: -.02em; }
.gate p.sub { margin: 0 0 22px; color: var(--faint); font-size: 13px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { color: var(--dim); font-size: 12.5px; font-weight: 540; }
.field input {
  padding: 10px 12px; border-radius: var(--r-md);
  background: var(--bg); border: 1px solid var(--line);
  color: var(--ink); font-size: 14px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.field input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.gate button[type="submit"] {
  width: 100%; margin-top: 6px; padding: 11px;
  border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink);
  font-weight: 620; font-size: 14px;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.gate button[type="submit"]:hover { background: #ffb63f; }
.gate button[type="submit"]:active { transform: translateY(1px); }
.alarm {
  display: flex; gap: 9px; align-items: flex-start;
  margin: 0 0 16px; padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3);
  color: #fca5a5; font-size: 13px;
  animation: shake 420ms var(--ease-soft) both;
}
.alarm svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  22% { transform: translateX(-5px); }
  46% { transform: translateX(4px); }
  72% { transform: translateX(-2px); }
}

/* ─── телефон ────────────────────────────────────────────────────────── */

.sheet-handle { display: none; }

@media (max-width: 900px) {
  .work { grid-template-columns: minmax(0, 1fr); }

  /* Журнал уезжает в выдвижную панель: на телефоне видео и таймлайн важнее,
   * а события нужны по требованию. */
  .side {
    position: fixed; z-index: 30; inset: auto 0 0 0;
    max-height: 76dvh; border-left: none;
    border-top: 1px solid var(--line);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,.45), 0 -18px 46px rgba(0,0,0,.4);
    transform: translateY(calc(100% - 52px));
    transition: transform var(--slow) var(--ease);
  }
  .side.open { transform: translateY(0); }
  .sheet-handle {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    height: 52px; flex: none; width: 100%;
    color: var(--dim); font-size: 13px; font-weight: 560;
  }
  .sheet-handle::before {
    content: ""; position: absolute; top: 7px; left: 50%;
    width: 34px; height: 3px; margin-left: -17px;
    border-radius: 99px; background: var(--line);
  }
  .side-head { display: none; }
  .events { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

  .topbar { height: 50px; padding: 0 12px; gap: 12px; }
  .status .text { display: none; }
  .mark span { display: none; }

  .timeline-wrap { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  #timeline { height: 108px; }          /* выше — палец точнее попадает */
  .iconbtn { width: 40px; height: 40px; }
  .iconbtn.primary { width: 46px; height: 46px; }
  .controls { padding: 8px 8px; gap: 3px; }
  .controls .clock { min-width: 84px; font-size: 14px; padding: 5px 8px; }
  .controls .date, .zoomhint { display: none; }
  .preview img { width: 176px; }
}

@media (max-width: 380px) {
  .modes button { padding: 6px 10px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
