:root {
    --ink: #1c1915;
    --muted: #6d6458;
    --paper: #f3ecdf;
    --card: #fffaf3;
    --line: #e2d5c3;
    --pine: #1b3a34;
    --pine-2: #24564c;
    --brass: #9a6b32;
    --brass-soft: #f3e4cc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Vazirmatn, Tahoma, sans-serif;
    background:
        radial-gradient(900px 280px at 100% -8%, rgba(154, 107, 50, 0.18), transparent 55%),
        var(--paper);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.7;
}

.wrap {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
}

.mast {
    background: var(--pine);
    color: #f6f1e7;
    padding: 1.4rem 0 1.15rem;
}

.mast-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.masthead {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.mag-badge {
    width: 3.1rem;
    height: 3.1rem;
    border-radius: 50%;
    background: #ea4335;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.55rem;
    font-weight: 700;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.brand-kicker {
    display: block;
    color: #f28b82;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
}

.wordmark {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.1rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
    border-bottom: 4px solid #f6f1e7;
    padding-bottom: 0.12rem;
}

.kicker {
    margin: 0 0 0.2rem;
    color: #e7c48a;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.site-title {
    font-size: clamp(1.8rem, 4vw, 2.7rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.library-count {
    margin: 0;
    color: #d7c4a2;
    font-size: 0.95rem;
}

.hero {
    background: var(--pine-2);
    color: #f6f1e7;
    padding: 0.2rem 0 1.35rem;
}

.hero p {
    margin: 0;
    max-width: 40rem;
    font-size: 1.05rem;
}

.hero-hint {
    margin-top: 0.35rem !important;
    color: #d7c4a2;
    font-size: 0.92rem !important;
}

.start h2,
.month-head h2 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--pine);
}

.start { margin-bottom: 1.2rem; }

.start-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
    margin-top: 0.55rem;
}

.month-block { margin: 0 0 1.4rem; }

.month-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0.2rem 0 0.55rem;
}

.month-head span { color: var(--muted); font-size: 0.86rem; }

.month-block .more-btn { margin-top: 0.7rem; }

.filter-label {
    margin: 0.65rem 0 0.3rem;
    color: var(--brass);
    font-size: 0.78rem;
    font-weight: 700;
}

.sort { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.75rem; max-width: 16rem; }

.sort select {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    font: inherit;
}

.site-footer {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 1rem;
    padding: 1.3rem 6vw 2.2rem;
    border-top: 1px solid var(--line);
    text-align: center;
}

.site-footer a { color: var(--ink); }

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

.site-branding { flex: 1; min-width: 0; }

.site-slug {
    font-size: 0.95rem;
    color: #d7c4a2;
    margin-bottom: 0.25rem;
    max-width: 40rem;
}

.back-link { color: #e7c48a; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.main {
    padding: 1.4rem 0 3rem;
    max-width: 1100px;
    margin: 0 auto;
    width: min(1100px, calc(100% - 2rem));
}

.toolbar { margin-bottom: 1rem; }

.search {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.search-label {
    color: var(--brass);
    font-size: 0.78rem;
    font-weight: 700;
}

.search input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    font: inherit;
}

.search input:focus {
    outline: 2px solid var(--brass);
    border-color: transparent;
}

.folders {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.folder-chip {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--pine);
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
}

.folder-chip.is-active {
    background: var(--brass-soft);
    border-color: var(--brass);
    color: var(--brass);
    font-weight: 700;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.85rem;
}

.video-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-inline-start: 4px solid var(--brass);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    cursor: pointer;
    position: relative;
}

.video-card:hover {
    border-color: #c9b394;
    border-inline-start-color: var(--pine);
}

.fact-mark {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--brass);
    font-size: 0.75rem;
    font-weight: 700;
}

.video-card-title {
    display: block;
    font-size: 0.98rem;
    font-weight: 500;
    padding-left: 2.2rem;
}

.video-card-title[contenteditable="true"] { outline: none; cursor: text; }
.video-card-title[contenteditable="true"]:focus {
    background: rgba(154, 107, 50, 0.08);
    border-radius: 4px;
}

.video-card-meta,
.video-card-duration {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.video-card-duration[hidden] { display: none; }

.admin-grid .video-card-duration {
    color: var(--pine);
    font-weight: 500;
}

.video-delete-btn {
    position: absolute;
    top: 0.55rem;
    left: 0.55rem;
    width: 2rem;
    height: 2rem;
    border: none;
    background: rgba(28, 25, 21, 0.08);
    color: var(--ink);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
}

.video-delete-btn:hover { background: #b62324; color: #fff; }
.video-delete-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.more-row {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1.1rem;
}

.more-btn {
    border: none;
    background: var(--pine);
    color: #f6f1e7;
    border-radius: 999px;
    padding: 0.55rem 1.1rem;
    font: inherit;
    cursor: pointer;
}

.more-btn-quiet {
    background: transparent;
    color: var(--pine);
    border: 1px solid var(--line);
}

.admin-toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    max-width: 90vw;
}

.admin-toast.success { background: #238636; color: #fff; }
.admin-toast.warning { background: #9e6a03; color: #fff; }
.admin-toast.error { background: #da3633; color: #fff; }

.loading, .error, .empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.player-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27, 58, 52, 0.82);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.player-overlay.open { display: flex; }

.player-box {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--card);
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid var(--line);
}

.player-close {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 2.4rem;
    height: 2.4rem;
    border: none;
    background: var(--pine);
    color: #f6f1e7;
    font-size: 1.4rem;
    border-radius: 8px;
    cursor: pointer;
    z-index: 2;
}

.player-box video {
    display: block;
    max-width: 85vw;
    max-height: 75vh;
    border-radius: 10px;
    background: #111;
}

.player-title {
    margin-top: 0.75rem;
    font-size: 0.95rem;
    color: var(--muted);
}

@media (max-width: 800px) {
    .start-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .video-grid { grid-template-columns: 1fr; }
}
