:root {
    --bg: #0f0f0f;
    --elev: #212121;
    --chip: #272727;
    --chip-active: #f1f1f1;
    --ink: #f1f1f1;
    --muted: #aaaaaa;
    --line: #303030;
    --red: #ff0000;
    --max: 1600px;
    --pad: clamp(1rem, 2.5vw, 1.75rem);
    --sans: Roboto, "Segoe UI", system-ui, sans-serif;
    --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.ts-body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; width: 100%; height: 100%; object-fit: cover; }

.ts-preview {
    background: var(--red);
    color: #fff;
    text-align: center;
    padding: .45rem;
    font-weight: 700;
    font-size: .85rem;
    position: relative;
    z-index: 60;
}
.ts-preview a { text-decoration: underline; }

/* —— Header —— */
.ts-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg);
    border-bottom: 1px solid transparent;
}
.ts-header-inner {
    width: min(var(--max), 100%);
    margin: 0 auto;
    min-height: 56px;
    padding: 0 var(--pad);
    display: grid;
    grid-template-columns: auto minmax(0, 640px) auto;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
}
.ts-header-left {
    display: flex;
    align-items: center;
    gap: .35rem;
}
.ts-brand {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.ts-brand-name {
    font-weight: 700;
    letter-spacing: -.02em;
    font-size: 1.1rem;
}
.ts-logo { display: grid; }
.ts-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    display: grid;
    place-content: center;
}
.ts-icon-btn:hover { background: var(--elev); }
.ts-burger,
.ts-burger::before,
.ts-burger::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    position: relative;
}
.ts-burger::before,
.ts-burger::after {
    content: "";
    position: absolute;
    left: 0;
}
.ts-burger::before { top: -6px; }
.ts-burger::after { top: 6px; }
.ts-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
}

