/* ===================================
   IAN'S LEARNING HUB
   Ocean Blue Learning Design System
   清爽蓝色学习主题 - 完整版
   =================================== */

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

html {
    height: 100%;
    scroll-behavior: smooth;
}

/* ==== DESIGN TOKENS ==== */
:root {
    /* Typography */
    --font-display: 'Fraunces', 'Noto Sans SC', serif;
    --font-body: 'Manrope', 'Noto Sans SC', sans-serif;

    /* Light Theme - Soft & Inviting */
    --bg: linear-gradient(135deg, #F0F8FF 0%, #F5F9FF 50%, #EFF6FF 100%);
    --bg-solid: #F5F9FF;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-solid: #FFFFFF;
    --surface-soft: rgba(255, 255, 255, 0.6);
    --surface-hover: rgba(255, 255, 255, 0.95);
    --surface-accent: rgba(224, 242, 254, 0.8);

    --text: #2D3142;
    --text-soft: #5C6272;
    --text-muted: #8B93A7;

    /* Soft Gradients - Candy-like */
    --primary: linear-gradient(135deg, #3B82F6 0%, #60A5FA 100%);
    --primary-solid: #3B82F6;
    --primary-hover: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
    
    --secondary: linear-gradient(135deg, #06B6D4 0%, #67E8F9 100%);
    --secondary-solid: #06B6D4;
    
    --accent: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
    --accent-solid: #6366F1;

    --success: linear-gradient(135deg, #10B981 0%, #34D399 100%);
    --success-solid: #10B981;
    
    --warning: linear-gradient(135deg, #F59E0B 0%, #FBBF24 100%);
    --warning-solid: #F59E0B;
    
    --danger: #EF4444;

    /* Soft Shadows */
    --shadow-xs: 0 1px 4px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.15);
    --shadow-colored: 0 8px 24px rgba(59, 130, 246, 0.2);
    --shadow-colored-hover: 0 12px 32px rgba(59, 130, 246, 0.3);

    /* Borders */
    --border-radius-sm: 12px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --border-radius-xl: 32px;
    --border-radius-full: 999px;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-bounce: 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-theme="dark"] {
    --bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --bg-solid: #16213e;
    --surface: rgba(255, 255, 255, 0.08);
    --surface-solid: rgba(255, 255, 255, 0.1);
    --surface-soft: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.12);
    --surface-accent: rgba(59, 130, 246, 0.15);

    --text: #F0F0F0;
    --text-soft: #C5C5C5;
    --text-muted: #909090;

    --shadow-xs: 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
    --shadow-colored: 0 8px 24px rgba(59, 130, 246, 0.25);
    --shadow-colored-hover: 0 12px 32px rgba(59, 130, 246, 0.35);
}

/* ==== GLOBAL STYLES ==== */
body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    background-attachment: fixed;
    min-height: 100%;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    position: relative;
}

/* Animated floating orbs background */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
    animation: float 25s ease-in-out infinite;
}

body::before {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, #3B82F6 0%, transparent 70%);
    top: -250px;
    right: -250px;
    animation-delay: 0s;
}

body::after {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #06B6D4 0%, transparent 70%);
    bottom: -200px;
    left: -200px;
    animation-delay: -12s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(40px, -40px) scale(1.1);
    }
    50% {
        transform: translate(-30px, 30px) scale(0.9);
    }
    75% {
        transform: translate(30px, 40px) scale(1.05);
    }
}

[data-theme="dark"] body::before,
[data-theme="dark"] body::after {
    opacity: 0.08;
    filter: blur(120px);
}

/* ==== TYPOGRAPHY ==== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 700;
    background: linear-gradient(135deg, #3B82F6 0%, #60A5FA 50%, #06B6D4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: clamp(1.8rem, 3.5vw, 2.5rem);
    margin-bottom: 1rem;
}

h3 {
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    margin-bottom: 0.75rem;
}

h4 {
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1em;
    color: var(--text-soft);
}

/* ==== CONTAINER ==== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 60px);
    min-height: 100vh;
    position: relative;
    z-index: 2;
}

.grammar-container,
.diagnostics-container {
    max-width: 1600px;
}

/* ==== HEADER ==== */
header,
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(40px, 6vw, 60px);
    padding: var(--space-md) var(--space-lg);
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    gap: var(--space-md);
    animation: slideDown 0.8s var(--transition-bounce);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header h1 {
    flex: 1;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    margin-bottom: 0;
}

/* ==== NAVIGATION ==== */
nav {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-wrap: wrap;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-muted);
    padding-right: var(--space-sm);
}

.nav-link {
    padding: 10px 20px;
    background: var(--surface-solid);
    color: var(--text);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-slow);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.nav-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--primary);
    color: white;
}

.nav-link:active {
    transform: translateY(0);
}

.nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-colored);
}

.theme-toggle {
    padding: 10px 16px;
    background: var(--surface-solid);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 1.3rem;
    transition: all 0.4s var(--transition-slow);
    box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
    transform: rotate(20deg) scale(1.1);
    box-shadow: var(--shadow-md);
}

.theme-toggle:active {
    transform: rotate(20deg) scale(0.95);
}


/* ==== MAIN LAYOUT ==== */
main {
    animation: fadeInUp 1s var(--transition-slow) 0.2s backwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==== HOME PAGE - CARDS ==== */
.cards-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.feature-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    position: relative;
    transition: all var(--transition-slow);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeInUp 0.8s var(--transition-slow) backwards;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }
.feature-card:nth-child(4) { animation-delay: 0.4s; }

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-slow);
}

.feature-card:nth-child(2)::before {
    background: var(--secondary);
}

.feature-card:hover::before {
    transform: scaleX(1);
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

.feature-card:nth-child(2):hover {
    transform: translateY(-8px);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius-md);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-colored);
    transition: all var(--transition-slow);
}

.feature-card:nth-child(2) .card-icon {
    background: var(--secondary);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.3);
}

.feature-card:hover .card-icon {
    transform: rotate(5deg) scale(1.1);
}

.card-icon svg {
    width: 28px;
    height: 28px;
    stroke: white;
    stroke-width: 2;
}

.feature-card h3 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin-bottom: var(--space-sm);
}

.feature-card p {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: var(--space-md);
}

.card-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--border-radius-full);
    transition: all var(--transition-slow);
    box-shadow: var(--shadow-colored);
}

.card-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-colored-hover);
}

.card-link::after {
    content: '→';
    transition: transform var(--transition-slow);
}

.card-link:hover::after {
    transform: translateX(4px);
}

/* Hero Image */
.hero-image-section {
    margin-top: var(--space-xl);
    border-radius: var(--border-radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 1s var(--transition-slow) 0.4s backwards;
}

.hero-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.6s ease;
}

.hero-image-section:hover .hero-image {
    transform: scale(1.05);
}

/* ==== TWO-PANEL LAYOUT (Essay page) ==== */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 40px;
    margin-top: 40px;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.left-panel {
    animation: fadeInLeft 0.8s var(--transition-slow) 0.3s backwards;
}

.right-panel {
    animation: fadeInRight 0.8s var(--transition-slow) 0.4s backwards;
}

/* ==== SECTIONS (generic) ==== */
section {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: clamp(24px, 4vw, 40px);
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
}

.upload-section,
.essay-section {
    min-height: 600px;
}

/* ==== FORM ELEMENTS ==== */
.file-upload {
    margin-bottom: 20px;
}

.file-label {
    display: inline-block;
    padding: 14px 28px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all var(--transition-slow);
    font-family: var(--font-body);
    box-shadow: var(--shadow-colored);
}

.file-label:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-colored-hover);
}

.file-label:active {
    transform: translateY(0);
}

.file-info {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: var(--surface-soft);
    border-left: 4px solid var(--secondary-solid);
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    font-size: 0.9rem;
    color: var(--text-soft);
}

/* Prompt Display */
.prompt-display {
    background: var(--surface-accent);
    border-radius: var(--border-radius-md);
    padding: 24px;
    margin-top: 24px;
    position: relative;
    min-height: 200px;
    border: 1px solid rgba(255, 154, 158, 0.1);
}

.prompt-display h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.prompt-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-soft);
}

.prompt-preview-container,
.image-preview-container {
    border-radius: var(--border-radius-md);
    margin-top: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

#imagePreview {
    width: 100%;
    height: auto;
    display: block;
}

#pdfPreview {
    width: 100%;
    height: 500px;
    border: none;
}

/* ==== ESSAY INPUT ==== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.input-group h2 {
    font-size: 1.6rem;
    margin-bottom: 0;
}

#wordCountDisplay {
    font-family: var(--font-body);
    font-size: 0.75rem !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted) !important;
    font-weight: 700 !important;
    margin-left: 16px !important;
}

#essayInput {
    flex: 1;
    min-height: 500px;
    padding: 20px;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text);
    background: var(--surface-soft);
    border: 2px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--border-radius-md);
    resize: vertical;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-xs);
}

#essayInput:focus {
    outline: none;
    border-color: var(--primary-solid);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

#essayInput::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Timer */
.timer-section {
    padding: 16px 0;
    margin: 20px 0;
}

.timer-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--surface-accent);
    padding: 16px 24px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.timer-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-soft);
}

.timer-display {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--primary-solid);
    letter-spacing: 0.05em;
    min-width: 80px;
    text-align: center;
}

/* ==== BUTTONS ==== */
.submit-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 24px;
}

.submit-btn,
.primary-btn {
    padding: 14px 32px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all var(--transition-slow);
    font-family: var(--font-body);
    box-shadow: var(--shadow-colored);
}

.submit-btn:hover,
.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-colored-hover);
}

.submit-btn:active,
.primary-btn:active {
    transform: translateY(-1px);
}

