:root {
    --bg: #f6f5f3;
    --card: #fff;
    --accent: #5d4037;
    --accent-rgb: 93, 64, 55;
    --muted: #666;
    --danger-bg: #ffebee;
    --danger-fg: #c0392b;
    --left-panel-width: 50%;
}

* {
    box-sizing: border-box
}

body {
    font-family: Inter, system-ui, Segoe UI, Arial;
    background: var(--bg);
    padding: 18px;
    margin: 0;
}

.wrap {
    max-width: 95vw;
    margin: 0 auto
}

.header-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    padding: 10px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
    width: 100%;
    max-width: 1000px;
    transition: all 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-text {
    color: var(--accent);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
    white-space: nowrap;
}

#main-nav-links {
    display: none; /* Removed as items moved to user menu */
}

.header-pills {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu-container {
    position: relative;
}

.user-pill {
    background: #e8e0d5;
    border: 1px solid #d2c8bc;
    border-radius: 25px;
    padding: 6px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    user-select: none;
    cursor: pointer;
}

.user-pill:hover {
    background: #dfd5c8;
    border-color: #c5b8a8;
}

.user-pill #user-display-email {
    font-size: 13px;
    font-weight: 700;
    color: #4b3a2a;
}

.user-name-display {
    font-size: 11px;
    color: #8d7b68;
    margin-top: -2px;
    display: block;
}

.dropdown-arrow {
    font-size: 9px;
    color: #8d7b68;
    transition: transform 0.2s;
}

.user-pill.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Выпадающее меню пользователя */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: white;
    border: 1px solid #ddd;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 8px 0;
    z-index: 10200;
    min-width: 200px;
    display: none;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    padding: 10px 18px;
    cursor: pointer;
    font-size: 13px;
    color: #4b3a2a;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.1s;
    font-weight: 600;
}

.dropdown-item:hover {
    background: #f8f5f2;
    color: var(--accent);
}

.dropdown-item.danger {
    color: #c0392b;
}

.dropdown-item.danger:hover {
    background: #fff5f5;
}

.dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 8px 0;
}

.lang-pill {
    background: #e8e0d5;
    border: 1px solid #d2c8bc;
    border-radius: 25px;
    padding: 2px;
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: default;
    transition: all 0.2s;
    user-select: none;
}

.lang-pill button {
    background: transparent;
    border: none;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 800;
    color: #8d7b68;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.lang-pill button:hover {
    color: #5d4037;
}

.lang-pill button.active {
    background: var(--accent);
    color: #fff;
}

/* Синонимы: Теги выбора */
.synonym-chip {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 5px 15px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    user-select: none;
}

.synonym-chip:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.synonym-chip.selected {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.synonym-chip input {
    display: none;
}

.more-syn-btn {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0 10px;
    font-size: 14px;
    cursor: pointer;
    height: 32px;
    display: flex;
    align-items: center;
    color: #555;
    transition: all 0.2s;
    font-weight: 500;
}

.more-syn-btn:hover {
    background: #eee;
    color: var(--accent);
    border-color: var(--accent);
}

/* --- МОДАЛЬНЫЕ ОКНА (Общие) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 30000;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 16px;
    width: 90%;
    max-width: 550px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

.modal-scroll {
    flex-grow: 1;
    overflow-y: auto;
    margin: 15px 0;
    padding-right: 5px;
}

.modal-scroll::-webkit-scrollbar {
    width: 6px;
}

.modal-scroll::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: var(--accent);
}

/* Выпадающее меню пользователя */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #ddd;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 6px 0;
    z-index: 10200;
    min-width: 180px;
    display: none;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #4b3a2a;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.1s;
    font-weight: 500;
}

.dropdown-item:hover {
    background: #f8f5f2;
    color: var(--accent);
}

.dropdown-item.danger {
    color: #c0392b;
}

.dropdown-item.danger:hover {
    background: #fff5f5;
}

.dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 6px 0;
}

#main-nav-links a.btn {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    padding: 5px 10px;
    background: var(--card);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
    font-size: 13px;
}

#main-nav-links a.btn:hover {
    background: #f9f9f9;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.07);
}

