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


:root {
    --site-shell-max-width: 1100px;
    --site-page-gutter: clamp(12px, 2.4vw, 22px);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #6631e1 0%, #ffffff 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--site-page-gutter);
}

.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 40px;
    max-width: var(--site-shell-max-width);
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    font-size: 32px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 12px;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: #718096;
    margin-bottom: 32px;
    font-size: 16px;
    line-height: 1.6;
}

.privacy-notice {
    background: linear-gradient(135deg, #e6f7ff 0%, #f0e6ff 100%);
    border: 2px solid #667eea;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.privacy-icon {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #4c51bf;
    background: rgba(102, 126, 234, 0.12);
    border-radius: 999px;
    padding: 6px 10px;
    flex-shrink: 0;
    margin-top: 2px;
}

.privacy-content strong {
    display: block;
    font-size: 17px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 6px;
}

.privacy-content p {
    font-size: 14px;
    color: #2d3748;
    line-height: 1.6;
}

.counter-section {
    margin-bottom: 24px;
}

.counter-section label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
}

.sr-only {
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    white-space: nowrap !important;
    width: 1px !important;
}

#textInput {
    width: 100%;
    min-height: 220px;
    border: 2px solid #d7deea;
    border-radius: 14px;
    padding: 14px;
    font-size: 16px;
    line-height: 1.55;
    color: #2d3748;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#textInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.14);
}

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

.analysis-controls {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}

.control-group {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    padding: 10px 12px;
}

.control-group label,
.control-group legend {
    font-size: 13px;
    font-weight: 700;
    color: #4a5568;
}

.mode-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.mode-group legend {
    margin-right: 8px;
}

.control-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #2d3748;
}

.control-option input[type="radio"] {
    accent-color: #667eea;
}

.preset-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preset-group select {
    width: 100%;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    color: #2d3748;
    background: #ffffff;
}

.preset-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.limit-status {
    margin-top: 12px;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
}

.limit-status.no-limit {
    background: #edf2f7;
    color: #4a5568;
}

.limit-status.within {
    background: #ebf8ff;
    color: #2c5282;
}

.limit-status.near {
    background: #fffaf0;
    color: #975a16;
}

.limit-status.over {
    background: #fff5f5;
    color: #c53030;
}

.analysis-status {
    margin-top: 8px;
    min-height: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #5f6f92;
}

.analysis-status.worker {
    color: #2f855a;
}

.analysis-status.fallback {
    color: #975a16;
}

.action-btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    min-height: 40px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.32);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.44);
}

.secondary-btn {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    box-shadow: 0 4px 12px rgba(45, 55, 72, 0.28);
}

.secondary-btn:hover {
    box-shadow: 0 6px 16px rgba(45, 55, 72, 0.38);
}

.io-controls {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.export-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.export-controls .export-label {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    color: #4a5568;
    margin: 0;
}

.export-controls select {
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    color: #2d3748;
    background: #ffffff;
}

.export-controls select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    padding: 14px 10px;
    text-align: center;
}

.stat-card h2 {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #2b2f77;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.insight-card {
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: linear-gradient(135deg, #f7f9ff 0%, #edf2ff 100%);
    padding: 14px 12px;
    text-align: center;
}

.insight-card h2 {
    font-size: 14px;
    font-weight: 700;
    color: #3b4d7a;
    margin-bottom: 8px;
}

.insight-value {
    font-size: 24px;
    font-weight: 700;
    color: #2c3d96;
    margin-bottom: 6px;
}

.insight-caption {
    font-size: 12px;
    color: #5f6f92;
}

.frequency-section {
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    padding: 14px 12px;
    margin-bottom: 16px;
}

.frequency-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.frequency-header h2 {
    font-size: 16px;
    color: #364061;
}

.frequency-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
}

.frequency-toggle input[type="checkbox"] {
    accent-color: #667eea;
}

.top-words-list {
    list-style: decimal inside;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.top-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 9px;
    background: #f8fbff;
}

.top-word-label {
    font-weight: 600;
    color: #2d3748;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80%;
}

.top-word-count {
    font-size: 12px;
    font-weight: 700;
    color: #3f51b5;
}

.top-words-empty {
    margin-top: 6px;
    font-size: 13px;
    color: #718096;
}

.seo-content {
    margin-top: 16px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    text-align: left;
}

.seo-summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    color: #667eea;
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.seo-summary::-webkit-details-marker {
    display: none;
}

.seo-details-body {
    margin-top: 16px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 220ms ease, opacity 180ms ease;
}

.seo-details[open] .seo-details-body,
.seo-details:hover .seo-details-body,
.seo-details:focus-within .seo-details-body {
    max-height: 1000px;
    opacity: 1;
}

.seo-content article {
    margin-bottom: 12px;
}

.seo-content h3 {
    font-size: 15px;
    color: #4a5568;
    margin-bottom: 4px;
}

.seo-content p {
    font-size: 14px;
    color: #718096;
    line-height: 1.55;
}

.footer-links {
    margin-top: 26px;
    padding-top: 18px;
    border-top: 2px solid #e2e8f0;
    text-align: center;
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 0 10px;
    transition: color 0.2s ease;
    display: inline-block;
}

.footer-links a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.back-btn {
    display: inline-block;
    padding: 10px 18px;
    margin-right: 6px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff !important;
    border-radius: 10px;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.back-btn:hover {
    text-decoration: none !important;
}

@media (max-width: 1024px) {
    body {
        align-items: flex-start;
        padding: 14px;
    }

    .container {
        padding: 28px 22px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }

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

@media (max-width: 768px) {
    .container {
        border-radius: 18px;
        padding: 22px 16px;
    }

    h1 {
        font-size: 27px;
    }

    .subtitle {
        font-size: 15px;
        margin-bottom: 22px;
    }

    .privacy-notice {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #textInput {
        min-height: 200px;
        font-size: 15px;
    }

    .actions {
        justify-content: stretch;
    }

    .action-btn {
        flex: 1 1 140px;
        min-height: 44px;
    }

    .io-controls {
        justify-content: stretch;
    }

    .export-controls {
        width: 100%;
    }

    .export-controls select {
        flex: 1 1 120px;
        min-height: 44px;
    }

    .analysis-controls {
        grid-template-columns: 1fr;
    }

    .mode-group {
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .insight-value {
        font-size: 22px;
    }

    .frequency-header {
        align-items: flex-start;
    }

    .footer-links a {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (hover: none), (pointer: coarse) {
    .action-btn:hover,
    .back-btn:hover {
        transform: none;
        box-shadow: none;
    }
}

