/* Re-themed to SnapStatic dark + indigo by aliasing to styles-base --ss-* tokens.
   styles-base.css loads first, so --ss-* are defined when these resolve. */
:root {
    --bg-primary: var(--ss-surface);
    --bg-secondary: var(--ss-bg);
    --bg-tertiary: var(--ss-surface-2);
    --text-primary: var(--ss-text);
    --text-secondary: var(--ss-text-dim);
    --text-muted: var(--ss-text-dim);
    --border-color: var(--ss-border);
    --accent: var(--ss-accent);
    --accent-hover: var(--ss-accent-hover);
    --warning: var(--ss-warn);
    --error: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* .container, header and footer are owned by the shared frame (styles-base.css). */

.hidden {
    display: none !important;
}

/* Header + tagline now rendered by the frame (.ss-nav + .tool-head). */

main {
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.content-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

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

.content-header label {
    font-weight: 600;
    font-size: 14px;
}

.btn-clear {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: var(--text-muted);
    color: white;
}

.textarea-wrapper {
    position: relative;
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    font-size: 15px;
    font-family: inherit;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
    line-height: 1.6;
}

textarea:focus {
    border-color: var(--accent);
}

.char-count {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.focus-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
}

.form-group input {
    padding: 10px 12px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
}

.density-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

#densityLabel {
    font-weight: 600;
    font-size: 14px;
}

#densityValue {
    font-weight: 700;
    font-size: 16px;
}

.badge {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.badge.optimal {
    background: #dcfce7;
    color: #166534;
}

.badge.low {
    background: #fef3c7;
    color: #92400e;
}

.badge.high {
    background: #fee2e2;
    color: #991b1b;
}

#densityStatus {
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-section h2 {
    font-size: 18px;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .keyword-table .bar-cell {
        display: none;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 22px;
    }

    .header .tagline {
        font-size: 14px;
    }

    main {
        padding: 20px 12px;
        gap: 20px;
    }

    .content-section,
    .focus-section,
    .keyword-section {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    textarea {
        min-height: 150px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .keyword-table {
        font-size: 13px;
    }

    .keyword-table th,
    .keyword-table td {
        padding: 8px 6px;
    }
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.keyword-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

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

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-secondary);
}

.toggle-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.keyword-table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.keyword-table {
    width: 100%;
    border-collapse: collapse;
}

.keyword-table th,
.keyword-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.keyword-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.keyword-table tbody tr:hover {
    background: var(--bg-secondary);
}

.keyword-table tbody tr.highlight {
    background: color-mix(in srgb, var(--ss-accent) 16%, transparent);
}

.keyword-table .word-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyword-table .bar-cell {
    width: 100px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

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

.keyword-table tbody tr.highlight .bar-fill {
    background: var(--ss-accent-hover);
}

.keyword-table .count-cell {
    font-weight: 600;
}

.keyword-table .density-cell {
    font-weight: 500;
}

.keyword-table tbody tr.highlight .word-cell {
    font-weight: 700;
}

/* .footer rendered by the frame (styles-base .site-footer). */