* {
    box-sizing: border-box;
}

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

header {
    background-color: #17212e;
    color: white;
    padding: 20px 40px;
}

header h1 {
    margin-top: 0;
}

nav {
    display: flex;
    gap: 24px;
}

nav a {
    color: #d6e2ee;
    text-decoration: none;
}

main {
    max-width: 800px;
    margin: 50px auto;
    padding: 30px;
    background: white;
    border-radius: 12px;
}

input {
    padding: 12px;
    width: 65%;
    border: 1px solid #ccc;
    border-radius: 6px;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    background: #2563eb;
    color: white;
    cursor: pointer;
}

button:hover {
    background: #1d4ed8;
}

#results {
    margin-top: 24px;
}

#analyze-form {
    display: flex;
    gap: 12px;
}

#analyze-form input {
    flex: 1;
    min-width: 0;
    width: auto;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.candidate-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 18px 0;
}

.candidate {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid #dce2e8;
    border-radius: 8px;
    cursor: pointer;
}

.candidate:hover {
    background: #f0f5ff;
}

.candidate:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
}

.candidate input {
    width: auto;
    margin: 0;
}

.message {
    padding: 14px;
    border-radius: 8px;
    background: #eff6ff;
}

.message.success {
    background: #dcfce7;
    color: #166534;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

@media (max-width: 600px) {
    #analyze-form {
        flex-direction: column;
    }
}


/* Dictionary page */

.dictionary-page {
    max-width: 1100px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.page-heading h2 {
    margin: 0 0 8px;
}

.page-heading p {
    margin: 0;
    color: #64748b;
}

.action-link {
    display: inline-block;
    background: #2563eb;
    color: white;
    padding: 12px 18px;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
}

.action-link:hover {
    background: #1d4ed8;
}

.dictionary-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.dictionary-toolbar input {
    flex: 1;
    min-width: 0;
    width: auto;
}

.dictionary-toolbar select {
    padding: 12px;
    border: 1px solid #dce2e8;
    border-radius: 6px;
    background: white;
}

#dictionary-count {
    color: #64748b;
    font-size: 14px;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

.dictionary-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.dictionary-table th {
    background: #f1f5f9;
    padding: 14px;
    font-size: 13px;
    color: #475569;
}

.dictionary-table td {
    padding: 14px;
    border-bottom: 1px solid #e2e8f0;
}

.dictionary-table tbody tr:hover {
    background: #f8fafc;
}

.pos-badge {
    display: inline-block;
    padding: 5px 10px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
}

.view-button {
    background: #e2e8f0;
    color: #1e293b;
    padding: 8px 12px;
}

.view-button:hover {
    background: #cbd5e1;
}

.forms-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e2e8f0;
}

.forms-section[hidden] {
    display: none;
}

.forms-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.secondary-button {
    background: #e2e8f0;
    color: #1e293b;
}

.user-input-yes {
    color: #15803d;
    font-weight: bold;
}

.user-input-no {
    color: #94a3b8;
}

#dictionary-message,
#forms-message {
    color: #64748b;
    font-size: 14px;
}

nav a.active {
    color: white;
    font-weight: bold;
    border-bottom: 2px solid #60a5fa;
    padding-bottom: 5px;
}

@media (max-width: 600px) {
    .dictionary-toolbar,
    .page-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .dictionary-table th,
    .dictionary-table td {
        padding: 10px;
        font-size: 13px;
    }
}


.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #17212e;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: white;
    border-radius: 12px;
    padding: 32px;
}

.login-card h1 {
    margin: 0 0 12px;
    text-align: center;
}

.login-card > p {
    text-align: center;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-card label {
    font-weight: 600;
    font-size: 14px;
}

.login-card input {
    width: 100%;
}

.login-card button {
    margin-top: 12px;
}

.login-error {
    padding: 12px;
    border-radius: 6px;
    background: #fee2e2;
    color: #991b1b;
}


.dictionary-page {
    max-width: 900px;
    margin: 32px auto;
    padding: 0 16px;
}

.dictionary-controls {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.dictionary-controls input,
.dictionary-controls select,
.collection-creator input {
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 16px;
}

.collection-creator {
    padding: 18px;
    margin-bottom: 24px;
    border: 1px solid #ddd;
    border-radius: 12px;
}

.collection-creator form {
    display: flex;
    gap: 10px;
}

.lexeme-card {
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 12px;
}

.lexeme-card h3 {
    margin: 0 0 8px;
}

.category-summary {
    color: #777;
    font-size: 14px;
}

.lexeme-details {
    border-top: 1px solid #ddd;
    margin-top: 16px;
    padding-top: 16px;
}

.category-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
}

.category-checkbox input {
    width: 18px;
    height: 18px;
}

.word-forms {
    margin-top: 20px;
}

#message {
    min-height: 20px;
}

