:root {
    --tg-theme-bg-color: var(--tg-theme-secondary-bg-color, #fff);
    --tg-theme-text-color: var(--tg-theme-text-color, #000);
    --tg-theme-hint-color: var(--tg-theme-hint-color, #999);
    --tg-theme-link-color: var(--tg-theme-link-color, #2481cc);
    --tg-theme-button-color: var(--tg-theme-button-color, #2481cc);
    --tg-theme-button-text-color: var(--tg-theme-button-text-color, #fff);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    position: fixed;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

.page-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding: 16px;
}

.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.container h1 {
    color: var(--tg-theme-text-color);
    font-size: 20px;
    font-weight: 500;
    line-height: 24px;
    text-align: center;
    margin: 0 0 16px;
}

input, textarea, select {
    width: 100%;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 16px;
    line-height: 20px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.category-input-container {
    position: relative;
    margin-bottom: 16px;
}

.category-input-container input {
    margin-bottom: 0;
}

input::placeholder, textarea::placeholder {
    color: var(--tg-theme-hint-color);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--tg-theme-button-color);
}

button {
    width: 100%;
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s ease;
    margin-top: 8px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button:active:not(:disabled) {
    opacity: 0.8;
}

.error-message {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.2);
    color: #d00;
    border-radius: 8px;
    padding: 12px;
    margin-top: 16px;
    font-size: 14px;
    line-height: 18px;
    text-align: center;
}

.sending-message {
    color: var(--tg-theme-link-color);
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    line-height: 18px;
}

input[type="file"] {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Fix для iOS zoom при фокусе */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Оптимизации для разных размеров экранов */
@media (max-width: 360px) {
    .container {
        padding: 0 12px;
    }
    
    input, textarea, select, button {
        padding: 10px;
    }
    
    .container h1 {
        font-size: 18px;
        line-height: 22px;
        margin-bottom: 12px;
    }
}

/* Поддержка тёмной темы */
@media (prefers-color-scheme: dark) {
    .error-message {
        background: rgba(255, 0, 0, 0.15);
        border-color: rgba(255, 0, 0, 0.25);
    }
}