:root {
    --ink: #1a1714;
    --muted: #6b645c;
    --paper: #f3eee6;
    --card: #fffaf3;
    --line: #e2d8cc;
    --red: #c1121f;
    --red-dark: #8a0d16;
    --ok: #2f6f4e;
    --ok-bg: #e6f2ea;
    --err: #9b1c1c;
    --err-bg: #fdecec;
    --shadow: 0 10px 30px rgba(26, 23, 20, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 400px at 0% -10%, rgba(193, 18, 31, 0.08), transparent 50%),
        var(--paper);
    line-height: 1.45;
}

a {
    color: inherit;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.5rem;
    background: var(--ink);
    color: #f7f1ea;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.4rem;
    background: var(--red);
    color: #fff;
    font-size: 0.75rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.user-chip {
    color: #cfc6bb;
    font-size: 0.9rem;
    font-weight: 400;
    text-decoration: none;
}

.user-chip:hover {
    color: #fff;
    text-decoration: underline;
}

.user-chip.is-active {
    color: #fff;
    font-weight: 700;
}

.text-link {
    color: #f3d5d2;
    text-decoration: none;
    font-size: 0.9rem;
}

.text-link:hover {
    text-decoration: underline;
}

.settings-link {
    color: #cfc6bb;
    font-size: 0.9rem;
    font-weight: 400;
    text-decoration: none;
}

.settings-link:hover {
    color: #fff;
    text-decoration: underline;
}

.settings-link.is-active {
    color: #fff;
    font-weight: 700;
}

.page {
    width: min(1080px, calc(100% - 2rem));
    margin: 1.75rem auto 3rem;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.eyebrow {
    margin: 0 0 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    color: var(--muted);
}

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

h1 {
    margin: 0;
    font-size: 2rem;
    letter-spacing: -0.03em;
}

h2 {
    margin: 0 0 0.85rem;
    font-size: 1.1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--red);
    color: #fff;
}

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

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid #f0c4c4;
    margin-left: auto;
}

.btn-block {
    width: 100%;
}

.status-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
    padding: 0.3rem;
    background: rgba(255, 250, 243, 0.8);
    border: 1px solid var(--line);
    border-radius: 999px;
    width: fit-content;
}

.status-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
}

.status-tab.is-active {
    background: var(--ink);
    color: #fff;
}

.count {
    font-size: 0.75rem;
    opacity: 0.75;
}

.project-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.project-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1rem;
    overflow: hidden;
    text-decoration: none;
    box-shadow: var(--shadow);
    height: 100%;
}

.project-card:hover {
    transform: translateY(-2px);
}

.thumb {
    aspect-ratio: 16 / 9;
    background: #2a2420;
    overflow: hidden;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b7aea4;
    font-size: 0.85rem;
}

.project-body {
    padding: 0.9rem 1rem 1.05rem;
}

.project-body h2 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
}

.meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.yt-pill {
    display: inline-block;
    margin-top: 0.65rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--red);
}

.empty-state {
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: 1rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
}

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

.flash {
    padding: 0.8rem 1rem;
    border-radius: 0.7rem;
    margin-bottom: 1rem;
}

.flash p {
    margin: 0.2rem 0;
}

.flash-success {
    background: var(--ok-bg);
    color: var(--ok);
}

.flash-error {
    background: var(--err-bg);
    color: var(--err);
}

.project-form {
    display: grid;
    gap: 1rem;
}

.form-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1.15rem 1.2rem 1.3rem;
    box-shadow: var(--shadow);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem 1rem;
}

.span-2 {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    padding: 0.55rem 0.7rem;
}

textarea {
    resize: vertical;
    min-height: 220px;
    line-height: 1.55;
}

textarea.compact {
    min-height: 4.5rem;
}

.thumb-preview,
.placeholder-preview {
    width: 220px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 0.6rem;
    margin-bottom: 0.4rem;
}

.placeholder-block {
    display: grid;
    gap: 0.45rem;
    justify-items: start;
}

.placeholder-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.placeholder-block .field-hint {
    margin: 0;
}

.placeholder-block .btn {
    width: auto;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.section-head h2 {
    margin: 0;
}

.repeat-list {
    display: grid;
    gap: 0.55rem;
}

.repeat-row {
    display: grid;
    grid-template-columns: 1fr 1.4fr auto;
    gap: 0.5rem;
    align-items: center;
}

.icon-btn {
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--muted);
}

.field-hint {
    margin: -0.35rem 0 0.85rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 400;
}

.settings-actions {
    display: grid;
    gap: 1.25rem;
}

.import-form {
    display: grid;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.check-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--ink);
}

.check-label input {
    width: auto;
}

.sample-table-wrap {
    overflow-x: auto;
    margin: 0 0 1.1rem;
}

.sample-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.sample-table th,
.sample-table td {
    border: 1px solid var(--line);
    padding: 0.45rem 0.6rem;
    text-align: left;
}

.sample-table th {
    background: #f3eee6;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.sample-table td:empty {
    background: repeating-linear-gradient(
        -45deg,
        #fff,
        #fff 4px,
        #f7f1ea 4px,
        #f7f1ea 8px
    );
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(420px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.2rem;
    padding: 1.6rem 1.5rem 1.7rem;
    box-shadow: var(--shadow);
}

.brand-login {
    margin-bottom: 0.6rem;
}

.login-kicker {
    margin: 0 0 1.1rem;
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 0.85rem;
}

.setup-card {
    width: min(640px, 100%);
}

.setup-title {
    margin: 0 0 0.5rem;
    font-size: 1.7rem;
    letter-spacing: -0.03em;
}

.setup-section {
    padding-top: 0.35rem;
}

.setup-section h2 {
    margin: 0 0 0.75rem;
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.config-copy {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    min-height: 240px;
    line-height: 1.45;
    white-space: pre;
}

@media (max-width: 720px) {
    .site-header,
    .page-head,
    .form-grid,
    .repeat-row,
    .form-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .status-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .btn-danger {
        margin-left: 0;
    }

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