:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-header: #ffffff;
  --color-header-text: #12203c;
  --color-header-border: #00989f;
  --color-accent: #00989f;
  --color-accent-hover: #017077;
  --color-live: #e5484d;
  --color-confirm: #1a9e5c;
  --color-confirm-hover: #157e49;
  --color-text: #1c2430;
  --color-muted: #6b7280;
  --radius: 8px;
  --font-main: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Гарнитуры как на sysincongress.ru: Oswald — заголовки (масштед Light,
     заголовки страниц Regular), Open Sans Light — поля ввода. */
  --font-display: Oswald, "PT Sans Narrow", "Arial Narrow", var(--font-main);
  --font-input: "Open Sans", var(--font-main);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
}

/* Верхняя полоса во всю ширину: логотипы и меню разнесены по краям экрана,
   а не выровнены по узкой сетке main. */
header.site-header {
  background: var(--color-header);
  color: var(--color-header-text);
  padding: 14px 0;
  border-bottom: 2px solid var(--color-header-border);
}

.site-header-inner {
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
  min-height: 48px;
}

.site-nav { margin-left: auto; font-size: .9rem; display: flex; gap: 20px; }
.site-nav a { color: var(--color-accent); text-decoration: none; font-weight: 600; }
.site-nav a:hover { color: var(--color-accent-hover); }

a { color: var(--color-accent); }
a:hover { color: var(--color-accent-hover); }
h1, h2 { color: var(--color-accent); }

main { max-width: 880px; margin: 0 auto; padding: 24px 16px 64px; }
main.main-full { max-width: none; padding: 0; }

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
  margin-bottom: 20px;
}

h1, h2, legend { font-family: var(--font-display); font-weight: 400; }
h1 { font-size: 1.5rem; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .01em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
p.muted { color: var(--color-muted); }

.field, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius);
  font-family: var(--font-input);
  font-weight: 300;
  /* 16px минимум: меньший font-size на инпуте заставляет iOS Safari
     авто-зумить страницу при фокусе. */
  font-size: 1rem;
  margin-bottom: 14px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; }

.btn-primary, .btn-secondary {
  display: inline-block;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 1rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border: none;
}
.btn-primary:hover { background: var(--color-accent-hover); color: #fff; }

.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}
.btn-secondary:hover { background: rgba(0, 152, 159, .08); border-color: var(--color-accent-hover); color: var(--color-accent-hover); }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-live);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
}
.live-badge::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.stream-frame-wrap { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.stream-frame-wrap iframe { width: 100%; height: 100%; border: 0; }

.timers { display: flex; gap: 24px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.timers .timer-label { color: var(--color-muted); font-size: .8rem; display: block; }
.timers .timer-value { font-size: 1.1rem; font-weight: 700; }

/* Всплывающее окно подтверждения присутствия (ТЗ: popup / banner) */
#attendance-modal {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, .55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
#attendance-modal.open { display: flex; }
#attendance-modal .modal-box {
  background: #fff; border-radius: var(--radius);
  padding: 28px; max-width: 360px; text-align: center;
}
#attendance-confirm-btn {
  background: var(--color-confirm);
  color: #fff; border: none; border-radius: var(--radius);
  padding: 14px 24px; font-size: 1.05rem; font-weight: 700;
  cursor: pointer; margin-top: 16px; width: 100%;
}
#attendance-confirm-btn:hover { background: var(--color-confirm-hover); }
#attendance-countdown { color: var(--color-muted); font-size: .85rem; margin-top: 8px; }

.chat-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 8px 0; border-bottom: 1px solid #eee;
  display: flex; flex-direction: column; gap: 10px;
}

.chat-msg { max-width: 82%; display: flex; flex-direction: column; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.theirs { align-self: flex-start; align-items: flex-start; }

.chat-msg-meta { display: flex; align-items: baseline; gap: 6px; font-size: .78rem; }
.chat-msg-author { font-weight: 600; color: var(--color-text); }
.chat-msg-role-badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  color: #fff; background: var(--color-accent); border-radius: 999px; padding: 1px 8px;
}

