/* =========================================================
   IELTS Prep AI — Global Stylesheet
   Bright, modern, friendly · Academic & professional
   ========================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
    --bg:               #f8faff;
    --bg-alt:           #eef2ff;
    --surface:          #ffffff;
    --text:             #0f172a;
    --text-muted:       #64748b;
    --text-soft:        #94a3b8;

    --primary:          #6366f1;
    --primary-dark:     #4f46e5;
    --primary-darker:   #4338ca;
    --primary-soft:     #eef2ff;
    --accent:           #06b6d4;
    --accent-soft:      #cffafe;
    --warm:             #f59e0b;

    --success:          #10b981;
    --success-bg:       #ecfdf5;
    --success-border:   #a7f3d0;
    --error:            #ef4444;
    --error-bg:         #fef2f2;
    --error-border:     #fecaca;
    --info-bg:          #eff6ff;
    --info-border:      #bfdbfe;

    --border:           #e2e8f0;
    --border-strong:    #cbd5e1;
    --border-focus:     #a5b4fc;

    --radius-sm:        10px;
    --radius:           14px;
    --radius-lg:        20px;
    --radius-full:      999px;

    --shadow-xs:        0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm:        0 2px 8px rgba(15, 23, 42, .06);
    --shadow:           0 8px 24px rgba(79, 70, 229, .10);
    --shadow-lg:        0 24px 60px rgba(79, 70, 229, .16);

    --font:             'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --transition:       160ms cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 2. Reset & base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    background-image:
        radial-gradient(circle at 8% 0%, rgba(99, 102, 241, .10), transparent 42%),
        radial-gradient(circle at 92% 18%, rgba(6, 182, 212, .10), transparent 46%),
        radial-gradient(circle at 30% 100%, rgba(245, 158, 11, .06), transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
}

h1,
h2,
h3,
h4 {
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0 0 0.5em;
}

h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }
p  { margin: 0 0 1em; }

a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-darker);
    text-decoration: underline;
}

/* ---------- 3. Layout ---------- */
.container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

.main-content {
    min-height: calc(100vh - 76px);
    padding: 0 0 80px;
}

/* ---------- 4. Navigation ---------- */
.site-nav {
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 76px;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.brand:hover {
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: inline-block;
}

.brand-mark svg {
    width: 100%;
    height: 100%;
    display: block;
}

.brand-name {
    white-space: nowrap;
}

.brand-dot {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-right: 4px;
}

.nav-user strong {
    color: var(--text);
    font-weight: 700;
}

/* ---------- 5. Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition);
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(99, 102, 241, .28);
}

.btn-primary:hover {
    color: #fff;
    box-shadow: 0 12px 26px rgba(99, 102, 241, .36);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    color: var(--primary-dark);
    border-color: var(--border-focus);
    background: var(--primary-soft);
}

.btn-danger {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 8px 20px rgba(239, 68, 68, .28);
}

.btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.btn-sm {
    padding: 9px 18px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 15px 30px;
    font-size: 1.02rem;
}

.btn-block {
    width: 100%;
}

/* ---------- 6. Forms ---------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.005em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 13px 16px;
    font-family: var(--font);
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-soft);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

.form-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ---------- 7. Alerts ---------- */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
    border-color: var(--success-border);
}

.alert-error {
    background: var(--error-bg);
    color: #991b1b;
    border-color: var(--error-border);
}

.alert-info {
    background: var(--info-bg);
    color: #1e40af;
    border-color: var(--info-border);
}

/* ---------- 8. Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-body {
    padding: 28px;
}

/* ---------- 9. Hero (landing) ---------- */
.hero {
    padding: 80px 0 60px;
    text-align: center;
}

.hero-eyebrow {
    display: inline-block;
    padding: 7px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-radius: var(--radius-full);
    margin-bottom: 24px;
}

.hero-title {
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    margin: 0 0 20px;
    letter-spacing: -0.03em;
}

.hero-title .highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-sub {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 620px;
    margin: 0 auto 36px;
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- 10. Feature cards ---------- */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 72px;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    font-size: 1.5rem;
}

