* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --card-bg: rgba(30, 41, 59, 0.8);
    --card-bg-hover: rgba(51, 65, 85, 0.6);
    --text-primary: #ffffff;
    --text-secondary: rgba(203, 213, 225, 0.8);
    --text-tertiary: rgba(148, 163, 184, 0.6);
    --border-color: rgba(148, 163, 184, 0.2);
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-focus: rgba(15, 23, 42, 0.8);
    --shadow-color: rgba(0, 0, 0, 0.3);
}

body.light-theme {
    --bg-primary: #f1f5f9;
    --bg-secondary: #e2e8f0;
    --bg-tertiary: #cbd5e1;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-bg-hover: rgba(248, 250, 252, 0.95);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --border-color: rgba(148, 163, 184, 0.3);
    --input-bg: rgba(248, 250, 252, 0.8);
    --input-focus: rgba(255, 255, 255, 0.95);
    --shadow-color: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
    transition: all 0.3s ease;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

body.light-theme::before {
    background: 
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
}

.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: var(--card-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    border: 2px solid var(--border-color);
    box-shadow: 0 10px 30px var(--shadow-color);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

body.light-theme .sun-icon {
    display: block;
}

body.light-theme .moon-icon {
    display: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 60px;
    padding: 30px;
}

header h1 {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa 0%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(59, 130, 246, 0.3);
    animation: glow 2s ease-in-out infinite alternate;
    margin-bottom: 20px;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5)); }
    to { filter: drop-shadow(0 0 20px rgba(52, 211, 153, 0.5)); }
}

.mode-selector {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--shadow-color);
}

.mode-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-color: #3b82f6;
}

body.light-theme .mode-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 40px;
    margin-bottom: 80px;
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 25px;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px var(--shadow-color);
    transform: translateY(0);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.card:hover::before {
    left: 100%;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 30px 80px var(--shadow-color);
}

.encode-card {
    border-top: 3px solid #3b82f6;
}

.decode-card {
    border-top: 3px solid #10b981;
}

.card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 35px;
}

.card-header svg {
    width: 64px;
    height: 64px;
    padding: 16px;
    border-radius: 20px;
    margin-bottom: 20px;
    filter: drop-shadow(0 10px 20px var(--shadow-color));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.encode-card .card-header svg {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
}

.decode-card .card-header svg {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
}

.card-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
    font-weight: 700;
}

.card-header p {
    font-size: 15px;
    color: var(--text-secondary);
}

.content-area {
    margin-bottom: 25px;
}

.content-area label {
    display: block;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

textarea {
    width: 100%;
    min-height: 100px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 18px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    direction: ltr;
    text-align: left;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 8px var(--shadow-color);
}

textarea::placeholder {
    color: var(--text-tertiary);
}

textarea:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.6);
    background: var(--input-focus);
    box-shadow: 
        inset 0 2px 8px var(--shadow-color),
        0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="text"].password-field {
    width: 100%;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 14px 18px;
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 8px var(--shadow-color);
    direction: ltr;
    text-align: left;
}

input[type="text"].password-field::placeholder {
    color: var(--text-tertiary);
}

input[type="text"].password-field:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.6);
    background: var(--input-focus);
    box-shadow: 
        inset 0 2px 8px var(--shadow-color),
        0 0 0 3px rgba(139, 92, 246, 0.1);
}

.btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 20px var(--shadow-color);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(59, 130, 246, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(16, 185, 129, 0.5);
}

.btn-success:active {
    transform: translateY(-1px);
}

.btn-clear {
    width: 60px;
    padding: 18px;
    border: none;
    border-radius: 16px;
    font-size: 20px;
    cursor: pointer;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px var(--shadow-color);
    flex-shrink: 0;
}

.btn-clear:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(239, 68, 68, 0.5);
}

.btn-clear:active {
    transform: translateY(-1px);
}

.btn-paste {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.btn-paste:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(139, 92, 246, 0.4);
}

.btn-paste:active {
    transform: translateY(0);
}

.btn-qr {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px var(--shadow-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-qr:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(245, 158, 11, 0.4);
}

.btn-qr:active {
    transform: translateY(0);
}

.result-area {
    margin-top: 25px;
}

.result-area label {
    display: block;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.result-box {
    position: relative;
}

.result-box textarea {
    min-height: 80px;
    background: var(--input-focus);
    cursor: pointer;
    border-color: rgba(52, 211, 153, 0.3);
}

.result-box textarea:hover {
    background: var(--input-focus);
    border-color: rgba(52, 211, 153, 0.5);
}

.copy-hint {
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 10px;
    transition: all 0.3s ease;
}

.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.qr-modal.active {
    display: flex;
}

.qr-modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    position: relative;
    border: 2px solid var(--border-color);
    box-shadow: 0 20px 60px var(--shadow-color);
}

.qr-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-close:hover {
    transform: rotate(90deg);
}

.qr-modal-content h3 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

#qrcode {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 15px;
}

#qrcode img {
    border-radius: 10px;
}

footer {
    text-align: center;
    padding: 25px;
    color: var(--text-tertiary);
    font-size: 14px;
}

@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    .card {
        padding: 30px 20px;
    }

    .mode-selector {
        flex-direction: column;
        gap: 10px;
    }

    .mode-btn {
        width: 100%;
        justify-content: center;
    }

    .theme-toggle {
        width: 45px;
        height: 45px;
    }
}
