:root {
    --primary: #4A5568;
    --primary-dark: #2D3748;
    --text: #1A202C;
    --muted: #718096;
    --card: #FFFFFF;
    --background: #F7FAFC;
    --border: #E2E8F0;
    --accent: #4A5568;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    color: var(--text);
    background: var(--background);
    min-height: 100vh;
    overflow-x: hidden;
}

.page-container {
    max-width: 1100px;
    margin: 40px auto;
    background: var(--card);
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    width: calc(100% - 64px);
}

h1 {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 2rem;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.intro {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: var(--muted);
    margin-bottom: 24px;
    line-height: 1.6;
}

.essay-type-selector {
    margin-top: 24px;
    padding: 16px;
    background: #F7FAFC;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.essay-type-selector label {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-right: 12px;
}

.essay-type-selector select {
    font-family: 'Inter', sans-serif;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
}

.essay-type-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 85, 104, 0.1);
}

.essay-tips {
    margin-top: 12px;
    padding: 12px;
    background: white;
    border-radius: 4px;
    border-left: 3px solid var(--primary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
}

.essay-tips strong {
    color: var(--primary);
    display: block;
    margin-bottom: 4px;
}

.education-level-indicator {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #EDF2F7;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text);
    border-left: 3px solid var(--primary);
    display: none;
}

.education-level-indicator.show {
    display: block;
}

.auto-save-indicator {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--muted);
    text-align: right;
    margin-top: 8px;
    margin-bottom: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.auto-save-indicator.show {
    opacity: 1;
}

.stats-bar {
    display: flex;
    gap: 48px;
    align-items: baseline;
    margin-bottom: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: fit-content;
}

.stat .label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    letter-spacing: 1.2px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
    white-space: nowrap;
}

.stat .value {
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 32px;
    font-weight: 500;
    color: var(--primary);
    letter-spacing: -1px;
    line-height: 1;
    margin: 0;
}

.stat-char {
    position: relative;
}

.char-toggle {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    padding: 4px 8px;
    margin-top: 6px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    align-self: flex-start;
}

.char-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.editor-divider {
    border: none;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

.editor-wrapper {
    display: flex;
    gap: 26px;
}

.essay-panel {
    flex: 3;
    min-width: 0;
}

.essay-panel textarea {
    font-family: 'Source Sans Pro', 'Segoe UI', sans-serif;
    width: 100%;
    height: 420px;
    padding: 16px;
    font-size: 15px;
    line-height: 1.7;
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
    color: var(--text);
    background: #FFFFFF;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.essay-panel textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 85, 104, 0.1);
}

.keyword-panel {
    flex: 1;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    min-width: 200px;
}

.keyword-panel h3 {
    font-family: 'Inter', sans-serif;
    margin-top: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.2px;
}

.keyword-panel p {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
}

.keyword-panel table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

.keyword-panel th {
    background: var(--background);
    font-weight: 600;
    color: var(--text);
    padding: 8px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    letter-spacing: 0.5px;
}

.keyword-panel th:nth-child(1) {
    width: 60%;
}

.keyword-panel th:nth-child(2) {
    width: 20%;
}

.keyword-panel th:nth-child(3) {
    width: 20%;
}

.keyword-panel td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.keyword-panel td:nth-child(1) {
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 0;
}

.keyword-panel td:nth-child(2),
.keyword-panel td:nth-child(3) {
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    color: var(--primary);
    white-space: nowrap;
}

.how-to-use {
    margin-top: 50px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.how-to-use h2 {
    font-family: 'Merriweather', serif;
    font-size: 1.75rem;
    color: var(--text);
    margin-bottom: 30px;
    letter-spacing: -0.5px;
}

.how-to-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.step-number {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    font-family: 'Inter', sans-serif;
}

.step-content h3 {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
}

.step-content p {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--muted);
    margin: 0;
    line-height: 1.6;
}

.faq-section {
    margin-top: 50px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.faq-section h2 {
    font-family: 'Merriweather', serif;
    font-size: 1.75rem;
    color: var(--text);
    margin-bottom: 30px;
    letter-spacing: -0.5px;
}

.faq-item {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--background);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.faq-question {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px 0;
}

.faq-answer {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--muted);
    margin: 0;
    line-height: 1.7;
}

@media (max-width: 768px) {
    .page-container {
        margin: 20px auto;
        padding: 20px;
        width: calc(100% - 40px);
    }

    h1 {
        font-size: 1.5rem;
    }

    .intro {
        font-size: 14px;
    }

    .stats-bar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        overflow-x: visible;
        padding-bottom: 0;
    }

    .stat {
        min-width: auto;
    }

    .stat .value {
        font-size: 28px;
    }

    .stat .label {
        font-size: 10px;
    }

    .editor-wrapper {
        flex-direction: column;
        gap: 20px;
    }

    .essay-panel textarea {
        height: 300px;
        font-size: 14px;
    }

    .keyword-panel {
        min-width: 100%;
    }

    .essay-type-selector {
        padding: 12px;
    }

    .essay-type-selector select {
        min-width: 100%;
        width: 100%;
        margin-top: 8px;
    }

    .how-to-steps {
        grid-template-columns: 1fr;
    }

    .how-to-use h2,
    .faq-section h2 {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .page-container {
        padding: 16px;
        width: calc(100% - 32px);
        border-radius: 6px;
    }

    h1 {
        font-size: 1.3rem;
    }

    .stats-bar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        grid-template-areas:
            "words chars"
            "reading sentences"
            "pages pages";
    }

    .stat:nth-child(1) { grid-area: words; }
    .stat:nth-child(2) { grid-area: chars; }
    .stat:nth-child(3) { grid-area: reading; }
    .stat:nth-child(4) { grid-area: sentences; }
    .stat:nth-child(5) { grid-area: pages; }

    .stat .value {
        font-size: 24px;
    }

    .stat .label {
        font-size: 9px;
        letter-spacing: 0.8px;
    }

    .char-toggle {
        font-size: 9px;
        padding: 3px 6px;
    }

    .essay-panel textarea {
        height: 250px;
        padding: 12px;
    }

    .step-content h3 {
        font-size: 15px;
    }

    .step-content p {
        font-size: 13px;
    }

    .faq-question {
        font-size: 15px;
    }

    .faq-answer {
        font-size: 13px;
    }
}