:root {
    /* Color Palette */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;

    --japanese-color: #e11d48;
    --chinese-color: #dc2626;

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-input: rgba(15, 23, 42, 0.4);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border-color: rgba(148, 163, 184, 0.1);
    --border-focus: rgba(99, 102, 241, 0.5);

    --success-color: #10b981;
    --error-color: #ef4444;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(225, 29, 72, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(220, 38, 38, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-2xl) var(--spacing-lg);
    z-index: 1;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
    animation: fadeInDown 0.6s ease-out;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.logo-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-color);
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.4));
    animation: float 3s ease-in-out infinite;
}

.logo-text {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* Translation Container */
.translation-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--spacing-xl);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.6s ease-out;
}

/* Section Styles */
.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.language-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--transition-base);
}

.language-badge svg {
    width: 20px;
    height: 20px;
}

.language-badge.japanese {
    background: rgba(225, 29, 72, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(225, 29, 72, 0.2);
}

.language-badge.chinese {
    background: rgba(220, 38, 38, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.char-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Input Textarea */
.input-textarea {
    width: 100%;
    min-height: 300px;
    padding: var(--spacing-md);
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
    font-size: 1rem;
    line-height: 1.8;
    resize: vertical;
    transition: all var(--transition-base);
}

.input-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
}

.btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn svg {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-base);
}

.btn:hover svg {
    transform: translateX(2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-secondary {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(100, 116, 139, 0.2);
    border-color: var(--secondary-color);
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    color: var(--success-color);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.copy-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    transform: translateY(-1px);
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.copy-btn.copied {
    background: rgba(16, 185, 129, 0.2);
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Only show spinner when button has the loading class (actively translating) */
.btn-primary.btn-loading .loading-spinner {
    display: inline-block;
}

.btn-primary.btn-loading svg:not(.loading-spinner) {
    display: none;
}

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

/* Turnstile Container */
.turnstile-container {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-md);
    min-height: 65px;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    justify-content: center;
}

.divider-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 50%;
    color: white;
    box-shadow: var(--shadow-md);
    animation: pulse 2s ease-in-out infinite;
}

.divider-icon svg {
    width: 24px;
    height: 24px;
}

/* Output Container */
.output-container {
    min-height: 300px;
    padding: var(--spacing-md);
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    color: var(--text-muted);
    opacity: 0.6;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    opacity: 0.4;
}

.placeholder-content p {
    font-size: 0.95rem;
    font-family: 'Noto Sans JP', sans-serif;
}

.translation-result {
    width: 100%;
    font-family: 'Noto Sans SC', 'Inter', sans-serif;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: fadeIn 0.4s ease-out;
}

/* Error Message */
.error-message {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: #fca5a5;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    animation: shake 0.5s ease-out;
}

.error-message svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Footer */
.footer {
    margin-top: var(--spacing-2xl);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    animation: fadeIn 1s ease-out;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .translation-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .divider {
        transform: rotate(90deg);
        margin: var(--spacing-md) 0;
    }
}

@media (max-width: 768px) {
    .container {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .logo-text {
        font-size: 2rem;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .translation-container {
        padding: var(--spacing-lg);
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.875rem;
    }

    .translation-container {
        padding: var(--spacing-md);
    }

    .input-textarea,
    .output-container {
        min-height: 250px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-hover);
}