:root {
    color-scheme: light;
    --bg: #f6f5f1;
    --panel: #ffffff;
    --text: #182026;
    --muted: #65717a;
    --line: #d9ddd8;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --danger: #b42318;
    --warn: #b7791f;
    --success: #247a3d;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

button,
input {
    font: inherit;
}

.home-shell {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0;
}

.home-header {
    margin-bottom: 24px;
}

.home-header h1 {
    max-width: 720px;
}

.home-header p:not(.eyebrow) {
    max-width: 680px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.5;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    background: #f7faf8;
    color: var(--accent-strong);
    font-weight: 800;
    text-decoration: none;
}

.admin-link:hover {
    border-color: var(--accent);
    background: #eef7f4;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.channel-card {
    position: relative;
    overflow: hidden;
    min-height: 210px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    background-image:
        linear-gradient(90deg, rgba(10, 17, 20, 0.82), rgba(10, 17, 20, 0.56) 48%, rgba(10, 17, 20, 0.18)),
        var(--channel-image);
    background-position: center;
    background-size: cover;
    box-shadow: 0 12px 32px rgba(24, 32, 38, 0.08);
    color: #fff;
    text-decoration: none;
}

.channel-card:hover {
    border-color: var(--accent);
}

.channel-card > * {
    position: relative;
}

.channel-card h2 {
    margin: 10px 0 8px;
    font-size: 1.45rem;
}

.channel-card p {
    margin-bottom: 18px;
    max-width: 32ch;
    color: rgba(255, 255, 255, 0.86);
    line-height: 1.45;
}

.channel-kicker,
.channel-action {
    color: #d7fff4;
    font-size: 0.86rem;
    font-weight: 800;
}

.channel-action {
    margin-top: auto;
}

.admin-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.login-shell {
    width: min(460px, calc(100% - 32px));
    margin: 0 auto;
    padding: 72px 0;
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 12px 32px rgba(24, 32, 38, 0.08);
}

.login-header {
    margin-bottom: 18px;
}

.login-header p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.5;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-header p:not(.eyebrow) {
    max-width: 700px;
    color: var(--muted);
    line-height: 1.5;
}

.admin-panel,
.admin-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(24, 32, 38, 0.08);
}

.admin-panel {
    padding: 22px;
    margin-bottom: 18px;
}

.admin-flash {
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    font-weight: 700;
}

.admin-flash[data-mode="success"] {
    border-color: rgba(36, 122, 61, 0.25);
    background: rgba(36, 122, 61, 0.08);
    color: var(--success);
}

.admin-flash[data-mode="error"] {
    border-color: rgba(180, 35, 24, 0.25);
    background: rgba(180, 35, 24, 0.08);
    color: var(--danger);
}

.admin-list {
    display: grid;
    gap: 16px;
}

.admin-card {
    overflow: hidden;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.admin-card-media {
    min-height: 100%;
    background-image:
        linear-gradient(180deg, rgba(10, 17, 20, 0.08), rgba(10, 17, 20, 0.34)),
        var(--channel-image);
    background-position: center;
    background-size: cover;
}

.admin-card-body {
    padding: 22px;
}

.admin-card-header {
    margin-bottom: 14px;
}

.admin-meta {
    color: var(--muted);
}

.admin-form,
.admin-delete {
    margin: 0;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field {
    display: block;
    margin-bottom: 12px;
}

.field span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 700;
}

input[type="file"] {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 12px;
    background: #fff;
}

.admin-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.button-secondary {
    background: #f7faf8;
    color: var(--accent-strong);
    border: 1px solid var(--line);
}

.button-secondary:hover:not(:disabled) {
    background: #eef7f4;
    border-color: var(--accent);
}

.button-danger {
    margin-top: 12px;
    background: var(--danger);
}

.button-danger:hover:not(:disabled) {
    background: #8f1f16;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
    gap: 24px;
}

.recorder,
.library {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 12px 32px rgba(24, 32, 38, 0.08);
}

.topbar,
.section-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.02;
}

h2 {
    margin-bottom: 0;
    font-size: 1.2rem;
}

h3 {
    margin-bottom: 6px;
    font-size: 0.98rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    background: #f7faf8;
    color: var(--accent-strong);
    font-weight: 800;
    text-decoration: none;
}

.back-link:hover {
    border-color: var(--accent);
    background: #eef7f4;
}

.channel-description {
    margin: 10px 0 0;
    color: var(--muted);
}

.status {
    flex: 0 0 auto;
    min-width: 142px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.9rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
}

.status[data-mode="ready"] {
    color: var(--success);
}

.status[data-mode="recording"] {
    color: var(--danger);
}

.status[data-mode="saving"] {
    color: var(--warn);
}

.status[data-mode="error"] {
    color: var(--danger);
}

.video-stage {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #11191f;
    aspect-ratio: 16 / 9;
}

.video-stage video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.empty-state {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    color: #dfe7e4;
    text-align: center;
}

.timer {
    position: absolute;
    right: 14px;
    bottom: 14px;
    min-width: 76px;
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.controls,
.save-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.controls {
    margin-top: 16px;
}

button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    padding: 0 16px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 800;
}

button:hover:not(:disabled) {
    background: var(--accent-strong);
}

button:disabled {
    cursor: not-allowed;
    background: #c5ccc7;
    color: #66716b;
}

.save-panel {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 700;
}

input {
    flex: 1 1 240px;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--text);
}

.hint {
    margin: 10px 0 0;
    color: var(--muted);
}

.hint[data-mode="success"] {
    color: var(--success);
}

.hint[data-mode="error"] {
    color: var(--danger);
}

.section-title span {
    color: var(--muted);
    font-size: 0.9rem;
}

.empty-library {
    margin-bottom: 0;
    color: var(--muted);
}

.video-list {
    display: grid;
    gap: 14px;
}

.video-card {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.video-card video {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    background: #11191f;
}

.video-card p {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.video-card a {
    color: var(--accent-strong);
    font-weight: 800;
    text-decoration: none;
}

@media (max-width: 880px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .channel-grid {
        grid-template-columns: 1fr;
    }

    .admin-card {
        grid-template-columns: 1fr;
    }

    .admin-card-media {
        min-height: 190px;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .home-shell {
        width: min(100% - 20px, 980px);
        padding: 24px 0;
    }

    .channel-card {
        min-height: 180px;
        padding: 18px;
    }

    .admin-shell {
        width: min(100% - 20px, 1180px);
        padding: 20px 0 32px;
    }

    .login-shell {
        width: min(100% - 20px, 460px);
        padding: 28px 0;
    }

    .admin-header {
        flex-direction: column;
    }

    .admin-header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .app-shell {
        width: min(100% - 20px, 1180px);
        padding: 16px 0;
    }

    .recorder,
    .library {
        padding: 16px;
    }

    .topbar {
        flex-direction: column;
    }

    .status {
        width: 100%;
    }

    .controls button,
    .save-row button,
    .admin-actions button,
    .admin-delete button {
        flex: 1 1 100%;
    }

    .video-card {
        grid-template-columns: 1fr;
    }
}
