* {
    box-sizing: border-box;
}

:root {
    --purple: #7650d5;
    --purple-dark: #6039bb;
    --purple-light: #eee8ff;
    --bg: #f0ebfa;
    --text: #24212c;
    --muted: #777184;
    --border: #e7e1f1;
    --white: #fff;
    --radius: 14px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    padding-bottom: 20px;
}

a {
    color: var(--purple-dark);
    text-decoration: none;
}

a:hover {
    color: var(--purple);
}

/* HEADER */

.top {
    min-height: 62px;
    background: #fff;
    box-shadow: 0 1px 5px rgba(35, 20, 65, .12);
    border-bottom: 1px solid var(--border);
    padding: 8px max(3%, calc((100% - 1250px)/2));
    display: flex;
    align-items: center;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -1px;
    color: var(--purple);
    white-space: nowrap;
}

.search {
    flex: 1;
    max-width: 330px;
    display: flex;
    gap: 6px;
}

.search input {
    margin: 0;
    border: 0;
    border-radius: 30px;
    background: #f0edf6;
    padding: 11px 16px;
}

.search button {
    padding: 9px 13px;
}

.top nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-left: auto;
}

.top nav a,
.top nav button {
    color: #514b5e;
    font-weight: 700;
    padding: 9px 11px;
    border-radius: 9px;
    white-space: nowrap;
}

.top nav a:hover {
    background: var(--purple-light);
    color: var(--purple-dark);
}

.top nav form {
    margin: 0;
}

.navbtn {
    background: #eee8ff;
    color: var(--purple-dark);
}

/* MAIN LAYOUT */

.layout {
    max-width: 1250px;
    margin: 20px auto;
    padding: 0 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 22px;
    align-items: start;
}

.maincol {
    min-width: 0;
}

.side .card {
    position: sticky;
    top: 82px;
}

/* CARDS */

.card,
.panel {
    background: #fff;
    border: 1px solid rgba(100, 70, 160, .10);
    border-radius: var(--radius);
    padding: 17px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(40, 25, 70, .08);
}

.card h2,
.card h3 {
    margin-top: 0;
    letter-spacing: -.3px;
}

/* POST */

.post {
    padding: 16px;
}

.posthead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.posthead a {
    color: var(--text);
    font-weight: 750;
}

.posthead small,
.counts,
small {
    color: var(--muted);
    font-size: 12px;
}

.postbody {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
    font-size: 15px;
    margin: 12px 0;
}

.postmedia,
video {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: 650px;
    border-radius: 9px;
    margin: 12px auto;
    object-fit: contain;
    background: #f4f1f8;
}

.counts {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

/* AVATAR */

.avatar {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e9ddff, #c6b1fa);
    color: #6840bd;
    display: grid;
    place-items: center;
    font-size: 21px;
    font-weight: 800;
    border: 2px solid #eee8ff;
    overflow: hidden;
}

/* BUTTONS */

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 9px;
    padding: 10px 15px;
    background: var(--purple);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    transition: .15s;
}

button:hover,
.button:hover {
    background: var(--purple-dark);
    color: #fff;
}

.light {
    background: #f0eaff;
    color: #6743b8;
}

.light:hover {
    background: #e4d9ff;
    color: #513098;
}

.danger {
    background: #dc3545;
    color: white;
}

.primary {
    background: var(--purple);
    color: white;
}

.actions {
    display: flex;
    gap: 7px;
    border-top: 0;
    padding-top: 10px;
    margin-top: 5px;
    flex-wrap: wrap;
}

.actions form {
    margin: 0;
    flex: 1;
    min-width: 0;
}

.actions button {
    width: 100%;
}

/* FORMS */

label {
    display: block;
    font-weight: 700;
    margin: 13px 0;
}

input,
textarea {
    display: block;
    width: 100%;
    border: 1px solid #ded7e9;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 7px;
    font: inherit;
    background: #fff;
    outline: none;
}

input:focus,
textarea:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(118, 80, 213, .12);
}

input[type="file"] {
    border: 0;
    padding: 8px 0;
}

textarea {
    resize: vertical;
    min-height: 90px;
}

