:root {
    --bg: #07111f;
    --panel: rgba(10, 20, 37, 0.88);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text: #f4f7fb;
    --muted: #9fb2ca;
    --primary: #ff5a36;
    --primary-dark: #d94827;
    --danger: #ff5c7a;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    --radius: 18px;
    --container: 1180px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 90, 54, 0.18), transparent 28%),
        linear-gradient(180deg, #091120 0%, #04070d 100%);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

iframe {
    border: 0;
}

.container {
    width: min(100% - 32px, var(--container));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(16px);
    background: rgba(4, 7, 13, 0.78);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-shell {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    letter-spacing: 0.14em;
}

.brand span {
    color: #ffbea8;
}

.brand strong {
    color: var(--primary);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.main-nav a {
    color: var(--muted);
}

.main-nav a:hover {
    color: var(--text);
}

.page-content {
    padding-bottom: 64px;
}

.hero {
    padding: 36px 0 10px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 28px;
    align-items: center;
}

.hero-copy,
.hero-media,
.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero-copy {
    padding: 38px;
}

.hero-copy h1,
.section-head h1,
.panel h1 {
    margin: 12px 0;
    font-size: clamp(2rem, 3vw, 3.7rem);
    line-height: 1.05;
}

.hero-copy p,
.section-head p,
.panel p,
.card-body p,
.history-item span {
    color: var(--muted);
}

.hero-actions,
.form-actions,
.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.hero-media {
    overflow: hidden;
    min-height: 360px;
}

.hero-media img,
.placeholder-card {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-card {
    display: grid;
    place-items: center;
    color: var(--muted);
}

.section-block {
    padding-top: 26px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.section-head h2,
.section-head h3,
.panel h2 {
    margin: 0;
    font-size: 1.5rem;
}

.category-row {
    margin-bottom: 30px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.episode-card {
    overflow: hidden;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.22s ease, border-color 0.22s ease;
}

.episode-card:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 90, 54, 0.5);
}

.episode-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.card-body {
    padding: 16px;
}

.card-body h3,
.card-body h4 {
    margin: 0 0 8px;
}

.panel {
    padding: 28px;
}

.btn {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.btn-danger {
    background: rgba(255, 92, 122, 0.16);
    color: #ffd4dd;
}

.pill,
.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffd8ce;
    font-size: 0.9rem;
}

.auth-shell {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}

.auth-form {
    width: min(100%, 480px);
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: #e8edf5;
}

input,
textarea,
select {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 14px 16px;
    font: inherit;
}

textarea {
    resize: vertical;
}

.auth-link {
    margin-top: 18px;
}

.flash-stack {
    padding-top: 18px;
    display: grid;
    gap: 12px;
}

.flash {
    border-radius: 14px;
    padding: 14px 16px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(31, 201, 122, 0.12);
    border-color: rgba(31, 201, 122, 0.32);
}

.flash-error {
    background: rgba(255, 92, 122, 0.12);
    border-color: rgba(255, 92, 122, 0.32);
}

.player-layout,
.dashboard-grid,
.admin-grid,
.stats-grid {
    display: grid;
    gap: 20px;
}

.player-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
    align-items: start;
}

.episode-main {
    display: grid;
    gap: 20px;
}

.video-frame {
    position: relative;
    padding-top: 56.25%;
    overflow: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.video-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.episode-content-panel {
    display: grid;
    gap: 20px;
}

.episode-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 18px;
    align-items: start;
}

.episode-heading h1 {
    margin: 14px 0 0;
    font-size: clamp(1.8rem, 3vw, 3rem);
    line-height: 1.08;
}

.episode-description {
    color: var(--muted);
    font-size: 1.02rem;
    line-height: 1.75;
}

.compact-stats {
    margin-top: 0;
}

.compact-stats strong,
.compact-stats span {
    display: block;
}

.compact-stats span {
    margin-top: 8px;
    color: var(--muted);
}

.chat-panel {
    display: grid;
    gap: 18px;
    position: sticky;
    top: 98px;
    max-height: calc(100vh - 126px);
}

.chat-head h2 {
    margin: 12px 0 8px;
}

.chat-head p {
    margin: 0;
}

.chat-stream {
    display: grid;
    gap: 16px;
    overflow-y: auto;
    padding-right: 6px;
    max-height: 760px;
}

.chat-message {
    padding: 16px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(18, 30, 52, 0.98), rgba(10, 21, 38, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    display: grid;
    gap: 10px;
    position: relative;
}

.chat-message::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary), #ff9b7f);
}

.chat-message-top {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    align-items: center;
}

.chat-time {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 90, 54, 0.14);
    color: #ffc5b5;
    font-size: 0.8rem;
}

.chat-message-top span,
.chat-context {
    font-size: 0.9rem;
}

.chat-context {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-left: 8px;
}

.chat-context-label {
    color: var(--muted);
}

.chat-context-title {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 90, 54, 0.16);
    color: #ffe3db;
    font-size: 0.86rem;
}

.chat-text {
    margin: 0;
    line-height: 1.6;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.07);
    color: #f4f7fb;
    margin-left: 8px;
}

.chat-form {
    display: grid;
    gap: 12px;
    margin-top: auto;
}

.chat-form label {
    margin-bottom: 0;
}

.stats-card,
.coin-highlight {
    margin-top: 20px;
    padding: 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
}

.coin-highlight {
    font-size: 2rem;
    font-weight: 700;
    color: #ffe1d8;
}

.dashboard-grid,
.admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-box {
    text-align: center;
}

.stat-box strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-item {
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.import-list {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.import-item {
    display: grid;
    grid-template-columns: auto 160px 1fr;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.import-item input[type="checkbox"] {
    width: auto;
}

.import-item img {
    width: 160px;
    height: 90px;
    object-fit: cover;
    border-radius: 12px;
}

.import-item div {
    display: grid;
    gap: 6px;
}

.import-item span,
.import-item small {
    color: var(--muted);
    word-break: break-word;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    vertical-align: top;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.inline-form input {
    min-width: 120px;
}

.admin-form {
    max-width: 760px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

.form-thumb-preview {
    width: 240px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.site-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--muted);
    padding: 24px 0 40px;
}

.empty-state {
    color: var(--muted);
}

@media (max-width: 980px) {
    .hero-grid,
    .player-layout,
    .dashboard-grid,
    .admin-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .hero-media {
        min-height: 260px;
    }

    .episode-heading {
        grid-template-columns: 1fr;
    }

    .chat-panel {
        position: static;
        max-height: none;
    }

    .chat-stream {
        max-height: 560px;
    }

    .import-item {
        grid-template-columns: auto 1fr;
    }
}

@media (max-width: 720px) {
    .nav-shell,
    .section-head,
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-copy,
    .panel {
        padding: 20px;
    }

    .main-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .import-item {
        grid-template-columns: 1fr;
    }
}