.feature-icon.indigo { background: var(--primary-soft); color: var(--primary-dark); }
.feature-icon.cyan   { background: var(--accent-soft);  color: #0e7490; }
.feature-icon.amber  { background: #fef3c7;             color: #b45309; }

.feature-card h3 {
    font-size: 1.15rem;
    margin: 0 0 8px;
}

.feature-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* ---------- 11. Auth split layout ---------- */
.page-auth .main-content {
    min-height: 100vh;
    padding: 0;
}

.auth-split {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

@media (min-width: 960px) {
    .auth-split {
        grid-template-columns: 460px 1fr;
    }
}

.auth-brand {
    position: relative;
    overflow: hidden;
    padding: 56px 48px;
    color: #fff;
    background: linear-gradient(140deg, #4338ca 0%, #6366f1 45%, #06b6d4 100%);
    display: none;
}

@media (min-width: 960px) {
    .auth-brand {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
}

.auth-brand::before,
.auth-brand::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.55;
    pointer-events: none;
}

.auth-brand::before {
    width: 320px;
    height: 320px;
    background: #a855f7;
    top: -100px;
    right: -80px;
}

.auth-brand::after {
    width: 260px;
    height: 260px;
    background: #22d3ee;
    bottom: -90px;
    left: -70px;
}

.auth-brand-logo {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    z-index: 1;
}

.auth-brand-logo .brand-mark { width: 34px; height: 34px; }
.auth-brand-logo .brand-mark svg rect { fill: rgba(255,255,255,.18); }
.auth-brand-logo .brand-mark svg path { fill: #fff; }
.auth-brand-logo .brand-mark svg circle { fill: #fff; }

.auth-brand-content {
    position: relative;
    z-index: 1;
}

.auth-brand-content h2 {
    color: #fff;
    font-size: 1.9rem;
    line-height: 1.25;
    margin: 0 0 20px;
    letter-spacing: -0.02em;
}

.auth-brand-content p {
    color: rgba(255, 255, 255, .85);
    font-size: 1rem;
    line-height: 1.65;
    margin: 0 0 28px;
    max-width: 340px;
}

.auth-brand-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-brand-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, .9);
}

.auth-brand-list li::before {
    content: '';
    display: inline-flex;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, .18);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 10l3.5 3.5L15 7'/%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

.auth-brand-footer {
    position: relative;
    z-index: 1;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, .7);
}

.auth-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

.auth-card-head {
    margin-bottom: 28px;
}

.auth-card-head .auth-mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    text-decoration: none;
    color: var(--text);
    font-weight: 800;
}

@media (min-width: 960px) {
    .auth-card-head .auth-mobile-brand {
        display: none;
    }
}

.auth-mobile-brand .brand-mark {
    width: 30px;
    height: 30px;
}

.auth-card-head h1 {
    font-size: 1.85rem;
    margin: 0 0 8px;
}

.auth-card-head p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.98rem;
}

.auth-card form {
    margin-top: 4px;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.93rem;
    color: var(--text-muted);
}

.auth-footer a {
    font-weight: 700;
}

/* ---------- 12. Dashboard placeholder ---------- */
.dashboard-welcome {
    padding: 64px 0 40px;
}

.dashboard-welcome h1 {
    font-size: clamp(1.8rem, 3.5vw, 2.5rem);
    margin: 0 0 12px;
}

.dashboard-welcome p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 560px;
}

/* ---------- 13. Footer ---------- */
.site-footer {
    background: transparent;
    border-top: 1px solid var(--border);
    padding: 32px 0;
    margin-top: 40px;
}

.footer-inner {
    text-align: center;
    color: var(--text-soft);
    font-size: 0.875rem;
}

.footer-inner p {
    margin: 0;
}

/* ---------- 14. Responsive tweaks ---------- */
@media (max-width: 640px) {
    .container { padding: 0 18px; }
    .nav-inner { height: 68px; gap: 12px; }
    .nav-user { display: none; }
    .hero { padding: 56px 0 40px; }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .hero-actions .btn { width: 100%; }
    .auth-form-wrap { padding: 32px 18px; }
    .auth-card-head h1 { font-size: 1.6rem; }
    .card-body { padding: 22px; }
}

/* =========================================================
   15. Inline nav items
   ========================================================= */
.nav-item {
    padding: 8px 14px;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.93rem;
    text-decoration: none;
    transition: all var(--transition);
}

.nav-item:hover {
    color: var(--primary-dark);
    background: var(--primary-soft);
    text-decoration: none;
}