.submit-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.submit-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.secondary-btn {
    padding: 12px 24px;
    background: var(--surface-solid);
    color: var(--text);
    border: 2px solid var(--primary-solid);
    border-radius: var(--border-radius-full);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-slow);
    font-family: var(--font-body);
}

.secondary-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.link-btn {
    padding: 10px 20px;
    background: var(--surface-solid);
    color: var(--text);
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-block;
    transition: all var(--transition-normal);
}

.link-btn:hover {
    background: var(--primary);
    color: white;
    border-color: transparent;
}

/* ==== LOADING / SPINNER ==== */
.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-soft);
    font-weight: 600;
}

.grading-wait {
    flex: 1 1 320px;
    min-width: min(100%, 320px);
    display: grid;
    gap: 0.85rem;
    padding: 0.95rem;
    background: var(--surface-solid);
    border: 1px solid var(--rule);
    border-radius: 22px;
}

.grading-wait-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.grading-orbit {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 1px solid var(--rule-strong);
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
}

.grading-orbit::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--primary-solid);
    border-right-color: var(--primary-solid);
    animation: spin 1.2s linear infinite;
}

.grading-orbit span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-solid);
    box-shadow: 0 0 0 5px rgba(39, 69, 96, 0.1);
}

.grading-wait-copy {
    display: grid;
    gap: 0.25rem;
}

.grading-wait-copy strong {
    color: var(--text);
    font-size: 0.96rem;
}

.grading-wait-copy span {
    color: var(--text-soft);
    font-size: 0.86rem;
    line-height: 1.45;
}

.grading-wait-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.grading-wait-step {
    min-width: 0;
    padding: 0.45rem 0.35rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    transition: background-color var(--transition-normal), color var(--transition-normal), border-color var(--transition-normal);
}

.grading-wait-step.is-active,
.grading-wait-step.is-complete {
    background: var(--surface-accent);
    border-color: var(--primary-solid);
    color: var(--primary-solid);
}

.grading-progress {
    height: 5px;
    overflow: hidden;
    background: var(--surface-soft);
    border-radius: 999px;
}

.grading-progress span {
    display: block;
    width: 42%;
    height: 100%;
    border-radius: inherit;
    background: var(--primary-solid);
    animation: gradingProgress 1.8s ease-in-out infinite;
}

@keyframes gradingProgress {
    0% { transform: translateX(-110%); }
    50% { transform: translateX(70%); }
    100% { transform: translateX(240%); }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top: 3px solid var(--primary-solid);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Score Toast */
.score-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 30px 60px;
    background: var(--surface-solid);
    border-radius: var(--border-radius-lg);
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    text-align: center;
    color: var(--text);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all var(--transition-normal);
    z-index: 5000;
    box-shadow: var(--shadow-xl);
}

.score-toast-visible {
    opacity: 1;
    visibility: visible;
    animation: popIn 0.5s var(--transition-bounce);
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.score-toast-low { color: var(--danger); }
.score-toast-mid { color: var(--secondary-solid); }
.score-toast-high { color: var(--primary-solid); }
.score-toast-elite {
    color: var(--accent-solid);
    text-shadow: 0 0 30px rgba(255, 211, 165, 0.5);
}

/* ==== HIDDEN ==== */
.hidden {
    display: none !important;
}


/* ==== GRAMMAR PAGE ==== */
.grammar-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 40px;
    margin-top: 40px;
}

.chapter-main {
    animation: fadeInLeft 0.8s var(--transition-slow) 0.3s backwards;
}

.grammar-summary {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeInRight 0.8s var(--transition-slow) 0.4s backwards;
}

.chapter-browser {}

.chapter-header {
    margin-bottom: 32px;
}

.chapter-header h2 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.chapter-header p {
    font-size: 1.05rem;
    color: var(--text-soft);
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.chapter-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: 28px;
    cursor: pointer;
    transition: all var(--transition-slow);
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.chapter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--secondary);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.chapter-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.chapter-card h3 {
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.chapter-card p {
    font-size: 0.95rem;
    color: var(--text-soft);
}

/* Summary Cards */
.summary-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.summary-card h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--text);
}

.summary-card p {
    font-size: 0.95rem;
    color: var(--text-soft);
    margin-bottom: 20px;
}

.summary-card ul {
    list-style: none;
    padding: 0;
}

.summary-card li {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.95rem;
}

.summary-card li:last-child {
    border-bottom: none;
}

.summary-card .label {
    color: var(--text-soft);
    font-weight: 600;
    font-size: 0.85rem;
}

.summary-card .value {
    font-weight: 800;
    color: var(--primary-solid);
}

/* ==== MODALS / OVERLAYS ==== */
.library-modal,
.chapter-overlay,
.function-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.library-dialog,
.chapter-overlay-dialog,
.function-dialog {
    width: min(900px, 90vw);
    max-height: 85vh;
    background: var(--surface-solid);
    border-radius: var(--border-radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.4s var(--transition-slow);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.library-header,
.chapter-overlay-header,
.function-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}

.library-header h3,
.chapter-overlay-header h3,
.function-header h2 {
    font-size: 2rem;
    margin: 0;
}

.library-list,
.subchapter-list {
    flex: 1;
    overflow-y: auto;
    border-radius: var(--border-radius-md);
    padding: 8px;
    background: rgba(0, 0, 0, 0.02);
}

.library-item,
.subchapter-card {
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--surface-solid);
    margin-bottom: 8px;
    border-radius: var(--border-radius-sm);
    border-left: 4px solid transparent;
}

.library-item:hover,
.subchapter-card:hover {
    background: var(--surface-accent);
    border-left-color: var(--primary-solid);
    transform: translateX(4px);
}

.library-item.selected {
    background: var(--primary);
    color: white;
}

.library-actions {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ==== ARCHIVE / RECORDS ==== */
.diagnostics-layout {
    margin-top: 40px;
}

.diagnostics-section {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: clamp(30px, 4vw, 50px);
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.diagnostics-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.section-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
}

.section-header h2 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.section-header p {
    font-size: 1.05rem;
    color: var(--text-soft);
    margin: 0;
}

.section-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Records Table */
.essay-records-viewport {
    min-height: 400px;
}

.records-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 20px;
    color: var(--text-soft);
    font-size: 1.1rem;
}

.archive-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--border-radius-md);
    max-height: 600px;
    overflow-y: auto;
}

.archive-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: all var(--transition-normal);
}

.archive-item:hover {
    background: var(--surface-accent);
}

.archive-item:last-child {
    border-bottom: none;
}

.archive-item-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    text-decoration: none;
    color: var(--text);
    gap: 16px;
}

.archive-item-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.archive-item-primary {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}

.archive-item-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.archive-item-action {
    font-weight: 700;
    color: var(--primary-solid);
    font-size: 0.85rem;
}

.score-tier {
    font-weight: 800;
    padding: 6px 14px;
    border-radius: var(--border-radius-full);
    display: inline-block;
    font-size: 0.9rem;
}

.score-tier-low { background: var(--danger); color: white; }
.score-tier-mid { background: var(--secondary-solid); color: white; }
.score-tier-high { background: var(--primary-solid); color: white; }
.score-tier-elite {
    background: var(--accent);
    color: white;
}

.records-table {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.records-table-header {
    display: grid;
    grid-template-columns: 100px 1fr 180px 140px 120px;
    gap: 20px;
    padding: 16px 24px;
    background: var(--primary);
    color: white;
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
    font-weight: 800;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.records-table-header .records-cell {
    color: white;
}

.records-table-body {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
}

.records-row {
    display: grid;
    grid-template-columns: 100px 1fr 180px 140px 120px;
    gap: 20px;
    padding: 20px 24px;
    background: var(--surface-solid);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: all var(--transition-normal);
    align-items: center;
}

.records-row:nth-child(even) {
    background: var(--surface-soft);
}

.records-row:last-child {
    border-bottom: none;
}

.records-row:hover {
    background: var(--surface-accent);
    transform: translateX(4px);
    border-left: 4px solid var(--primary-solid);
    padding-left: 20px;
}

.records-cell {
    font-size: 0.95rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
}

.records-col-score {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-display);
}

.records-col-title {
    font-weight: 500;
    line-height: 1.5;
}

.records-col-submitted,
.records-col-duration {
    font-size: 0.9rem;
    color: var(--text-soft);
    font-family: var(--font-body);
    font-weight: 600;
}

.records-col-action {
    display: flex;
    gap: 8px;
}

.records-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all var(--transition-normal);
    font-family: var(--font-body);
    text-decoration: none;
    display: inline-block;
}

.records-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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


/* ==== GRADING RESULTS PAGE ==== */
.results-section {
    margin-top: 40px;
    animation: fadeInUp 0.6s var(--transition-slow);
}

.grading-header {
    background: var(--surface) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-radius: var(--border-radius-xl) !important;
    padding: 40px !important;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    margin-bottom: 30px !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

.grading-score-section,
.grading-time-section,
.grading-writing-time-section {
    text-align: center;
}

.grading-score-section h3,
.grading-time-section h3,
.grading-writing-time-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 16px !important;
    font-family: var(--font-body);
}

.grading-score {
    font-family: var(--font-display) !important;
    font-size: 4rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, var(--primary-solid) 0%, var(--accent-solid) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 !important;
}

.grading-time,
.grading-writing-time {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-body);
    color: var(--text-soft);
}

.grading-writing-time {
    color: var(--primary-solid);
}

/* Grading Content */
.grading-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 30px;
}

.grading-left-panel,
.grading-right-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.grading-section {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: clamp(24px, 4vw, 40px);
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.grading-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 3px;
    background: var(--secondary);
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
}

.grading-section h3 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    font-family: var(--font-body);
    font-weight: 700;
}

.grading-content-box,
.grading-suggestions-box {
    background: var(--surface-soft);
    border-radius: var(--border-radius-md);
    padding: 24px;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text);
    min-height: 200px;
}

.grading-suggestions-box {
    color: var(--text-soft);
}

