* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    background: #f7f3ec;
    color: #333;
    line-height: 1.7;
}

a {
    color: #7a5c2e;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.header {
    background: #fffaf2;
    border-bottom: 1px solid #e2d6c4;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header h1 {
    margin: 0;
    font-size: 24px;
    color: #5d4523;
}

.header div {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.container {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 24px;
}

.login-container {
    width: min(420px, 100%);
    margin: 80px auto;
    padding: 32px 24px;
    background: #fffaf2;
    border: 1px solid #e2d6c4;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(80, 60, 30, 0.08);
}

.login-container h1 {
    margin: 0 0 8px;
    text-align: center;
    color: #5d4523;
}

.login-text {
    margin: 0 0 24px;
    text-align: center;
    color: #776b5d;
}

.error {
    background: #fff0f0;
    color: #b00020;
    border: 1px solid #f0b8b8;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
}

.top-actions {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr 220px auto auto;
    gap: 8px;
    align-items: center;
}

.search-form input {
    min-width: 0;
}

.search-form select {
    max-width: none;
}

.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.add-button {
    display: inline-block;
    background: #8b6f3e;
    color: #fff;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: bold;
    white-space: nowrap;
}

.add-button:hover {
    background: #6f572f;
    text-decoration: none;
}

.word-list {
    display: grid;
    gap: 16px;
}

.word-card {
    background: #fffaf2;
    border: 1px solid #e2d6c4;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(80, 60, 30, 0.06);
}

.word-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.word-card h2 {
    margin: 0;
    font-size: 24px;
    color: #4f3a1f;
}

.category {
    background: #efe3ce;
    color: #6f572f;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    white-space: nowrap;
}

.word-section {
    margin-top: 14px;
}

.word-section h3 {
    margin: 0 0 4px;
    font-size: 14px;
    color: #8b6f3e;
}

.word-section p {
    margin: 0;
    white-space: normal;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #eadfce;
}

.card-actions form {
    margin: 0;
}

.card-actions button {
    background: transparent;
    color: #b00020;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.card-actions button:hover {
    text-decoration: underline;
}

.word-form,
.login-form {
    background: #fffaf2;
    border: 1px solid #e2d6c4;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(80, 60, 30, 0.06);
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #5d4523;
}

.required {
    font-size: 12px;
    color: #b00020;
    margin-left: 4px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #d8c8b1;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #8b6f3e;
    box-shadow: 0 0 0 3px rgba(139, 111, 62, 0.15);
}

textarea {
    resize: vertical;
}

button {
    background: #8b6f3e;
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font: inherit;
    font-weight: bold;
    cursor: pointer;
}

button:hover {
    background: #6f572f;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 24px;
}

.search-result,
.empty {
    color: #776b5d;
}

.group-heading {
    margin: 28px 0 8px;
    padding-left: 4px;
    font-size: 22px;
    color: #5d4523;
    border-bottom: 2px solid #d8c8b1;
}

.favorite-form {
    margin: 0;
}

.favorite-button {
    background: transparent;
    color: #c49a2c;
    border: none;
    padding: 0;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.favorite-button:hover {
    background: transparent;
    transform: scale(1.1);
}

.favorite-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-weight: normal;
}

.favorite-filter input {
    width: auto;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.tag {
    display: inline-block;
    background: #f1eadc;
    color: #6f572f;
    border: 1px solid #e2d6c4;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 13px;
}

.export-button {
    display: inline-block;
    background: #fffaf2;
    color: #6f572f;
    border: 1px solid #d8c8b1;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: bold;
    white-space: nowrap;
}

.export-button:hover {
    background: #efe3ce;
    text-decoration: none;
}

.search-form select {
    max-width: 220px;
}

.word-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.word-title-wrap h2 {
    margin: 0;
}

.word-title-wrap .favorite-button {
    font-size: 24px;
}

@media (max-width: 600px) {
    .search-form select {
        max-width: none;
    }

    .favorite-filter {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
    }

    .header h1 {
        font-size: 22px;
    }

    .header div {
        flex-wrap: wrap;
    }

    .container {
        padding: 16px;
    }

    .login-container {
        margin: 40px 16px;
        width: auto;
    }

    .top-actions {
        flex-direction: column;
        align-items: stretch;
    }

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

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons a {
        text-align: center;
    }

    .add-button {
        text-align: center;
    }

    .word-card {
        padding: 16px;
        border-radius: 14px;
    }

    .word-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .word-card h2 {
        font-size: 22px;
    }

    .word-form,
    .login-form {
        padding: 18px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions button,
    .form-actions a {
        text-align: center;
    }
}
