:root {
    color-scheme: light;
    --bg: #f4f7f5;
    --surface: #ffffff;
    --surface-muted: #eef4f0;
    --text: #14201a;
    --muted: #64756b;
    --line: #d8e2dc;
    --brand: #147a4b;
    --brand-dark: #0f5d3a;
    --accent: #255e8a;
    --warning: #a96500;
    --danger: #b42318;
    --ok: #16704a;
    --shadow: 0 18px 48px rgba(18, 38, 30, 0.1);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.hero {
    padding: 34px 0 24px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2 {
    letter-spacing: 0;
}

h1 {
    max-width: 780px;
    margin: 0;
    font-size: clamp(2.2rem, 5vw, 4.4rem);
    line-height: 0.98;
}

h2 {
    margin: 0 0 14px;
    font-size: 1.18rem;
}

.hero-copy {
    max-width: 760px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: stretch;
}

.editor-panel,
.stats-panel,
.seo-panel,
.word-panel,
.metric-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.editor-panel,
.stats-panel,
.seo-panel,
.word-panel {
    padding: 20px;
}

.section-heading {
    display: flex;
    gap: 16px;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

label {
    font-weight: 850;
}

.section-heading span {
    color: var(--muted);
    font-size: 0.86rem;
}

textarea {
    width: 100%;
    min-height: 430px;
    resize: vertical;
    padding: 16px;
    color: var(--text);
    background: #fbfdfc;
    border: 1px solid #bdcbc3;
    border-radius: 6px;
    font: 1rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

textarea:focus {
    outline: 3px solid rgba(20, 122, 75, 0.18);
    border-color: var(--brand);
}

.actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

button {
    min-height: 44px;
    padding: 0 17px;
    color: #ffffff;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 6px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

button:hover,
button:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.button-secondary {
    color: var(--text);
    background: var(--surface-muted);
    border-color: var(--line);
}

.button-secondary:hover,
.button-secondary:focus {
    color: var(--text);
    background: #e2ece6;
    border-color: #bdcbc3;
}

.stat-list {
    display: grid;
    gap: 10px;
}

.stat-item {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.stat-item span,
.metric-card span,
.metric-card small {
    color: var(--muted);
}

.stat-item strong {
    color: var(--text);
    font-size: 1.35rem;
    line-height: 1;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.metric-card {
    display: grid;
    gap: 3px;
    padding: 18px;
}

.metric-card strong {
    color: var(--brand-dark);
    font-size: 2rem;
    line-height: 1.05;
}

.analysis-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    margin-top: 18px;
    align-items: start;
}

.seo-panel,
.word-panel {
    min-height: 100%;
}

.seo-item + .seo-item {
    margin-top: 18px;
}

.seo-label {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 7px;
}

.seo-label span {
    font-weight: 850;
}

.seo-label strong {
    color: var(--muted);
    font-size: 0.86rem;
}

.seo-bar {
    height: 10px;
    background: #dfe8e3;
    border-radius: 999px;
    overflow: hidden;
}

.seo-fill {
    width: 0;
    height: 100%;
    background: var(--ok);
    border-radius: 999px;
    transition: width 0.2s ease, background-color 0.2s ease;
}

.seo-fill.warning {
    background: var(--warning);
}

.seo-fill.danger {
    background: var(--danger);
}

.seo-text {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.word-list {
    display: grid;
    gap: 10px;
}

.word-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 11px 12px;
    background: #f9fbfa;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.word-text {
    overflow-wrap: anywhere;
    font-weight: 800;
}

.word-count {
    min-width: 34px;
    padding: 3px 8px;
    color: #ffffff;
    background: var(--accent);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 900;
    text-align: center;
}

.empty-state {
    margin: 0;
    padding: 14px;
    color: var(--muted);
    background: #f9fbfa;
    border: 1px dashed #bdcbc3;
    border-radius: 6px;
}

@media (max-width: 940px) {
    .workspace,
    .analysis-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .page-shell {
        width: min(100% - 22px, 1180px);
        padding-top: 18px;
    }

    .hero {
        padding-top: 18px;
    }

    h1 {
        font-size: 2.25rem;
    }

    .section-heading,
    .seo-label,
    .actions {
        display: grid;
        justify-content: stretch;
    }

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

    textarea {
        min-height: 320px;
    }

    button {
        width: 100%;
    }
}
