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

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #242734;
    --border: #2e3347;
    --text: #e4e6f0;
    --text-muted: #8b8fa3;
    --accent: #6c5ce7;
    --accent-hover: #7c6ff7;
    --green: #00b894;
    --red: #e17055;
    --orange: #fdcb6e;
    --radius: 8px;
}

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

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

/* Usage Bar */
.usage-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 20px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.usage-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.usage-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.usage-value {
    color: var(--text);
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.btn-refresh {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 1rem;
    cursor: pointer;
    margin-left: auto;
    transition: border-color 0.2s, color 0.2s;
}

.btn-refresh:hover {
    border-color: var(--accent);
    color: var(--accent);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 8px;
    font-size: 0.95rem;
}

/* Input Section */
.input-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

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

.form-group.full-width {
    margin-bottom: 20px;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.required {
    color: var(--red);
}

input[type="text"],
input[type="number"],
select,
textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

textarea {
    resize: vertical;
    min-height: 200px;
}

/* Rich Text Editor */
.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.toolbar-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.btn-clear {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.btn-clear:hover {
    border-color: var(--red);
    color: var(--red);
}

.rich-editor {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    min-height: 240px;
    max-height: 500px;
    overflow-y: auto;
    transition: border-color 0.2s;
    word-break: break-word;
}

.rich-editor:focus {
    outline: none;
    border-color: var(--accent);
}

.rich-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.rich-editor img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
    margin: 8px 0;
    border: 1px solid var(--border);
}

/* Image Alt Text */
.image-alt-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-alt-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.image-alt-item img {
    width: 100px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.image-alt-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.image-alt-info label {
    font-size: 0.78rem;
    color: var(--accent);
}

.image-alt-value {
    background: var(--bg);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.image-alt-item .btn-copy-small {
    align-self: flex-start;
    margin-top: 4px;
}

input[type="range"] {
    accent-color: var(--accent);
    cursor: pointer;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error */
.error-box {
    background: rgba(225, 112, 85, 0.1);
    border: 1px solid var(--red);
    border-radius: 6px;
    padding: 14px 18px;
    color: var(--red);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Output Section */
.output-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}

/* Score Overview */
.score-overview {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.score-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 4px solid var(--green);
    transition: border-color 0.3s;
}

.score-circle.medium {
    border-color: var(--orange);
}

.score-circle.low {
    border-color: var(--red);
}

.score-circle span {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}

.score-circle small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.score-meta p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.score-meta strong {
    color: var(--text);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
}

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

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Preview */
.preview-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.btn-secondary:hover {
    border-color: var(--accent);
}

.article-preview {
    background: #ffffff;
    color: #1a1a2e;
    border-radius: 6px;
    padding: 32px;
    line-height: 1.8;
    max-height: 600px;
    overflow-y: auto;
}

.article-preview h1 {
    font-size: 1.8rem;
    margin-bottom: 16px;
    color: #1a1a2e;
}

.article-preview h2 {
    font-size: 1.4rem;
    margin: 24px 0 12px;
    color: #2d3436;
}

.article-preview h3 {
    font-size: 1.15rem;
    margin: 20px 0 10px;
    color: #2d3436;
}

.article-preview p {
    margin-bottom: 14px;
}

.article-preview img {
    max-width: 100%;
    border-radius: 6px;
    margin: 16px 0;
}

.article-preview ul, .article-preview ol {
    margin: 12px 0 12px 24px;
}

.article-preview li {
    margin-bottom: 6px;
}

.article-preview figure {
    margin: 20px 0;
    text-align: center;
}

.article-preview figcaption {
    font-size: 0.85rem;
    color: #636e72;
    margin-top: 8px;
}

/* Code block */
.code-block {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* SEO Checklist */
.seo-category {
    margin-bottom: 24px;
}

.seo-category h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.check-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(46, 51, 71, 0.5);
}

.check-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 2px;
}

.check-icon.pass {
    background: rgba(0, 184, 148, 0.15);
    color: var(--green);
}

.check-icon.fail {
    background: rgba(225, 112, 85, 0.15);
    color: var(--red);
}

.check-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.check-message {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.check-message.pass {
    color: var(--green);
}

.check-message.fail {
    color: var(--red);
}

/* Meta & URL */
.meta-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.meta-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
}

.meta-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--accent);
}

.meta-value {
    background: var(--bg);
    border-radius: 4px;
    padding: 12px;
    font-size: 0.95rem;
    margin-bottom: 10px;
    line-height: 1.5;
    word-break: break-word;
}

.url-slug {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--green);
    font-size: 0.9rem;
}

.btn-copy-small {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.btn-copy-small:hover {
    border-color: var(--accent);
    color: var(--text);
}

/* Keywords Section */
.keywords-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.keyword-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.8rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.keyword-tag {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
}

.keyword-tag.focus {
    background: rgba(108, 92, 231, 0.2);
    color: #a29bfe;
    border: 1px solid rgba(108, 92, 231, 0.4);
    font-size: 1.1rem;
    padding: 10px 20px;
}

.keyword-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-tag.secondary {
    background: rgba(0, 184, 148, 0.1);
    color: var(--green);
    border: 1px solid rgba(0, 184, 148, 0.3);
    font-size: 0.85rem;
}

.keyword-reasoning {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--green);
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    animation: fadeInUp 0.3s ease, fadeOut 0.3s ease 2s forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Responsive */
@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .score-overview {
        flex-direction: column;
        text-align: center;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab {
        padding: 8px 12px;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .usage-bar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 8px 14px;
    }
}