/* NOTICES */

.notice {
    padding: 12px 15px;
    background: #eee8ff;
    color: #57349d;
    border-radius: 10px;
    margin-bottom: 14px;
    border: 1px solid #ded1ff;
}

.alert {
    padding: 12px 15px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 10px;
}

/* STORIES */

.stories {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 3px 1px 13px;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
}

.stories::-webkit-scrollbar {
    display: none;
}

.story {
    flex: 0 0 115px;
    height: 190px;
    border-radius: 13px;
    overflow: hidden;
    background: linear-gradient(160deg, #b69bf1, #7650d5);
    position: relative;
    box-shadow: 0 1px 5px rgba(50, 30, 90, .15);
    scroll-snap-align: start;
    color: white;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 10px;
    font-weight: 700;
    text-align: center;
}

.story a {
    color: white;
}

/* SEARCH RESULTS */

.search-result {
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

/* ADMIN */

.adminrow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding: 13px 0;
}

.adminrow form {
    margin: 0;
}

.install {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
}

.panel {
    width: min(100%, 560px);
    padding: 25px;
}

.panel h1 {
    color: var(--purple);
}

/* BOTTOM NAV */

.mobile-nav {
    display: none;
}

/* TABLET */

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr) 240px;
        gap: 12px;
    }

    .top {
        gap: 10px;
    }

    .top nav {
        gap: 2px;
    }

    .top nav a {
        padding: 8px;
        font-size: 13px;
    }
}

/* MOBILE */

@media (max-width: 700px) {
    body {
        background: #f0ebfa;
        font-size: 14px;
        padding-bottom: 75px;
    }

    .top {
        min-height: 55px;
        padding: 7px 12px;
        gap: 8px;
        flex-wrap: wrap;
        position: sticky;
        top: 0;
    }

    .brand {
        font-size: 25px;
        flex: 1;
    }

    .search {
        order: 3;
        flex-basis: 100%;
        max-width: none;
        margin: 0;
    }

    .search input {
        padding: 9px 14px;
    }

    .search button {
        padding: 8px 12px;
    }

    .top nav {
        display: none;
    }

    .layout {
        display: block;
        margin: 9px auto;
        padding: 0 7px;
    }

    .maincol {
        width: 100%;
    }

    .side {
        display: none;
    }

    .card,
    .post {
        padding: 13px;
        margin-bottom: 9px;
        border-radius: 12px;
    }

    .posthead {
        gap: 8px;
    }

    .postbody {
        font-size: 15px;
    }

    .postmedia,
    video {
        border-radius: 8px;
        max-height: 520px;
    }

    .actions {
        gap: 5px;
    }

    .actions button,
    .actions .button {
        padding: 9px 4px;
        font-size: 12px;
    }

    .avatar {
        width: 42px;
        height: 42px;
        min-width: 42px;
        font-size: 19px;
    }

    .stories {
        gap: 8px;
    }

    .story {
        flex-basis: 105px;
        height: 165px;
        border-radius: 12px;
    }

    .adminrow {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel {
        padding: 17px;
    }

    /* THANH ĐIỀU HƯỚNG DƯỚI */

    .mobile-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 999;
        height: 62px;
        padding: 5px 3px env(safe-area-inset-bottom);
        background: rgba(255, 255, 255, .97);
        border-top: 1px solid #e4dcef;
        box-shadow: 0 -2px 10px rgba(45, 25, 75, .08);
        align-items: center;
        justify-content: space-around;
        backdrop-filter: blur(12px);
    }

    .mobile-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2px;
        min-width: 0;
        color: #756c83;
        font-size: 10px;
        font-weight: 700;
        text-align: center;
        padding: 5px 1px;
    }

    .mobile-nav a span {
        font-size: 21px;
        line-height: 23px;
    }

    .mobile-nav a.active {
        color: var(--purple);
    }
}

@media (max-width: 380px) {
    .brand {
        font-size: 22px;
    }

    .story {
        flex-basis: 95px;
        height: 150px;
    }

    .card {
        padding: 11px;
    }
}

::selection {
    background: #d9caff;
    color: #43247f;
}