.nav-item.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.nav-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
}

/* =========================================================
   16. Dashboard header + stats
   ========================================================= */
.dash-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 44px 0 28px;
}

.dash-header h1 {
    margin: 0 0 8px;
}

.dash-header p {
    color: var(--text-muted);
    margin: 0;
}

.dash-header .back-link {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.dash-header .back-link:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text);
}

.stat-value-text {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-meta {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.stat-card-accent {
    background: linear-gradient(140deg, #ffffff 0%, var(--primary-soft) 100%);
    border-color: var(--border-focus);
}

.stat-link {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 4px;
}

/* =========================================================
   17. Attempt list (dashboard) & section headers
   ========================================================= */
.dash-section {
    margin-bottom: 48px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.section-head h2 {
    font-size: 1.25rem;
    margin: 0;
}

.section-link {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.attempt-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.attempt-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.attempt-row:last-child {
    border-bottom: none;
}

.attempt-info {
    flex: 1;
    min-width: 0;
}

.attempt-title {
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--text);
    margin: 6px 0 4px;
}

.attempt-meta {
    font-size: 0.86rem;
    color: var(--text-muted);
}

.attempt-score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 64px;
}

.band {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1;
}

.band-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 3px;
}

.band-empty {
    color: var(--text-soft);
    font-size: 1.4rem;
}

/* =========================================================
   18. Badges & statuses
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-writing {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.badge-speaking {
    background: var(--accent-soft);
    color: #0e7490;
}

.status {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-in_progress {
    background: #fef3c7;
    color: #92400e;
}

.status-completed {
    background: var(--success-bg);
    color: #065f46;
}

.status-abandoned {
    background: #f1f5f9;
    color: #475569;
}

/* =========================================================
   19. Practice selector, history table, empty state
   ========================================================= */
.practice-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 860px) {
    .practice-columns {
        grid-template-columns: 1fr;
    }
}

.practice-column {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.practice-column-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
}

.practice-column-head h2 {
    margin: 0 0 2px;
    font-size: 1.2rem;
}

.practice-column-head p {
    margin: 0;
    font-size: 0.86rem;
    color: var(--text-muted);
}

.practice-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.practice-icon-indigo { background: var(--primary-soft); }
.practice-icon-cyan   { background: var(--accent-soft); }

.practice-list {
    padding: 8px;
}

.practice-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.practice-item:hover {
    background: #fafbff;
}

.practice-item-body {
    flex: 1;
    min-width: 0;
}

.practice-item-label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary-dark);
    background: var(--primary-soft);
    padding: 3px 9px;
    border-radius: var(--radius-full);
    margin-bottom: 6px;
}

.practice-item h3 {
    font-size: 1.02rem;
    margin: 0 0 4px;
    font-weight: 700;
}

.practice-item-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.muted {
    color: var(--text-muted);
}

.ta-right {
    text-align: right;
}

.filter-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.filter-tab {
    padding: 10px 16px;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.filter-tab:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

.filter-tab.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

.history-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.history-table th,
.history-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.93rem;
}

.history-table th {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: #fafbff;
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tr:hover td {
    background: #fafbff;
}

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 56px 24px;
    text-align: center;
    margin-bottom: 32px;
}

.empty-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 1.15rem;
}

.empty-state p {
    color: var(--text-muted);
    margin: 0 0 20px;
}

.writing-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

@media (max-width: 860px) {
    .writing-layout {
        grid-template-columns: 1fr;
    }
}

.prompt-heading {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 12px;
}

.prompt-text {
    font-size: 1.02rem;
    line-height: 1.7;
    color: var(--text);
    margin: 0;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 16px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.92rem;
}

/* =========================================================
   20. Writing editor
   ========================================================= */
.writing-container {
    padding-top: 24px;
}

.writing-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    position: sticky;
    top: 88px;
    z-index: 20;
}

.writing-toolbar-left,
.writing-toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.writing-toolbar-title {
    font-weight: 700;
    color: var(--text);
    font-size: 0.98rem;
}

.writing-toolbar .back-link {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.writing-toolbar .back-link:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

.timer {
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary-dark);
    transition: background var(--transition), color var(--transition);
}

.timer.is-warning {
    background: #fef3c7;
    color: #92400e;
}

