*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f8f8f6;
    --surface: #ffffff;
    --border: #e2e2dc;
    --text: #1a1a18;
    --muted: #6b6b66;
    --accent: #2563eb;
    --accent-light: #eff6ff;
    --green: #16a34a;
    --green-light: #f0fdf4;
    --amber: #d97706;
    --amber-light: #fffbeb;
    --red: #dc2626;
    --red-light: #fef2f2;
    --radius: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* ---------- Header / nav ---------- */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
}

.header-inner {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-link {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    text-decoration: none;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.85rem;
    color: var(--muted);
}

.main-nav {
    display: flex;
    gap: 1.25rem;
}

.main-nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s;
}

.main-nav a:hover, .main-nav a.active {
    color: var(--accent);
}

/* ---------- Main layout ---------- */
main {
    max-width: 860px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    width: 100%;
}

.content-narrow {
    max-width: 680px;
    margin: 0 auto;
}

.content-narrow h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 24px;
    line-height: 1.2;
}

.content-narrow h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 32px 0 12px;
}

.content-narrow p {
    margin-bottom: 0;
}

.content-narrow a {
    color: var(--text);
}

.content-narrow .meta {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 48px;
}

.content-narrow ul {
    margin: 0 0 16px 20px;
}

.content-narrow ul li {
    margin-bottom: 6px;
}

.contact-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 16px;
}

.contact-box a {
    font-weight: 500;
}

/* ---------- Intro ---------- */
.intro {
    margin-bottom: 1.5rem;
}

.intro h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    letter-spacing: -0.02em;
}

.intro p {
    color: var(--muted);
    font-size: 0.95rem;
}

/* ---------- Input card ---------- */
.input-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

textarea {
    width: 100%;
    min-height: 180px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s;
    outline: none;
}

textarea:focus {
    border-color: var(--accent);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.word-count {
    font-size: 0.82rem;
    color: var(--muted);
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

button:hover {
    opacity: 0.88;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-clear {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    font-weight: 400;
}

.btn-clear:hover {
    background: var(--bg);
    opacity: 1;
}

a.button {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
}

a.button:hover {
    opacity: 0.88;
}

/* ---------- Results ---------- */
#results {
    display: none;
}

.lang-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 99px;
    padding: 0.25rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.score-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
}

.score-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.score-value {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.score-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.3rem;
}

.cefr-a {
    color: var(--green);
}

.cefr-b {
    color: var(--amber);
}

.cefr-c {
    color: var(--red);
}

.cefr-approx {
    opacity: 0.6;
}

.approx-note {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.3rem;
    font-style: italic;
}

/* ---------- Flesch bar ---------- */
.flesch-bar-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.flesch-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.flesch-bar-track {
    height: 10px;
    border-radius: 99px;
    background: linear-gradient(to right, #dc2626, #d97706, #16a34a);
    position: relative;
}

.flesch-marker {
    position: absolute;
    top: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text);
    border: 2px solid var(--surface);
    transform: translateX(-50%);
    transition: left 0.5s ease;
}

/* ---------- Stats ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    text-align: center;
}

.stat-num {
    font-size: 1.4rem;
    font-weight: 700;
    display: block;
}

.stat-name {
    font-size: 0.78rem;
    color: var(--muted);
}

/* ---------- Tips ---------- */
.tips-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}

.tips-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.tip {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    font-size: 0.88rem;
    line-height: 1.5;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.tip:last-child {
    border-bottom: none;
}

.tip-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--amber-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.tip-good .tip-icon {
    background: var(--green-light);
}

.error-msg {
    background: var(--red-light);
    color: var(--red);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---------- Sections ---------- */
section {
    padding-top: 5%;
}

p {
    padding: 0px 0px 20px 0px;
}

ul {
    padding: 20px;
}

/* ---------- Language list (FAQ) ---------- */
.language-list {
    columns: 3;
    column-gap: 2rem;
    padding-left: 1.25rem;
}

.language-list li {
    break-inside: avoid;
    margin-bottom: 0.4rem;
}

@media (max-width: 768px) {
    .language-list {
        columns: 2;
    }
}

@media (max-width: 480px) {
    .language-list {
        columns: 1;
    }
}

/* ---------- 404 ---------- */
.error-404 {
    text-align: center;
    padding: 4rem 1.5rem;
}

.error-404 .code {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 12px;
}

.error-404 h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.error-404 p {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.6;
}

/* ---------- Footer ---------- */
footer {
    text-align: center;
    padding: 2rem;
    font-size: 0.8rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

footer a {
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

footer a:hover {
    color: var(--text);
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}
