/* ============================================
   Word Counter & Readability Analyzer
   Clean editorial aesthetic, dark focus mode
============================================ */
:root {
    --bg: #0d0d1a;
    --surface: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.07);
    --text: #f1f5f9;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --green: #10b981;
    --yellow: #f59e0b;
    --red: #ef4444;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 0% 0%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
}

.tool-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--text);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--accent);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #f1f5f9, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tool-header p {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.65;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    min-width: 100px;
}

.stat-pill.accent {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.08);
}

.stat-num {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-pill.accent .stat-num {
    color: var(--accent);
}

.stat-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tool Layout */
.tool-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.panel-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-action {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 7px;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.icon-action:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.15);
}

#mainEditor {
    width: 100%;
    min-height: 520px;
    resize: vertical;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 1.5rem;
    font-size: 1rem;
    line-height: 1.7;
    font-family: 'Outfit', sans-serif;
    transition: border-color 0.2s;
}

#mainEditor:focus {
    outline: none;
    border-color: var(--accent);
}

#mainEditor::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Analysis Panel */
.analysis-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.analysis-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.card-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

/* Flesch Score */
.flesch-display {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.flesch-score {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.flesch-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.flesch-bar-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.35rem;
}

.flesch-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--green);
    transition: width 0.5s ease, background 0.5s ease;
    width: 0%;
}

.flesch-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.flesch-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Reading Level */
.reading-level {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

/* Two-col */
.two-col .mini-stat:not(:last-child) {
    border-right: 1px solid var(--border);
}

.analysis-card.two-col {
    display: flex;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.mini-stat {
    flex: 1;
    padding: 1.25rem;
    text-align: center;
}

.mini-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.mini-lbl {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Keywords */
.keyword-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.keyword-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.keyword-word {
    font-weight: 600;
    min-width: 100px;
    color: var(--text);
}

.keyword-bar-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.keyword-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}

.keyword-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 30px;
    text-align: right;
}

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

@media (max-width:900px) {
    .tool-layout {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 2rem;
    }
}

@media (max-width:600px) {
    .stats-bar {
        gap: 0.5rem;
    }

    .stat-pill {
        min-width: 80px;
        padding: 0.5rem 1rem;
    }
}