@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: #f0f4f8;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.wrapper-table {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.main-content-cell {
    padding: 40px 48px 48px;
    position: relative;
}

/* Кнопка "Назад" для админки */
.back-btn {
    background: #f1f5f9;
    border: none;
    color: #64748b;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.2s;
}

.back-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.brand-section {
    margin-bottom: 35px;
}

.logo-img {
    height: 48px;
    display: block;
    margin-bottom: 16px;
}

.brand-section h1 {
    font-size: 26px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.5px;
}

.brand-section p {
    color: #64748b;
    font-size: 14px;
    margin-top: 4px;
    font-weight: 500;
}

.direction-toggle {
    display: flex;
    width: 100%;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
    gap: 4px;
}

.direction-btn {
    flex: 1;
    min-height: 44px;
    border: none;
    background: transparent;
    padding: 12px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-radius: 9px;
    text-align: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.direction-btn.active {
    background: #ffffff;
    color: #0058D0;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}

.search-container {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 500;
    color: #0f172a;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    outline: none;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: #0058D0;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 88, 208, 0.08);
}

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
    display: none;
    margin-top: 6px;
}

.suggestion-item {
    padding: 14px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
    text-align: left;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: #e0ecfc;
    color: #0058D0;
}

.keyboard-panel {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.key-btn {
    background: #f1f5f9;
    border: none;
    min-width: 48px;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 600;
    color: #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.key-btn:hover {
    background: #0058D0;
    color: #ffffff;
}

.translation-area {
    margin-top: 8px;
    min-height: 320px;
}

.result-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 28px 32px;
    min-height: 280px;
    display: none;
    text-align: left;
}

.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #0058D0;
}

.result-title {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    flex: 1;
    min-width: 0;
}

.result-text {
    font-size: 15px;
    line-height: 1.7;
    color: #334155;
    font-weight: 400;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.placeholder-text {
    color: #64748b;
    text-align: center;
    font-size: 15px;
    padding: 48px 24px;
    font-weight: 500;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px dashed #e2e8f0;
    border-radius: 16px;
}

.placeholder-message {
    margin-bottom: 16px;
    line-height: 1.6;
}

.similar-label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 12px;
}

.similar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.similar-chip {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0058D0;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.similar-chip:hover {
    background: #0058D0;
    border-color: #0058D0;
    color: #ffffff;
}

/* Скрытая ссылка внизу меню */
.admin-link-wrapper {
    margin-top: 40px;
    text-align: left;
}

.admin-hidden-link {
    font-size: 11px;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.2s;
    user-select: none;
}

.admin-hidden-link:hover {
    color: #94a3b8;
}

.admin-panel {
    text-align: left;
}

.admin-panel h3 {
    margin-bottom: 16px;
    color: #0f172a;
    font-size: 16px;
    font-weight: 700;
}

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

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #64748b;
}

.admin-input, .admin-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    background: #f8fafc;
}

.admin-input:focus, .admin-select:focus {
    border-color: #0058D0;
    background: #ffffff;
}

.admin-submit-btn {
    width: 100%;
    background: #0058D0;
    color: white;
    border: none;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 6px;
    transition: background 0.15s;
}

.admin-submit-btn:hover {
    background: #0046a4;
}

.admin-message {
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    display: none;
}

.footer-note {
    text-align: center;
    width: 100%;
    max-width: 960px;
    margin-top: 30px;
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
    font-weight: 600;
}

.footer-note .developer {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    font-weight: 500;
}

.footer-note .sources {
    font-size: 12px;
    color: #64748b;
    margin-top: 8px;
    font-weight: 500;
}

.footer-note .sources a {
    color: #0058D0;
    text-decoration: none;
}

.footer-note .sources a:hover {
    text-decoration: underline;
}

/* ——— Планшет ——— */
@media (max-width: 768px) {
    body {
        padding: 12px 12px 20px;
    }

    .wrapper-table {
        border-radius: 20px;
    }

    .main-content-cell {
        padding: 28px 24px 32px;
    }

    .brand-section {
        margin-bottom: 24px;
    }

    .brand-section h1 {
        font-size: 22px;
    }

    .translation-area {
        min-height: 240px;
    }

    .result-box,
    .placeholder-text {
        min-height: 220px;
    }

    .placeholder-text {
        padding: 48px 20px;
    }

    .result-box {
        padding: 22px 20px;
    }

    .footer-note {
        margin-top: 20px;
        font-size: 12px;
        padding: 0 8px;
    }
}

/* ——— Телефон ——— */
@media (max-width: 480px) {
    body {
        padding: 8px 8px 16px;
        justify-content: flex-start;
    }

    .wrapper-table {
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    }

    .main-content-cell {
        padding: 20px 16px 24px;
    }

    .logo-img {
        height: 40px;
        margin-bottom: 12px;
    }

    .brand-section {
        margin-bottom: 20px;
    }

    .brand-section h1 {
        font-size: 18px;
        line-height: 1.3;
        letter-spacing: -0.3px;
    }

    .direction-toggle {
        margin-bottom: 16px;
    }

    .direction-btn {
        font-size: 12px;
        padding: 10px 6px;
    }

    .search-input {
        padding: 14px 16px;
        border-radius: 12px;
    }

    .suggestions-list {
        max-height: min(40vh, 220px);
        -webkit-overflow-scrolling: touch;
    }

    .suggestion-item {
        padding: 16px;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .keyboard-panel {
        margin-bottom: 16px;
        gap: 6px;
    }

    .key-btn {
        flex: 1 1 calc(33.333% - 6px);
        max-width: calc(33.333% - 6px);
        min-width: 0;
    }

    .key-btn:nth-child(n+4) {
        flex: 1 1 calc(50% - 6px);
        max-width: calc(50% - 6px);
    }

    .translation-area {
        min-height: 200px;
        margin-top: 4px;
    }

    .placeholder-text {
        font-size: 14px;
        min-height: 180px;
        padding: 32px 16px;
        border-radius: 12px;
    }

    .result-box {
        min-height: 180px;
        padding: 18px 16px;
        border-radius: 12px;
    }

    .result-title {
        font-size: 18px;
    }

    .result-text {
        font-size: 14px;
        line-height: 1.65;
    }

    .footer-note {
        margin-top: 16px;
        font-size: 11px;
        line-height: 1.5;
    }

    .footer-note .developer {
        font-size: 10px;
    }
}

/* Узкие экраны (iPhone SE и т.п.) */
@media (max-width: 360px) {
    .brand-section h1 {
        font-size: 16px;
    }

    .direction-btn {
        font-size: 11px;
    }
}