* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #34333b;
    background-color: #faf7f4;
}

header {
    padding: 24px 16px 18px;
    text-align: center;
    background-color: #eee6f2;
    border-bottom: 1px solid #d7cadd;
}

header h2 {
    margin: 0;
    color: #59436b;
    font-size: 28px;
}

.header-description {
    margin: 4px 0 18px;
    color: #62566a;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.main-nav form {
    margin: 0;
}

.nav-item {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    font: inherit;
    color: #59436b;
    text-decoration: none;
    cursor: pointer;
}

.nav-item:hover {
    background-color: #ffffff;
    border-color: #d7cadd;
}

main {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 20px 48px;
    flex: 1;
}

h1, h2 {
    text-align: center;
    line-height: 1.3;
}

h1 {
    margin: 8px 0 12px;
    font-size: 30px;
    color: #59436b;
}

h2 {
    font-size: 22px;
}

a {
    color: #59436b;
    text-underline-offset: 3px;
}

a:hover {
    color: #3d6457;
}

.page-description {
    margin: 8px 0;
    text-align: center;
    color: #655f69;
}

.forum-image {
    display: block;
    width: 100%;
    max-width: 760px;
    height: auto;
    margin: 28px auto;
    border: 1px solid #e0d6df;
    border-radius: 8px;
}

.grid-container-index {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.grid-item-index {
    padding: 20px 12px;
    text-align: center;
    background-color: #ffffff;
    border: 1px solid #e0d6df;
    border-radius: 8px;
}

.grid-item-index h2 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: normal;
}

.stat-number {
    margin: 0;
    color: #3d6457;
    font-size: 30px;
    font-weight: bold;
}

.grid-form-container {
    max-width: 460px;
    margin: 24px auto 0;
    padding: 28px;
    background-color: #ffffff;
    border: 1px solid #e0d6df;
    border-radius: 8px;
}

.grid-container-lr {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.grid-container-lr fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.grid-container-lr label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.grid-container-lr input, .grid-container-lr textarea, .grid-container-lr select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #bcb4c1;
    border-radius: 5px;
    background-color: #ffffff;
    font: inherit;
    color: #34333b;
}

.grid-container-lr textarea {
    resize: vertical;
}

.grid-container-lr button, .button-link {
    display: inline-block;
    padding: 11px 20px;
    border: 1px solid #59436b;
    border-radius: 5px;
    background-color: #59436b;
    font: inherit;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.grid-container-lr button {
    width: 100%;
}

.grid-container-lr button:hover, .button-link:hover {
    background-color: #453253;
    color: #ffffff;
}

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
    outline: 3px solid #668d7f;
    outline-offset: 3px;
}

.user-greeting {
    margin: 16px 0 0;
    text-align: center;
}

.user-greeting a {
    font-weight: bold;
}

.profile-details {
    max-width: 600px;
    margin: 24px auto;
    padding: 24px;
    border: 1px solid #e0d6df;
    border-radius: 8px;
    background-color: #ffffff;
    overflow-wrap: anywhere;
}

.profile-details p {
    margin: 12px 0;
}

.profile-avatar {
    display: block;
    width: 128px;
    height: 128px;
    margin: 0 auto 16px;
    border: 1px solid #e0d6df;
    border-radius: 50%;
    object-fit: cover;
}

.profile-avatar-form {
    margin: 32px auto 0;
}

.profile-avatar-form form + form {
    margin-top: 16px;
}

.delete-profile {
    max-width: 600px;
    margin: 32px auto 0;
    padding-top: 16px;
    border-top: 1px solid #dfc8c8;
}

.delete-profile h2 {
    color: #914343;
}

.delete-profile > p {
    text-align: center;
    margin: 6px 0;
}

.delete-profile button {
    border-color: #914343;
    background-color: #914343;
}

.delete-profile button:hover {
    background-color: #733333;
}

.error, .success {
    max-width: 600px;
    margin: 16px auto;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: 5px;
    text-align: center;
    overflow-wrap: anywhere;
}

.error {
    color: #863737;
    background-color: #fcf0f0;
    border-color: #e1bdbd;
}

.success {
    color: #315c43;
    background-color: #edf5ef;
    border-color: #b9d3c1;
}

footer {
    padding: 20px 16px;
    text-align: center;
    color: #62566a;
    background-color: #eee6f2;
    border-top: 1px solid #d7cadd;
}