.grading-model-essay {
    font-style: italic;
    background: var(--surface-accent);
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.suggestions-header h3 {
    margin-bottom: 0;
}

.fullscreen-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    padding: 8px 16px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
    transition: all var(--transition-normal);
    font-family: var(--font-body);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Dashboard Cards */
.result-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 40px;
}

.dashboard-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-xl);
    padding: 32px;
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
}

.dashboard-card.history-overview::before {
    background: var(--secondary);
}

.dashboard-card.ladder-overview::before {
    background: var(--accent);
}

.score-pill {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.score-pill-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 800;
    color: var(--text-muted);
}

.score-delta {
    font-size: 1rem;
    font-weight: 700;
}

.score-delta-up {
    color: var(--success-solid);
}

.score-delta-up::before {
    content: '↑ ';
}

.score-delta-down {
    color: var(--danger);
}

.score-delta-down::before {
    content: '↓ ';
}

.score-delta-first {
    color: var(--primary-solid);
}

/* --- Dimension Scores --- */
.dimension-scores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--surface-soft);
    border-radius: var(--border-radius-sm);
}

.dimension-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dimension-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.dimension-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-soft);
}

.dimension-score {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
}

.dimension-bar {
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.dimension-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.dim-bar-elite {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.dim-bar-high {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.dim-bar-mid {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.dim-bar-low {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

@media (max-width: 600px) {
    .dimension-scores {
        grid-template-columns: 1fr;
    }
}

.score-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.meta-item {
    background: var(--surface-soft);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meta-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-muted);
}

.meta-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.score-highlights {
    font-size: 0.95rem;
    color: var(--text-soft);
    line-height: 1.6;
}

.score-history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    background: var(--surface-soft);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item.is-current {
    background: var(--surface-accent);
    border: 2px solid var(--primary-solid);
}

.history-item.is-best {
    border-left: 4px solid var(--accent-solid);
}

.history-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-score {
    font-weight: 800;
    font-size: 1.2rem;
    font-family: var(--font-display);
    color: var(--text);
}

.history-tag {
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--border-radius-full);
}

.history-date {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: var(--border-radius-full);
    position: relative;
    overflow: hidden;
}

.history-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--primary);
    border-radius: var(--border-radius-full);
}

.history-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.empty-subcard {
    background: var(--surface-soft);
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-md);
    padding: 32px;
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.prize-ladder {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ladder-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface-soft);
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-md);
}

.ladder-item.achieved {
    background: var(--surface-accent);
    border: 2px solid var(--primary-solid);
}

.ladder-icon {
    font-size: 1.8rem;
}

.ladder-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ladder-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.ladder-req {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.ladder-reward {
    font-size: 0.9rem;
    color: var(--primary-solid);
    font-weight: 600;
}

.ladder-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
    min-width: 100px;
}

.ladder-item.achieved .ladder-status {
    color: var(--primary-solid);
    font-weight: 700;
}

/* ==== ACHIEVEMENT LIST ==== */
.achievement-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.achievement-empty {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ==== RESPONSIVE DESIGN ==== */
@media (max-width: 1200px) {
    .cards-section {
        grid-template-columns: 1fr;
    }

    .main-layout,
    .grammar-layout {
        grid-template-columns: 1fr;
    }

    .grading-content {
        grid-template-columns: 1fr;
    }

    .result-dashboard {
        grid-template-columns: 1fr;
    }

    .records-table-header,
    .records-row {
        grid-template-columns: 80px 1fr 140px 100px 100px;
        gap: 12px;
        padding: 16px;
    }
}

@media (max-width: 768px) {
    header, .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    nav {
        width: 100%;
    }

    .nav-label {
        display: none;
    }

    h1 {
        font-size: 2rem;
    }

    .container {
        padding: 20px;
    }

    section {
        padding: 20px;
    }

    .feature-card {
        padding: 24px;
    }

    .grading-header {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
        padding: 24px !important;
    }

    .chapter-grid {
        grid-template-columns: 1fr;
    }

    .records-table-header {
        display: none;
    }

    .records-row {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 20px;
        border-radius: var(--border-radius-md);
        margin-bottom: 12px;
    }

    .records-row:hover {
        transform: translateY(-2px);
        border-left: none;
        padding-left: 20px;
    }

    .records-cell::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.75rem;
        color: var(--text-muted);
        display: block;
        margin-bottom: 4px;
    }

    .records-col-action {
        flex-direction: column;
    }

    .score-meta-grid {
        grid-template-columns: 1fr;
    }
}

/* ==== UTILITIES ==== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }

/* ==== ACCESSIBILITY ==== */
:focus-visible {
    outline: 3px solid var(--primary-solid);
    outline-offset: 4px;
    border-radius: var(--border-radius-sm);
}

/* ==== SELECTION ==== */
::selection {
    background: var(--primary);
    color: white;
}

/* ==== SIMPLE HOME SPECIFIC ==== */
.simple-home main {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* ==== INPUT FIELDS (generic) ==== */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 14px 18px;
    background: var(--surface-solid);
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-xs);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-solid);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

/* ==== EXTRACTED TEXT TITLE ==== */
.extracted-text-title {
    font-size: 1.1rem;
    margin-top: 20px;
    margin-bottom: 12px;
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==== CHAPTER OVERLAY SUBTITLE ==== */
.chapter-overlay-subtitle {
    font-size: 0.95rem;
    color: var(--text-soft);
    margin-top: 4px;
}

/* ==== FUNCTION BODY ==== */
.function-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.function-body section {
    margin-bottom: var(--space-lg);
}

.function-body section h3 {
    font-size: 1.3rem;
    margin-bottom: var(--space-sm);
    color: var(--primary-solid);
}

.function-body section p {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: var(--space-xs);
}

.function-body section p strong {
    font-weight: 700;
    color: var(--text);
}

/* ==== TREND CLOSE BTN ==== */
.trend-close-btn {
    padding: 10px 20px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: var(--border-radius-full);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    font-family: var(--font-body);
}

.trend-close-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==== LOGIN PAGE ==== */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

.login-container main {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.login-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-xl);
    padding: clamp(32px, 5vw, 48px);
    width: min(420px, 100%);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    animation: fadeInUp 0.8s var(--transition-slow);
    position: relative;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
}

.login-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--border-radius-md);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-md);
    box-shadow: var(--shadow-colored);
}

.login-icon svg {
    stroke: white;
}

.login-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.login-card > p {
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
}

.login-input-group {
    margin-bottom: var(--space-md);
}

.login-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.05rem;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    border-left: 4px solid var(--danger);
}

/* ===================================
   2026-04 Editorial Study Redesign
   =================================== */

