* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.5;
}

/* Современные табы с переносом */
nav {
    margin-bottom: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 10px;
    overflow: visible;
}

ul {
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    gap: 5px;
}

ul li {
    margin: 0;
    border: none;
    border-radius: 6px;
    overflow: hidden;
    min-width: auto;
    flex: 0 0 auto;
}

ul li:last-child {
    border-right: none;
}

a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 13px;
    white-space: nowrap;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

a:hover {
    background-color: #e9ecef;
    color: #007bff;
    transform: translateY(-1px);
}

a[aria-selected="true"] {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.3);
}

/* Улучшенные формы */
.forms {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 30px;
    margin-bottom: 20px;
}

.forms > div[hidden] {
    display: none;
}

h1 {
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 28px;
    font-weight: 600;
    border-bottom: 3px solid #007bff;
    padding-bottom: 10px;
}

label {
    display: block;
    margin: 15px 0 5px 0;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

input[type='text'], select {
    width: 100%;
    max-width: 300px;
    height: 45px;
    font-size: 16px;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fff;
}

input[type='text']:focus, select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

input[type='text']:invalid {
    border-color: #dc3545;
}

/* Современные кнопки */
input[type='submit'] {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0,123,255,0.3);
}

input[type='submit']:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,123,255,0.4);
}

input[type='submit']:active {
    transform: translateY(0);
}

/* Улучшенный preview */
#preview {
    margin-top: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    width: 100%;
    min-height: 60px;
    font-size: 14px;
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    max-height: 400px;
    transition: all 0.3s ease;
}

/* Состояния preview */
.error-state {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
    box-shadow: 0 0 0 3px rgba(220,53,69,0.1);
}

.success-state {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
    box-shadow: 0 0 0 3px rgba(40,167,69,0.1);
}

/* Улучшенный лоадер */
.loader {
    display: none;
    color: #007bff;
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0;
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 10px;
    border: 2px solid #e3f2fd;
}

.loader.active {
    display: block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.loader::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid #007bff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Улучшенное сообщение об ошибке ключа */
#keyNotFound {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(220,53,69,0.3);
    border: none;
}

/* Заголовок ответа */
h4 {
    color: #495057;
    font-size: 18px;
    font-weight: 600;
    margin: 30px 0 10px 0;
    padding-left: 10px;
    border-left: 4px solid #007bff;
}

/* Адаптивность */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    nav {
        padding: 8px;
    }
    
    a {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    input[type='text'], select {
        max-width: 100%;
    }
    
    .forms {
        padding: 20px;
    }
}

/* Улучшенные select элементы */
select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}