.grid {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 20px;
}

.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Modal styling for the editor form */
#editor-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10005;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#editor-modal-overlay.open {
    display: flex;
    opacity: 1;
}

#left-panel {
    width: 90%;
    max-width: 800px;
    height: 90vh;
    margin: 0;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

#editor-modal-overlay.open #left-panel {
    transform: translateY(0);
}

#right-panel {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

#form-top-section {
    flex-shrink: 0;
    padding-bottom: 10px;
}

#form-scroll-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
}

#form-bottom-section {
    flex-shrink: 0;
    padding-top: 10px;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #eee;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--muted);
    z-index: 10;
}

.modal-close:hover {
    background: #ddd;
    color: var(--accent);
}

@keyframes highlight-fade {
    0% { background: rgba(var(--accent-rgb), 0.2); }
    100% { background: transparent; }
}

.highlight-save {
    animation: highlight-fade 2s ease-out;
    border: 2px solid var(--accent) !important;
}

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
}

input[type=text],
textarea,
select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px
}

textarea {
    min-height: auto;
    height: auto;
    resize: vertical
}

.row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
}

.grid-3 label {
    font-size: 11px;
}

.btn {
    background: var(--accent);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.btn:hover {
    opacity: 0.9;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn.secondary {
    background: #eee;
    color: var(--accent);
}

.btn.danger {
    background: var(--danger-fg);
    color: #fff;
}

.small {
    font-size: 13px;
    padding: 6px 8px
}

.medium {
    padding: 8px 16px;
}

.list {
    flex-grow: 1;
    overflow-y: auto;
    border-top: 1px solid #eee;
    margin-top: 10px;
}

.item {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.item:hover {
    background: #fafafa;
}

.item-main-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-actions {
    flex-shrink: 0;
    align-self: flex-start;
}

/* Аккордеон-панель деталей */
.item-details-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.item-details-panel.open {
    grid-template-rows: 1fr;
}
.item-details-panel > * {
    overflow: hidden;
}

/* Внутреннее содержимое панели */
.item-details-inner {
    padding: 12px 0 4px 0;
    border-top: 1px dashed #e8e0d5;
    margin-top: 8px;
}

/* Строка загрузки */
.item-details-loading {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}
.item-details-loading.active {
    display: flex;
}
.details-spin {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(var(--accent-rgb), 0.15);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

/* Строки деталей */
.detail-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: flex-start;
    font-size: 13px;
    line-height: 1.5;
}
.detail-row:last-child { margin-bottom: 0; }
.detail-label {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: #e8e0d5;
    color: #4b3a2a;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}
.detail-val {
    color: #444;
    font-style: italic;
}
.detail-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--accent);
    margin: 10px 0 6px 0;
}
.detail-section-title:first-child { margin-top: 0; }

.meta {
    color: #777;
    font-size: 13px;
    line-height: 1.5;
    margin-top: 4px;
    width: 100%;
}

.meta-syn {
    color: var(--accent);
    font-style: italic;
    font-size: 12px;
}

.meta-context {
    color: #333;
    font-weight: 500;
}

.meta-note {
    color: #005580;
    font-style: italic;
    font-size: 12px;
}

.item-ru[title],
.meta>span[title] {
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: var(--accent);
}

.desc-toggle {
    padding: 2px 6px !important;
    font-size: 11px !important;
}

.item-description {
    display: none;
    font-size: 12px;
    background: #fdfdfd;
    border: 1px solid #eee;
    padding: 8px;
    margin-top: 8px;
    border-radius: 4px;
    color: #555;
    line-height: 1.4;
    white-space: pre-wrap;
}

.pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #faf7f5;
    border: 1px solid #eee;
    font-size: 12px
}

#drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
    margin-top: 10px;
}

#drop-zone.dragover {
    background-color: #f0f0f0;
    border-color: var(--accent);
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #ddd;
    padding-bottom: -1px;
    align-items: center;
}