@media (max-width: 600px) {
    .dictionary-controls {
        grid-template-columns: 1fr;
    }

    .collection-creator form {
        flex-direction: column;
    }

    .lexeme-card {
        padding: 14px;
    }
}


/* ========================================
   COMPACT DICTIONARY
======================================== */

.dictionary-page,
.collections-page {
    max-width: 1000px;
    margin: 32px auto;
    padding: 0 16px;
}

.dictionary-controls {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 22px;
}

.dictionary-controls input,
.dictionary-controls select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    font-size: 16px;
}

.dictionary-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    background: white;
    border: 1px solid #dedede;
    border-radius: 12px;
}

.dictionary-item + .dictionary-item {
    border-top: 1px solid #e8e8e8;
}

.dictionary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 52px;
    padding: 8px 14px;
}

.dictionary-row:hover {
    background: #f8fafc;
}

.dictionary-word {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.dictionary-word-button {
    appearance: none;
    background: transparent;
    border: none;
    padding: 4px 0;
    color: #1f2937;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.dictionary-word-button:hover {
    color: #2563eb;
    text-decoration: underline;
}

.dictionary-pos {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 5px;
    background: #edf2f7;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 7px;
}

.dictionary-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    flex: 0 1 auto;
}

.dictionary-categories {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    min-width: 0;
    flex-wrap: wrap;
}

.dictionary-category-tag {
    border-radius: 5px;
    background: #eff6ff;
    color: #1d4ed8;
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
}

.dictionary-no-category {
    color: #94a3b8;
    font-size: 12px;
    white-space: nowrap;
}

.dictionary-add-category {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #d1d5db;
    background: white;
    color: #475569;
    border-radius: 7px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.dictionary-add-category:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

/* Expanded panels */

.dictionary-panel {
    padding: 14px 16px 18px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
}

.dictionary-panel h4 {
    margin: 0 0 12px;
    font-size: 14px;
}

.category-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 16px;
}

.category-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.category-checkbox input {
    width: 17px;
    height: 17px;
}

.dictionary-forms {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.word-form-tag {
    display: inline-block;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #dbe2ea;
    background: white;
    border-radius: 6px;
}

/* ========================================
   COLLECTIONS PAGE
======================================== */

.collections-description {
    color: #64748b;
    margin-bottom: 24px;
}

.collection-create-section {
    background: white;
    border: 1px solid #dedede;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.collection-create-section h3 {
    margin-top: 0;
}

.collection-create-section form {
    display: flex;
    gap: 10px;
}

.collection-create-section input {
    flex: 1;
    min-width: 0;
    padding: 12px;
    font-size: 16px;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
}

.collections-list {
    background: white;
    border: 1px solid #dedede;
    border-radius: 12px;
    overflow: hidden;
}

.collection-item + .collection-item {
    border-top: 1px solid #e8e8e8;
}

.collection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: none;
    border-radius: 0;
    background: white;
    color: #1f2937;
    padding: 16px 18px;
    text-align: left;
    cursor: pointer;
}

.collection-header:hover {
    background: #f8fafc;
}

.collection-name {
    font-weight: 600;
    font-size: 16px;
}

.collection-expand-icon {
    font-size: 20px;
    color: #64748b;
}

.collection-content {
    padding: 12px 18px 18px;
    background: #f8fafc;
    border-top: 1px solid #e8e8e8;
}

.collection-count {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 12px;
}

.collection-lexeme-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid #e5e7eb;
}

.collection-lexeme-word {
    font-weight: 500;
}

.empty-state {
    padding: 16px;
    color: #64748b;
    font-size: 14px;
}

/* ========================================
   MOBILE
======================================== */

@media (max-width: 600px) {
    .dictionary-page,
    .collections-page {
        margin: 16px auto;
        padding: 0 10px;
    }

    .dictionary-controls {
        grid-template-columns: 1fr 1fr;
    }

    .dictionary-controls input {
        grid-column: 1 / -1;
    }

    .dictionary-row {
        padding: 8px 10px;
        gap: 8px;
    }

    .dictionary-word {
        gap: 6px;
    }

    .dictionary-word-button {
        font-size: 14px;
    }

    .dictionary-category-tag {
        font-size: 11px;
        padding: 3px 5px;
    }

    .dictionary-categories {
        max-width: 44vw;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .dictionary-add-category {
        flex-basis: 30px;
    }

    .category-checkbox-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .collection-create-section form {
        flex-direction: column;
    }
}


/* ========================================
   LEMMA / LEXEME DICTIONARY
======================================== */

/* Основний контейнер */

.dictionary-list {
    display: flex;
    flex-direction: column;
    gap: 0;

    border: 1px solid #dedede;
    border-radius: 12px;

    background: #ffffff;
    overflow: hidden;
}

.dictionary-item + .dictionary-item {
    border-top: 1px solid #e8e8e8;
}


/* ========================================
   LEMMA ROW
======================================== */

.lemma-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 48px;
    padding: 7px 14px;
    gap: 16px;

    background: #ffffff;
}

