:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 28, 45, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-color: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success-color: #10b981;
    --cyber-cyan: #06b6d4;
    --cyber-magenta: #ec4899;
    --font-sans: 'Inter', 'Sarabun', system-ui, -apple-system, sans-serif;
    --input-bg: rgba(255, 255, 255, 0.02);
    --header-bg: rgba(255, 255, 255, 0.02);
    --footer-bg: rgba(255, 255, 255, 0.01);
}

body.light-theme {
    --bg-color: #f0f4f8;
    --card-bg: rgba(255, 255, 255, 0.7);
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #4f46e5;
    --accent-glow: rgba(79, 70, 229, 0.1);
    --input-bg: rgba(0, 0, 0, 0.02);
    --header-bg: rgba(0, 0, 0, 0.02);
    --footer-bg: rgba(0, 0, 0, 0.01);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Background Glowing Orbs */
.background-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.25;
    mix-blend-mode: screen;
    transition: opacity 0.4s ease;
}

body.light-theme .glow-orb {
    opacity: 0.08;
    mix-blend-mode: multiply;
}

.orb-1 {
    top: -10%;
    right: 10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--accent-color) 0%, transparent 80%);
}

.orb-2 {
    bottom: -10%;
    left: 5%;
    width: 45vw;
    height: 45vw;
    background: radial-gradient(circle, var(--cyber-cyan) 0%, transparent 80%);
}

.container {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    z-index: 1;
}

header {
    margin-bottom: 2.5rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2.25rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

body.light-theme h1 {
    background: linear-gradient(135deg, #0f172a 30%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Day/Night Custom Switch Slider Style matching reference image */
.theme-toggle-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 90px;
    height: 42px;
    cursor: pointer;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, #7dd3fc, #38bdf8, #0ea5e9);
    border-radius: 21px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
}

.switch-knob {
    position: absolute;
    content: "";
    height: 32px;
    width: 32px;
    left: 4px;
    bottom: 3px;
    background-color: #facc15; /* Yellow Sun */
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(251, 191, 36, 0.5), inset 0 -2px 3px rgba(0, 0, 0, 0.1);
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Craters on Moon (only visible in Dark Mode) */
.crater {
    position: absolute;
    background-color: #cbd5e1;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.crater-1 { width: 6px; height: 6px; top: 6px; left: 8px; }
.crater-2 { width: 8px; height: 8px; bottom: 8px; right: 6px; }
.crater-3 { width: 5px; height: 5px; top: 16px; left: 18px; }

/* Switch Background & Knob state when checked (Dark Mode) */
.theme-switch input:checked + .switch-slider {
    background: linear-gradient(to right, #111827, #1f2937, #374151);
    border-color: rgba(255, 255, 255, 0.1);
}

.theme-switch input:checked + .switch-slider .switch-knob {
    transform: translateX(46px);
    background-color: #f1f5f9; /* White Moon */
    box-shadow: 0 2px 6px rgba(255, 255, 255, 0.2), inset -2px -2px 4px rgba(0, 0, 0, 0.15);
}

.theme-switch input:checked + .switch-slider .switch-knob .crater {
    opacity: 1;
}

/* Switch decorations (stars and clouds) */
.decorations {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.star {
    position: absolute;
    color: #ffffff;
    font-size: 0.6rem;
    transition: all 0.4s ease;
    opacity: 0;
    transform: translateY(-10px);
}

.star-1 { top: 6px; left: 16px; font-size: 0.7rem; transition-delay: 0.1s; }
.star-2 { top: 22px; left: 24px; font-size: 0.5rem; transition-delay: 0.15s; }
.star-3 { top: 12px; left: 36px; font-size: 0.55rem; transition-delay: 0.2s; }

.cloud {
    position: absolute;
    font-size: 1.2rem;
    opacity: 0.95;
    transition: all 0.4s ease;
    filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.5));
}

.cloud-1 { bottom: -6px; right: 12px; font-size: 1.3rem; }
.cloud-2 { bottom: -2px; right: -2px; font-size: 1.1rem; }

/* Show stars / hide clouds in dark mode */
.theme-switch input:checked + .switch-slider .star {
    opacity: 0.8;
    transform: translateY(0);
}

.theme-switch input:checked + .switch-slider .cloud {
    opacity: 0;
    transform: translateY(15px);
}

/* Main glassmorphism card */
.main-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.2);
    padding: 2.5rem;
    margin-bottom: 2rem;
    transition: background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Mode Selector Switch */
.mode-selector-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 2.25rem;
}

.mode-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 5px;
    border-radius: 16px;
    gap: 4px;
    width: 100%;
    max-width: 650px;
}

body.light-theme .mode-selector {
    background: rgba(0, 0, 0, 0.03);
}

.mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.75rem 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .mode-selector {
        flex-direction: column;
        border-radius: 18px;
    }
    .mode-btn {
        width: 100%;
    }
}

.mode-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

body.light-theme .mode-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mode-btn.active {
    color: #ffffff;
    background: var(--accent-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* Editor Grid */
.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .editor-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.4s ease;
}

.panel:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.4rem;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

body.light-theme .badge {
    background: rgba(0, 0, 0, 0.05);
}

.badge-accent {
    background: rgba(6, 182, 212, 0.15);
    color: var(--cyber-cyan);
}

body.light-theme .badge-accent {
    background: rgba(8, 145, 178, 0.1);
    color: #0891b2;
}

.badge-thai {
    background: rgba(236, 72, 153, 0.15);
    color: var(--cyber-magenta);
}

body.light-theme .badge-thai {
    background: rgba(219, 39, 119, 0.1);
    color: #db2777;
}

.badge-english {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

body.light-theme .badge-english {
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
}

textarea {
    width: 100%;
    height: 250px;
    background: transparent;
    border: none;
    outline: none;
    padding: 1.4rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    line-height: 1.65;
    resize: none;
}

.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.4rem;
    background: var(--footer-bg);
    border-top: 1px solid var(--border-color);
}

.counter {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.65rem 1.35rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

body.light-theme .btn-primary {
    color: #ffffff;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

body.light-theme .btn-secondary {
    background: rgba(0, 0, 0, 0.04);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

body.light-theme .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(16, 185, 129, 0.95);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.3);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 1rem;
    line-height: 1.6;
}

.copyright {
    opacity: 0.6;
    margin-top: 0.25rem;
}