.timer.is-critical {
    background: #fee2e2;
    color: #991b1b;
    animation: timer-pulse 1.2s ease-in-out infinite;
}

@keyframes timer-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

.writing-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

@media (max-width: 1024px) {
    .writing-grid {
        grid-template-columns: 1fr;
    }
}

.writing-prompt .card-body {
    padding: 24px;
}

.prompt-meta {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.writing-editor .card-body {
    padding: 24px;
}

.essay-textarea {
    width: 100%;
    min-height: 420px;
    padding: 18px;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    background: #fbfcff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.essay-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
    background: #ffffff;
}

.essay-textarea::placeholder {
    color: var(--text-soft);
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.editor-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.word-count {
    font-size: 0.92rem;
    color: var(--text-muted);
    font-weight: 600;
}

.word-count strong {
    color: var(--text);
    font-weight: 800;
}

.word-count.is-good strong {
    color: var(--success);
}

.word-warning {
    font-size: 0.82rem;
    color: #b45309;
    background: #fef3c7;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-weight: 700;
}

.editor-hint {
    margin: 16px 0 0;
    font-size: 0.82rem;
    color: var(--text-soft);
    font-style: italic;
}

/* OVERLAY DENGAN CLASS .is-active (MUTLAK DISPLAY NONE) */
.assessing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
    
    /* Kunci mutlak: Sembunyikan total */
    display: none; 
}

/* Hanya tampilkan jika ada class .is-active */
.assessing-overlay.is-active {
    display: flex;
}

.assessing-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.assessing-overlay.is-active .assessing-card {
    transform: translateY(0);
}

.assessing-card h3 {
    margin: 20px 0 8px;
    font-size: 1.25rem;
}

.assessing-card p {
    color: var(--text-muted);
    margin: 0 0 8px;
    font-size: 0.95rem;
    line-height: 1.55;
}

.assessing-meta {
    font-size: 0.82rem !important;
    color: var(--text-soft) !important;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   21. Result page
   ========================================================= */
.result-hero {
    padding: 44px 0 32px;
}

.result-hero .back-link {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.result-hero .back-link:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

.result-hero-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    flex-wrap: wrap;
    padding: 28px 32px;
    background: linear-gradient(135deg, #ffffff 0%, #f5f7ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.result-hero-text h1 {
    margin: 12px 0 6px;
}

.result-hero-text .muted {
    margin: 0;
    font-size: 0.9rem;
}

.result-hero-band {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding-left: 32px;
    border-left: 1px solid var(--border);
}

@media (max-width: 640px) {
    .result-hero-band {
        padding-left: 0;
        border-left: none;
        align-items: flex-start;
        border-top: 1px solid var(--border);
        padding-top: 16px;
        width: 100%;
    }
}

.result-hero-band-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.result-hero-band-value {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.04em;
}

.result-hero-band-scale {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-section-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 32px 0 16px;
}

.result-summary {
    margin-bottom: 8px;
}

.result-summary p {
    margin: 0;
    line-height: 1.7;
    font-size: 1.02rem;
}

.criteria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.criteria-card .card-body {
    padding: 22px;
}

.criteria-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.criteria-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.criteria-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.criteria-band {
    font-size: 0.82rem;
    color: var(--primary-dark);
    font-weight: 800;
}

.criteria-comments {
    margin: 0;
    font-size: 0.93rem;
    color: var(--text-muted);
    line-height: 1.65;
}

.result-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 860px) {
    .result-two-col {
        grid-template-columns: 1fr;
    }
}

.result-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-list li {
    padding-left: 24px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text);
}

.result-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 9px;
}

