:root {
  --bg: #0e1118;
  --panel: #151a24;
  --panel-2: #1d2331;
  --line: #283042;
  --text: #e9edf5;
  --muted: #8c95aa;
  --accent: #ffb627;
  --accent-ink: #1a1200;
  --like: #ff5d73;
  --danger: #ff6b6b;
  --ok: #5fd68a;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  overflow-wrap: anywhere;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Шапка ---------- */
.header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: rgba(14, 17, 24, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; flex-shrink: 0; }
.logo svg { width: 28px; height: 28px; }
.logo em { font-style: normal; color: var(--accent); }
.search { flex: 1; max-width: 520px; margin: 0 auto; display: flex; }
.search input {
  flex: 1; min-width: 0; padding: 9px 16px;
  background: var(--panel); border: 1px solid var(--line); border-right: 0;
  border-radius: 999px 0 0 999px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button {
  padding: 0 18px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 0 999px 999px 0; cursor: pointer; color: var(--muted);
}
.search button:hover { color: var(--text); }
.nav { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
a.me:hover { color: var(--text); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #10131a; text-transform: uppercase;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 36px; height: 36px; }
.avatar.xl { width: 96px; height: 96px; font-size: 40px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; min-height: 38px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #262e41; border-color: #36405a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.liked { background: var(--like); border-color: var(--like); color: #fff; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }

/* ---------- Каркас ---------- */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 18px; letter-spacing: -.01em; }
.muted { color: var(--muted); }

/* ---------- Сетка видео ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 28px 18px; }
.vcard { display: block; }
.thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, #1b2233, #10141d);
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb .play {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0;
  background: rgba(0, 0, 0, .28); transition: opacity .15s;
}
.thumb .play svg { width: 46px; height: 46px; fill: #fff; }
.vcard:hover .play, .vcard:focus-visible .play { opacity: 1; }
.dur {
  position: absolute; right: 8px; bottom: 8px; padding: 1px 6px;
  background: rgba(0, 0, 0, .8); border-radius: 4px; font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.vinfo { display: flex; gap: 12px; margin-top: 10px; }
.vtitle {
  font-weight: 600; font-size: 15px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vmeta { color: var(--muted); font-size: 13px; margin-top: 2px; }
a.vmeta { display: block; width: fit-content; }
a.vmeta:hover, .comment .who a:hover { color: var(--text); text-decoration: underline; }
a.vtitle:hover { text-decoration: underline; text-underline-offset: 2px; }

.skeleton .thumb { animation: pulse 1.2s ease-in-out infinite; }
.skeleton .bar { height: 14px; border-radius: 4px; background: var(--panel-2); margin-top: 10px; animation: pulse 1.2s ease-in-out infinite; }
.skeleton .bar.short { width: 60%; }
@keyframes pulse { 50% { opacity: .5; } }

.empty { text-align: center; color: var(--muted); padding: 80px 16px; }
.empty h2 { color: var(--text); font-size: 20px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }
.more { text-align: center; margin-top: 32px; }

/* ---------- Просмотр ---------- */
.watch { max-width: 1040px; margin: 0 auto; }
.player { width: 100%; max-height: 72vh; background: #000; border-radius: 12px; display: block; }
.watch h1 { font-size: 22px; line-height: 1.3; margin: 16px 0 12px; letter-spacing: -.01em; }
.watch-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.author { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.author-link { display: flex; align-items: center; gap: 10px; }
.author-link:hover b { text-decoration: underline; }
.author b { display: block; line-height: 1.2; }
.author span { font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.desc {
  background: var(--panel); border-radius: 12px; padding: 14px 16px; margin: 16px 0 28px;
  white-space: pre-wrap; font-size: 15px;
}
.desc .stats { font-weight: 600; display: block; margin-bottom: 4px; }

.comments h2 { font-size: 18px; margin-bottom: 14px; }
.comment-form { display: flex; gap: 10px; margin-bottom: 22px; align-items: flex-start; }
.comment-form input { flex: 1; min-width: 0; }
.comment { display: flex; gap: 12px; padding: 12px 0; }
.comment .who { font-size: 13px; color: var(--muted); }
.comment .who b { color: var(--text); margin-right: 6px; }
.comment .body { flex: 1; min-width: 0; white-space: pre-wrap; }
.comment .del {
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px;
  padding: 2px 6px; border-radius: 6px; align-self: flex-start;
}
.comment .del:hover { color: var(--danger); background: var(--panel-2); }

/* ---------- Канал и подписки ---------- */
.chead { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 32px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.cinfo { flex: 1; min-width: 0; }
.cinfo h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.02em; }
.cstats { color: var(--muted); font-size: 14px; margin-top: 4px; }
.cbio { margin-top: 12px; max-width: 70ch; white-space: pre-wrap; }
.cbio:empty { display: none; }
.cactions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.bio-edit { margin-top: 16px; max-width: 70ch; }
.chips { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 24px; }
.chips:empty { display: none; }
.chip { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; font-size: 14px; white-space: nowrap; }
.chip:hover { background: var(--panel-2); }

/* ---------- Формы ---------- */
.form-box { max-width: 440px; margin: 48px auto; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.form-box.wide { max-width: 640px; }
.form-box h1 { font-size: 24px; margin-bottom: 4px; letter-spacing: -.01em; }
.form-box .sub { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.form-box label { display: block; font-size: 14px; color: var(--muted); margin: 16px 0 6px; }
.form-box .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-box .btn.block { margin-top: 22px; padding: 12px; }
.alt { margin-top: 16px; font-size: 14px; color: var(--muted); text-align: center; }
.alt a { color: var(--accent); font-weight: 600; }

input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; outline: none;
  font-size: 16px; /* 16px — чтобы iOS не зумил поле */
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 110px; }

.msg { display: none; margin-top: 16px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.msg.error { display: block; background: rgba(255, 107, 107, .12); color: #ff9c9c; }
.msg.ok { display: block; background: rgba(95, 214, 138, .12); color: var(--ok); }

/* ---------- Загрузка ---------- */
.drop {
  display: grid; place-items: center; text-align: center; gap: 4px;
  min-height: 150px; padding: 20px; margin-top: 8px;
  border: 2px dashed var(--line); border-radius: 12px; cursor: pointer;
  color: var(--muted); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255, 182, 39, .05); }
.drop b { color: var(--text); }
.drop input { display: none; }
.preview { display: none; gap: 14px; align-items: center; margin-top: 8px; padding: 12px; background: var(--panel-2); border-radius: 12px; }
.preview.show { display: flex; }
.preview .pthumb { width: 128px; aspect-ratio: 16/9; border-radius: 8px; object-fit: cover; background: #000; flex-shrink: 0; }
.preview .pname { font-weight: 600; font-size: 14px; }
.preview .psize { font-size: 13px; color: var(--muted); }
.progress { display: none; margin-top: 18px; }
.progress .track { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.progress .label { font-size: 13px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast {
  padding: 11px 14px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast.error { border-color: var(--danger); }

/* ---------- Адаптив ---------- */
@media (max-width: 720px) {
  .header { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .nav { margin-left: auto; }
  .me .name { display: none; }
  .container { padding: 16px 14px; }
  .grid { grid-template-columns: 1fr; gap: 24px; }
  .watch h1 { font-size: 19px; }
  .chead { flex-direction: column; gap: 14px; }
  .avatar.xl { width: 72px; height: 72px; font-size: 30px; }
  .cinfo h1 { font-size: 24px; }
  .player { border-radius: 0; margin: 0 -14px; width: calc(100% + 28px); max-height: 60vh; }
  .comment-form { flex-direction: column; }
  .comment-form .btn { align-self: flex-end; }
  .form-box { margin: 20px 14px; padding: 20px; }
  .preview { flex-direction: column; align-items: flex-start; }
  .preview .pthumb { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
