* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f7f5f1;
    color: #222;
    font-family: "DM Sans", sans-serif;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 245px;
    background: #171717;
    color: #fff;
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 10px 38px;
}

.brand-mark {
    width: 39px;
    height: 39px;
    border-radius: 12px;
    background: #d9b47a;
    color: #171717;
    display: grid;
    place-items: center;
    font-family: "Playfair Display";
    font-size: 23px;
}

.brand strong {
    display: block;
    font-size: 19px;
}

.brand small {
    color: #929292;
    font-size: 11px;
}

.nav-label {
    font-size: 10px;
    color: #777;
    letter-spacing: 1.5px;
    padding: 0 12px;
    margin: 0 0 9px;
}

.nav-item {
    width: 100%;
    border: 0;
    background: transparent;
    color: #aaa;
    text-align: left;
    padding: 12px 13px;
    border-radius: 10px;
    margin: 2px 0;
    font: inherit;
    cursor: pointer;
    display: flex;
    gap: 12px;
    align-items: center;
}

.nav-item.active,
.nav-item:hover {
    background: #2b2b2b;
    color: #fff;
}

.nav-item.active {
    border-left: 3px solid #d9b47a;
}

.sidebar-bottom {
    margin-top: auto;
}

.main {
    margin-left: 245px;
    padding: 42px 6%;
    max-width: 1500px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
}

.eyebrow {
    font-size: 10px;
    letter-spacing: 2px;
    color: #9a876d;
    font-weight: 700;
    margin: 0 0 8px;
}

.topbar h1 {
    font-family: "Playfair Display";
    font-size: 39px;
    line-height: 1.1;
    margin: 0;
    font-weight: 700;
}

.topbar h1 em {
    color: #ad7d3d;
    font-style: normal;
}

.add-btn {
    border: 0;
    background: #222;
    color: white;
    padding: 12px 18px;
    border-radius: 9px;
    font: 600 13px "DM Sans";
    cursor: pointer;
}

.add-btn:hover {
    background: #444;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 34px 0;
}

.stat {
    background: #fff;
    border: 1px solid #e8e3db;
    border-radius: 14px;
    padding: 19px 20px;
    box-shadow: 0 5px 20px #00000006;
}

.stat span {
    font-size: 9px;
    letter-spacing: 1.4px;
    color: #a1978b;
}

.stat strong {
    display: block;
    font-size: 28px;
    margin: 7px 0 1px;
}

.stat small {
    color: #999;
    font-size: 11px;
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.search {
    flex: 1;
    background: #fff;
    border: 1px solid #e2ddd4;
    border-radius: 9px;
    display: flex;
    align-items: center;
    padding: 0 13px;
}

.search span {
    font-size: 23px;
    color: #999;
}

.search input {
    width: 100%;
    border: 0;
    outline: 0;
    padding: 12px;
    background: transparent;
    font: inherit;
}

.toolbar select {
    border: 1px solid #e2ddd4;
    background: #fff;
    padding: 0 14px;
    border-radius: 9px;
    min-width: 145px;
    color: #555;
    outline: 0;
}

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

.section-head h2 {
    font-family: "Playfair Display";
    margin: 0;
    font-size: 25px;
}

.section-head p {
    margin: 3px 0;
    color: #999;
    font-size: 11px;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.book {
    background: #fff;
    border: 1px solid #e7e1d8;
    border-radius: 14px;
    overflow: hidden;
    transition: .2s;
    box-shadow: 0 6px 18px #00000008;
}

.book:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px #00000010;
}

.cover-wrap {
    height: 245px;
    background: #e8e2d8;
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
}

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

.placeholder {
    font-family: "Playfair Display";
    font-size: 34px;
    color: #8c7a64;
}

.badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #fffdf9d9;
    padding: 5px 8px;
    border-radius: 20px;
    font-size: 9px;
    font-weight: 700;
}

.book-body {
    padding: 15px;
}

.book h3 {
    font-family: "Playfair Display";
    margin: 0 0 4px;
    font-size: 18px;
}

.author {
    color: #8e877f;
    font-size: 11px;
    margin-bottom: 12px;
}

.meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #777;
}

.rating {
    color: #a26d29;
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 7px;
    margin-top: 13px;
}

.actions button {
    flex: 1;
    border: 1px solid #ddd5ca;
    background: #faf8f5;
    border-radius: 7px;
    padding: 7px;
    cursor: pointer;
    font-size: 10px;
}

.actions button:hover {
    background: #eee9e2;
}

.actions .delete {
    color: #b04a4a;
}

.empty {
    text-align: center;
    padding: 70px;
    color: #999;
    grid-column: 1 / -1;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: #0008;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20;
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    background: #fff;
    width: min(650px, 100%);
    border-radius: 16px;
    padding: 25px;
    max-height: 90vh;
    overflow: auto;
}

.modal-head {
    display: flex;
    justify-content: space-between;
}

.modal h2 {
    font-family: "Playfair Display";
    margin: 0 0 20px;
}

.close {
    border: 0;
    background: #f2efea;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 22px;
    cursor: pointer;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-grid label {
    font-size: 11px;
    color: #777;
    font-weight: 600;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    border: 1px solid #ddd6cc;
    border-radius: 8px;
    padding: 10px;
    font: inherit;
    outline: 0;
}

.form-grid textarea {
    resize: vertical;
}

.full {
    grid-column: 1 / -1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.cancel {
    border: 1px solid #ddd;
    background: #fff;
    padding: 11px 16px;
    border-radius: 8px;
    cursor: pointer;
}

/* DARK MODE */

.dark {
    background: #111;
    color: #eee;
}

.dark .main {
    background: #111;
}

.dark .stat,
.dark .book,
.dark .search,
.dark .toolbar select {
    background: #1d1d1d;
    border-color: #333;
    color: #eee;
}

.dark .book .author,
.dark .stat small,
.dark .section-head p {
    color: #999;
}

.dark .modal {
    background: #1d1d1d;
    color: #eee;
}

.dark .form-grid input,
.dark .form-grid select,
.dark .form-grid textarea {
    background: #111;
    color: #eee;
    border-color: #444;
}

.dark .cancel {
    background: #222;
    color: white;
    border-color: #444;
}


/* RESPONSIVE */

@media (max-width: 1050px) {

    .book-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

@media (max-width: 760px) {

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        padding: 15px;
    }

    .brand {
        padding-bottom: 15px;
    }

    .sidebar nav,
    .sidebar-bottom {
        display: flex;
        overflow: auto;
    }

    .nav-label {
        display: none;
    }

    .nav-item {
        white-space: nowrap;
        width: auto;
    }

    .main {
        margin-left: 0;
        padding: 25px 16px;
    }

    .topbar {
        align-items: start;
    }

    .topbar h1 {
        font-size: 28px;
    }

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

    .toolbar {
        flex-wrap: wrap;
    }

    .search {
        flex-basis: 100%;
    }

    .toolbar select {
        height: 42px;
        flex: 1;
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cover-wrap {
        height: 210px;
    }
}

@media (max-width: 480px) {

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

    .stats {
        gap: 8px;
    }

    .stat {
        padding: 14px;
    }

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

    .full {
        grid-column: auto;
    }
}