footer p {
    margin: 4px 0;
}

footer p:first-child {
    font-weight: bold;
}

.admin-search {
    margin-bottom: 24px;
}

.admin-table {
    margin-bottom: 16px;
    overflow-x: auto;
    border: 1px solid #e0d6df;
    border-radius: 8px;
    background-color: #ffffff;
}

.admin-table table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    text-align: left;
}

.admin-table caption {
    padding: 12px;
    text-align: left;
    color: #655f69;
}

.admin-table th, .admin-table td {
    padding: 12px;
    border-bottom: 1px solid #e0d6df;
}

.admin-table th {
    background-color: #eee6f2;
    color: #59436b;
}

.admin-table td {
    overflow-wrap: anywhere;
}

.admin-table tbody tr:last-child td {
    border-bottom: 0;
}

.admin-actions {
    min-width: 240px;
}

.admin-actions form {
    display: inline-block;
    margin: 0;
}

.admin-actions .admin-role {
    display: block;
    margin-bottom: 8px;
}

.admin-role label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: bold;
}

.admin-role select, .admin-role button {
    vertical-align: middle;
}

.admin-avatar {
    border-left: 1px solid #e0d6df;
}

.admin-avatar form + form {
    margin-top: 8px;
}

.admin-avatar button:disabled {
    opacity: 0.6;
    cursor: default;
}

.admin-avatar .photo-picker {
    width: 190px;
    max-width: 100%;
    margin-bottom: 5px;
}

.photo-picker input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    clip-path: inset(50%);
}

.photo-picker label.button-link {
    display: inline-block;
    margin-bottom: 5px;
    font-weight: normal;
}

.admin-avatar .photo-picker label.button-link {
    padding: 6px 10px;
}

.photo-picker input:focus-visible + label {
    outline: 3px solid #668d7f;
    outline-offset: 3px;
}

.photo-picker-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-table select {
    padding: 6px 8px;
    border: 1px solid #bcb4c1;
    border-radius: 5px;
    background-color: #ffffff;
    font: inherit;
    color: #34333b;
}

.admin-table button {
    padding: 6px 10px;
    white-space: nowrap;
}

.status-active {
    color: #315c43;
    font-weight: bold;
}

.admin-table:focus-visible {
    outline: 3px solid #668d7f;
    outline-offset: 3px;
}

.topics-list, .replies-list {
    margin: 28px 0;
}

.topic-card, .reply-card {
    margin: 16px 0;
    padding: 24px;
    border: 1px solid #e0d6df;
    border-radius: 8px;
    background-color: #ffffff;
    overflow-wrap: anywhere;
}

.topic-card h2, .reply-card h3 {
    margin: 0 0 12px;
    text-align: left;
    color: #59436b;
}

.post-info {
    margin: 6px 0;
    font-size: 14px;
    color: #655f69;
}

.post-content {
    white-space: pre-wrap;
}

.post-status {
    color: #914343;
    font-weight: bold;
}

.post-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.post-actions form {
    margin: 0;
}

.delete-button {
    border-color: #914343;
    background-color: #914343;
}

.delete-button:hover {
    background-color: #733333;
}

.post-form {
    max-width: 760px;
    margin-bottom: 24px;
}

@media (max-width: 600px) {
    main {
        padding: 24px 16px 32px;
    }

    h1 {
        font-size: 26px;
    }

    .grid-container-index {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .grid-form-container, .profile-details, .topic-card, .reply-card {
        padding: 20px;
    }

    .nav-item {
        padding: 8px 12px;
    }
}

.home-topics-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.recent-topics, .popular-topics {
    padding: 20px;
    background-color: #ffffff;
    border: 1px solid #e0d6df;
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.recent-topics h2, .popular-topics h2 {
    margin: 0 0 16px;
    color: #59436b;
}

.topic-item {
    padding: 12px 0;
    border-bottom: 1px solid #e0d6df;
}

.topic-item:last-child {
    border-bottom: 0;
}

.topic-item h3 {
    margin: 0 0 6px;
    font-size: 17px;
}

.topic-item p {
    margin: 4px 0;
    font-size: 14px;
    color: #655f69;
}

@media (max-width: 768px) {
    .home-topics-container {
        grid-template-columns: 1fr;
    }
}