.chat-msg-bubble {
  margin-top: 2px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #eef0f2;
  color: var(--color-text);
  font-size: .9rem;
  line-height: 1.4;
  word-break: break-word;
}
.chat-msg.mine .chat-msg-bubble { background: var(--color-accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.theirs .chat-msg-bubble { border-bottom-left-radius: 4px; }

.chat-msg-time { font-size: .72rem; color: var(--color-muted); margin-top: 2px; }

.chat-input-row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.chat-input-row .field { flex: 1; margin-bottom: 0; }

.masthead {
  display: grid;
  /* Ширина колонки портрета задана явно: при "auto" она зависела бы от
     картинки, а картинка (width/max-width в процентах) — от колонки,
     и связка схлопывалась в ноль. */
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: center;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--color-accent);
}
/* Логотипы живут в верхней полосе (.site-header-inner) вместе с меню,
   в самом масштеде остаются только надпись и портрет. */
.masthead-logo { height: 52px; width: auto; }
/* Заголовок набран как на sysincongress.ru: узкий гротеск, светлое
   начертание, капслок, межстрочный 1.5. */
.masthead-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1.5;
  text-transform: uppercase;
  margin: 0;
  color: var(--color-text);
}
/* Колонка указана явно: элемент с заданной строкой (grid-row) размещается
   раньше остальных, и при автоподборе колонки портрет уезжал в первую. */
.masthead-portrait { grid-column: 2; grid-row: 1 / 3; justify-self: end; }
.masthead-portrait img { display: block; width: 100%; height: auto; }

@media (max-width: 640px) {
  .masthead { grid-template-columns: 1fr; }
  .masthead-portrait { grid-column: 1; grid-row: auto; justify-self: start; }
  .masthead-portrait img { width: 180px; }
  .masthead-logo { height: 44px; }
  .masthead-title { font-size: 1.05rem; }
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.event-card { margin-bottom: 0; display: flex; flex-direction: column; }
.event-card-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 8px; }

@media (max-width: 640px) {
  .events-grid { grid-template-columns: 1fr; }
}

.form-section { border: none; padding: 0; margin: 0 0 24px; }
.form-section legend { font-weight: 700; font-size: 1rem; padding: 0 0 12px; color: var(--color-text); }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.consent-field { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.consent-field input { width: auto; margin: 4px 0 0; }

@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

.watch-shell {
  position: relative;
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.watch-main h1 { margin-bottom: 16px; }

.watch-chat {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  margin-bottom: 0;
}
.watch-chat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.watch-chat-header h2 { margin: 0; }

.watch-shell.chat-collapsed { grid-template-columns: 1fr; }
.watch-shell.chat-collapsed .watch-chat { display: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  background: transparent;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  border-radius: var(--radius);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(0, 152, 159, .08); border-color: var(--color-accent-hover); color: var(--color-accent-hover); }

.chat-send-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 44px; height: 44px; padding: 0;
  border: none; border-radius: var(--radius);
  background: var(--color-accent); color: #fff;
  cursor: pointer;
}
.chat-send-btn:hover { background: var(--color-accent-hover); }
.chat-send-btn:disabled { background: #d0d5dd; cursor: default; }

.chat-reopen {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px; padding: 0;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
}
.watch-shell.chat-collapsed .chat-reopen { display: inline-flex; }

@media (max-width: 900px) {
  .watch-shell { grid-template-columns: 1fr; }
  .watch-chat { align-self: auto; }
  .chat-panel { flex: none; height: 400px; }
  .chat-toggle { display: none; }
  .chat-reopen,
  .watch-shell.chat-collapsed .chat-reopen { display: none; }
  .watch-shell.chat-collapsed .watch-chat { display: flex; }
}