.tabs .btn {
    background: #eee;
    color: var(--muted);
    border-radius: 6px 6px 0 0;
    border: 1px solid #ddd;
    border-bottom: none;
    flex-shrink: 0;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.tabs .btn.active {
    background: var(--card);
    color: var(--accent);
    border-bottom: 1px solid var(--card);
    margin-bottom: -1px;
    font-weight: bold;
}

.tabs .btn.tab-highlight {
    box-shadow: 0 0 10px 2px #28a745;
    border-color: #28a745 !important;
}

.list-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

/* Обновленные стили для компактных блоков */
details.control-group {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #eee;
    margin-bottom: 10px;
}

details.control-group summary {
    outline: none;
}

/* Компактная красная зона */
/* Ультра-компактная зона удаления */
.delete-zone {
    background: #fff;
    border: 1px solid #eee;
    border-left: 3px solid var(--danger-fg);
    padding: 2px 8px !important;
    /* Еще меньше отступы */
    border-radius: 4px;
    margin-bottom: 5px !important;
}

.delete-zone[open] {
    background: var(--danger-bg);
    padding-bottom: 6px !important;
}

.delete-zone summary {
    margin: 0;
    padding: 2px 0;
    font-size: 11px;
    cursor: pointer;
    color: var(--danger-fg);
    font-weight: 600;
}


.filter-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.filter-checks label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    user-select: none;
    cursor: pointer;
}

.filter-checks input {
    width: auto;
}

#lang-switcher {
    display: flex;
    gap: 5px;
}

#lang-switcher .btn {
    padding: 5px 10px;
    font-size: 12px;
    background: #eee;
    color: var(--muted);
}

#lang-switcher .btn.active {
    background: var(--accent);
    color: #fff;
    font-weight: bold;
}

/* Компактный режим списка */
.list.compact-mode .item:not(.expanded) .meta,
.list.compact-mode .item:not(.expanded) .item-description,
.list.compact-mode .item:not(.expanded) .desc-toggle-container {
    display: none !important;
}

.list.compact-mode .item:not(.expanded) {
    padding: 8px 15px;
    min-height: unset;
    border-bottom: 1px solid #f9f9f9;
    cursor: pointer;
}

.list.compact-mode .item:not(.expanded):hover {
    background: #fdfdfd;
}

.item {
    border-bottom: 1.5px solid #ececec !important;
    margin-bottom: 2px;
}

.fav-btn {
    padding: 2px 5px !important;
    min-width: 26px;
    font-size: 14px !important;
    line-height: 1;
}

.item.selected {
    background: rgba(108, 92, 231, 0.08) !important;
    border-left: 4px solid var(--accent) !important;
}

/* Плавающая панель инструментов */
#tools-panel {
    position: fixed;
    top: 150px;
    right: 40px;
    width: 320px;
    z-index: 9998;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
    
    /* Анимация скрытия */
    opacity: 0;
    visibility: hidden;
    transform: translate(50px, 50px) scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#tools-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translate(0, 0) scale(1);
}
#tools-header {
    padding: 12px 15px;
    background: #f1f2f6;
    border-bottom: 1px solid #dfe4ea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}
#tools-header b { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }
#tools-body {
    padding: 15px;
    max-height: 80vh;
    overflow-y: auto;
}
.tools-close {
    background: none; border: none; font-size: 18px; cursor: pointer; color: #a4b0be;
}
.tools-close:hover { color: var(--danger); }

#tools-panel.dragging {
    transition: none !important;
}

/* Компактные кнопки действий в списке */
.fav-btn, .edit, .delete {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    min-width: 32px !important;
    line-height: 1 !important;
}

