:root {
  --bg: #fff8ec;
  --panel: #ffffff;
  --panel-2: #fff1d6;
  --ink: #1a1a2e;
  --muted: #6b6478;
  --line: #1a1a2e;
  --soft-line: #eadfca;
  --accent: #ff6b6b;
  --accent-2: #ffd43b;
  --accent-3: #4dabf7;
  --good: #2f9e44;
  --shadow: 4px 4px 0 var(--line);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131f; --panel: #1f1d2e; --panel-2: #2a2740; --ink: #f4f1ff; --muted: #a9a3bd;
    --line: #000; --soft-line: #34314a; --shadow: 4px 4px 0 #000; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14131f; --panel: #1f1d2e; --panel-2: #2a2740; --ink: #f4f1ff; --muted: #a9a3bd;
  --line: #000; --soft-line: #34314a; --shadow: 4px 4px 0 #000; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 Nunito, system-ui, sans-serif; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, .logo, .btn, .chip { font-family: 'Baloo 2', Nunito, system-ui, sans-serif; }
h1 { font-size: 28px; margin: 0 0 12px; line-height: 1.15; }
h2 { font-size: 22px; margin: 24px 0 12px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--accent-3); outline-offset: 1px; }
:focus-visible { outline: 3px solid var(--accent-3); outline-offset: 2px; }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg); border-bottom: 3px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; font-size: 24px; font-weight: 800; white-space: nowrap; }
.logo img { width: 38px; height: 38px; }
.logo b { color: var(--accent); }
.search { flex: 1; display: flex; max-width: 620px; margin: 0 auto; }
.search input { border-radius: 999px 0 0 999px; border-right: 0; }
.search button { border: 2px solid var(--line); background: var(--accent-2); border-radius: 0 999px 999px 0; padding: 0 16px; color: #1a1a2e; }
.lang { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border: 2px solid var(--line); border-radius: 999px; background: var(--accent-3); color: #1a1a2e; box-shadow: 3px 3px 0 var(--line); font-size: 18px; cursor: pointer; flex: none; }
.lang select { width: auto; border: 0; background: transparent; color: #1a1a2e; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 15px; padding: 2px 4px; cursor: pointer; }
.lang select:focus { outline: none; }
.lang:focus-within { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.lang option { color: #1a1a2e; background: #fff; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 0; font-size: 22px; padding: 6px 8px; border-radius: 10px; }
.icon-btn:hover { background: var(--panel-2); }
.menu-btn { display: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border: 2px solid var(--line); border-radius: 999px; background: var(--panel); box-shadow: 3px 3px 0 var(--line); font-weight: 700; font-size: 16px; transition: transform .08s, box-shadow .08s; white-space: nowrap; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--line); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.yellow { background: var(--accent-2); color: #1a1a2e; }
.btn.on { background: var(--ink); color: var(--bg); }
.btn.small { padding: 4px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.avatar { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-family: 'Baloo 2', sans-serif; font-weight: 800; color: #1a1a2e; flex: none; text-transform: uppercase; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.lg { width: 96px; height: 96px; font-size: 40px; border-width: 3px; box-shadow: var(--shadow); }

/* Estructura */
.layout { display: flex; }
.sidebar { position: sticky; top: 64px; align-self: flex-start; width: 230px; height: calc(100vh - 64px); overflow-y: auto; padding: 14px 10px; flex: none; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; font-weight: 700; }
.sidebar a:hover { background: var(--panel-2); }
.sidebar a.active { background: var(--accent-2); color: #1a1a2e; }
.sidebar .sec { margin: 16px 12px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.main { flex: 1; min-width: 0; padding: 20px 24px 60px; }

/* Chips de categoría */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; scrollbar-width: thin; }
.chip { flex: none; padding: 5px 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--panel); font-weight: 700; font-size: 15px; }
.chip.active { background: var(--ink); color: var(--bg); }

/* Rejilla de videos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px 18px; }
.card { display: block; }
.thumb { position: relative; aspect-ratio: 16/9; border: 3px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel-2); box-shadow: var(--shadow); transition: transform .12s; }
.card:hover .thumb { transform: translate(-2px, -2px) rotate(-.6deg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.thumb .state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.meta { display: flex; gap: 10px; margin-top: 12px; }
.meta h3 { font-size: 16px; line-height: 1.25; margin: 0 0 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta .sub { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--soft-line); margin-top: 4px; }

/* Ver video */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; max-width: 1500px; }
.player { width: 100%; aspect-ratio: 16/9; background: #000; border: 3px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: block; }
.watch h1 { margin-top: 16px; font-size: 24px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.channel-line { display: flex; align-items: center; gap: 10px; }
.channel-line .name { font-weight: 800; font-family: 'Baloo 2', sans-serif; font-size: 17px; line-height: 1.1; }
.channel-line .subs { color: var(--muted); font-size: 13px; }
.likebar { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; box-shadow: 3px 3px 0 var(--line); }
.likebar button { background: var(--panel); border: 0; padding: 7px 14px; font-weight: 800; font-family: 'Baloo 2', sans-serif; font-size: 16px; }
.likebar button + button { border-left: 2px solid var(--line); }
.likebar button.on { background: var(--accent-2); color: #1a1a2e; }
.desc { background: var(--panel-2); border-radius: var(--radius); padding: 12px 16px; margin-top: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.desc .stats { font-weight: 800; margin-bottom: 4px; white-space: normal; }
.related .card { display: grid; grid-template-columns: 168px 1fr; gap: 10px; margin-bottom: 14px; }
.related .thumb { box-shadow: 3px 3px 0 var(--line); border-width: 2px; border-radius: 12px; }
.related .meta { margin-top: 0; }
.related .meta h3 { font-size: 14px; }

/* Comentarios */
.comment-form { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; }
.comment-form textarea { min-height: 44px; resize: vertical; }
.comment { display: flex; gap: 10px; margin-bottom: 16px; }
.comment .who { font-weight: 800; font-size: 14px; }
.comment .who span { color: var(--muted); font-weight: 600; margin-left: 6px; }
.comment p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.linkish { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 0; text-decoration: underline; }

/* Canal */
.banner { height: 160px; border: 3px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.35) 0 14px, transparent 15px), radial-gradient(circle at 70% 60%, rgba(255,255,255,.25) 0 22px, transparent 23px), radial-gradient(circle at 90% 20%, rgba(255,255,255,.3) 0 9px, transparent 10px); }
.channel-head { display: flex; gap: 20px; align-items: center; margin: -40px 0 20px 24px; flex-wrap: wrap; }
.channel-head .info { margin-top: 40px; flex: 1; min-width: 200px; }
.channel-head h1 { margin: 0; }
.channel-head .sub { color: var(--muted); }
.channel-head .actions { margin-top: 40px; display: flex; gap: 8px; }

/* Formularios */
.panel { background: var(--panel); border: 3px solid var(--line); border-radius: 20px; box-shadow: 6px 6px 0 var(--line); padding: 24px; max-width: 560px; margin: 20px auto; }
.panel label { display: block; font-weight: 700; margin: 14px 0 6px; }
.panel .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 600 !important; }
.check input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.drop { border: 3px dashed var(--line); border-radius: 16px; padding: 28px; text-align: center; background: var(--panel-2); cursor: pointer; }
.drop.over { background: var(--accent-2); color: #1a1a2e; }
.progress { height: 14px; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 14px; background: var(--panel-2); }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.error { color: #e03131; font-weight: 700; margin-top: 10px; min-height: 1em; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); }
.colors button.on { outline: 3px solid var(--accent-3); outline-offset: 2px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 56px; }
.empty h2 { color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; transition: transform .25s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); }

.hide-btn { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 800; opacity: 0; transition: opacity .15s; }
.card:hover .hide-btn, .hide-btn:focus-visible { opacity: 1; }
@media (hover: none) { .hide-btn { opacity: .85; } }
.keybox { font-family: ui-monospace, Menlo, monospace; font-size: 22px; font-weight: 700; letter-spacing: .06em; text-align: center; padding: 16px; border: 3px dashed var(--line); border-radius: 14px; background: var(--accent-2); color: #1a1a2e; overflow-wrap: anywhere; user-select: all; }
.notice { display: flex; gap: 14px; align-items: center; justify-content: space-between; background: #ffe3e3; color: #1a1a2e; border: 3px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 16px; }
.notice .btn { background: #fff; color: #1a1a2e; }
.notice p { margin: 4px 0 0; font-size: 14px; }
.warn { background: #fff3bf; color: #1a1a2e; border-radius: 12px; padding: 10px 12px; font-weight: 600; }
#pwForm h2 { margin-top: 22px; }

.legal-links { margin: 18px 12px 6px; font-size: 13px; color: var(--muted); }
.legal-links a { display: inline; padding: 0; text-decoration: underline; font-weight: 600; }
.legal h2 { font-size: 19px; margin: 18px 0 4px; }
.legal p { margin: 0 0 6px; }
.legal a { text-decoration: underline; }
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { margin: 0; width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; }
.check.radio { margin: 6px 0 !important; }
.check.radio input { width: 18px; height: 18px; }
.report-card { background: var(--panel); border: 3px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px; max-width: 860px; }
.report-card a { display: block; margin: 8px 0; }
.quote { background: var(--panel-2); border-radius: 10px; padding: 8px 12px; margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.panel.danger { border-color: #e03131; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.app-card { background: var(--panel); border: 3px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; }
.app-card h3 { margin: 0; font-family: 'Baloo 2', sans-serif; font-size: 20px; }
.app-card p { margin: 8px 0 0; }
.app-card.adult { border-color: #e03131; }
.badge18 { display: inline-block; background: #e03131; color: #fff; font-weight: 800; border-radius: 999px; padding: 2px 10px; font-size: 13px; }

/* Responsive */
@media (max-width: 1100px) {
  .watch { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .sidebar { position: fixed; left: 0; top: 64px; z-index: 30; background: var(--bg); border-right: 3px solid var(--line); transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { padding: 16px; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .logo span { display: none; }
  .search { order: 3; flex-basis: 100%; }
  .sidebar { top: 108px; height: calc(100vh - 108px); }
  .top-actions .btn .lbl { display: none; }
  .grid { grid-template-columns: 1fr; }
  .related .card { grid-template-columns: 140px 1fr; }
  .channel-head { margin-left: 0; }
  .panel { padding: 18px; }
}
