* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f5f6f8;
    color: #222;
}
main { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

.auth { max-width: 380px; margin: 80px auto; background: #fff; padding: 24px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.auth label { display: block; margin-bottom: 12px; font-size: 14px; }
.auth input { width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font: inherit; margin-top: 4px; }
.auth button { width: 100%; padding: 10px; border: 0; border-radius: 6px; background: #3b6ef5; color: #fff; font: inherit; cursor: pointer; }
.auth button:hover { background: #2f5cd6; }
.error { background: #fee; color: #a00; padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: #fff; border-bottom: 1px solid #e5e5e5; }
.brand { font-weight: 600; }
.user { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.muted { color: #888; }

.create-form {
    display: flex;
    gap: 8px;
    margin: 16px 0 24px;
}
.create-form input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font: inherit;
}
.create-form button {
    padding: 8px 16px;
    border: 0;
    border-radius: 6px;
    background: #3b6ef5;
    color: #fff;
    font: inherit;
    cursor: pointer;
}
.create-form button:hover { background: #2f5cd6; }

.boards {
    list-style: none;
    padding: 0;
    margin: 0;
}
.boards li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    margin-bottom: 8px;
}
.boards li a {
    color: #222;
    text-decoration: none;
    font-weight: 500;
}
.boards li a:hover { color: #3b6ef5; }

.success {
    background: #e6f7ec;
    color: #1a7f37;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
}
.small { font-size: 12px; }

.btn-plus {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #3b6ef5;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.btn-plus:hover { background: #2f5cd6; }

[hidden] { display: none !important; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
}
.modal-body {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: min(480px, calc(100% - 32px));
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-body h2 { margin: 0 0 16px; font-size: 18px; }
.modal-body label {
    display: block;
    margin-bottom: 14px;
    font-size: 14px;
}
.modal-body input[type=file],
.modal-body input[type=text],
.modal-body select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.btn-cancel {
    padding: 8px 16px;
    background: #eee;
    border: 0;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}
.btn-primary {
    padding: 8px 16px;
    background: #3b6ef5;
    color: #fff;
    border: 0;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}
.btn-primary:disabled { opacity: .6; cursor: default; }
.modal-error {
    margin-top: 12px;
    padding: 8px 12px;
    background: #fee;
    color: #a00;
    border-radius: 6px;
    font-size: 14px;
}

.boards li {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.board-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.board-name { font-weight: 500; }

.board-count {
    display: inline-block;
    background: #eef0f4;
    color: #666;
    font-size: 12px;
    padding: 1px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.board-thumbs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.board-thumbs img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 3px;
    display: block;
    background: #eee;
}

.boards li {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    margin-bottom: 8px;
}

.board-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.board-name {
    color: #222;
    text-decoration: none;
    font-weight: 500;
}
.board-name:hover { color: #3b6ef5; }

.board-thumbs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.board-thumbs img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 3px;
    display: block;
    background: #eee;
}


/* === Галерея === */
.gallery {
    column-count: 4;
    column-gap: 12px;
    margin-top: 16px;
}
@media (max-width: 1200px) { .gallery { column-count: 3; } }
@media (max-width: 800px)  { .gallery { column-count: 2; } }
@media (max-width: 500px)  { .gallery { column-count: 1; } }

.gallery-item {
    margin: 0 0 12px;
    break-inside: avoid;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
}

.gallery-item img,
.gallery-item video,
.gallery-item .video-placeholder {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

.gallery-link { display: block; }

.video-placeholder {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 32px;
}
.video-placeholder .play {
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 4px;
}

/* === Лайтбокс === */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.9);
}
.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    z-index: 1;
}
.lightbox-content img,
.lightbox-content video {
    max-width: 95vw;
    max-height: 95vh;
    display: block;
    border-radius: 4px;
}
.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,.3); }

.back { color: #222; text-decoration: none; }
.back:hover { color: #3b6ef5; }

.lightbox-panel {
    position: relative;
    z-index: 1;
    background: #1a1a1a;
    border-radius: 10px;
    max-width: min(1100px, 95vw);
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #eee;
}

.lightbox-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #333;
    gap: 12px;
}

.lb-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}
.lb-tag {
    background: #2a2a2a;
    color: #b9d0ff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    text-decoration: none;
}
.lb-tag:hover { background: #3b6ef5; color: #fff; }

.lb-actions { display: flex; gap: 8px; }
.lb-btn {
    background: #3b6ef5;
    border: 0;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.lb-btn:disabled { opacity: .5; cursor: default; }
.lb-btn.lb-danger { background: #b22; }
.lb-btn.lb-danger:hover { background: #d33; }

.lb-fav {
    background: transparent;
    border: 0;
    color: #888;
    font-size: 20px;
    line-height: 1;
    width: 36px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    border-radius: 6px;
    transition: color .15s, background .15s;
}
.lb-fav:hover { background: rgba(255,255,255,.08); color: #bbb; }
.lb-fav.is-fav { color: #e23a3a; }
.lb-fav.is-fav:hover { color: #ff5555; }
.lb-fav:disabled { opacity: .5; cursor: default; }

.lightbox-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 200px;
    overflow: auto;
}
.lightbox-content img,
.lightbox-content video {
    max-width: 100%;
    max-height: 70vh;
    display: block;
}

.lightbox-meta {
    padding: 12px 16px;
    border-top: 1px solid #333;
    max-height: 40vh;
    overflow-y: auto;
}
.lightbox-meta label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    color: #aaa;
}
.lightbox-meta input,
.lightbox-meta textarea,
.lightbox-meta select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 6px 10px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #eee;
    font: inherit;
    resize: vertical;
}
.lightbox-error {
    background: #4a1515;
    color: #faa;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
}

/* Закрыть — внутри .lightbox-panel уже не нужно absolute */
.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
}



.gallery-media {
    position: relative;
    display: block;
    width: 100%;
    background: #000;
}
.gallery-media img {
    display: block;
    width: 100%;
    height: auto;
}
.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 22px;
    line-height: 48px;
    text-align: center;
    padding-left: 4px;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}


.btn-play {
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: #eef0f4;
    color: #444;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 2px;
    transition: background .15s, color .15s;
}
.btn-play:hover { background: #3b6ef5; color: #fff; }

/* === Слайдшоу === */
.slideshow {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slideshow-backdrop {
    position: absolute;
    inset: 0;
}

.slideshow-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: #3b6ef5;
    z-index: 5;
    transition: width .1s linear;
}

.slideshow-content {
    position: relative;
    z-index: 1;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.slideshow-content img,
.slideshow-content video {
    max-width: 95vw;
    max-height: 95vh;
    display: block;
    border-radius: 4px;
    user-select: none;
}

.slideshow-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 0;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.slideshow-close:hover { background: rgba(255,255,255,.3); }

.slideshow-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,.1);
    color: #fff;
    border: 0;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, background .15s;
}
.slideshow:hover .slideshow-nav { opacity: 1; }
.slideshow-nav:hover { background: rgba(255,255,255,.3); }
.slideshow-nav.prev { left: 24px; }
.slideshow-nav.next { right: 24px; }

.slideshow-status {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,.6);
    font-size: 13px;
    z-index: 5;
}

.btn-play-lg {
    width: 28px;
    height: 28px;
    font-size: 13px;
    vertical-align: middle;
    margin-left: 8px;
}