.lemma-row:hover {
    background: #f8fafc;
}

.lemma-row .dictionary-word {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lemma-toggle {
    flex: 0 0 22px;

    width: 22px;
    height: 28px;

    padding: 0;
    border: none;
    border-radius: 5px;

    background: transparent;
    color: #64748b;

    font-size: 20px;
    cursor: pointer;
}

.lemma-toggle:hover {
    color: #2563eb;
    background: #edf2f7;
}

.lemma-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 10px;
    margin-left: auto;
}

.lemma-count {
    color: #94a3b8;
    font-size: 12px;
    white-space: nowrap;
}


/* ========================================
   NESTED LEXEMES
======================================== */

.lemma-children {
    background: #f8fafc;
    border-top: 1px solid #e8e8e8;
}

.lexeme-nested {
    background: #f8fafc;
}

.lexeme-nested + .lexeme-nested {
    border-top: 1px solid #e5e7eb;
}

.lexeme-nested .lexeme-row {
    padding-left: 48px;
    background: transparent;
}

.lexeme-nested .lexeme-row:hover {
    background: #eef2f7;
}


/* ========================================
   LEXEME ROW
======================================== */

.lexeme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;
    min-height: 46px;
    padding: 7px 14px;
}

.lexeme-row .dictionary-word {
    display: flex;
    align-items: center;
    flex: 1 1 auto;

    gap: 12px;
    min-width: 0;
}

.lexeme-row .dictionary-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    flex: 0 1 auto;
    gap: 10px;
    min-width: 0;
}

.dictionary-word-button {
    appearance: none;
    border: none;
    background: transparent;

    padding: 4px 0;
    border-radius: 0;

    color: #1f2937;
    font-size: 16px;
    font-weight: 600;
    text-align: left;

    cursor: pointer;
}

.dictionary-word-button:hover {
    color: #2563eb;
    text-decoration: underline;
}

.dictionary-pos-button {
    appearance: none;
    border: none;
    cursor: pointer;
}

.dictionary-pos-button:hover {
    background: #dbeafe;
    color: #1d4ed8;
}


/* ========================================
   CATEGORIES
======================================== */

.dictionary-categories {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;

    gap: 5px;
    min-width: 0;
}

.dictionary-category-tag {
    display: inline-flex;
    align-items: center;

    padding: 4px 8px;
    border-radius: 5px;

    background: #eff6ff;
    color: #1d4ed8;

    font-size: 12px;
    white-space: nowrap;
}

.dictionary-no-category {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}

.dictionary-add-category {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 30px;

    width: 30px;
    height: 30px;

    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 7px;

    background: #ffffff;
    color: #475569;

    font-size: 20px;
    line-height: 1;

    cursor: pointer;
}

.dictionary-add-category:hover {
    border-color: #2563eb;
    background: #eff6ff;
    color: #2563eb;
}


/* ========================================
   EXPANDED PANELS
======================================== */

.lexeme-entry > .dictionary-panel {
    padding: 14px 16px 18px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
}

.lexeme-nested > .dictionary-panel {
    padding-left: 48px;
}

.dictionary-panel h4 {
    margin: 0 0 12px;
    font-size: 14px;
}

.category-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 16px;
}

.category-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 14px;
    cursor: pointer;
}

.category-checkbox input {
    width: 17px;
    height: 17px;
}

.dictionary-forms {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.word-form-tag {
    display: inline-block;

    padding: 6px 10px;
    border: 1px solid #dbe2ea;
    border-radius: 6px;

    background: white;
    font-size: 13px;
}

.user-input-form {
    border-color: #93c5fd;
    background: #eff6ff;
}


/* ========================================
   MOBILE ADAPTATION
======================================== */

@media (max-width: 600px) {

    .lemma-row {
        padding: 7px 10px;
        min-height: 44px;
    }

    .lemma-count {
        font-size: 11px;
    }

    .lexeme-row {
        padding: 7px 10px;
        gap: 8px;
    }

    .lexeme-row .dictionary-word {
        gap: 6px;
    }

    .lexeme-nested .lexeme-row {
        padding-left: 30px;
    }

    .dictionary-word-button {
        font-size: 14px;
    }

    .dictionary-pos-button {
        font-size: 11px;
    }

    .dictionary-categories {
        max-width: 42vw;

        flex-wrap: nowrap;
        overflow: hidden;
    }

    .dictionary-category-tag {
        font-size: 11px;
        padding: 3px 5px;
    }

    .dictionary-add-category {
        flex-basis: 30px;
    }

    .category-checkbox-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lexeme-nested > .dictionary-panel {
        padding-left: 30px;
    }
}