.result-list-success li::before {
    background-color: var(--success-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2310b981' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8l2.5 2.5L12 5'/%3E%3C/svg%3E");
}

.result-list-warning li::before {
    background-color: #fef3c7;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23b45309' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 5v4M8 11.5v.01'/%3E%3C/svg%3E");
}

.revised-sentences {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.revised-card .card-body {
    padding: 20px 22px;
}

.revised-block {
    margin-bottom: 14px;
}

.revised-block:last-of-type {
    margin-bottom: 8px;
}

.revised-label {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.revised-label.improved {
    color: var(--success);
}

.revised-original {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: rgba(239, 68, 68, .4);
}

.revised-improved {
    margin: 0;
    font-size: 0.98rem;
    color: var(--text);
    font-weight: 600;
}

.revised-reason {
    margin: 8px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 0.86rem;
    color: var(--text-muted);
    font-style: italic;
}

.result-response {
    margin-bottom: 24px;
}

.result-response summary {
    cursor: pointer;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 0.93rem;
    color: var(--text-muted);
}

.result-response summary:hover {
    color: var(--primary-dark);
}

.result-response[open] summary {
    border-radius: var(--radius) var(--radius) 0 0;
}

.result-response-text {
    white-space: pre-wrap;
    font-family: var(--font);
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
    margin: 0;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* =========================================================
   22. Speaking recorder
   ========================================================= */
.speaking-recorder .card-body {
    padding: 28px;
}

.record-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 8px 0 24px;
}

.record-btn {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 12px 28px rgba(99, 102, 241, .35);
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.record-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 16px 36px rgba(99, 102, 241, .45);
}

.record-btn:active {
    transform: scale(0.98);
}

.record-btn.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, .6), 0 12px 28px rgba(239, 68, 68, .35);
    animation: record-pulse 1.6s ease-out infinite;
}

.record-btn-icon {
    line-height: 1;
}

@keyframes record-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55), 0 12px 28px rgba(239, 68, 68, .35); }
    70%  { box-shadow: 0 0 0 22px rgba(239, 68, 68, 0), 0 12px 28px rgba(239, 68, 68, .35); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0), 0 12px 28px rgba(239, 68, 68, .35); }
}

.record-status {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 340px;
    line-height: 1.5;
}

.transcript-wrap {
    margin-top: 8px;
}

.transcript-area {
    min-height: 220px;
    max-height: 380px;
    overflow-y: auto;
    padding: 18px;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    background: #fbfcff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.transcript-placeholder {
    color: var(--text-soft);
    font-style: italic;
}

.transcript-final {
    color: var(--text);
    font-weight: 500;
}

.transcript-interim {
    color: var(--text-muted);
    font-style: italic;
}

.speaking-fallback .alert-info {
    font-size: 0.92rem;
    line-height: 1.55;
}

/* =========================================================
   23. Writing Prompt Image (Admin Edit)
   ========================================================= */
.prompt-image-wrap {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}

.prompt-image {
    width: 100%;
    height: auto;
    display: block;
}

/* =========================================================
   24. Admin Panel
   ========================================================= */
.admin-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    margin-bottom: 24px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.admin-table th,
.admin-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.93rem;
    vertical-align: top;
}

.admin-table th {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: #fafbff;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: #fafbff;
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================================================
   25. Perbaikan Layout Writing (Vertikal / Atas-Bawah)
   ========================================================= */

/* Mengubah layout dari 2 kolom (side-by-side) menjadi 1 kolom penuh */
.writing-stacked-layout {
    display: flex;
    flex-direction: column;
    gap: 24px; /* Jarak antara kartu soal dan kartu editor */
    margin-bottom: 40px;
}

/* Kartu Soal di Atas */
.writing-prompt-card .card-body {
    padding: 28px;
}

/* Wadah Gambar agar Tampil Besar dan Lebar */
.prompt-image-wrap-large {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: #ffffff;
    text-align: center; /* Memastikan gambar berada di tengah */
}

.image-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: left;
    font-weight: 600;
}

.prompt-image-large {
    width: 100%;       /* Memaksa gambar mengambil lebar penuh kartu */
    max-width: 900px;  /* Batas maksimal agar tidak terlalu raksasa di layar ultrawide */
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: var(--radius-sm);
}

/* Pesan jika gambar tidak ada */
.prompt-image-missing {
    margin-top: 20px;
    padding: 12px;
    background: #fef3c7;
    color: #92400e;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

/* Kartu Editor di Bawah */
.writing-editor-card .card-body {
    padding: 28px;
}

/* Memastikan area esai cukup tinggi dan lebar */
.writing-editor-card .essay-textarea {
    min-height: 500px;
    width: 100%;
    font-size: 1.05rem;
    line-height: 1.8;
}

/* Responsif untuk layar kecil (HP/Tablet) */
@media (max-width: 768px) {
    .writing-prompt-card .card-body,
    .writing-editor-card .card-body {
        padding: 20px;
    }
    .prompt-image-large {
        max-width: 100%;
    }
}