/* ============================================================
   KidsTube — родительская часть (каталог, аккаунт, редактор)
   Тёмная тема по умолчанию.
   ============================================================ */

:root, :root[data-theme="dark"] {
    --bg: #0f0f0f;
    --bg-soft: #1a1a1a;
    --card: #1c1c1c;
    --fg: #f1f1f1;
    --muted: #a3a3a3;
    --line: #2e2e2e;
    --field: #262626;
    --field-line: #3a3a3a;
    --link: #7cb0ff;
    --accent: #ff0033;
    --accent-dark: #cc0029;
    --ok: #14331f;      --okfg: #7ee2a0;
    --warn: #3a2e12;    --warnfg: #ffd48a;
    --err: #46141e;     --errfg: #ff9db0;
    --shadow: rgba(0, 0, 0, .55);
    --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --bg-soft: #f6f6f8;
    --card: #ffffff;
    --fg: #111111;
    --muted: #5f6368;
    --line: #e2e2e6;
    --field: #ffffff;
    --field-line: #cdcdd3;
    --link: #0b57d0;
    --ok: #e6f6ea;      --okfg: #0f6b2f;
    --warn: #fff4dd;    --warnfg: #7a4d00;
    --err: #ffe6ea;     --errfg: #a1002a;
    --shadow: rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
img { max-width: 100%; }
code { background: var(--field); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.hidden { display: none !important; }

/* шапка */
.top {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    position: sticky; top: 0; z-index: 20;
}
.brand {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 800; font-size: 20px; text-decoration: none; color: var(--fg);
}
.brand-mark {
    width: 30px; height: 30px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 100%; height: 100%; }
.top-nav { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top-nav a { text-decoration: none; color: var(--fg); font-weight: 600; }
.top-nav a:hover { color: var(--link); }
.top-nav a.btn-primary { color: #fff; }
.inline { display: inline; margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; }

h1 { font-size: 28px; margin: 0 0 16px; line-height: 1.25; }
h2 { font-size: 20px; margin: 0 0 12px; }

/* кнопки */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--bg-soft); color: var(--fg);
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover { background: var(--field); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--errfg); border-color: var(--err); background: transparent; }
.btn-danger:hover { background: var(--err); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 13px 26px; font-size: 17px; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px 12px; }

/* сообщения */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 12px; }
.flash.ok    { background: var(--ok);   color: var(--okfg); }
.flash.warn  { background: var(--warn); color: var(--warnfg); }
.flash.error { background: var(--err);  color: var(--errfg); }
.ok-badge  { color: var(--okfg); }
.err-badge { color: var(--errfg); }

/* карточки-контейнеры */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}
.card.narrow { max-width: 460px; margin: 40px auto; }
.card.center { text-align: center; }
.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 26px; }
.prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }

/* формы */
label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label.chk { display: flex; align-items: flex-start; gap: 8px; color: var(--fg); font-size: 15px; }
label.chk input { margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
    display: block; width: 100%; margin-top: 4px;
    padding: 11px 13px;
    border: 1px solid var(--field-line); border-radius: 10px;
    background: var(--field); color: var(--fg);
    font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row.tight { align-items: center; margin-bottom: 8px; }
.row .grow { flex: 1; min-width: 200px; }
.row label { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

/* главная */
.hero { text-align: center; padding: 20px 0 28px; }
.hero h1 { font-size: 34px; }
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto 20px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.search { display: flex; gap: 10px; margin: 0 0 24px; }
.search input { margin: 0; }

.pl-grid {
    margin: 0 0 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 20px;
}
.pl-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 16px;
    padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.pl-cover {
    display: block; position: relative;
    aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--field);
}
.pl-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-count {
    position: absolute; right: 8px; bottom: 8px;
    background: rgba(0,0,0,.72); color: #fff;
    padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
}
.pl-title { font-size: 17px; margin: 0; line-height: 1.3; }
.pl-title a { color: var(--fg); text-decoration: none; }
.pl-title a:hover { color: var(--link); }
.pl-desc { color: var(--muted); font-size: 14px; margin: 0; }
.pl-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.pl-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.pager { display: flex; gap: 8px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pager a {
    padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
    text-decoration: none; color: var(--fg);
}
.pager a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* редактор плейлиста */
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; flex: 1; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.items { display: grid; gap: 14px; margin: 0 0 22px; }
.item {
    display: grid; grid-template-columns: 160px 1fr; gap: 14px;
    padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-soft);
}
.item-thumb { width: 160px; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: var(--field); }
.item-body { min-width: 0; }
.item-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.item-actions .small { margin-right: auto; }
@media (max-width: 640px) {
    .item { grid-template-columns: 1fr; }
    .item-thumb { width: 100%; }
}

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-size: 13px; font-weight: 600; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* подвал */
.foot {
    border-top: 1px solid var(--line);
    padding: 24px 20px 40px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}
.foot a { color: var(--muted); }
.foot-note { max-width: 720px; margin: 10px auto 0; font-size: 13px; }

/* устройства и стоп-кнопка */
.card-alarm { border-color: #7a2230; background: #2a1218; }
.item-device { grid-template-columns: 56px 1fr; }
.item-device.is-blocked { border-color: #7a2230; background: #2a1218; }
.dev-icon { font-size: 34px; text-align: center; line-height: 1.2; }

/* однотонные иконки */
.ic { vertical-align: -0.15em; flex: none; }
.btn .ic { margin-right: 2px; }
.btn-icon .ic { margin: 0; }
h2 .ic { vertical-align: -0.2em; margin-right: 4px; opacity: .85; }

/* индикатор «на связи» */
.dot-on {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: #4ade80; margin-right: 4px; vertical-align: 1px;
}
.dev-meta { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ограничение времени */
.limit-box {
    margin-top: 10px; padding: 10px 12px;
    border: 1px dashed var(--line); border-radius: 12px;
}
.limit-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.limit-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.limit-row input[type=time] { padding: 6px 8px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field); color: var(--fg); }

/* разделы в редакторе */
.item-section { grid-template-columns: 1fr; gap: 10px; }
.sect-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sect-move-items { margin: 0; padding-top: 8px; border-top: 1px dashed var(--line); }
.opts { display: grid; gap: 8px; margin: 14px 0 4px; }
.pager-gap { color: var(--muted); padding: 8px 4px; }

/* вход через Google */
.or-line { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-google { background: #fff; color: #1a1a1a; border-color: #dadce0; font-weight: 600; }
.btn-google:hover { background: #f1f3f4; }
.btn-google .ic { color: #4285f4; }

/* код для входа в приложение */
.app-code {
    font-size: 40px; font-weight: 800; letter-spacing: 10px;
    padding: 18px 10px; margin: 10px 0 6px;
    background: var(--field); border: 1px dashed var(--field-line); border-radius: 14px;
    font-variant-numeric: tabular-nums;
}

/* колокольчик */
.bell { position: relative; display: inline-flex; align-items: center; padding: 4px; }
.bell-badge {
    position: absolute; top: -4px; right: -6px;
    min-width: 18px; height: 18px; padding: 0 4px;
    border-radius: 9px; background: var(--accent); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* уведомления */
.note { grid-template-columns: 44px 1fr; padding: 14px; }
.note .item-body > p:last-child { margin-bottom: 0; }
.note-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.note-body { margin: 8px 0 0; white-space: pre-line; }
.note-warning { border-color: #7a4b22; background: #2a1d12; }
.note-promo { border-color: #24506e; background: #101d28; }

/* сводка админки */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat-num { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat-warn { border-color: #7a2230; }
.item-user { grid-template-columns: 56px 1fr; }
.notify-box { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.notify-box summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.notify-box form { margin-top: 10px; }

/* ============================================================
   Мобильная вёрстка кабинета: компактная шапка (две невысокие строки:
   логотип + тема, ниже — ссылки прокруткой), таблицы без «гармошки».
   ============================================================ */
@media (max-width: 720px) {
    .top { padding: 8px 12px 6px; gap: 6px; row-gap: 4px; }
    .brand { font-size: 17px; gap: 6px; }
    .brand-mark { width: 26px; height: 26px; }
    .brand-mark svg { width: 100%; height: 100%; }
    .top-nav {
        margin-left: 0; width: 100%; flex-wrap: nowrap; gap: 14px;
        overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
        font-size: 14px; padding: 2px 44px 2px 0;
    }
    .top-nav::-webkit-scrollbar { display: none; }
    .top-nav a { white-space: nowrap; }
    .top-nav .nav-catalog { display: none; }   /* на телефоне в каталог ведёт логотип */
    .top-nav .inline .btn { padding: 4px 10px; font-size: 13px; }
    /* переключатель темы — в правый верхний угол, рядом с логотипом */
    .top-nav .btn-icon { position: absolute; right: 10px; top: 6px; width: 34px; height: 34px; padding: 0; }
    .top-nav .btn-icon svg { width: 18px; height: 18px; }
    .bell { padding: 2px; }
    .wrap { padding: 16px 12px 32px; }
    .card { padding: 14px; margin-bottom: 14px; border-radius: 14px; }
    .pl-grid { gap: 12px; margin-bottom: 16px; }
    .pl-card { padding: 12px; }
    .page-head { margin-bottom: 12px; gap: 10px; }
    .page-head h1 { font-size: 22px; }

    /* широкие таблицы (админка, отчёты) прокручиваются по горизонтали, а не сжимаются */
    .tbl:not(.tbl-stats) { display: block; overflow-x: auto; white-space: nowrap; }

    /* «Что чаще смотрят»: строка = карточка: название в две строки, ниже плейлист и просмотры */
    .tbl-stats { font-size: 14px; }
    .tbl-stats thead { display: none; }
    .tbl-stats tbody, .tbl-stats tr, .tbl-stats td { display: block; }
    .tbl-stats tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
    .tbl-stats td { padding: 0; border: 0; }
    .tbl-stats td.t-title {
        font-weight: 600; line-height: 1.3; margin-bottom: 4px;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    }
    .tbl-stats td.t-pl { display: inline; color: var(--muted); font-size: 13px; }
    .tbl-stats td.t-num { display: inline; color: var(--muted); font-size: 13px; }
    .tbl-stats td.t-num::before { content: " · "; }
    .tbl-stats td.t-num::after { content: " просм."; }
}
/* обложка плейлиста в редакторе */
.item-thumb-wrap { position: relative; display: block; }
.item-thumb-wrap .item-thumb { display: block; }
.cover-badge {
    position: absolute; left: 6px; top: 6px;
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(0,0,0,.72); color: #fff; font-size: 11px; font-weight: 600;
    padding: 3px 7px; border-radius: 6px;
}
.cover-badge svg { fill: #fff; }
.item.is-cover { border-color: var(--accent); }
.pl-cover-sm { margin: -2px 0 4px; }
@media (max-width: 640px) { .item-thumb-wrap .item-thumb { width: 100%; } }

/* строка со ссылкой на приложение под первым экраном каталога */
.app-line { margin-top: 14px; align-items: center; }
.app-line-note { text-align: center; }
.app-line-note a { color: var(--fg); }

/* «Что показывать сейчас» на карточке устройства */
.assign { margin: 10px 0 4px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--bg-soft); }
.assign summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.assign summary svg { vertical-align: -0.2em; }
.assign-form { margin-top: 10px; }
.assign-list { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 10px; }
.assign-list .chk { font-size: 14px; }