.header-actions-group {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px;
    border-radius: 20px;
    gap: 2px;
}
.header-actions-group .btn {
    border-radius: 18px;
    border: none;
    padding: 4px 12px;
    margin: 0 !important;
    box-shadow: none;
    background: transparent;
    color: #555;
}
.header-actions-group .btn:hover {
    background: rgba(255, 255, 255, 0.5);
}
.header-actions-group .btn.active-pill {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.logo-text {
    cursor: pointer;
    transition: all 0.2s;
    padding: 4px 8px;
    border-radius: 8px;
}
.logo-text:hover {
    background: rgba(108, 92, 231, 0.08);
    color: var(--accent);
    text-decoration: underline dotted;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-overlay.open {
    display: flex !important;
}

.modal-content {
    background: var(--card);
    border-radius: 12px;
    padding: 30px;
    width: 95%;
    max-width: 850px;
    height: 90vh; /* Еще немного увеличено */
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-scroll {
    overflow-y: auto;
    padding-right: 15px;
    flex-grow: 1;
}

.modal-content h2 {
    color: var(--accent);
    margin-top: 0;
}

.modal-content h3 {
    color: var(--accent);
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-top: 15px;
}

.modal-content p,
.modal-content li {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--muted);
    border: none;
    background: none;
    cursor: pointer;
    line-height: 1;
}

select.small-select {
    padding: 4px 6px;
    font-size: 13px;
    height: 30px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    flex-shrink: 1;
    width: auto;
}

input[type=number] {
    text-align: center;
}

#len-lang-switcher .btn {
    padding: 5px 8px;
    font-size: 11px;
    background: #eee;
    color: var(--muted);
}

#len-lang-switcher .btn.active {
    background: var(--accent);
    color: #fff;
    font-weight: bold;
}

/* Виджет импорта */
#import-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 300px;
    background: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid #ddd;
    z-index: 9999;
    display: none;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    transition: height 0.3s ease;
}

.widget-header {
    background: var(--accent);
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.widget-body {
    padding: 15px;
}

.progress-container {
    width: 100%;
    background-color: #eee;
    border-radius: 4px;
    height: 10px;
    margin: 10px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: #27ae60;
    width: 0%;
    transition: width 0.3s ease;
}

.import-stats {
    font-size: 12px;
    color: #555;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.widget-controls {
    display: flex;
    gap: 10px;
}

#import-widget.minimized .widget-body {
    display: none;
}

#import-widget.minimized {
    width: 200px;
}

/* === МОДАЛЬНЫЕ ОКНА (Modern UI) === */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10050;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.custom-modal-overlay.open {
    display: flex;
    opacity: 1;
}

.custom-modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.custom-modal-overlay.open .custom-modal {
    transform: scale(1);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
}

.modal-message {
    font-size: 14px;
    color: #444;
    line-height: 1.5;
    margin: 0;
}

.modal-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 5px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 14px;
    transition: background 0.2s;
}

.modal-btn.primary {
    background: var(--accent);
    color: white;
}

.modal-btn.primary:hover {
    opacity: 0.9;
}

.modal-btn.danger {
    background: var(--danger-fg);
    color: white;
}

.modal-btn.secondary {
    background: #eee;
    color: #333;
}

.modal-btn.secondary:hover {
    background: #e0e0e0;
}


/* --- Стили для шапки пользователя --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    border-left: 4px solid var(--accent);
}

.user-info {
    font-weight: 500;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-btn-mini {
    background: transparent;
    border: 1px solid var(--danger-fg);
    color: var(--danger-fg);
    padding: 5px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
}

.logout-btn-mini:hover {
    background: var(--danger-fg);
    color: white;
}

.nav-home-btn {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.9em;
    margin-right: 15px;
}

.nav-home-btn:hover {
    color: var(--accent);
}

/* --- Стили для прав доступа --- */
.btn-disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
    cursor: not-allowed;
    border-color: #ccc !important;
}