:root {
    --bg: #f4efe6;
    --bg-solid: #f4efe6;
    --surface: rgba(251, 248, 241, 0.96);
    --surface-solid: #fbf8f1;
    --surface-soft: #f6f1e7;
    --surface-hover: #fffdf9;
    --surface-accent: #ece3d3;
    --text: #182028;
    --text-soft: #43515f;
    --text-muted: #756f66;
    --primary: linear-gradient(135deg, #274560 0%, #365b7d 100%);
    --primary-solid: #274560;
    --primary-hover: linear-gradient(135deg, #182028 0%, #274560 100%);
    --secondary: linear-gradient(135deg, #b8742d 0%, #d49a55 100%);
    --secondary-solid: #b8742d;
    --accent: linear-gradient(135deg, #5b7352 0%, #708968 100%);
    --accent-solid: #5b7352;
    --warning-solid: #b8742d;
    --danger: #c14c31;
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --shadow-xl: none;
    --shadow-colored: none;
    --shadow-colored-hover: none;
    --rule: #d8cfbf;
    --rule-strong: #b7aa95;
    --radius-panel: 28px;
}

[data-theme="dark"] {
    --bg: #11161c;
    --bg-solid: #11161c;
    --surface: rgba(22, 29, 37, 0.96);
    --surface-solid: #161d25;
    --surface-soft: #1c2530;
    --surface-hover: #202b36;
    --surface-accent: #1f2b37;
    --text: #f1ece1;
    --text-soft: #c6c1b6;
    --text-muted: #998f82;
    --primary: linear-gradient(135deg, #d0ab73 0%, #f0c78e 100%);
    --primary-solid: #d0ab73;
    --primary-hover: linear-gradient(135deg, #f0c78e 0%, #d0ab73 100%);
    --secondary: linear-gradient(135deg, #8cb0d1 0%, #b2cbe4 100%);
    --secondary-solid: #8cb0d1;
    --accent: linear-gradient(135deg, #92b18c 0%, #b8cfaf 100%);
    --accent-solid: #92b18c;
    --danger: #e4886f;
    --rule: #2f3944;
    --rule-strong: #4b5765;
}

body {
    background:
        radial-gradient(circle at top left, rgba(39, 69, 96, 0.08), transparent 32%),
        linear-gradient(var(--bg-solid), var(--bg-solid));
    color: var(--text);
}

body::before,
body::after {
    display: none;
}

::selection {
    background: rgba(184, 116, 45, 0.18);
    color: var(--text);
}

.container {
    max-width: 1380px;
    padding: clamp(18px, 3vw, 44px);
}

header,
.page-header,
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    padding: 0 0 1.1rem;
    margin-bottom: clamp(28px, 4vw, 48px);
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--rule);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    animation: none;
}

.compact-header {
    align-items: center;
}

header h1,
.page-header h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    font-weight: 600;
    color: var(--text);
    background: none;
    -webkit-text-fill-color: currentColor;
    letter-spacing: -0.035em;
}

.brand-block {
    max-width: 760px;
}

.eyebrow,
.feature-kicker,
.hero-caption-label {
    display: inline-block;
    margin-bottom: 0.8rem;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.page-intro {
    max-width: 36rem;
    margin-top: 0.6rem;
    margin-bottom: 0;
    font-size: 1.02rem;
    line-height: 1.8;
}

nav {
    gap: 0.65rem;
}

.nav-label {
    color: var(--text-muted);
    letter-spacing: 0.16em;
}

.nav-link,
.theme-toggle,
.secondary-link,
.records-action-btn,
.control-btn,
.trend-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1rem;
    background: var(--surface-solid);
    color: var(--text);
    border: 1px solid var(--rule);
    border-radius: 999px;
    box-shadow: none;
    text-decoration: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.nav-link:hover,
.theme-toggle:hover,
.secondary-link:hover,
.records-action-btn:hover,
.control-btn:hover,
.trend-close-btn:hover {
    transform: none;
    background: var(--surface-hover);
    border-color: var(--rule-strong);
    box-shadow: none;
}

.nav-link.active {
    background: var(--text);
    color: var(--surface-solid);
    border-color: var(--text);
}

[data-theme="dark"] .nav-link.active {
    background: var(--primary-solid);
    color: #11161c;
    border-color: var(--primary-solid);
}

.theme-toggle {
    width: 44px;
    padding: 0;
    font-size: 1.1rem;
}

main {
    animation: none;
}

.home-shell,
.essay-studio-shell {
    display: grid;
    gap: 1.5rem;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
    gap: 1.5rem;
    align-items: stretch;
}

.hero-copy,
.workspace-summary,
.feature-card,
.login-card,
.upload-section,
.essay-section,
.diagnostics-section,
.dashboard-card,
.grading-section,
.prompt-display {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-panel);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.hero-copy {
    padding: clamp(24px, 3vw, 40px);
}

.hero-copy h2,
.login-intro h2,
.workspace-summary h2,
.section-heading h2 {
    font-size: clamp(1.9rem, 4vw, 3.2rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
    margin-bottom: 0.9rem;
}

.hero-copy p,
.login-intro p,
.section-heading p {
    max-width: 42rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 1.4rem;
}

.card-link,
.submit-btn,
.file-label,
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.9rem 1.25rem;
    background: var(--primary-solid);
    color: var(--surface-solid);
    border: 1px solid var(--primary-solid);
    border-radius: 999px;
    box-shadow: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.card-link::after {
    content: '↗';
    transition: none;
}

.card-link:hover,
.submit-btn:hover,
.file-label:hover,
.primary-btn:hover {
    transform: none;
    background: var(--text);
    border-color: var(--text);
    color: var(--surface-solid);
    box-shadow: none;
}

.secondary-link {
    font-weight: 700;
}

.hero-image-section {
    position: relative;
    min-height: 380px;
    margin-top: 0;
    border-radius: var(--radius-panel);
    overflow: hidden;
    border: 1px solid var(--rule);
    box-shadow: none;
}

.hero-image-section:hover .hero-image {
    transform: none;
}

.hero-image {
    width: 100%;
    height: 100%;
    min-height: 380px;
    object-fit: cover;
    filter: saturate(0.92) contrast(1.02);
}

.hero-caption {
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    padding: 1rem 1.1rem;
    background: rgba(251, 248, 241, 0.88);
    border: 1px solid rgba(216, 207, 191, 0.7);
    border-radius: 18px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .hero-caption {
    background: rgba(22, 29, 37, 0.88);
    border-color: rgba(75, 87, 101, 0.8);
}

.hero-caption p {
    margin-bottom: 0;
    color: var(--text);
}

.cards-section {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 0;
}

.feature-card {
    padding: 1.45rem;
    overflow: visible;
    animation: none;
    transform: none;
}

.feature-card::before {
    display: none;
}

.feature-card:hover {
    transform: none;
    background: var(--surface-hover);
    border-color: var(--rule-strong);
    box-shadow: none;
}

.card-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 1rem;
    border-radius: 16px;
    background: var(--surface-accent);
    color: var(--primary-solid);
    box-shadow: none;
}

.feature-card:nth-child(2) .card-icon,
.feature-card:nth-child(2):hover .card-icon,
.feature-card:hover .card-icon {
    background: var(--surface-accent);
    color: var(--primary-solid);
    transform: none;
    box-shadow: none;
}

.card-icon svg {
    stroke: currentColor;
}

.feature-card h3 {
    font-size: 1.55rem;
    margin-bottom: 0.6rem;
}

.feature-card p {
    margin-bottom: 1.1rem;
    font-size: 0.98rem;
}

.workspace-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    padding: 1.35rem 1.5rem;
}

.workspace-summary h2 {
    font-size: clamp(1.6rem, 2.8vw, 2.35rem);
}

.summary-notes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-end;
}

.summary-notes span {
    padding: 0.5rem 0.8rem;
    background: var(--surface-solid);
    border: 1px solid var(--rule);
    border-radius: 999px;
    color: var(--text-soft);
    font-size: 0.86rem;
    font-weight: 600;
}

.editorial-layout {
    grid-template-columns: minmax(320px, 0.88fr) minmax(0, 1.12fr);
    gap: 1.25rem;
    margin-top: 0;
    align-items: start;
}

.panel {
    gap: 1rem;
}

.left-panel,
.right-panel {
    animation: none;
}

section,
.grading-section,
.dashboard-card {
    padding: clamp(20px, 3vw, 34px);
    border: 1px solid var(--rule);
}

section::before {
    display: none;
}

.upload-section,
.essay-section {
    min-height: auto;
}

.section-heading {
    margin-bottom: 1.2rem;
}

.section-heading h2 {
    font-size: clamp(1.45rem, 2.4vw, 2.15rem);
}

.prompt-action-grid {
    display: grid;
    gap: 0.85rem;
}

.file-upload {
    margin-bottom: 0;
}

.file-label {
    width: 100%;
    justify-content: center;
    background: var(--surface-solid);
    color: var(--text);
    border: 1px dashed var(--rule-strong);
    border-radius: 18px;
}

.file-info {
    margin-top: 0.65rem;
    padding: 0.65rem 0 0;
    background: transparent;
    border-left: none;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    color: var(--text-soft);
}

.prompt-display {
    min-height: 320px;
    padding: 1.2rem;
    margin-top: 1.2rem;
}

.prompt-display h3 {
    font-size: 0.74rem;
    font-family: var(--font-body);
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.prompt-content {
    color: var(--text);
    line-height: 1.8;
}

.prompt-preview-container,
.image-preview-container {
    border-radius: 20px;
    box-shadow: none;
    border: 1px solid var(--rule);
}

#pdfPreview {
    height: 560px;
    background: var(--surface-solid);
}

.writing-sheet {
    position: relative;
}

.input-group h2 {
    font-family: var(--font-body);
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

#wordCountDisplay {
    color: var(--text-muted) !important;
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    transition: color var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal);
}

#wordCountDisplay.word-count-ready {
    color: var(--success-solid) !important;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.22);
    border-radius: 999px;
    padding: 0.16rem 0.48rem;
}

.prompt-content.prompt-ready {
    animation: promptReady 0.7s ease-out;
}

@keyframes promptReady {
    0% {
        background: rgba(39, 69, 96, 0.09);
        box-shadow: 0 0 0 0 rgba(39, 69, 96, 0.16);
    }
    100% {
        background: transparent;
        box-shadow: 0 0 0 12px rgba(39, 69, 96, 0);
    }
}

#essayInput {
    min-height: 600px;
    padding: 1.5rem 1.5rem 1.8rem;
    background: #fffdf9;
    border: 1px solid var(--rule-strong);
    border-radius: 22px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    font-size: 1.04rem;
    line-height: 1.95;
}

[data-theme="dark"] #essayInput {
    background: #151d26;
    color: var(--text);
}

#essayInput:focus {
    border-color: var(--primary-solid);
    box-shadow: 0 0 0 4px rgba(39, 69, 96, 0.14);
}

.timer-section {
    margin: 1rem 0;
    padding: 0;
}

.timer-container {
    justify-content: flex-start;
    background: var(--surface-accent);
    border: 1px solid var(--rule);
    box-shadow: none;
}

.timer-display {
    color: var(--primary-solid);
}

.submit-controls {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.submit-btn:disabled,
.submit-btn:disabled:hover {
    background: var(--text-muted);
    border-color: var(--text-muted);
    color: var(--surface-solid);
}

.secondary-btn,
.link-btn {
    background: var(--surface-solid);
    color: var(--text);
    border: 1px solid var(--rule-strong);
    box-shadow: none;
}

.secondary-btn:hover,
.link-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--rule-strong);
    transform: none;
    box-shadow: none;
}

.loading {
    color: var(--text-soft);
}

.spinner {
    border-color: rgba(67, 81, 95, 0.18);
    border-top-color: var(--primary-solid);
}

.login-stage {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.78fr);
    gap: 1.5rem;
    align-items: stretch;
}

