/* Консоль помощника EnclHelp: крупно, просто, светлая и тёмная тема по системе. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #15171c;
  --muted: #5d6470;
  --border: #d6d9e0;
  --primary: #1f6feb;
  --primary-text: #ffffff;
  --danger: #d1242f;
  --ok: #1a7f37;
  --warn: #b7791f;
  --stage: #0b0c0f;
  --radius: 14px;
  --gap: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 18px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --border: #2e333d;
    --primary: #3b82f6;
    --danger: #f85149;
    --ok: #3fb950;
    --warn: #d29922;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs)/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1 { font-size: 30px; margin: 0; }
h2 { font-size: 22px; margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; }
.empty { color: var(--muted); margin: 8px 0 0; }
.status { min-height: 1.4em; margin: 8px 0 0; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }

/* Кнопки и поля */
.btn {
  font: inherit;
  font-size: 17px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.97); }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.big { min-height: 56px; font-size: 20px; padding: 12px 24px; }
.btn.small { min-height: 36px; font-size: 15px; padding: 4px 12px; }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; min-height: 36px; }
.btn.toggle[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
input {
  font: inherit;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
label { display: grid; gap: 6px; font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Вход */
.view { min-height: 100%; }
#view-login { display: grid; place-items: center; padding: var(--gap); }
.login { width: min(420px, 100%); padding: 32px; display: grid; gap: 18px; }

/* Шапка */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap;
  padding: 10px max(var(--gap), env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 22px; }
.tabs { display: flex; gap: 6px; flex: 1; }
.tab { font: inherit; background: none; border: none; color: var(--muted); padding: 8px 14px; border-radius: 10px; cursor: pointer; min-height: 44px; }
.tab.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }

.tab-body { max-width: 1000px; margin: 0 auto; padding: var(--gap); display: grid; gap: var(--gap); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { width: 200px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px; border-radius: 12px; background: var(--surface-2);
}
.item.highlight { outline: 3px solid var(--warn); }
.item .info { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.item .title { font-weight: 700; font-size: 20px; }
.item .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.state { font-size: 15px; padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.state.wait { color: var(--warn); border-color: var(--warn); }
.state.mine { color: var(--ok); border-color: var(--ok); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 16px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; }

/* Вызов */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); padding: var(--gap); }
.modal-card { width: min(480px, 100%); padding: 32px; display: grid; gap: 14px; text-align: center; }
.modal-card .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ring { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto; background: var(--danger); animation: ring 1.2s ease-out infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(209, 36, 47, 0.6); } 100% { box-shadow: 0 0 0 28px rgba(209, 36, 47, 0); } }
@media (prefers-reduced-motion: reduce) { .ring { animation: none; } }

/* Сеанс */
.session { position: fixed; inset: 0; z-index: 10; display: grid; grid-template-rows: auto 1fr auto; background: var(--stage); color: #e8eaee; }
.session-top, .session-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px max(14px, env(safe-area-inset-left)); background: #15171c;
}
.session-title { flex: 1; display: grid; min-width: 0; }
.session-title .muted { color: #9aa3b2; }
.session .btn:not(.danger):not([aria-pressed="true"]) { background: #262a33; border-color: #343a46; color: #e8eaee; }
.session input { background: #0f1115; border-color: #343a46; color: #e8eaee; }
.session-bar { justify-content: space-between; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.keys { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 15px; padding: 6px 12px; border-radius: 999px; background: #262a33; }
.badge.on { background: var(--ok); color: #fff; }
.badge.off { background: var(--danger); color: #fff; }

.stage { position: relative; min-height: 0; overflow: hidden; }
.stage video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair;
}
.stage.pointing video { cursor: pointer; }
.stage-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: 22px; text-align: center; padding: 24px; color: #e8eaee;
}
.pointer-mark {
  position: absolute; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%;
  border: 4px solid #ffcc00; pointer-events: none; animation: fade 1.2s forwards;
}
@keyframes fade { to { opacity: 0; transform: scale(1.6); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); font-size: 17px;
}

@media (max-width: 640px) {
  :root { --fs: 17px; --gap: 12px; }
  .inline-form { width: 100%; }
  .inline-form input { flex: 1; width: auto; }
  .btn { font-size: 16px; padding: 8px 12px; }
}
