/* ====================================
   Reset & Base Styles
==================================== */
* {
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  :root {
    /* Обновлённая цветовая схема */
    --primary: #00ff00;      /* Основной цвет (зелёный) */
    --secondary: #1f1f1f;    /* Тёмный фон/оттенок */
    --background: #1f1f1f;   /* Фон */
    --surface: #2c2c2c;      /* Поверхность (слегка светлее фона) */
    --text: #d64306;         /* Основной цвет текста (светлый) */
  }
  
  html {
    height: 100%;
    margin: 0;
    padding: 0;
    font-size: clamp(10px, 1vw + 0.5em, 15px);
  }
  
  body {
    font-family: 'Roboto', Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: #000 url('web/bodybackground.jpg') no-repeat center center fixed;
    background-size: cover;
    position: relative;
    z-index: 0;
    color: var(--text);
    display: flex;
    flex-direction: column;
    /* Fixed overlays must be relative to the viewport, not a transformed body. */
    min-height: 100vh;
  }
  
  /* ====================================
     Layout Containers
  ==================================== */
  .container {
    width: 90%;
    max-width: 1200px;
    margin: auto;
    padding: 20px;
    flex: 1;
  }
  
  /* ====================================
     Navigation
  ==================================== */
  nav {
    background: url('./web/header-bg.jpg');
    background-size: cover;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 20px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 1),
                inset 0 -5px 15px rgba(0, 0, 0, 0.7);
    border-bottom: black 1px solid;
  }
  
  .nav-title {
    font-size: 1.2em;
    color: var(--text);
    flex-grow: 1;
  }
  
  nav a {
    color: var(--primary);
    text-decoration: none;
    font-weight: bold;
  }
  
  /* Кнопка меню */
  #sidebar-toggle {
    background: url('web/icon.ico') no-repeat center center;
    background-size: contain;
    width: 40px;
    height: 40px;
    border: var(--text) 1px solid;
    border-radius: 42%;
    cursor: pointer;
    transition: all 0.15s ease;
  }
  
  #sidebar-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--primary) 0 0 10px;
    border: var(--primary) 1px solid;
    border-radius: 15px;
  }
  
  #sidebar-toggle:active {
    transform: scale(0.96);
    box-shadow: var(--text) 0 0 15px;
    border: var(--text) 1px solid;
    border-radius: 15px;
  }
  
  /* ====================================
     Sidebar
  ==================================== */
  .sidebar-header {
    padding: 20px 15px 10px;
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
    color: var(--text);
    font-family: 'Roboto', sans-serif;
    background: url('web/header-bg.jpg') no-repeat 30% center;
    background-size: 300% 500%;
    background-color: var(--primary);
    background-blend-mode: multiply;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
  }
  
  #sidebar {
    position: sticky;
    margin-top: -768px;
    top: 60px;
    left: 0;
    width: 250px;
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: repeating-linear-gradient(
        45deg,
        #111 0px,
        #111 10px,
        #1b1b1b 10px,
        #1b1b1b 20px
      ),
      repeating-linear-gradient(
        45deg,
        #0f0f0f 0px,
        #0f0f0f 10px,
        #1a1a1a 10px,
        #1a1a1a 20px
      ),
      radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.05), transparent 50%),
      radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.03), transparent 50%);
    transform: translateX(-100%);
    transition: transform 0.4s ease;
    z-index: 998;
    overflow: auto;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
  }
  
  #sidebar::-webkit-scrollbar {
    display: none;
  }
  
  #sidebar.active {
    transform: translateX(0);
    border-right: 2px solid var(--primary);
    box-shadow: 5px 0 20px rgba(0, 255, 0, 0.3);
  }
  
  .sidebar-content {
    flex: 1 1 auto;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: flex-start;
    min-height: 0;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
  }


  .sidebar-content::-webkit-scrollbar {
    display: none;
  }
  
  .sidebar-btn {
    background: url('web/bodybackground.jpg') no-repeat 20% center;
    background-size: 500% 1000%;
    color: var(--text);
    font-size: 0.9em;
    padding: 10px 16px;
    width: 90%;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
    margin: 10px auto;
    display: block;
    transition: all 0.15s ease;
  }
  
  .sidebar-btn:hover {
    background-color: var(--primary);
    background-blend-mode: multiply;
  }
  
  .sidebar-btn:active {
    box-shadow: inset 0 0 20px black, 0 0 10px var(--primary);
    transform: scale(0.96);
  }
  
  .sidebar-footer {
    flex-shrink: 0;
    padding: 40px;
    text-align: center;
    background: url('web/logo.png') no-repeat center center;
    background-size: 200%;
    border-radius: 10px;
    border-top: 1px solid var(--primary);
  }
  
  /* ====================================
     Status & Command Log
  ==================================== */
  .ws-status {
    margin: 20px 15px;
    padding: 10px;
    font-size: 0.8em;
    text-align: center;
    font-weight: bold;
    border-radius: 6px;
    width: auto;
    transition: background 0.3s, color 0.3s;
    background-color: rgba(255, 0, 0, 0.2);
    color: #ff5555;
  }
  
  .ws-status.connected {
    color: var(--primary);
    text-shadow: var(--primary);
  }
  
  .ws-status.disconnected {
    color: var(--text);
    text-shadow: var(--text);
  }
  
  .command-log {
    background-color: #000;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 10px;
    border: 1px solid #00ff00;
    border-radius: 6px;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.4;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
  }
  
  .command-log::-webkit-scrollbar {
    display: none;
  }
  
  .command-log div {
    margin-bottom: 6px;
  }
  
  .command-log::after {
    content: "_";
    animation: blink 1s step-start infinite;
    margin-left: 5px;
  }
  
  /* ====================================
     Preloader & Spinner
  ==================================== */
  #preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }
  
  .spinner {
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-top: 6px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
  }
  
  /* ====================================
     Accordion
  ==================================== */
  .accordion-section {
    margin-bottom: 15px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 0 10px var(--primary);
    transition: all 1s ease-in-out;
    animation: glow 10s infinite;
  }
  
  .accordion-header {
    padding: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease-out;
    background: url('web/bodybackground.jpg') no-repeat center center;
    background-size: cover;
  }
  
  .accordion-header:hover {
    background: linear-gradient(135deg, rgba(0, 255, 0, 0.3), transparent),
                url('web/bodybackground.jpg');
    background-color: var(--primary);
    background-blend-mode: multiply;
    background-position: center;
    background-size: cover;
  }
  
  .accordion-content {
    max-height: 0;
    opacity: 0;
    transform: none;
    overflow: hidden;
    transition: max-height 0.5s ease-out, opacity 0.5s ease-out;
    position: relative;
    /* fixed scale: «cover» enlarged the picture with the height of the open section (long texts) */
    background: url('web/header-bg.jpg') repeat center top;
    background-size: 1200px auto;
  }
  
  .accordion-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    opacity: 0;
    pointer-events: none;
  }
  
  .accordion-header.active + .accordion-content {
    max-height: 1000px;
    opacity: 1;
    transform: none;
    padding: 20px;
  }
  
  /* ====================================
     Lists & Typography
  ==================================== */
  ul {
    list-style: none;
    padding: 20px;
  }
  
  li {
    margin: 10px 0 20px 0;
    padding: 20px;
    background: rgba(72, 22, 2, 0.5);
    border-left: 4px solid var(--primary);
    border-radius: 5px;
    transition: all 0.3s ease;
    position: relative;
    color: white;
  }
  
  li:hover {
    transform: translateX(10px);
    background: rgba(72, 22, 2, 0.7);
    box-shadow: 0 0 15px rgba(214, 66, 6, 0.2);
    text-shadow: rgba(0, 0, 0, 0.8);
  }
  
  h1 {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    color: var(--primary);
    text-align: center;
    font-size: 2em;
    border: black solid rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.5);
    text-shadow: 0 0 20px black transparent;
  }
  
  h2 {
    margin: 0;
  }
  
  p,
  span,
  li,
  body,
  h1,
  h2 {
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
  }
  
  code {
    color: var(--primary);
    font-size: 1.2em;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
  }
  
  p {
    color: white;
    margin-right: 10%;
  }
  
  a {
    color: var(--primary);
    text-decoration: none;
    transition: color 1s ease;
  }
  
  a:hover {
    color: white;
    text-shadow: 1px 1px 5px var(--primary);
  }
  
  /* ====================================
     Video & Iframes
  ==================================== */
  .video-section {
    margin: 90px 0;
    text-align: center;
  }
  
  img {
    animation: glow 10s infinite;
    width: 100%;
    border: var(--secondary) solid 1px;
    border-radius: 10px;
  }
  
  iframe {
    animation: glow 10s infinite;
    width: 50%;
    max-width: 100%;
    border: var(--secondary) solid 1px;
    border-radius: 10px;
  }
  
  .small-video {
    margin-top: 15px;
    text-align: center;
  }
  
  .small-video iframe {
    width: 320px;
    height: 180px;
    border: none;
    border-radius: 5px;
  }
  
  /* ====================================
     Footer
  ==================================== */
  footer {
    background: url('web/header-bg.jpg') no-repeat center 65%;
    background-size: cover;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
    border-top: black 2px solid;
    box-shadow: inset 0 10px 10px rgba(0, 0, 0, 1),
                 0 -5px 5px rgba(0, 0, 0, 0.7);
  }
  
  /* ====================================
     Responsive Media Queries
  ==================================== */
  @media (max-width: 768px) {
    body {
      background-attachment: scroll;
      transform: none;
      will-change: auto;
      padding: 0px;
      font-size: 14px;
    }

    .sidebar-header{
        border-radius: 8px;
        animation: glow 10s infinite;
    }
    .sidebar-btn{
        border: var(--primary) 0.5px solid;
    }

    
    .sidebar-footer,
    .command-log {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
  
    nav a {
      padding: 5px 10px;
      gap: 10px;
      box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
      white-space: nowrap;
    }
  
    iframe {
      width: 100%;
    }
  
    footer {
      align-items: center;
    }
  
    ul {
      padding: 10px;
    }
  
    li {
      padding: 10px;
    }
  
    .accordion-header {
      padding: 15px;
    }
  
    .accordion-content {
      padding: 0 10px;
    }
  
    .accordion-header.active + .accordion-content {
      padding: 10px;
    }
  
    .video-section {
      margin: 50px 0;
      text-align: center;
    }
  
    #sidebar {
      position: sticky;
      top: 40px;
      left: 0;
      height: 100vh;
      width: 250px;
      transform: translateX(-100%);
      transition: transform 0.3s ease-in-out;
      z-index: 998;
      overflow-y: auto;
      background-color: rgba(0, 0, 0, 0.9);
      padding: 20px;
      box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
    }
  
    #sidebar.active {
      transform: translateX(0);
    }
  }
  .sidebar-content{
    flex: 1;

  }
  
  /* Дополнительный медиа-запрос для очень маленьких экранов */
  @media (max-width: 480px) {
    body {
      font-size: 12px;
    }
    
    nav {
      padding: 5px 10px;
    }
    
    .container {
      padding: 10px;
    }
    
    h1 {
      font-size: 1.8em;
    }
  }
  
  /* ====================================
     Gesture Area for Sidebar
  ==================================== */
  #gesture-area {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 30px;
    z-index: 997;
  }
  
  /* ====================================
     Keyframes & Animations
  ==================================== */
  @keyframes spin {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
  
  @keyframes blink {
    50% {
      opacity: 0;
    }
  }
  
  @keyframes glow {
    0% {
      box-shadow: 0 0 10px var(--primary);
    }
    25% {
      box-shadow: 0 0 20px black;
    }
    50% {
      box-shadow: 0 0 10px silver;
    }
    75% {
      box-shadow: 0 0 20px black;
    }
    100% {
      box-shadow: 0 0 10px var(--primary);
    }
  }
  


/* ====================================
   Пульт (боковая панель): состояние, список ТВ, действия
==================================== */
#sidebar { width: 320px; }
@media (max-width: 768px) { #sidebar { width: 88vw; max-width: 360px; } }
.remote-head { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.remote-logo { width: 120px; max-width: 60%; border-radius: 10px; }
.remote-state { color: #e8e8e8; font-size: 0.9em; padding: 0 4px; }
#r-state { color: var(--primary); font-weight: bold; }
.r-small { font-size: 0.8em; color: #bdbdbd; }
.r-trouble { color: #ff5555; font-weight: bold; font-size: 0.85em; margin-top: 4px; }
.r-sync { display: flex; align-items: center; gap: 6px; justify-content: center; color: var(--text); font-size: 0.85em; }
.r-sync input {
    width: 48px; padding: 4px; text-align: center; font-size: 0.95em;
    background: #000; color: var(--primary); border: 1px solid var(--primary); border-radius: 6px;
}
.r-tvs { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.r-group { color: var(--text); font-weight: bold; font-size: 0.8em; margin-top: 8px; text-transform: uppercase; }
.r-tv {
    display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; text-align: left;
    width: 100%; padding: 7px 9px; background: rgba(0, 0, 0, 0.55); color: #e8e8e8; font-size: 0.85em;
    border: 1px solid #333; border-radius: 8px; cursor: pointer;
}
.r-tv:active { border-color: var(--primary); }
.r-dot { width: 8px; height: 8px; border-radius: 50%; background: #666; }
.r-dot.ok { background: var(--primary); }
.r-dot.wait { background: var(--text); }
.r-dot.bad { background: #ff3333; }
.r-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; }
.r-st { font-size: 0.85em; color: #bdbdbd; }
.r-meta { grid-column: 2 / 4; font-size: 0.75em; color: #8a8a8a; }
.tv-sheet {
    position: fixed; inset: 0; z-index: 1001; background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: flex-end; justify-content: center;
}
.tv-sheet[hidden] { display: none; }
.tv-sheet-box {
    width: 100%; max-width: 420px; padding: 14px 16px 22px; background: #111;
    border-top: 2px solid var(--primary); border-radius: 14px 14px 0 0;
}
.tv-sheet-title { color: var(--primary); font-weight: bold; font-size: 1.05em; }
.r-modes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 5%; color: #ccc; font-size: 0.85em; }
.r-modes button {
    padding: 6px 10px; background: #000; color: var(--text); border: 1px solid var(--text); border-radius: 6px; font-size: 0.9em;
}
.r-modes button.on { background: var(--text); color: #000; }

#tv-sheet [hidden], .sidebar-content [hidden] { display: none !important; }

/* Текст инструкции можно выделить и скопировать (адреса, пути настроек) */
.container, .container li, .container code, .r-meta, .command-log { -webkit-user-select: text; user-select: text; }
.accordion-content img { max-width: 100%; height: auto; }

/* Пульт всегда виден целиком под шапкой, на любой прокрутке страницы (раньше: sticky со сдвигом -768px) */
#sidebar, #sidebar.active {
    position: fixed !important;
    margin-top: 0 !important;
    top: var(--nav-h, 60px) !important;
    left: 0;
    height: calc(100vh - var(--nav-h, 60px)) !important;
    height: calc(100dvh - var(--nav-h, 60px)) !important;
}
/* Больше места списку ТВ в пульте: компактный журнал и логотип внизу */
#sidebar .command-log { max-height: 70px; font-size: 12px; }
#sidebar .sidebar-footer { padding: 18px; background-size: 140%; }
#sidebar .sidebar-btn { margin: 4px auto; padding: 8px 14px; }
#sidebar .ws-status { margin: 6px 10px; padding: 6px; }

.r-connect { display: flex; flex-direction: column; gap: 4px; }
.r-connect input {
    margin: 0 5%; padding: 6px 8px; text-align: center; font-size: 0.95em;
    background: #000; color: var(--primary); border: 1px solid var(--primary); border-radius: 6px;
}

/* Layout corrections shared by the instruction and remote. */
#sidebar {
    padding: 0;
    overflow: hidden;
    overscroll-behavior: contain;
}
.sidebar-header { flex-shrink: 0; border-radius: 0; }
.sidebar-content { min-width: 0; overscroll-behavior: contain; }
#sidebar .command-log {
    flex-shrink: 0;
    width: 100%;
    margin: 0;
    border-radius: 0;
    overflow-wrap: anywhere;
}
.command-log:empty { display: none; }
#sidebar .sidebar-footer {
    width: 100%;
    height: 54px;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background-size: contain;
    background-color: #000;
}
.r-name, .r-meta, .r-small, .tv-sheet-info { min-width: 0; overflow-wrap: anywhere; }
.r-st { max-width: 100px; overflow-wrap: anywhere; }
.tv-sheet { padding-top: var(--nav-h, 60px); }
.tv-sheet-box { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.video-section iframe { width: 560px; height: auto; aspect-ratio: 16 / 9; background: #000; }
.small-video iframe { width: 320px; max-width: 100%; height: auto; aspect-ratio: 16 / 9; background: #000; }
#preview { display: block; width: 100%; max-width: 100%; }
#preview:fullscreen { object-fit: contain; background: #000; border: 0; border-radius: 0; }
.accordion-content { overflow-wrap: anywhere; }
.accordion-header { scroll-margin-top: calc(var(--nav-h, 60px) + 8px); }
.sidebar-btn, .r-tv, #sidebar-toggle { touch-action: manipulation; }
@media (max-width: 480px) {
    .container { width: 100%; padding: 14px; }
    .accordion-header h2 { font-size: 1.35em; }
    .accordion-content ul { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}

#sidebar { font-size: 15px; }
#sidebar .sidebar-btn { font-size: 0.9em; }
.accordion-content figure { margin: 0; }
.accordion-content figcaption { margin-top: 10px; font-size: 0.95em; }
.accordion-header h2 { min-width: 0; }
.accordion-header .fas { flex-shrink: 0; margin-left: 12px; }

/* The animated logo is the header artwork itself, not a thumbnail on another image. */
#sidebar .remote-head {
    padding: 0;
    gap: 0;
    background: #000;
    border-radius: 0;
    box-shadow: none;
}
#sidebar .remote-logo {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    border: 0;
    border-radius: 0;
    animation: none;
}
.remote-head > div { width: 100%; padding: 8px 12px; font-size: 0.9em; }
#sidebar .command-log {
    min-height: 72px;
    max-height: 120px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.5;
    white-space: normal;
    border: 0;
    border-top: 1px solid #255125;
    box-shadow: none;
}
#sidebar .command-log:empty { display: none; }
.command-log div { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.command-log div:last-child { margin-bottom: 0; }
.command-log::after { content: none; }
footer {
    width: 100%;
    padding: 18px 20px;
    background: #090b09;
    border-top: 1px solid #255125;
    box-shadow: none;
    align-items: center;
    justify-content: center;
}
footer p { margin: 0; color: #a8b5a8; font-size: 0.9em; }
@media (max-height: 480px) {
    #sidebar .remote-logo { max-height: 100px; }
    #sidebar .command-log { max-height: 90px; }
}

/* Explicit borders avoid the browser's raised grey button edge and pulsing silver outlines. */
#sidebar .sidebar-btn {
    border: 1px solid #387838;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.12);
}
#sidebar .sidebar-btn:hover, #sidebar .sidebar-btn:focus-visible { border-color: var(--primary); }
.accordion-section, .accordion-content img, iframe { animation: none; box-shadow: 0 0 10px rgba(0, 255, 0, 0.16); }
.accordion-header.active .fa-chevron-down { transform: rotate(180deg); }

#sidebar .sidebar-content { scrollbar-width: thin; scrollbar-color: #387838 #111; }
#sidebar .sidebar-content::-webkit-scrollbar { display: block; width: 5px; }
#sidebar .sidebar-content::-webkit-scrollbar-thumb { background: #387838; border-radius: 4px; }

.tv-sheet .sidebar-btn { border: 1px solid #387838; box-shadow: 0 0 8px rgba(0, 255, 0, 0.12); }
.tv-sheet .sidebar-btn:hover, .tv-sheet .sidebar-btn:focus-visible { border-color: var(--primary); }

/* пульт: код сопряжения с экрана ТВ, найденные ТВ */
.r-codes { position: fixed; z-index: 3000; left: 8px; right: 8px; top: calc(var(--nav-h, 60px) + 6px);
           max-width: 420px; margin: 0 auto; }
.r-codes[hidden] { display: none; }
.r-code { background: #070707; box-shadow: 0 0 0 100vmax rgba(0,0,0,.6), 0 6px 30px rgba(0,0,0,.9); }
.r-code { border: 2px solid var(--primary); border-radius: 10px; padding: 10px; background: #070707; color: var(--text); }
.r-code b { color: var(--primary); display: block; margin-bottom: 4px; }
.r-code input { width: 100%; box-sizing: border-box; margin: 8px 0; padding: 10px; font-size: 1.4em; letter-spacing: .3em;
                text-align: center; border-radius: 8px; border: 1px solid var(--text); background: #000; color: var(--text); }
.r-code-btns { display: flex; gap: 6px; }
.r-code-btns .sidebar-btn { flex: 1; margin: 0; }
.r-center { text-align: center; margin: 4px 0; }
.r-new .r-st { color: var(--primary); }
.r-link { display: block; width: 100%; background: none; border: none; color: var(--text); cursor: pointer; text-decoration: underline; }

.instr-note { margin: 6px 0 10px; color: #ddd; line-height: 1.45; }
.instr-choice { margin: 8px 0 8px 10px; padding: 8px 10px; border-left: 3px solid var(--primary); background: rgba(0,0,0,.35); border-radius: 6px; }
/* пульт компактнее: лого прячется после первого действия */
#sidebar.compact .remote-head { display: none; }
/* на телефоне пульт во всю ширину: сбоку не просвечивает страница */
@media (max-width: 768px) { #sidebar, #sidebar.active { width: 100vw; max-width: none; border-right: none; } }
/* журнал ответов: тонкая строка с последним сообщением, по нажатию — последние несколько */
#sidebar .command-log {
    font-family: inherit; font-size: 11px; line-height: 1.4; color: #a8e6a8;
    background: rgba(0, 0, 0, .78); border: none; border-top: 1px solid rgba(0, 255, 0, .35);
    padding: 5px 12px; min-height: 0; max-height: none; overflow: hidden; cursor: pointer;
}
#sidebar .command-log::after { display: none; }
#sidebar .command-log div { display: none; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar .command-log div:last-child { display: block; }
#sidebar .command-log.open { max-height: 8.5em; overflow-y: auto; }
#sidebar .command-log.open div { display: block; white-space: normal; padding: 1px 0; }
/* настройки ТВ в карточке: строки «название — значение ›» */
.r-settings { margin: 8px 5%; border: 1px solid #333; border-radius: 10px; overflow: hidden; }
.r-setting { display: flex; align-items: center; width: 100%; gap: 8px; padding: 11px 12px; background: rgba(255,255,255,.03);
             border: none; border-bottom: 1px solid #2a2a2a; color: #ddd; font-size: 14px; text-align: left; cursor: pointer; }
.r-setting:last-child { border-bottom: none; }
.r-setting-name { flex: 0 0 auto; color: #aaa; }
.r-setting-value { flex: 1; text-align: right; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-setting-go { color: #777; font-size: 18px; line-height: 1; }
/* список выбора: выезжает снизу поверх карточки */
.r-picker { position: fixed; inset: 0; z-index: 3500; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; }
.r-picker[hidden] { display: none; }
.r-picker-box { width: 100%; max-width: 520px; margin: 0 auto; background: #0b0b0b; border-top: 2px solid var(--primary);
                border-radius: 14px 14px 0 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); max-height: 75vh; overflow-y: auto; }
.r-picker-title { color: var(--primary); font-weight: bold; font-size: 1.05em; }
.r-picker-list { display: flex; flex-direction: column; margin: 8px 0; }
.r-option { display: flex; align-items: center; gap: 10px; padding: 12px 6px; background: none; border: none;
            border-bottom: 1px solid #222; color: #ddd; font-size: 15px; text-align: left; cursor: pointer; }
.r-option:disabled { color: #555; }
.r-check { width: 18px; height: 18px; border: 1px solid #555; border-radius: 50%; flex: 0 0 auto; }
.r-option.on .r-check { border-color: var(--primary); background: radial-gradient(var(--primary) 45%, transparent 50%); }
.r-option.on { color: var(--primary); }
.r-picker-btns { display: flex; gap: 8px; }
.r-picker-btns .sidebar-btn { flex: 1; margin: 0; }
.r-picker-btns .sidebar-btn[hidden] { display: none; }
.r-picker-list.multi .r-check { border-radius: 4px; }
.r-picker-list.multi .r-option.on .r-check { background: var(--primary); box-shadow: inset 0 0 0 3px #0b0b0b; }
/* ---------- пульт: компактные действия (2 в ряд, иконки), тонкая строка связи ---------- */
.r-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 10px 4px; }
.r-sync { grid-column: 1 / -1; display: flex; align-items: center; gap: 5px; margin: 0; }
.r-sync input { width: 42px; padding: 7px 2px; }
.r-sync .r-act { flex: 1; }
.r-act {
    display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 8px;
    font-size: 13px; line-height: 1.2; color: #e4e4e4; background: rgba(255, 255, 255, .05);
    border: 1px solid #3a3a3a; border-radius: 10px; cursor: pointer; text-align: center;
}
.r-act i { color: var(--text); font-size: 14px; flex: 0 0 auto; }
.r-act:active { background: rgba(0, 255, 0, .12); }
.r-act:disabled { opacity: .45; }
.r-act.warn { border-color: var(--text); color: var(--text); background: rgba(214, 67, 6, .1); }
.r-act[hidden] { display: none !important; }
.r-wide { width: auto; margin: 8px 5% 4px; }
#tv-sheet .r-wide { width: 90%; }
#sidebar .ws-status.connected { font-size: 11px; padding: 2px 8px; margin: 6px 10px 0; background: none; border: none;
                                 color: #6fbf6f; box-shadow: none; text-align: left; }
/* карточка ТВ: крестик в углу вместо кнопки «Закрыть», действия сеткой */
.tv-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.r-close { background: none; border: none; color: #aaa; font-size: 20px; padding: 4px 8px; cursor: pointer; }
.r-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 5% 4px; }
/* лого пульта на весь блок, надпись поверх него снизу; блок прячется после первого нажатия */
#sidebar .remote-head { position: relative; height: 130px; padding: 0; gap: 0; overflow: hidden; justify-content: flex-end;
                        background: #000; }
#sidebar .remote-logo { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
                        object-fit: cover; border-radius: 0; }
#sidebar .remote-head > div { position: relative; z-index: 1; padding: 18px 12px 8px; text-align: center;
                              background: linear-gradient(transparent, rgba(0, 0, 0, .78)); text-shadow: 0 1px 4px #000; }
/* список ТВ плотнее: больше ТВ на экране, строки по-прежнему удобно нажимать */
#sidebar .r-tvs { gap: 4px; }
#sidebar .r-tv { padding: 6px 10px; gap: 0 8px; font-size: 14px; min-height: 44px; }
#sidebar .r-tv .r-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
#sidebar .r-tv .r-st { font-size: 11.5px; }
#sidebar .r-group { margin-top: 10px; font-size: 11px; letter-spacing: .04em; }
/* заголовок группы ТВ — кнопка сворачивания */
#sidebar .r-group { display: block; width: 100%; background: none; border: none; padding: 6px 2px; text-align: left; cursor: pointer; }