/* Стиль кнопки Избранного */
.fav-btn {
    background-color: #eee !important;
    color: #555 !important;
    border: 1px solid #ccc !important;
    font-weight: 500;
    min-width: 145px;
    /* Фикс скачков ширины */
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.fav-btn:hover {
    background-color: #e0e0e0 !important;
}

/* Активное состояние (В избранном) - ЗОЛОТОЙ */
.fav-btn.is-favorite {
    background-color: #ffc107 !important;
    /* Золотой цвет */
    color: #000 !important;
    border-color: #e0a800 !important;
    font-weight: bold;
}

.fav-btn.is-favorite:hover {
    background-color: #e0a800 !important;
    /* Темнее при наведении */
}

/* Анимация для кнопки обновления */
@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.rotating-icon {
    animation: spin 1s linear infinite;
    display: inline-block;
}

.refresh-btn {
    margin-left: auto;
    /* Отодвигает кнопку вправо */
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 0.9em;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.translate-btn {
    padding: 4px 6px !important;
    font-size: 11px !important;
    height: 32px;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #5d4037;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.translate-btn:hover {
    background: #e0e0e0;
}

.translate-btn img {
    width: 14px;
    height: 14px;
}

/* Контекстное меню для перевода */
.ctx-menu {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 5px 0;
    z-index: 10100;
    min-width: 200px;
    font-family: sans-serif;
}

.ctx-header {
    padding: 5px 15px;
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    border-bottom: 1px solid #eee;
    margin-bottom: 5px;
}

.ctx-item {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ctx-item:hover {
    background: #f5f5f5;
    color: var(--accent);
}

.ctx-divider {
    height: 1px;
    background: #eee;
    margin: 5px 0;
}

/* ==========================================================================
   MOBILE & VIEWPORT RESPONSIVENESS (≤ 768px)
   ========================================================================== */

@media (max-width: 768px) {
    body {
        padding: 8px !important;
    }

    .wrap {
        max-width: 100% !important;
    }

    .main-header {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 12px 15px !important;
        border-radius: 10px !important;
        align-items: stretch !important;
    }

    .header-left {
        justify-content: center !important;
    }

    .logo-text {
        font-size: 16px !important;
    }

    .header-pills {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }

    .header-actions-group {
        display: flex !important;
        justify-content: space-between !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
        width: 100% !important;
    }

    .header-actions-group button {
        flex: 1 !important;
        justify-content: center !important;
        padding: 6px 10px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
    }

    .user-menu-container {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .user-pill {
        justify-content: center !important;
        padding: 6px 14px !important;
        width: 100% !important;
    }

    .user-pill #user-display-email {
        font-size: 12px !important;
    }

    .dropdown-menu {
        right: 50% !important;
        transform: translateX(50%) !important;
        width: 100% !important;
        max-width: 280px !important;
    }

    .lang-pill {
        justify-content: center !important;
        width: 100% !important;
    }

    .lang-pill button {
        flex: 1 !important;
        text-align: center !important;
    }

    /* Grid & Layout */
    .grid {
        margin-top: 10px !important;
    }

    #right-panel {
        padding: 10px !important;
        border-radius: 8px !important;
    }

    .list-controls {
        padding: 10px !important;
        gap: 10px !important;
    }

    /* Filters row styling in Dictionary list */
    .list-controls .row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .list-controls .input-group,
    .list-controls select,
    .list-controls input {
        width: 100% !important;
    }

    .filter-checks {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
    }

    /* Tabs */
    .tabs {
        overflow-x: auto !important;
        white-space: nowrap !important;
        justify-content: flex-start !important;
        padding-bottom: 5px !important;
        -webkit-overflow-scrolling: touch;
    }

    .tabs button {
        padding: 8px 12px !important;
        font-size: 13px !important;
        flex: 0 0 auto !important;
    }

    /* Dictionary Item Cards */
    .item {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 12px 10px !important;
        gap: 10px !important;
    }

    .item > div:first-child {
        width: 100% !important;
    }

    .item-actions {
        display: flex !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        width: 100% !important;
        border-top: 1px dashed #eee !important;
        padding-top: 8px !important;
    }

    /* Modal Import / Add Word Form */
    #left-panel {
        width: 96% !important;
        height: 94vh !important;
        max-height: 94vh !important;
        border-radius: 12px !important;
        padding: 15px !important;
    }

    #form-top-section .row {
        flex-direction: row !important;
        gap: 8px !important;
    }

    .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* FAQ Helping Modal */
    .modal-content {
        padding: 15px !important;
        width: 95% !important;
        max-height: 90vh !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Tools panel popup/drawer */
    #tools-panel {
        width: 96% !important;
        right: 2% !important;
        left: 2% !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
    }
}

@media (max-width: 480px) {
    .header-actions-group button span:last-child {
        display: none !important;
    }
    .header-actions-group button {
        min-width: 40px !important;
        padding: 8px !important;
    }
}


