*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.6;
    min-height: 100vh;
}

.header {
    background-color: #2563eb;
    color: #ffffff;
    padding: 1.25rem 1rem;
    text-align: center;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

.translate-section {
    background: #ffffff;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.textarea {
    width: 100%;
    border: 1.5px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.15s ease;
    background: #ffffff;
    color: #1a1a1a;
}

.textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.textarea::placeholder {
    color: #9ca3af;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    padding: 0.75rem 1.5rem;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
    width: 100%;
    margin-top: 0.75rem;
}

.btn-primary:not(:disabled):hover {
    background-color: #1d4ed8;
}

.btn-primary:not(:disabled):active {
    background-color: #1e40af;
}

.btn-play {
    background-color: #f3f4f6;
    color: #1f2937;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1.5px solid #e5e7eb;
    margin-top: 0.5rem;
}

.btn-play:not(:disabled):hover {
    background-color: #e5e7eb;
}

.play-icon {
    font-size: 0.75rem;
}

.error-message {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.result-area {
    margin-top: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.result-entry {
    display: flex;
    flex-direction: column;
}

.result-pl {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.result-en {
    font-size: 1.15rem;
    font-weight: 600;
    color: #111827;
    word-break: break-word;
}

.history-section {
    background: #ffffff;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.history-header {
    font-size: 1.05rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.history-list {
    list-style: none;
}

.history-list:empty::after {
    content: "Brak zapisanych tłumaczeń";
    display: block;
    color: #9ca3af;
    font-size: 0.9rem;
    text-align: center;
    padding: 1.5rem 0;
}

.history-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
}

.history-entry:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-entry:first-child {
    padding-top: 0;
}

.history-pl {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 0.15rem;
    word-break: break-word;
}

.history-en {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    word-break: break-word;
}

.btn-mic {
    background-color: #f59e0b;
    color: #ffffff;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-mic:not(:disabled):hover {
    background-color: #d97706;
}

.btn-mic:not(:disabled):active {
    background-color: #b45309;
}

.btn-mic.recording {
    background-color: #dc2626;
}

.btn-mic.recording:not(:disabled):hover {
    background-color: #b91c1c;
}

.btn-mic.recording:not(:disabled):active {
    background-color: #991b1b;
}

.mic-status {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.5rem;
    text-align: center;
}

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.3em;
}

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

@media (max-width: 400px) {
    .header h1 {
        font-size: 1.1rem;
    }

    .container {
        padding: 1rem 0.75rem 1.5rem;
    }

    .translate-section,
    .history-section {
        padding: 1rem;
    }

    .textarea {
        font-size: 1rem;
    }
}