:root {
  --bg: #fff; --text: #0f0f0f; --muted: #606060; --chip: rgba(0,0,0,.05); --chip-hover: rgba(0,0,0,.1);
  --line: rgba(0,0,0,.1); --hover: rgba(0,0,0,.05); --box: rgba(0,0,0,.05); --input: #fff; --input-line: #ccc;
  --search-btn: #f8f8f8; --red: #f00; --blue: #065fd4; --chip-on: #0f0f0f; --chip-on-text: #fff;
  --dialog: #fff; --badge: rgba(0,0,0,.8); --skeleton: #e5e5e5;
}
:root[data-theme="dark"] {
  --bg: #0f0f0f; --text: #f1f1f1; --muted: #aaa; --chip: rgba(255,255,255,.1); --chip-hover: rgba(255,255,255,.2);
  --line: rgba(255,255,255,.2); --hover: rgba(255,255,255,.1); --box: rgba(255,255,255,.1); --input: #121212;
  --input-line: #303030; --search-btn: #222; --blue: #3ea6ff; --chip-on: #f1f1f1; --chip-on-text: #0f0f0f;
  --dialog: #212121; --skeleton: #272727;
}
* { box-sizing: border-box; }
html { color-scheme: light; } :root[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.43 Roboto, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { fill: currentColor; }

/* ---------- шапка ---------- */
.masthead { position: fixed; inset: 0 0 auto; height: 56px; z-index: 20; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; }
.mh-start, .mh-end { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }
.logo { display: flex; align-items: center; gap: 4px; padding: 0 14px 0 8px; font-size: 19px; letter-spacing: -.6px; font-weight: 700; }
.logo-mark { width: 29px; height: 20px; }
.logo b { color: var(--red); font-weight: 700; }
.search { flex: 0 1 640px; display: flex; height: 40px; }
.search input { flex: 1; min-width: 0; border: 1px solid var(--input-line); border-right: 0; border-radius: 40px 0 0 40px;
  padding: 0 16px; font: 16px Roboto, Arial, sans-serif; background: var(--input); color: var(--text); outline: none; }
.search input:focus { border-color: #1c62b9; box-shadow: inset 0 1px 2px rgba(0,0,0,.3); }
.search button { width: 64px; border: 1px solid var(--input-line); background: var(--search-btn); border-radius: 0 40px 40px 0; cursor: pointer; display: grid; place-items: center; }
.search button svg { width: 24px; height: 24px; }
.create-btn { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px 0 10px; border: 0; border-radius: 18px;
  background: var(--chip); font-weight: 500; cursor: pointer; }
.create-btn:hover { background: var(--chip-hover); }
.search-back, .search-open, .tabbar { display: none; }
.create-btn svg { width: 24px; height: 24px; }

/* ---------- меню слева ---------- */
.guide { position: fixed; top: 56px; bottom: 0; left: 0; width: 240px; padding: 12px; overflow-y: auto; z-index: 15; background: var(--bg); }
.guide a { display: flex; align-items: center; gap: 24px; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.guide a:hover { background: var(--hover); }
.guide a.on { background: var(--chip); font-weight: 500; }
.guide svg { width: 24px; height: 24px; flex: none; }
.guide hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.guide-foot { color: var(--muted); font-size: 12px; line-height: 1.5; padding: 12px; margin: 0; }
/* переключатели внизу меню — красные, как у YouTube */
.toggles { display: flex; flex-direction: column; gap: 2px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; height: 40px; padding: 0 12px;
  border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.toggle:hover { background: var(--hover); }
.toggle i { position: relative; flex: none; width: 36px; height: 20px; border-radius: 10px; background: var(--chip-hover); transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.toggle[aria-checked="true"] i { background: var(--red); }
.toggle[aria-checked="true"] i::after { transform: translateX(16px); }
body.mini .toggle { flex-direction: column; justify-content: center; gap: 6px; height: 64px; padding: 0; font-size: 10px; text-align: center; line-height: 1.2; }
.scrim { display: none; }
body.mini .guide { width: 72px; padding: 4px; }
body.mini .guide a { flex-direction: column; gap: 6px; height: 74px; justify-content: center; padding: 0; font-size: 10px; text-align: center; line-height: 1.2; }
body.mini .guide hr, body.mini .guide-foot { display: none; }
main { padding: 56px 0 0 240px; min-height: 100vh; }
body.mini main { padding-left: 72px; }
body.watching .guide { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 20px rgba(0,0,0,.2); }
body.watching.guide-open .guide { transform: none; }
body.watching main { padding-left: 0; }
body.guide-open .scrim { display: block; position: fixed; inset: 56px 0 0; background: rgba(0,0,0,.5); z-index: 14; }

/* ---------- чипы ---------- */
.chips-wrap { position: sticky; top: 56px; z-index: 10; background: var(--bg); }
.chips { display: flex; gap: 12px; padding: 12px 24px; overflow-x: auto; scrollbar-width: none; }
.chip-arrow { display: none; position: absolute; top: 8px; z-index: 2; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--bg); font-size: 26px; line-height: 36px; cursor: pointer; color: var(--text); }
.chip-arrow:hover { background: var(--hover); }
.chip-arrow[data-dir="left"] { left: 4px; box-shadow: 14px 0 14px 2px var(--bg); }
.chip-arrow[data-dir="right"] { right: 4px; box-shadow: -14px 0 14px 2px var(--bg); }
.chips-wrap.can-left .chip-arrow[data-dir="left"], .chips-wrap.can-right .chip-arrow[data-dir="right"] { display: block; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: var(--chip); font-weight: 500; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; }
.chip:hover { background: var(--chip-hover); }
.chip.on { background: var(--chip-on); color: var(--chip-on-text); }
.chip.yt:not(.on) { background: none; box-shadow: inset 0 0 0 1px var(--line); font-weight: 400; }
.cat-box a.empty { opacity: .45; }

/* ---------- сетка ---------- */
.page { padding: 0 24px 40px; }
.page-title { font-size: 24px; font-weight: 700; margin: 20px 0 16px; }
.page-sub { color: var(--muted); margin: -8px 0 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 40px 16px; padding-top: 12px; }
.card { display: block; min-width: 0; position: relative; }
.thumb { position: relative; display: block; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: var(--skeleton); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frames { position: absolute; left: 8px; right: 8px; bottom: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.frames i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.45); }
.frames i.on { background: #fff; }
.thumb:hover .frames { opacity: 1; }
.thumb:hover .dur { bottom: 12px; }
.dur { position: absolute; right: 8px; bottom: 8px; background: var(--badge); color: #fff; font-size: 12px; font-weight: 500; padding: 1px 4px; border-radius: 4px; line-height: 18px; }
.card:hover .thumb { border-radius: 0; transition: border-radius .2s .1s; }
.details { display: flex; gap: 12px; margin-top: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 500; font-size: 15px; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.md { width: 40px; height: 40px; font-size: 17px; }
.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.meta { min-width: 0; }
.title { font-size: 16px; font-weight: 500; line-height: 22px; margin: 0 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sub { color: var(--muted); font-size: 14px; line-height: 20px; }
.sub.people { color: var(--red); font-weight: 500; }
.why { display: none; position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px); background: var(--dialog);
  box-shadow: 0 4px 32px rgba(0,0,0,.2); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--text); }
.card:hover .why { display: block; }
.more-sentinel { height: 1px; }
.empty { text-align: center; color: var(--muted); padding: 80px 20px; font-size: 16px; }
.empty b { display: block; color: var(--text); font-size: 20px; margin-bottom: 8px; }
.skel .thumb { animation: pulse 1.2s infinite alternate; }
@keyframes pulse { to { opacity: .5; } }

/* ---------- страница видео ---------- */
.watch { display: flex; gap: 24px; padding: 24px; max-width: 1754px; margin: 0 auto; }
.primary-col { flex: 1; min-width: 0; }
.secondary-col { width: 402px; flex: none; }
.player { aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: #000; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.v-title { font-size: 20px; line-height: 28px; font-weight: 700; margin: 12px 0 8px; }
.owner-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.owner { display: flex; align-items: center; gap: 12px; min-width: 0; }
.owner b { display: block; font-size: 16px; font-weight: 500; }
.owner small { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { height: 36px; padding: 0 16px; border-radius: 18px; border: 0; background: var(--chip); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill:hover { background: var(--chip-hover); }
.pill svg { width: 24px; height: 24px; }
.pill.primary { background: var(--text); color: var(--bg); }
.pill.primary:hover { opacity: .85; }
.pill.on svg { color: var(--text); }
.seg { display: inline-flex; border-radius: 18px; background: var(--chip); overflow: hidden; }
.seg .pill { border-radius: 0; background: none; }
.seg .pill:hover { background: var(--chip-hover); }
.seg .pill + .pill { border-left: 1px solid var(--line); padding: 0 14px; }
.desc { background: var(--box); border-radius: 12px; padding: 12px; margin-top: 12px; }
.desc .stats { font-weight: 500; }
.desc p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.desc .clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.desc .more { border: 0; background: none; font-weight: 500; cursor: pointer; padding: 0; margin-top: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tags a { background: var(--chip); padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.tags a:hover { background: var(--chip-hover); }
.tags small { opacity: .6; font-weight: 400; margin-left: 2px; }
.tags a.mine { outline: 2px solid var(--text); outline-offset: -2px; }
.tags a.yt-cat { background: none; border: 1px dashed var(--line); font-weight: 400; color: var(--muted); }
.theme-add { border: 0; background: var(--text); color: var(--bg); padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.theme-picker { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.theme-picker p { margin: 0 0 10px; color: var(--muted); font-size: 13px; white-space: normal; }
.theme-picker div { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-picker button { border: 1px solid var(--line); background: var(--bg); padding: 5px 10px; border-radius: 16px; font-size: 13px; cursor: pointer; }
.theme-picker button:hover { background: var(--hover); }
.theme-picker button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.theme-box { display: grid; gap: 4px; padding: 14px 16px; border-radius: 12px; background: var(--box); }
.theme-box:hover { background: var(--chip-hover); }
.theme-box b { font-size: 16px; }
.theme-box span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.theme-box small { font-size: 12px; font-weight: 500; margin-top: 4px; }
.theme-box.empty { opacity: .55; }
.c-head { display: flex; align-items: center; gap: 32px; margin: 24px 0 20px; }
.c-head h2 { font-size: 20px; margin: 0; }
.addrec { display: flex; gap: 16px; margin-bottom: 32px; }
.addrec form { flex: 1; }
.addrec textarea { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; padding: 4px 0; resize: none; outline: none; min-height: 26px; }
.addrec textarea:focus { border-bottom: 2px solid var(--text); }
.addrec .row { display: none; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 8px; }
.addrec.open .row { display: flex; }
.addrec input { border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; padding: 6px 0; outline: none; margin-right: auto; width: 160px; }
.comment { display: flex; gap: 16px; margin-bottom: 24px; }
.comment .body { min-width: 0; flex: 1; }
.c-meta { font-size: 13px; color: var(--muted); }
.c-meta b { color: var(--text); font-weight: 500; margin-right: 4px; }
.c-text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 20px; }
.c-text.clamped { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.c-foot { display: flex; align-items: center; gap: 16px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.c-foot a { font-weight: 500; color: var(--blue); }
.c-foot button { border: 0; background: none; color: var(--muted); font-weight: 500; cursor: pointer; padding: 0; font-size: 12px; }
.stance { font-weight: 500; }
.stance.rec { color: #2ba640; } .stance.crit { color: #cc0000; } .stance.site { color: var(--blue); }
.c-text .vid { color: var(--blue); }
.rel { display: flex; gap: 8px; margin-bottom: 8px; }
.rel .thumb { width: 168px; flex: none; border-radius: 8px; }
.rel .title { font-size: 14px; line-height: 20px; }
.rel .sub { font-size: 12px; line-height: 18px; }

/* ---------- рубрики ---------- */
.cat-grid { columns: 3 300px; column-gap: 16px; }
.cat-box { break-inside: avoid; border: 1px solid var(--line); border-radius: 12px; padding: 4px 0; margin-bottom: 16px; }
.cat-box a { display: flex; justify-content: space-between; gap: 12px; padding: 6px 16px; }
.cat-box a:hover { background: var(--hover); }
.cat-box a span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-box h3 { margin: 10px 16px 6px; font-size: 16px; }

/* ---------- о сайте ---------- */
.about { max-width: 760px; padding: 24px; font-size: 16px; line-height: 1.6; }
.about h1 { font-size: 32px; margin: 8px 0 4px; }
.about h2 { font-size: 20px; margin: 32px 0 8px; }
.nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 24px 0; }
.nums div { background: var(--box); border-radius: 12px; padding: 14px; }
.nums b { display: block; font-size: 26px; }
.nums span { color: var(--muted); font-size: 13px; }

/* ---------- диалог ---------- */
dialog { border: 0; border-radius: 12px; padding: 0; background: var(--dialog); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 4px 32px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog form { padding: 24px; display: grid; gap: 16px; }
dialog h2 { margin: 0; font-size: 20px; }
.muted { color: var(--muted); margin: -8px 0 0; }
dialog label { display: grid; gap: 6px; font-weight: 500; }
dialog input, dialog textarea { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--input-line); background: var(--input); color: var(--text); }
dialog input:focus, dialog textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.dlg-row { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.err { color: #cc0000; font-size: 13px; margin-right: auto; }
.toast { position: fixed; left: 24px; bottom: 24px; background: #0f0f0f; color: #fff; padding: 14px 20px; border-radius: 8px; opacity: 0; transform: translateY(20px); transition: .2s; pointer-events: none; z-index: 50; }
:root[data-theme="dark"] .toast { background: #f1f1f1; color: #0f0f0f; }
.toast.show { opacity: 1; transform: none; }

/* ---------- адаптив ---------- */
@media (max-width: 1312px) { body:not(.watching) .guide { width: 72px; padding: 4px; }
  body:not(.watching) .guide a { flex-direction: column; gap: 6px; height: 74px; justify-content: center; padding: 0; font-size: 10px; text-align: center; line-height: 1.2; }
  body:not(.watching) .guide hr, body:not(.watching) .guide-foot { display: none; }
  body:not(.watching) .toggle { flex-direction: column; justify-content: center; gap: 6px; height: 64px; padding: 0; font-size: 10px; text-align: center; line-height: 1.2; }
  body:not(.watching) main { padding-left: 72px; } }
@media (max-width: 1016px) { .watch { flex-direction: column; } .secondary-col { width: auto; } }
@media (max-width: 792px) {
  body:not(.watching) .guide { transform: translateX(-100%); width: 240px; padding: 12px; }
  body:not(.watching) .guide a { flex-direction: row; gap: 24px; height: 40px; justify-content: flex-start; padding: 0 12px; font-size: 14px; }
  body:not(.watching) .toggle { flex-direction: row; justify-content: space-between; height: 40px; padding: 0 12px; font-size: 14px; text-align: left; }
  body.guide-open .guide { transform: none !important; }
  body:not(.watching) main { padding-left: 0; }
  .create-btn span, .logo span { display: none; }
  .masthead { gap: 8px; padding: 0 8px; }
  .page { padding: 0 16px 32px; } .chips { padding: 12px 16px; } .watch { padding: 0 0 24px; }
  .player { border-radius: 0; } .primary-col > :not(.player), .secondary-col { padding: 0 16px; }
  .grid { grid-template-columns: 1fr; gap: 24px; }
}

/* ---------- телефон: как приложение YouTube ---------- */
@media (max-width: 600px) {
  /* шапка: логотип, лупа, тема; поиск раскрывается во всю ширину */
  .search { display: none; }
  .search-open { display: grid; }
  .mh-end .create-btn, .mh-end a.icon-btn { display: none; }
  .mh-end { gap: 0; }
  body.searching .mh-start, body.searching .mh-end { display: none; }
  body.searching .search { display: flex; flex: 1; gap: 4px; }
  body.searching .search-back { display: grid; flex: none; }
  body.searching .search input { border-radius: 40px; border-right: 1px solid var(--input-line); }
  body.searching .search > button:last-child { display: none; }

  /* нижняя панель вкладок */
  .tabbar { display: flex; position: fixed; inset: auto 0 0; z-index: 16; height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line); }
  .tabbar > a, .tabbar > button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none; color: var(--text); font-size: 10px; cursor: pointer; padding: 0; -webkit-tap-highlight-color: transparent; }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar a.on { font-weight: 500; }
  .tabbar a.on svg { color: var(--red); }
  .tabbar .tab-add svg { width: 36px; height: 36px; padding: 6px; border-radius: 50%; border: 1px solid var(--line); box-sizing: border-box; }
  main { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* меню «Ещё» — над нижней панелью, переключатели видны */
  body:not(.watching) .guide, body.watching .guide { bottom: calc(56px + env(safe-area-inset-bottom)); width: min(280px, 85vw); }
  body.guide-open .scrim { bottom: calc(56px + env(safe-area-inset-bottom)); }

  /* ленты: обложки от края до края, как в приложении */
  .page { padding: 0 0 24px; }
  .page-title, .page-sub { padding: 0 16px; }
  .grid { gap: 20px; }
  .card .thumb { border-radius: 0; }
  .card .details { padding: 0 12px; }
  .card:hover .why { display: none; }  /* на телефоне «наведения» нет — разбор оценки только мешает тапу */
  .chips { padding: 10px 12px; }
  .chip-arrow { display: none !important; }
  .theme-grid, .cat-grid, .empty { margin-left: 16px; margin-right: 16px; }
  dialog { width: calc(100vw - 24px); max-width: none; }
}