.login-intro {
    padding: 1rem 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.login-intro h2 {
    max-width: 12ch;
}

.hero-points {
    list-style: none;
    display: grid;
    gap: 0.85rem;
    margin-top: 1.3rem;
    padding: 0;
}

.hero-points li {
    padding: 0.85rem 0 0;
    border-top: 1px solid var(--rule);
    color: var(--text-soft);
}

.login-card {
    width: 100%;
    text-align: left;
    padding: clamp(26px, 4vw, 40px);
    border: 1px solid var(--rule);
    box-shadow: none;
    backdrop-filter: none;
}

.login-card::before {
    display: none;
}

.login-icon {
    margin: 0 0 1rem;
    background: var(--surface-accent);
    color: var(--primary-solid);
    box-shadow: none;
}

.login-icon svg {
    stroke: currentColor;
}

.login-input-group input {
    width: 100%;
    padding: 1rem 1.1rem;
    background: #fffdf9;
    border: 1px solid var(--rule-strong);
    border-radius: 18px;
    color: var(--text);
    font: inherit;
}

[data-theme="dark"] .login-input-group input {
    background: #151d26;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.result-dashboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.dashboard-card,
.grading-section {
    background: var(--surface);
    border: 1px solid var(--rule);
    box-shadow: none;
}

.score-pill,
.meta-item,
.empty-subcard,
.records-row,
.records-table-header {
    background: var(--surface-solid);
    border: 1px solid var(--rule);
    box-shadow: none;
}

.score-meta-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.grading-content {
    grid-template-columns: minmax(0, 0.96fr) minmax(360px, 1.04fr);
    gap: 1rem;
}

.grading-content-box,
.grading-suggestions-box {
    background: #fffdf9;
    border: 1px solid var(--rule);
}

[data-theme="dark"] .grading-content-box,
[data-theme="dark"] .grading-suggestions-box {
    background: #151d26;
}

.records-page .diagnostics-layout {
    display: block;
}

@media (max-width: 1080px) {
    .hero-panel,
    .login-stage,
    .editorial-layout,
    .grading-content,
    .result-dashboard,
    .workspace-summary {
        grid-template-columns: 1fr;
    }

    .summary-notes {
        justify-content: flex-start;
    }

    .cards-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .container {
        padding: 1rem;
    }

    header,
    .page-header,
    .site-header {
        align-items: flex-start;
    }

    nav {
        width: 100%;
    }

    .nav-link,
    .secondary-link,
    .theme-toggle {
        min-height: 40px;
    }

    .hero-copy,
    .workspace-summary,
    .feature-card,
    .upload-section,
    .essay-section,
    .login-card,
    .dashboard-card,
    .grading-section,
    .diagnostics-section {
        padding: 1.1rem;
        border-radius: 22px;
    }

    #essayInput {
        min-height: 420px;
    }

    .grading-wait-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }

    .grading-progress span {
        transform: none;
        width: 100%;
    }
}

.grammar-focus-section { margin: 18px 0; padding: 24px; }
.grammar-focus-list { display: grid; gap: 9px; }
.grammar-focus-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px; border: 1px solid var(--line-soft); border-radius: 13px; color: var(--text); background: var(--surface-soft); text-decoration: none; }
.grammar-focus-row span:first-child { display: grid; gap: 3px; }
.grammar-focus-row small { color: var(--text-muted); }
.grammar-focus-row > span:last-child { color: var(--primary-solid); font-weight: 650; white-space: nowrap; }

/* ================================================================
   2026 APPLE-INSPIRED DESKTOP SYSTEM
   Final overrides for the current product. DESIGN.md is authoritative.
   ================================================================ */

:root {
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    --font-cjk: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
    --bg: #f5f5f7;
    --bg-solid: #f5f5f7;
    --surface: #ffffff;
    --surface-solid: #ffffff;
    --surface-soft: #f9f9fb;
    --surface-hover: #f2f2f4;
    --surface-accent: #f0f7ff;
    --text: #1d1d1f;
    --text-soft: #424245;
    --text-muted: #6e6e73;
    --primary: #0071e3;
    --primary-solid: #0071e3;
    --primary-hover: #0077ed;
    --secondary: #424245;
    --secondary-solid: #424245;
    --accent: #0071e3;
    --accent-solid: #0071e3;
    --success: #248a3d;
    --success-solid: #248a3d;
    --warning: #b25000;
    --warning-solid: #b25000;
    --danger: #d70015;
    --line: #d2d2d7;
    --line-soft: #e8e8ed;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 28px 70px rgba(0, 0, 0, 0.16);
    --shadow-colored: 0 8px 20px rgba(0, 113, 227, 0.18);
    --shadow-colored-hover: 0 10px 24px rgba(0, 113, 227, 0.24);
    --border-radius-sm: 10px;
    --border-radius-md: 14px;
    --border-radius-lg: 20px;
    --border-radius-xl: 28px;
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;
    --transition-fast: 160ms ease;
    --transition-normal: 240ms ease;
    --transition-slow: 320ms ease;
    --transition-bounce: 240ms ease;
}

[data-theme="dark"] {
    --bg: #000000;
    --bg-solid: #000000;
    --surface: #1c1c1e;
    --surface-solid: #1c1c1e;
    --surface-soft: #242426;
    --surface-hover: #2c2c2e;
    --surface-accent: #0a3157;
    --text: #f5f5f7;
    --text-soft: #d1d1d6;
    --text-muted: #98989d;
    --line: #3a3a3c;
    --line-soft: #2c2c2e;
    --primary: #2997ff;
    --primary-solid: #2997ff;
    --primary-hover: #40a9ff;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

html { background: var(--bg); }

body {
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    background-attachment: initial;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: -0.011em;
}

body::before,
body::after { display: none !important; }

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    background: none;
    -webkit-text-fill-color: currentColor;
    font-family: var(--font-display);
    font-weight: 650;
    letter-spacing: -0.035em;
    line-height: 1.08;
}

h1 { font-size: clamp(2.75rem, 5vw, 4.75rem); margin: 0; }
h2 { font-size: clamp(1.8rem, 3vw, 2.75rem); margin: 0; }
h3 { font-size: 1.25rem; margin: 0; letter-spacing: -0.02em; }
p { color: var(--text-soft); }
a { color: var(--primary-solid); }

button,
input,
textarea,
select { font: inherit; }

button,
a,
input,
textarea,
select { outline: none; }

:where(button, a, input, textarea, select):focus-visible {
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.22) !important;
    border-color: var(--primary-solid) !important;
}

.container,
.app-container {
    width: min(100%, 1440px);
    max-width: none;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 40px 64px;
}

.app-wordmark {
    color: var(--text);
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.02em;
    text-decoration: none;
    white-space: nowrap;
}

.app-nav.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 54px;
    margin: 0 -40px 0;
    padding: 0 40px;
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    border-radius: 0;
    background: color-mix(in srgb, var(--bg-solid) 84%, transparent);
    box-shadow: none;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    animation: none;
}

.site-header:not(.app-nav),
.page-header:not(.app-nav) {
    margin: 28px 0 48px;
    padding: 28px 32px;
    border: 1px solid var(--line-soft);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    animation: none;
    backdrop-filter: none;
}

.app-nav nav,
.site-header nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-link,
.theme-toggle {
    min-height: 34px;
    width: auto;
    padding: 7px 12px;
    border: 0;
    border-radius: 9px;
    color: var(--text-soft);
    background: transparent;
    box-shadow: none;
    font-size: 13px;
    font-weight: 520;
    text-decoration: none;
    transform: none;
    cursor: pointer;
}

.nav-link:hover,
.theme-toggle:hover { color: var(--text); background: var(--surface-hover); transform: none; }
.nav-link.is-current,
.nav-link.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-xs); }

