* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    margin: 0;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
    overflow-x: hidden;
}

.container {
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 100%;
    margin: 0;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 600;
}

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

textarea {
    width: 100%;
    height: 180px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    font-size: 16px;
    resize: none;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.3s ease;
    line-height: 1.5;
    background: #fafafa;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    align-items: center;
}

.button-row {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.mic-button, .openai-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 20px 30px;
    border-radius: 50px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    min-height: 60px;
    flex: 1;
    max-width: 220px;
    min-width: 160px;
    font-weight: 600;
    touch-action: manipulation;
}

.mic-button:hover, .mic-button:active,
.openai-button:hover, .openai-button:active {
    background: #5a67d8;
    transform: scale(0.98);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.openai-button {
    background: #10a37f;
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.3);
}

.openai-button:hover, .openai-button:active {
    background: #0d8568;
    box-shadow: 0 6px 20px rgba(16, 163, 127, 0.4);
}

.mic-button.listening {
    background: #e53e3e;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 4px 15px rgba(229, 62, 62, 0.3); }
    50% { transform: scale(1.02); box-shadow: 0 6px 20px rgba(229, 62, 62, 0.5); }
    100% { transform: scale(1); box-shadow: 0 4px 15px rgba(229, 62, 62, 0.3); }
}

.clear-button {
    background: #718096;
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 50px;
    max-width: 200px;
    width: 100%;
    font-weight: 500;
    touch-action: manipulation;
}

.clear-button:hover, .clear-button:active {
    background: #4a5568;
    transform: scale(0.98);
}

.openai-button:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.openai-button.loading {
    background: #10a37f;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.openai-icon {
    width: 18px;
    height: 18px;
}

.openai-response {
    margin-top: 20px;
    padding: 15px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.openai-response h3 {
    margin: 0 0 10px 0;
    color: #2d3748;
    font-size: 16px;
    font-weight: 600;
}

.openai-response #responseContent {
    color: #4a5568;
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.status {
    text-align: center;
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
}

.status.listening {
    background: #fed7d7;
    color: #c53030;
}

.status.success {
    background: #c6f6d5;
    color: #2d7d32;
}

.status.error {
    background: #fed7d7;
    color: #c53030;
}

.status.info {
    background: #bee3f8;
    color: #2b6cb0;
}

.hidden {
    display: none;
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    body {
        padding: 5px;
        padding-top: 10px;
    }

    .container {
        padding: 15px;
        border-radius: 15px;
        margin: 0;
    }

    h1 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }

    textarea {
        height: 160px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    .button-row {
        flex-direction: row;
        gap: 10px;
    }

    .mic-button, .openai-button {
        padding: 18px 25px;
        font-size: 17px;
        min-height: 55px;
        max-width: none;
    }

    .clear-button {
        padding: 12px 20px;
        font-size: 15px;
        min-height: 45px;
    }

    .status {
        font-size: 13px;
        padding: 10px 12px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    body {
        padding: 3px;
    }

    .container {
        padding: 12px;
    }

    h1 {
        font-size: 1.4em;
        margin-bottom: 15px;
    }

    textarea {
        height: 140px;
        padding: 10px;
    }

    .mic-button, .openai-button {
        padding: 16px 20px;
        font-size: 16px;
        min-height: 50px;
    }

    .clear-button {
        padding: 10px 18px;
        font-size: 14px;
        min-height: 40px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        justify-content: flex-start;
        padding-top: 5px;
    }

    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }

    textarea {
        height: 100px;
    }

    .controls {
        margin-top: 10px;
        gap: 10px;
    }
}