.ts-search {
    display: flex;
    width: 100%;
    max-width: 640px;
    justify-self: center;
}
.ts-search input {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: 1px solid #303030;
    border-right: 0;
    border-radius: 40px 0 0 40px;
    background: #121212;
    color: var(--ink);
    padding: 0 1rem;
    font: inherit;
    outline: none;
}
.ts-search input:focus { border-color: #1c62b9; }
.ts-search button {
    width: 64px;
    border: 1px solid #303030;
    border-radius: 0 40px 40px 0;
    background: #222;
    color: var(--ink);
    cursor: pointer;
    display: grid;
    place-content: center;
}
.ts-search button:hover { background: #303030; }

.ts-tools {
    display: flex;
    align-items: center;
    gap: .25rem;
    justify-self: end;
}
.ts-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-content: center;
    background: #3ea6ff;
    color: #0f0f0f;
    font-weight: 700;
    margin-left: .25rem;
}

.ts-drawer {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(240px, 85vw);
    z-index: 45;
    background: var(--bg);
    border-right: 1px solid var(--line);
    padding: .75rem;
    overflow: auto;
}
.ts-drawer nav {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.ts-drawer a {
    padding: .7rem .9rem;
    border-radius: 10px;
    font-size: .95rem;
}
.ts-drawer a:hover,
.ts-drawer a.is-active { background: var(--elev); }
.ts-drawer-veil {
    position: fixed;
    inset: 56px 0 0;
    background: rgba(0,0,0,.5);
    z-index: 44;
}
body.ts-drawer-open { overflow: hidden; }

.ts-main {
    width: min(var(--max), 100%);
    margin: 0 auto;
    padding: .75rem var(--pad) 2.5rem;
}

/* —— Chips —— */
.ts-chips-wrap {
    position: sticky;
    top: 56px;
    z-index: 20;
    background: var(--bg);
    margin: 0 calc(var(--pad) * -1);
    padding: .55rem var(--pad) .85rem;
}
.ts-chips {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: .15rem;
}
.ts-chips::-webkit-scrollbar { display: none; }
.ts-chip {
    flex: 0 0 auto;
    padding: .45rem .9rem;
    border-radius: 8px;
    background: var(--chip);
    color: var(--ink);
    font-size: .9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}
.ts-chip:hover { background: #3f3f3f; }
.ts-chip.is-active {
    background: var(--chip-active);
    color: #0f0f0f;
}

.ts-feed-head {
    margin: .25rem 0 1rem;
}
.ts-feed-head h1 {
    margin: 0 0 .25rem;
    font-size: 1.35rem;
}
.ts-feed-head p {
    margin: 0;
    color: var(--muted);
    font-size: .9rem;
}

/* —— Grid —— */
.ts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem 1rem;
}
.ts-card { min-width: 0; }
.ts-thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background: #222;
    margin-bottom: .75rem;
}
.ts-thumb:hover { filter: brightness(1.05); }
.ts-fallback {
    display: grid;
    place-content: center;
    height: 100%;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: .06em;
}
.ts-duration {
    position: absolute;
    right: 6px;
    bottom: 6px;
    background: rgba(0,0,0,.8);
    color: #fff;
    font-size: .75rem;
    font-weight: 500;
    padding: .1rem .35rem;
    border-radius: 4px;
    line-height: 1.3;
}
.ts-card-meta {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: .75rem;
}
.ts-channel-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-content: center;
    background: linear-gradient(145deg, #ff0000, #aa0000);
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}
.ts-card-copy h3 {
    margin: 0 0 .25rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ts-channel {
    display: block;
    color: var(--muted);
    font-size: .875rem;
}
.ts-channel:hover { color: var(--ink); }
.ts-stats {
    margin: .15rem 0 0;
    color: var(--muted);
    font-size: .875rem;
}

.ts-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--muted);
}
.ts-empty a { color: #3ea6ff; }
.ts-empty-page { min-height: 50vh; display: grid; place-content: center; gap: .5rem; }
.ts-empty-page h1 { margin: 0; color: var(--ink); }

.ts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .55rem 1rem;
    border-radius: 18px;
    background: var(--elev);
    font-weight: 500;
    font-size: .9rem;
}
.ts-btn:hover { background: #3f3f3f; }
.ts-btn-red {
    background: var(--red);
    color: #fff;
}
.ts-btn-red:hover { filter: brightness(1.08); background: var(--red); }

/* —— Watch —— */
.ts-watch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.5rem;
    align-items: start;
}
.ts-player {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    margin-bottom: 1rem;
}
.ts-play {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    background: rgba(0,0,0,.25);
    transition: background .2s ease;
}
.ts-play:hover { background: rgba(0,0,0,.4); }
.ts-duration-lg { font-size: .85rem; padding: .2rem .45rem; }
.ts-watch-main h1 {
    margin: 0 0 .85rem;
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    font-weight: 700;
    line-height: 1.3;
}
.ts-watch-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.ts-watch-channel {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.ts-watch-channel p {
    margin: .15rem 0 0;
    color: var(--muted);
    font-size: .875rem;
}
.ts-watch-actions {
    display: flex;
    gap: .5rem;
}
.ts-desc {
    background: var(--elev);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}
.ts-excerpt {
    margin: 0 0 .75rem;
    font-weight: 500;
}
.ts-prose {
    color: #ddd;
    line-height: 1.65;
    font-size: .95rem;
}
.ts-prose p { margin: 0 0 .9rem; }
.ts-prose img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: .75rem 0;
}

.ts-related h2 {
    margin: 0 0 .85rem;
    font-size: 1rem;
}
.ts-related-list {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}
.ts-related .ts-card-meta { grid-template-columns: 1fr; }
.ts-related .ts-channel-avatar { display: none; }
.ts-related .ts-thumb {
    border-radius: 8px;
    margin-bottom: .45rem;
}
.ts-related .ts-card-copy h3 { font-size: .9rem; }

.ts-footer {
    border-top: 1px solid var(--line);
    padding: 1.25rem var(--pad) 2rem;
    color: var(--muted);
    font-size: .85rem;
}
.ts-footer-inner {
    width: min(var(--max), 100%);
    margin: 0 auto;
}
.ts-footer p { margin: 0; }

@media (max-width: 1100px) {
    .ts-watch { grid-template-columns: 1fr; }
    .ts-related-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
    .ts-related .ts-card-meta {
        grid-template-columns: 36px minmax(0, 1fr);
    }
    .ts-related .ts-channel-avatar { display: grid; }
}
@media (max-width: 760px) {
    .ts-header-inner {
        grid-template-columns: auto 1fr auto;
    }
    .ts-search { max-width: none; }
    .ts-brand-name { display: none; }
    .ts-grid { grid-template-columns: 1fr; gap: 1.25rem; }
}
