.hidden {
    display: none;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f8f6f1;
    color: #222;
}

header,
main {
    width: min(700px, calc(100% - 1.5rem));
    margin-left: auto;
    margin-right: auto;
}

header {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    align-items: center;
    gap: 1rem;
    background: #ffffff;
    border: 1px solid #ded8cd;
    border-radius: 14px 14px 0 0;
    padding: 0.9rem 1rem;
}


.nav,
.othernav {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    background: #f1ece3;
    border: 1px solid #ded8cd;
    border-top: none;
    border-radius: 0 0 14px 14px;
    padding: 0.8rem 1rem;
}

a {
    color: #245c3a;
    text-decoration: none;
    padding: 0.2rem 0.15rem;
    font-weight: 600;
}

a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .top {
        align-items: stretch;
    }

    .top > * {
        width: 100%;
    }

    .nav,
    .othernav {
        justify-content: center;
    }
}

h1, h2, h3 {
    color: #1f1f1f;
    line-height: 1.2;
}

h1 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.6;
}

.title {
    text-align: center;
    margin: 0 auto 2rem auto;
    max-width: 480px;
    background: #efe7da;
    border: 1px solid #ded8cd;
    border-radius: 16px;
    padding: 1rem 1.25rem;
}

.recipe-box {
    border: 1px solid #ded8cd;
    border-radius: 16px;
    padding: 1rem;
    background: #ffffff;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.recipe-box h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.recipe-box p {
    padding: 0;
}

.recipe-box img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    margin: 0.75rem 0;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.tag-list span {
    background: #eef3ec;
    color: #245c3a;
    border: 1px solid #d4dfd4;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.85rem;
}

.search-block {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: #efe7da;
    border: 1px solid #ded8cd;
    border-radius: 16px;
    padding: 1rem 1.25rem;
}

.search-block button{
    background: #245c3a;
    color: white;
    border: 1px solid #245c3a;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}

.search-block button:hover {
    background: #1e4a2f;
    border-color: #1e4a2f;
}

.login-form {
    background: #ffffff;
    border: 1px solid #ded8cd;
    border-radius: 16px;
    padding: 1.25rem;
    max-width: 400px;
}

.login-form button{
    background: #245c3a;
    color: white;
    border: 1px solid #245c3a;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}

.login-form button:hover {
    background: #1e4a2f;
    border-color: #1e4a2f;
}

.profile-intro {
    background: #efe7da;
    border: 1px solid #ded8cd;
    border-radius: 16px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.recipe-detail {
    background: #ffffff;
    border: 1px solid #ded8cd;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.recipe-detail .time-plus-servings {
    background: #efe7da;
    border: 1px solid #ded8cd;
    border-radius: 14px;
    padding: 1rem 1.25rem;
    margin: 1rem 0 1.25rem;
}

.recipe-detail .recipe-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0 1rem;
}

.recipe-detail .recipe-tags span {
    background: #eef3ec;
    color: #245c3a;
    border: 1px solid #d4dfd4;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.85rem;
}

.recipe-detail .recipe-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    margin: 1rem 0;
}

.recipe-detail .two-column {
    display: grid;
    gap: 1rem;
}

.recipe-detail .panel {
    background: #f8f6f1;
    border: 1px solid #ded8cd;
    border-radius: 14px;
    padding: 1rem;
}

.recipe-detail ul,
.recipe-detail ol {
    margin-top: 0.5rem;
    margin-bottom: 0;
    padding-left: 1.2rem;
}

@media (min-width: 720px) {
    .recipe-detail .two-column {
        grid-template-columns: 1fr 1fr;
    }
}

/* The following styles are for the comment section and modals. */
.comment-section {
    width: min(700px, calc(100% - 1.5rem));
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    margin-left: auto;
    margin-right: auto;
    background: #ffffff;
    border: 1px solid #ded8cd;
    border-radius: 14px;
    padding: 1rem;
}

#comment-form {
    background: #f8f6f1;
    border: 1px solid #ded8cd;
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

#comment-form h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #1f1f1f;
}

#comment-content {
    width: 100%;
    min-height: 80px;
    border: 1px solid #ded8cd;
    border-radius: 6px;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 0.75rem;
}

#comment-content:focus {
    outline: none;
    border-color: #245c3a;
    box-shadow: 0 0 0 2px rgba(36, 92, 58, 0.1);
}

#comment-form button {
    background: #245c3a;
    color: white;
    border: 1px solid #245c3a;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}

#comment-form button:hover {
    background: #1e4a2f;
    border-color: #1e4a2f;
}

.comment {
    background: #f8f6f1;
    border: 1px solid #ded8cd;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.comment p {
    margin: 0 0 0.5rem 0;
}

.comment-actions {
    margin-top: 0.75rem;
}

.comment-actions button {
    padding: 0.4rem 0.8rem;
    border: 1px solid #ded8cd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.comment-actions button:hover {
    border-color: #245c3a;
}

.comment-edited {
    color: #666;
    font-style: italic;
    font-size: 0.9rem;
}

.edit-comment-button, .delete-comment-button {
    color: #245c3a;
}

.edit-comment-button:hover, .delete-comment-button:hover {
    text-decoration: underline;
    cursor: pointer;
}

.success-message,
.error-message {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #ded8cd;
}

.success-message {
    background: #eef3ec;
    color: #245c3a;
    border-color: #d4dfd4;
}

.error-message {
    background: #f8eaea;
    color: #8a2d2d;
    border-color: #e2c7c7;
}

.comment-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    box-sizing: border-box;
}

.comment-modal.hidden {
    display: none;
}

.comment-modal-box {
    background: #ffffff;
    border: 1px solid #ded8cd;
    border-radius: 14px;
    padding: 1.25rem;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.comment-modal-box h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #1f1f1f;
}

.comment-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.comment-modal-actions button {
    padding: 0.75rem 1.5rem;
    border: 1px solid #ded8cd;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
}

#save-edit-button, #confirm-delete-button {
    background: #245c3a;
    color: white;
    border-color: #245c3a;
}

#cancel-edit-button, #cancel-delete-button {
    background: #f8f6f1;
    color: #245c3a;
}

#save-edit-button:hover, #confirm-delete-button:hover {
    background: #1e4a2f;
    border-color: #1e4a2f;
}

#cancel-edit-button:hover, #cancel-delete-button:hover {
    background: #efe7da;
}