.eyebrow,
.feature-kicker {
    margin: 0 0 10px;
    color: var(--primary-solid);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.primary-link,
.card-link,
.submit-btn,
.primary-btn {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 10px 21px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: var(--primary-solid);
    box-shadow: none;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.primary-link:hover,
.card-link:hover,
.submit-btn:hover,
.primary-btn:hover { color: #fff; background: var(--primary-hover); transform: translateY(-1px); }

.secondary-link,
.secondary-btn,
.control-btn,
.icon-btn {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 9px 17px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    background: var(--surface);
    box-shadow: none;
    font-size: 14px;
    font-weight: 550;
    text-decoration: none;
}

.secondary-link:hover,
.secondary-btn:hover,
.control-btn:hover,
.icon-btn:hover { color: var(--text); background: var(--surface-hover); transform: none; }

button:disabled,
.submit-btn:disabled,
.primary-btn:disabled { cursor: not-allowed; opacity: 0.42; transform: none; }

/* Home */
.apple-home { padding: 0 0 80px; }
.home-hero {
    max-width: 920px;
    margin: 0 auto;
    padding: 118px 32px 112px;
    text-align: center;
}
.home-hero h1 { font-size: clamp(4.25rem, 8vw, 7.4rem); line-height: 0.92; letter-spacing: -0.065em; }
.home-hero-copy { max-width: 680px; margin: 28px auto 30px; font-size: 22px; line-height: 1.35; }
.hero-actions { display: flex; justify-content: center; gap: 12px; }
.home-modules { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.home-module {
    min-height: 330px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 38px;
    border: 1px solid var(--line-soft);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.home-module--write { min-height: 680px; grid-row: span 2; background: #101012; }
.home-module--write h2,
.home-module--write p { color: #f5f5f7; }
.home-module h2 { max-width: 520px; margin-bottom: 16px; }
.home-module p:not(.eyebrow) { max-width: 560px; font-size: 18px; line-height: 1.55; }
.home-module a { font-weight: 600; text-decoration: none; }

/* Login */
.site-login { overflow: auto; }
.site-login .login-stage {
    width: min(100%, 1440px);
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.12fr 0.88fr;
    margin: 0 auto;
    padding: 24px;
    gap: 24px;
}
.login-brand-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    border-radius: 30px;
    background: #101012;
}
.login-brand-panel .app-wordmark,
.login-brand-panel h1,
.login-brand-panel p { color: #f5f5f7; }
.login-brand-panel h1 { max-width: 760px; font-size: clamp(3.5rem, 6vw, 6.7rem); letter-spacing: -0.06em; }
.login-brand-panel div > p:last-child { max-width: 620px; margin: 28px 0 0; color: #a1a1a6; font-size: 20px; }
.login-footnote { color: #a1a1a6 !important; font-size: 13px; }
.login-form-panel { display: grid; place-items: center; padding: 48px; }
.login-card { width: min(100%, 420px); padding: 0; border: 0; background: transparent; box-shadow: none; }
.login-card h2 { font-size: 42px; margin-bottom: 12px; }
.login-card > p:not(.eyebrow) { margin-bottom: 32px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { color: var(--text-soft); font-size: 13px; font-weight: 600; }
.login-card input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    background: var(--surface);
}
.login-btn { width: 100%; margin-top: 8px; }
.login-error { color: var(--danger); font-size: 14px; }

/* Writing workspace */
.writing-app { padding: 48px 0 0; }
.workspace-header { display: flex; align-items: flex-end; justify-content: space-between; margin: 0 0 28px; padding: 0 4px; background: none; box-shadow: none; animation: none; }
.workspace-header h1 { font-size: 48px; }
.workspace-header-note { margin: 0 0 4px; color: var(--text-muted); font-size: 14px; }
.writing-grid { display: grid; grid-template-columns: minmax(320px, 0.72fr) minmax(620px, 1.65fr); gap: 20px; align-items: start; }
.prompt-workbench,
.editor-workbench {
    border: 1px solid var(--line-soft);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.prompt-workbench { position: sticky; top: 74px; max-height: calc(100vh - 96px); overflow: auto; padding: 24px; }
.editor-workbench { min-height: calc(100vh - 160px); overflow: visible; padding: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.panel-heading h2 { font-size: 25px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.status-dot.is-ready { background: var(--success-solid); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success-solid) 14%, transparent); }
.prompt-actions { display: grid; gap: 8px; margin-bottom: 14px; }
.prompt-action {
    width: 100%;
    min-height: 66px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 12px 15px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    color: var(--text);
    background: var(--surface-soft);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.prompt-action:hover,
.prompt-action.is-dragging { border-color: var(--primary-solid); background: var(--surface-accent); transform: none; }
.prompt-action span { font-weight: 620; }
.prompt-action small { margin-top: 2px; color: var(--text-muted); font-size: 12px; }
.inline-status { min-height: 0; color: var(--text-muted); font-size: 12px; }
.inline-status:not(:empty) { margin: 8px 2px; }
.inline-status[data-tone="error"] { color: var(--danger); }
.inline-status[data-tone="success"] { color: var(--success-solid); }
.prompt-content {
    max-height: 44vh;
    min-height: 180px;
    margin-top: 18px;
    overflow: auto;
    padding: 18px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    color: var(--text-soft) !important;
    background: var(--surface-soft);
    font-size: 14px;
    line-height: 1.65;
    white-space: pre-wrap;
}
.prompt-content[data-state="empty"] { color: var(--text-muted) !important; }
.extracted-text-title { margin: 18px 2px -8px; color: var(--text-muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.prompt-preview-container iframe { width: 100%; height: 240px; margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; }
.image-preview-container img { width: 100%; max-height: 260px; margin-top: 16px; border-radius: 12px; object-fit: contain; background: var(--surface-soft); }
.editor-toolbar {
    position: sticky;
    top: 54px;
    z-index: 4;
    min-height: 70px;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--line-soft);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: blur(16px);
    border-radius: 24px 24px 0 0;
}
.editor-stat { display: grid; gap: 1px; }
.editor-stat-label { color: var(--text-muted); font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.editor-stat strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.editor-save-state { margin-left: auto; color: var(--text-muted); font-size: 13px; }
.editor-save-state[data-state="saved"] { color: var(--success-solid); }
.editor-save-state[data-state="error"] { color: var(--danger); }
#essayInput {
    width: 100%;
    min-height: calc(100vh - 310px);
    display: block;
    resize: vertical;
    padding: 34px 42px;
    border: 0;
    border-radius: 0;
    color: var(--text);
    background: var(--surface);
    box-shadow: none;
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.78;
}
#essayInput::placeholder { color: var(--text-muted); }
#essayInput:focus { box-shadow: inset 0 0 0 2px var(--primary-solid) !important; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 24px; border-top: 1px solid var(--line-soft); }
.submit-message { margin: 0; color: var(--text-muted); font-size: 13px; }
.submit-message[data-tone="error"] { color: var(--danger); }
.draft-recovery { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--primary-solid) 30%, var(--line)); border-radius: 16px; background: var(--surface-accent); }
.draft-recovery > div:first-child { display: grid; gap: 2px; }
.draft-recovery span { color: var(--text-muted); font-size: 13px; }
.draft-recovery-actions { display: flex; gap: 8px; }
.grading-wait { margin: 0 24px 24px; border: 1px solid var(--line-soft); border-radius: 16px; background: var(--surface-soft); }

/* Prompt library */
.modal-open { overflow: hidden; }
.library-modal { position: fixed; inset: 0; z-index: 500; display: none; align-items: center; justify-content: center; padding: 28px; background: rgba(0, 0, 0, 0.38); backdrop-filter: blur(8px); }
.library-modal.is-open { display: flex; }
.library-dialog { width: min(820px, 92vw); max-height: 82vh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 14px; padding: 24px; border: 1px solid var(--line-soft); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-xl); }
.library-header { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 0; background: none; box-shadow: none; animation: none; }
.library-search-label { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.library-search,
.records-toolbar input,
.records-toolbar select { min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: var(--surface); }
.library-list { display: grid; gap: 7px; min-height: 220px; overflow: auto; padding: 2px; }
.library-item { display: grid; gap: 5px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: 13px; color: var(--text); background: var(--surface-soft); text-align: left; }
.library-item:hover { background: var(--surface-hover); transform: none; }
.library-item.is-selected { border-color: var(--primary-solid); background: var(--surface-accent); }
.library-item span { overflow: hidden; color: var(--text-muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.library-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--text-muted); font-size: 13px; }

/* History */
.records-main { padding: 58px 0 0; }
.records-page-header { display: flex; align-items: flex-end; justify-content: space-between; margin: 0 0 30px; padding: 0 4px; background: none; box-shadow: none; animation: none; }
.records-page-header h1 { font-size: 54px; }
.records-page-header p:last-child { margin: 14px 0 0; }
.records-panel { overflow: hidden; border: 1px solid var(--line-soft); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-xs); }
.records-toolbar { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.records-search-wrap { flex: 1; }
.records-search-wrap input { width: 100%; }
.records-check { display: flex; align-items: center; gap: 7px; padding: 0 6px; color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.records-result-count { min-width: 76px; color: var(--text-muted); font-size: 13px; text-align: right; }
.essay-records-viewport { min-height: 240px; }
.records-table-header,
.records-row { display: grid; grid-template-columns: 92px minmax(300px, 1fr) 190px 100px 40px; align-items: center; }
.records-table-header { min-height: 46px; padding: 0 20px; border-bottom: 1px solid var(--line-soft); color: var(--text-muted); background: var(--surface-soft); font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; }
.records-table-header .records-cell { color: inherit; }
.records-row { min-height: 78px; padding: 0 20px; border-bottom: 1px solid var(--line-soft); color: var(--text); text-decoration: none; transition: background var(--transition-fast); }
.records-row:last-child { border-bottom: 0; }
.records-row:hover { background: var(--surface-hover); transform: none; }
.records-row.is-excluded { opacity: 0.58; }
.records-cell { min-width: 0; padding: 8px; }
.records-prompt-block { display: grid; gap: 4px; }
.records-prompt-block strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.records-prompt-block small { color: var(--text-muted); font-size: 12px; }
.records-score-badge { min-width: 42px; display: inline-flex; align-items: baseline; justify-content: center; padding: 6px 9px; border-radius: 9px; color: var(--text); background: var(--surface-hover); font-size: 16px; font-weight: 680; font-variant-numeric: tabular-nums; }
.records-score-high { color: var(--success-solid); background: color-mix(in srgb, var(--success-solid) 10%, var(--surface)); }
.records-score-mid { color: var(--primary-solid); background: var(--surface-accent); }
.records-score-low { color: var(--warning-solid); background: color-mix(in srgb, var(--warning-solid) 10%, var(--surface)); }
.records-col-submitted,
.records-col-duration { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.records-row-arrow { color: var(--text-muted); font-size: 24px; }
.records-status { min-height: 240px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); }
.records-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding: 16px 20px; border-top: 1px solid var(--line-soft); color: var(--text-muted); font-size: 13px; }

/* Review and grammar pages */
.result-dashboard { gap: 18px; }
.dashboard-card,
.grading-section,
.diagnostics-section,
.chapter-browser,
.summary-card {
    border: 1px solid var(--line-soft);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.score-record-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--text-muted); font-size: 12px; }
.score-record-actions .is-active { border-color: var(--warning-solid); color: var(--warning-solid); }
.grading-score { color: var(--text); font-variant-numeric: tabular-nums; }
.grading-content-box,
.grading-suggestions-box { border: 1px solid var(--line-soft); border-radius: 14px; color: var(--text-soft); background: var(--surface-soft); }
.chapter-card { border: 1px solid var(--line-soft); border-radius: 18px; color: var(--text); background: var(--surface); box-shadow: var(--shadow-xs); }
.chapter-card:hover { border-color: var(--line); background: var(--surface-hover); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.subchapter-card { border-color: var(--line-soft); background: var(--surface-soft); }
.grammar-summary { position: sticky; top: 24px; }
.grammar-summary .summary-card { border: 1px solid var(--line-soft); }
.grammar-page .chapter-main,
.grammar-page .chapter-browser { border-color: var(--line-soft); }
.spinner { border-color: var(--line); border-top-color: var(--primary-solid); }
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 1100px) {
    .writing-grid { grid-template-columns: 320px minmax(0, 1fr); }
    .home-modules { grid-template-columns: 1fr; }
    .home-module--write { min-height: 440px; grid-row: auto; }
    .records-table-header,
    .records-row { grid-template-columns: 82px minmax(260px, 1fr) 170px 90px 30px; }
}

@media (max-width: 760px) {
    .container,
    .app-container { padding: 0 16px 40px; }
    .app-nav.site-header { margin: 0 -16px; padding: 8px 16px; align-items: flex-start; }
    .app-wordmark { display: none; }
    .writing-grid,
    .site-login .login-stage { grid-template-columns: 1fr; }
    .prompt-workbench { position: static; max-height: none; }
    .home-hero { padding: 72px 8px; }
    .home-hero h1 { font-size: 4rem; }
    .home-module { min-height: 300px; padding: 28px; }
    .login-brand-panel { min-height: 46vh; padding: 30px; }
    .login-form-panel { padding: 34px 20px; }
    .records-page-header { align-items: flex-start; }
    .records-toolbar { align-items: stretch; flex-direction: column; }
    .records-table-header { display: none; }
    .records-row { grid-template-columns: 62px 1fr 28px; padding: 12px; }
    .records-col-submitted,
    .records-col-duration { display: none; }
    #essayInput { min-height: 460px; padding: 26px 22px; }
}

/* Grammar learning system v2 — quiet, action-first, no decorative effects */
[hidden] { display: none !important; }
.learning-page {
    --learn-canvas: #f5f5f7;
    --learn-surface: #ffffff;
    --learn-soft: #f7f7f9;
    --learn-text: #1d1d1f;
    --learn-muted: #6e6e73;
    --learn-line: #d2d2d7;
    --learn-blue: #0071e3;
    --learn-green: #248a3d;
    --learn-red: #c9342f;
    color: var(--learn-text);
    background: var(--learn-canvas);
    background-image: none;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
}
.learning-page::before, .learning-page::after { display: none; }
[data-theme="dark"] .learning-page {
    --learn-canvas: #101012;
    --learn-surface: #1c1c1e;
    --learn-soft: #252528;
    --learn-text: #f5f5f7;
    --learn-muted: #a1a1a6;
    --learn-line: #3a3a3c;
    --learn-blue: #0a84ff;
    --learn-green: #30d158;
    --learn-red: #ff6961;
}
.learning-page h1, .learning-page h2, .learning-page h3 { color: var(--learn-text); font-family: inherit; letter-spacing: -0.025em; }
.learning-page p { color: var(--learn-muted); }
.learning-page .container { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 72px; }
.learning-page .site-header { position: sticky; top: 0; z-index: 20; margin: 0 -24px 34px; padding: 22px 24px 18px; border-bottom: 1px solid color-mix(in srgb, var(--learn-line) 75%, transparent); background: color-mix(in srgb, var(--learn-canvas) 88%, transparent); backdrop-filter: blur(18px); }
.learning-page .site-header nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.learning-page .nav-link, .learning-page .theme-toggle { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border: 0; border-radius: 10px; color: var(--learn-muted); background: transparent; font: inherit; text-decoration: none; }
.learning-page .nav-link:hover, .learning-page .nav-link.active, .learning-page .theme-toggle:hover { color: var(--learn-text); background: var(--learn-soft); }
.learning-page .eyebrow { margin-bottom: 6px; color: var(--learn-blue); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.learning-page .page-intro { max-width: 720px; }
.learning-surface { border: 1px solid var(--learn-line); border-radius: 22px; background: var(--learn-surface); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.learning-page .primary-btn, .learning-page .secondary-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 17px; border-radius: 12px; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.learning-page .primary-btn { border: 1px solid var(--learn-blue); color: #fff; background: var(--learn-blue); }
.learning-page .secondary-btn { border: 1px solid var(--learn-line); color: var(--learn-text); background: var(--learn-surface); }
.learning-page button:disabled { opacity: .55; cursor: wait; }
.learning-page :focus-visible { outline: 3px solid color-mix(in srgb, var(--learn-blue) 40%, transparent); outline-offset: 3px; }

.grammar-home, .progress-flow, .knowledge-flow { display: grid; gap: 24px; }
.today-card, .next-action-card { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: 34px; }
.today-card h2, .next-action-card h2 { margin-bottom: 8px; font-size: clamp(28px, 3vw, 42px); }
.today-actions, .lesson-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.today-metrics { grid-column: 1 / -1; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; padding-top: 22px; border-top: 1px solid var(--learn-line); }
.today-card { display: grid; grid-template-columns: 1fr auto; }
.today-metrics div { padding-right: 20px; }
.today-metrics dt { color: var(--learn-muted); font-size: 13px; }
.today-metrics dd { margin-top: 3px; color: var(--learn-text); font-size: 22px; font-weight: 700; }
.grammar-priority-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grammar-priority-grid > section, .chapter-browser, .progress-flow > .learning-surface:not(.next-action-card) { padding: 28px; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin-bottom: 4px; }
.action-list { display: grid; gap: 8px; }
.learning-action-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 16px; padding: 14px; border: 1px solid transparent; border-radius: 13px; color: var(--learn-text); background: var(--learn-soft); text-decoration: none; }
.learning-action-row:hover { border-color: var(--learn-line); transform: none; }
.action-row-title { min-width: 0; font-weight: 650; }
.action-row-detail { min-width: 0; overflow: hidden; color: var(--learn-muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.action-row-arrow { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--learn-blue); font-size: 13px; font-weight: 650; }
.empty-state { padding: 20px; border: 1px dashed var(--learn-line); border-radius: 13px; }
.chapter-accordion { display: grid; gap: 10px; }
.chapter-disclosure { border: 1px solid var(--learn-line); border-radius: 15px; overflow: clip; }
.chapter-disclosure summary, .report-disclosure summary { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; cursor: pointer; list-style: none; }
.chapter-disclosure summary::-webkit-details-marker, .report-disclosure summary::-webkit-details-marker { display: none; }
.chapter-disclosure summary span:first-child, .report-disclosure summary span { display: grid; }
.chapter-disclosure summary small, .report-disclosure summary small { color: var(--learn-muted); }
.chapter-count { color: var(--learn-muted); font-size: 13px; }
.chapter-point-list { display: grid; gap: 6px; padding: 0 12px 12px; }

.lesson-card { padding: 32px; }
.lesson-card > h2 { margin: 4px 0 24px; font-size: clamp(30px, 4vw, 46px); }
.knowledge-breadcrumb { color: var(--learn-blue) !important; font-weight: 650; }
.lesson-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.lesson-block { padding: 22px; border-radius: 16px; background: var(--learn-soft); }
.lesson-block h3 { margin-bottom: 10px; font-size: 17px; }
.lesson-english { margin-top: 8px; font-size: 14px; }
.mistake-block { border-left: 4px solid #ff9f0a; }
.example-list { display: grid; gap: 12px; list-style: none; }
.example-list li { display: grid; gap: 3px; }
.example-list strong { color: var(--learn-green); font-size: 13px; }
.lesson-actions { margin-top: 24px; }
.question-card { padding: 30px; }
.question-header { display: flex; justify-content: space-between; gap: 20px; }
.question-index { min-width: 64px; height: 38px; display: grid; place-items: center; border-radius: 20px; color: var(--learn-muted); background: var(--learn-soft); font-weight: 650; }
.star-timer-block { display: grid; justify-items: end; gap: 6px; }
.star-item-timer {
  margin: 0;
  min-width: 4.6rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--learn-blue);
  text-align: right;
}
.star-item-timer.is-low { color: var(--learn-red, #c0392b); }
.question-text { margin: 28px 0 18px; color: var(--learn-text) !important; font-size: clamp(21px, 2.4vw, 29px); font-weight: 650; line-height: 1.35; }
.options-list { display: grid; gap: 10px; }
.option-item { min-height: 54px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--learn-line); border-radius: 13px; color: var(--learn-text); background: var(--learn-surface); cursor: pointer; }
.option-item:hover, .option-item:has(input:checked) { border-color: var(--learn-blue); background: color-mix(in srgb, var(--learn-blue) 7%, var(--learn-surface)); }
.option-item input { width: 19px; height: 19px; accent-color: var(--learn-blue); }
.option-correct { border-color: var(--learn-green) !important; background: color-mix(in srgb, var(--learn-green) 10%, var(--learn-surface)) !important; }
.question-actions { display: flex; gap: 10px; margin-top: 20px; }
.feedback-panel { margin-top: 18px; padding: 18px; border-left: 4px solid var(--learn-blue); border-radius: 12px; background: var(--learn-soft); }
.feedback-correct { border-left-color: var(--learn-green); }
.feedback-incorrect { border-left-color: var(--learn-red); }
.feedback-panel p { margin-top: 7px; }
.completion-card { padding: 38px; text-align: left; }

.mixed-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.mixed-main { display: grid; gap: 20px; }
.mixed-intro, .mixedResult { padding: 32px; }
.size-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px 0; }
.size-option { min-height: 92px; display: grid; gap: 2px; padding: 15px; border: 1px solid var(--learn-line); border-radius: 14px; color: var(--learn-text); background: var(--learn-surface); text-align: left; cursor: pointer; }
.size-option strong { font-size: 25px; }
.size-option span { color: var(--learn-muted); font-size: 12px; }
.size-option.selected { border: 2px solid var(--learn-blue); padding: 14px; }
.session-rail { position: sticky; top: 130px; padding: 22px; }
.star-page .session-rail { top: 70px; }
.session-stats { display: grid; gap: 12px; margin: 18px 0; }
.session-stats div { display: flex; justify-content: space-between; }
.session-stats dt { color: var(--learn-muted); }
.session-stats dd { font-weight: 700; }
.question-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.question-dot { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--learn-muted); background: var(--learn-soft); font-size: 11px; }
.question-dot.answered { color: white; background: var(--learn-blue); }
.question-dot.current { box-shadow: 0 0 0 2px var(--learn-surface), 0 0 0 4px var(--learn-blue); }
.mistake-review { display: grid; gap: 10px; margin: 24px 0; }
.star-page .mistake-review { gap: 16px; }
.mistake-row { padding: 16px; border-radius: 13px; background: var(--learn-soft); }
.mistake-row p { margin: 6px 0; }
.mistake-row .star-explain { white-space: pre-wrap; line-height: 1.55; }
.star-review-item {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background: var(--learn-soft);
  border: 1px solid var(--learn-line);
}
.star-review-item.is-hit {
  border-color: color-mix(in srgb, var(--learn-green) 40%, var(--learn-line));
}
.star-review-item.is-miss {
  border-color: color-mix(in srgb, var(--learn-red) 40%, var(--learn-line));
}
.star-review-status {
  margin: 0;
  color: var(--learn-text);
  font-weight: 750;
}
.star-review-block {
  padding: 12px 14px;
  border-radius: 12px;
  border-left: 5px solid var(--learn-line);
  background: var(--learn-surface);
}
.star-review-block h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.star-review-block p {
  margin: 0;
  color: var(--learn-text);
  line-height: 1.65;
}
.star-review-block p + p { margin-top: 6px; }
.star-review-stem {
  background: color-mix(in srgb, var(--learn-text) 6%, var(--learn-surface));
  border-left-color: var(--learn-text);
}
.star-review-stem h3 { color: var(--learn-text); }
.star-review-stem-text {
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.55;
}
.star-review-blank {
  display: inline-block;
  min-width: 2.6em;
  padding: 0 0.4em;
  border-radius: 6px;
  border: 1.5px dashed var(--learn-blue);
  background: color-mix(in srgb, var(--learn-blue) 10%, var(--learn-surface));
  color: var(--learn-blue);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
}
.star-review-why {
  background: color-mix(in srgb, var(--learn-blue) 11%, var(--learn-surface));
  border-left-color: var(--learn-blue);
}
.star-review-why h3 { color: var(--learn-blue); }
.star-review-right {
  background: color-mix(in srgb, var(--learn-green) 13%, var(--learn-surface));
  border-left-color: var(--learn-green);
}
.star-review-right h3 { color: var(--learn-green); }
.star-review-wrongs { display: grid; gap: 8px; }
.star-review-wrong {
  background: color-mix(in srgb, var(--learn-red) 8%, var(--learn-surface));
  border-left-color: color-mix(in srgb, var(--learn-red) 65%, var(--learn-line));
}
.star-review-wrong h3 { color: var(--learn-red); }
.star-review-wrong.is-picked {
  background: color-mix(in srgb, var(--learn-red) 16%, var(--learn-surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--learn-red) 35%, transparent);
}
.star-review-word {
  font-weight: 800;
  letter-spacing: -0.02em;
}
.star-review-picked {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--learn-red);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
}
.star-review-extra {
  color: var(--learn-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}
.star-review-extra p { margin: 0; }
.history-zh {
    font-family: var(--font-cjk);
    font-size: 15px;
    line-height: 1.6;
}
.history-paper-list { display: grid; gap: 10px; margin-top: 18px; }
.history-paper-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    min-height: 54px;
    padding: 12px 16px;
    border: 1px solid var(--learn-line);
    border-radius: 13px;
    color: var(--learn-text);
    background: var(--learn-surface);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.history-paper-row:hover { border-color: var(--learn-blue); background: color-mix(in srgb, var(--learn-blue) 7%, var(--learn-surface)); }
.history-paper-row > span:last-child { color: var(--learn-muted); white-space: nowrap; }
.history-page .question-text { font-family: var(--font-cjk); font-size: 16px; line-height: 1.6; }
.history-page .option-item { font-family: var(--font-cjk); font-size: 15px; line-height: 1.6; }
.history-page .star-review-item { font-family: var(--font-cjk); font-size: 15px; }
.history-page .star-review-stem-text { font-size: 15px; }
.star-needed-count {
  display: none;
  min-width: 1.35em;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--learn-blue, #2563eb);
  color: #fff;
  font-size: 0.85em;
  font-weight: 700;
  vertical-align: middle;
}
.star-needed-count.is-on { display: inline-block; }
.star-needed-list { list-style: none; padding: 0; margin: 0; }
.star-needed-list li {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) repeat(3, auto);
  gap: 12px;
  align-items: baseline;
  padding: 14px 16px;
  margin: 8px 12px;
  border-radius: 13px;
  background: var(--learn-soft);
}
.star-needed-list .word { font-weight: 700; }
.star-needed-list .meta { color: var(--learn-muted, #64748b); font-size: 0.92em; }
.star-page {
  --learn-canvas: var(--bg-solid);
  --learn-surface: var(--surface);
  --learn-soft: var(--surface-soft);
  --learn-text: var(--text);
  --learn-muted: var(--text-muted);
  --learn-line: var(--line);
  --learn-blue: var(--primary-solid);
  --learn-green: var(--success-solid);
  --learn-red: var(--danger);
}
.star-page .question-text {
  margin: 16px 0 14px;
  color: var(--text) !important;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: -0.011em;
}
.star-page .question-card h2,
.star-page .star-method h3 {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.star-page .records-toolbar h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.star-workspace { display: grid; gap: 24px; }
.star-workspace.has-rail {
  grid-template-columns: minmax(0, 1fr) 280px;
  align-items: start;
}
.star-main-col { display: grid; gap: 20px; min-width: 0; }
.star-pager {
  justify-content: space-between;
}
.star-subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0 0 28px;
}
.star-subnav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.star-subnav a { text-decoration: none; }
.star-pool-count {
  margin: 0 0 0 auto;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.star-mode {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.star-mode legend { font-weight: 700; margin-bottom: 6px; }
.star-cup-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.star-cup {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--learn-soft);
  opacity: 0.45;
  font-weight: 700;
}
.star-cup.is-on { opacity: 1; }
.star-cup.is-main.is-on { outline: 2px solid var(--learn-blue, #2563eb); }
.star-cup-streak { font-size: 0.92em; }
.star-trap-stats { font-size: 0.95em; opacity: 0.85; }
.star-vocab-list, .star-wrong-list { list-style: none; padding: 0; margin: 0; }
.star-vocab-list li, .star-wrong-group { padding: 14px 16px; margin: 8px 12px; border-radius: 13px; background: var(--learn-soft); }
.star-vocab-list .word { font-weight: 700; margin-right: 8px; }
.star-vocab-list .lit { color: var(--learn-blue, #2563eb); }
.star-method { padding: 28px; margin-bottom: 0; }
.star-method-list { display: grid; gap: 28px; }
.star-method-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.star-method-jump a {
  color: var(--learn-blue, #2563eb);
  font-weight: 650;
  text-decoration: none;
}
.star-method-step {
  display: grid;
  gap: 16px;
  scroll-margin-top: 24px;
}
.star-method-intro {
  display: grid;
  gap: 0;
  padding: 28px;
}
.star-method-intro h2,
.star-method-intro p {
  max-width: 46rem;
}
.star-method-kicker {
  margin: 0 0 8px;
  color: var(--learn-muted, #64748b);
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.star-method-intro h2 {
  margin: 0 0 14px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.star-method-intro p {
  margin: 0 0 10px;
  line-height: 1.7;
  color: var(--learn-text, var(--text));
}
.star-method-intro p:last-child { margin-bottom: 0; }
.star-method h3 { margin: 0 0 8px; }
.star-method .options-list { margin: 12px 0 0; }
.star-method .star-explain {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--learn-line, #e5e7eb);
  line-height: 1.7;
}
.star-method .star-explain p { margin: 0 0 10px; }
.star-method .star-explain p:last-child { margin-bottom: 0; }
.star-method .option-item.is-right { outline: 2px solid var(--success-solid, #16a34a); }
.star-method .option-item.is-wrong { outline: 2px solid var(--danger, #dc2626); }
.mistake-row a { color: var(--learn-blue); font-weight: 650; }

.next-action-card { padding: 32px; }
.stage-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stage-card { display: grid; gap: 2px; padding: 18px; border-radius: 14px; background: var(--learn-soft); }
.stage-card strong { font-size: 30px; }
.stage-card small { color: var(--learn-muted); }
.activity-summary { margin-top: 16px; padding: 16px; border-radius: 12px; color: var(--learn-muted); background: var(--learn-soft); }
.report-disclosure { padding: 0 !important; overflow: clip; }
.report-disclosure > div { padding: 0 22px 22px; }
.chapter-report, .history-panel { display: grid; gap: 8px; }
.chapter-report-row, .history-row { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px; border-radius: 12px; color: var(--learn-text); background: var(--learn-soft); text-decoration: none; }
.chapter-report-row span:first-child, .history-row span { display: grid; }
.chapter-report-row small, .history-row small { color: var(--learn-muted); }
.mini-meter { width: 120px; height: 7px; border-radius: 8px; background: var(--learn-line); overflow: hidden; }
.mini-meter i { height: 100%; display: block; background: var(--learn-green); }
.inline-error { padding: 18px; border: 1px solid var(--learn-red); border-radius: 14px; color: var(--learn-red); background: var(--learn-surface); }

@media (max-width: 900px) {
    .grammar-priority-grid, .lesson-grid, .mixed-workspace, .star-workspace.has-rail { grid-template-columns: 1fr; }
    .session-rail { position: static; }
    .stage-grid { grid-template-columns: repeat(2, 1fr); }
    .today-card { grid-template-columns: 1fr; }
    .today-metrics { grid-column: 1; }
}
@media (max-width: 600px) {
    .learning-page .container { width: min(100% - 28px, 1240px); }
    .learning-page .site-header { position: static; margin: 0 -14px 24px; padding: 18px 14px; }
    .today-card, .next-action-card { padding: 24px; align-items: flex-start; flex-direction: column; }
    .today-metrics, .size-options { grid-template-columns: 1fr; }
    .grammar-priority-grid > section, .chapter-browser, .lesson-card, .question-card { padding: 20px; }
    .learning-action-row { grid-template-columns: 1fr; }
    .action-row-arrow { grid-column: 1; grid-row: auto; }
    .stage-grid { grid-template-columns: 1fr; }
    .mini-meter { width: 80px; }
}
@media (prefers-reduced-motion: reduce) {
    .learning-page *, .learning-page *::before, .learning-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
