:root {
    /* Premium Color Palette */
    --primary: #4338ca;
    /* Indigo 700 */
    --primary-light: #818cf8;
    /* Indigo 400 */
    --secondary: #e11d48;
    /* Rose 600 */
    --accent: #f59e0b;
    /* Amber 500 */

    --bg-base: #0f172a;
    /* Slate 900 */
    --bg-surface: rgba(30, 41, 59, 0.7);
    /* Slate 800 with opacity */
    --bg-surface-hover: rgba(51, 65, 85, 0.8);

    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #cbd5e1;
    /* Slate 300 */

    --success: #10b981;
    /* Emerald 500 */
    --error: #ef4444;
    /* Red 500 */

    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* Background Effects */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at top right, #1e1b4b, var(--bg-base));
    z-index: -2;
}

.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: rgba(67, 56, 202, 0.4);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 40vw;
    height: 40vw;
    background: rgba(159, 18, 57, 0.3);
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(10%, 10%) scale(1.1);
    }
}

/* Glassmorphism Containers */
.glass-panel {
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--glass-shadow);
}

.glass-panel-inner {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 30px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel-inner:hover {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}

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

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

.section-card {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

/* Header & Typography */
.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 25px;
    margin-bottom: 35px;
    flex-wrap: wrap;
    gap: 20px;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(129, 140, 248, 0.2);
    color: var(--primary-light);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 {
    font-family: 'Playfair Display', serif;
    color: #fff;
    margin: 0 0 10px 0;
    font-size: 2.2rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

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

/* ── Theme Button Grid ────────────────────────────────────────────── */
.theme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-start;
}

.theme-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    transform: translateY(-2px);
}

.theme-btn.active {
    background: var(--primary);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Selectors */
.selector-box {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    border-left: 4px solid var(--primary-light);
}

.select-group {
    flex: 1;
    min-width: 250px;
}

.select-group label {
    display: block;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    appearance: none;
    outline: none;
    transition: all 0.3s;
}

select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

/* Custom select arrow */
.custom-select-wrapper {
    position: relative;
}

.custom-select-wrapper::after {
    content: "▼";
    font-size: 0.8rem;
    color: var(--text-muted);
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Section Headings */
.section-label {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 0 25px 0;
    color: #fff;
    font-size: 1.4rem;
    font-family: 'Playfair Display', serif;
}

.step-num {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(67, 56, 202, 0.5);
}

/* 3D Flip Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.flip-card {
    background-color: transparent;
    height: 250px;
    perspective: 1000px;
    cursor: pointer;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner,
.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.flip-card-front {
    background: linear-gradient(135deg, rgba(67, 56, 202, 0.8), rgba(30, 27, 75, 0.9));
    border: 1px solid var(--glass-border);
    color: white;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.flip-card-front .letter {
    font-size: 56px;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(to bottom right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.flip-card-front .label {
    font-size: 16px;
    opacity: 0.9;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.flip-card-back {
    background: rgba(30, 41, 59, 0.95);
    color: #fff;
    transform: rotateY(180deg);
    font-size: 1.05rem;
    line-height: 1.6;
    border: 2px solid var(--primary-light);
    overflow-y: auto;
    box-shadow: 0 8px 20px rgba(67, 56, 202, 0.2);
    padding: 25px;
}

/* Scrollbar for back card */
.flip-card-back::-webkit-scrollbar {
    width: 4px;
}

.flip-card-back::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 4px;
}

/* Tabs */
.tab-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.tab-buttons {
    display: flex;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    scrollbar-width: none;
    /* Firefox */
}

.tab-buttons::-webkit-scrollbar {
    display: none;
}

/* Chrome */

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 15px;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.tab-btn.active {
    color: var(--primary-light);
    background: rgba(67, 56, 202, 0.1);
    border-bottom-color: var(--primary-light);
}

.tab-content-wrapper {
    padding: 25px;
}

.tab-content {
    display: none;
    font-size: 1.1rem;
    line-height: 1.8;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

.highlight {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
}

/* Quiz Section */
.quiz-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.highlight-inline {
    color: #f8fafc;
    font-weight: 500;
    border-bottom: 1px dashed var(--primary-light);
}

.inline-select {
    display: inline-block;
    width: auto;
    min-width: 300px;
    padding: 8px 12px;
    margin-left: 10px;
    font-size: 1rem;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.quiz-action-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 25px;
}

/* Buttons */
.action-btn {
    padding: 10px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.primary-glow {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(67, 56, 202, 0.4);
}

.primary-glow:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(67, 56, 202, 0.6);
}

.outline-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
}

.outline-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: #fff;
}

.feedback {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Paragraph Builder */
.builder-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
}

.builder-btn-group {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sentence-btn {
    text-align: left;
    padding: 15px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
}

.sentence-btn strong {
    color: var(--primary-light);
    margin-right: 8px;
}

.sentence-btn:hover {
    background: rgba(67, 56, 202, 0.15);
    border-color: var(--primary-light);
    color: #fff;
    transform: translateX(8px);
}

.builder-result-area {
    flex: 1.5;
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

.result-box {
    flex-grow: 1;
    min-height: 200px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 20px;
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.result-box span {
    display: inline;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
}

.result-box span:hover {
    background: rgba(225, 29, 72, 0.2);
    color: #fca5a5;
}

.builder-action-bar {
    display: flex;
    align-items: center;
    gap: 15px;
}

.success-msg {
    color: var(--success);
    font-weight: 600;
    animation: fadeIn 0.3s;
}

/* Vocab Grid */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.vocab-item {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: 16px;
    border-left: 4px solid var(--secondary);
    transition: all 0.3s;
}

.vocab-item:hover {
    background: rgba(30, 41, 59, 0.8);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.vocab-item h4 {
    margin: 0;
    color: #e2e8f0;
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-style: italic;
    cursor: help;
    display: inline-block;
}

.vocab-item .meaning {
    display: none;
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.vocab-item:hover .meaning {
    display: block;
    animation: fadeIn 0.4s;
}

.vocab-item em {
    color: var(--accent);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Step Navigation & Progress Tabs */
.progress-tabs {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 25px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.process-scrollbar::-webkit-scrollbar {
    height: 6px;
}

.process-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.prog-btn {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 12px 16px;
    border-radius: 8px;
    flex: 1;
    min-width: 120px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.prog-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateY(-2px);
}

.prog-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    font-weight: 600;
}

.step-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.step-section.active {
    display: block;
}

.step-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .glass-panel {
        padding: 25px 15px;
    }

    .header-flex {
        flex-direction: column;
        align-items: stretch;
    }

    .selector-box {
        flex-direction: column;
        align-items: stretch;
    }

    .builder-layout {
        flex-direction: column;
    }

    .lang-toggles {
        top: 10px;
        right: 10px;
        gap: 5px;
    }

    .translate-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Translation Styling */
.lang-toggles {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.translate-btn {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 10px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.translate-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
    border-color: var(--primary-light);
}

.translate-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.lang-text {
    margin-bottom: 5px;
}

.ms-text {
    color: #fff;
}

.en-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9em;
}

.zh-text {
    color: #cbd5e1;
    font-weight: 300;
    font-size: 0.9em;
}

/* Hide by default unless the body has the toggle class */
body:not(.show-en) .en-text {
    display: none;
}

body:not(.show-zh) .zh-text {
    display: none;
}

/* Framework Styling */
.framework-container {
    padding: 24px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    margin-bottom: 25px;
}

.framework-container h3 {
    margin-top: 0;
    color: var(--primary-light);
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.two-column-layout {
    display: flex;
    gap: 30px;
    margin-top: 25px;
    height: 65vh;
    /* Independent scrolling height */
    min-height: 450px;
}

.layout-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 50%;
    overflow-y: auto;
    padding-right: 15px;
    /* Space for scrollbar */
}

/* Custom layout column scrollbar */
.layout-col::-webkit-scrollbar {
    width: 8px;
}

.layout-col::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.layout-col::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.layout-col::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.col-title {
    color: var(--primary-light);
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 10px;
}

.fw-card {
    background: rgba(30, 41, 59, 0.6);
    padding: 20px;
    border-radius: 12px;
    border-left: 3px solid var(--primary);
}

.fw-card h4 {
    margin-top: 0;
    color: #fbbf24;
    font-family: 'Playfair Display', serif;
    margin-bottom: 15px;
}

.template-box {
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #e2e8f0;
    border-left: 2px dashed rgba(255, 255, 255, 0.2);
    min-height: 150px;
    outline: none;
    transition: border-color 0.3s;
}

.template-box:empty:before {
    content: "Tampal isi karangan di sini / Paste essay content here / 在此粘贴作文内容...";
    color: rgba(255, 255, 255, 0.3);
}

.template-box:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.6);
}

.content-col .fw-card {
    border-left-color: var(--secondary);
    background: rgba(44, 62, 80, 0.6);
}

.content-col .fw-card h4 {
    color: var(--success);
}

.imbakup-point {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.imbakup-point:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.imbakup-label {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin-right: 10px;
    color: #fbbf24;
    min-width: 35px;
    text-align: center;
}

.imbakup-text {
    display: inline;
}

@media (max-width: 900px) {
    .two-column-layout {
        flex-direction: column;
        height: auto;
    }

    .layout-col {
        max-width: 100%;
        height: 70vh;
        /* Maintain scrollability for each column on mobile */
    }
}

/* Congratulations Overlay */
#congrats-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.congrats-content {
    padding: 40px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 50px rgba(251, 191, 36, 0.2);
    max-width: 600px;
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -20px;
    z-index: 10000;
    animation: confettiFall 4s linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

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