body {
    overflow-x: hidden;
}

/* Views */
.view {
    display: none;
    min-height: 100vh;
    padding: 16px 24px 80px 24px;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
}

.view.active {
    display: block;
}

/* Header */
.view-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    position: sticky;
    top: 45px;
    background: #f5f5f5;
    z-index: 10;
}

.view-header h1,
.view-header h2 {
    margin: 0;
    font-size: 1.3rem;
    flex: 1;
}

.back-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 1.1rem;
    cursor: pointer;
    text-decoration: none;
    color: #333;
    display: inline-flex;
    align-items: center;
}

.back-btn:hover {
    background: #eee;
}

/* Answer header */
.answer-header-content {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.answer-header-content h2 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.answer-date {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
}

/* Questions list */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.question-item {
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.15s;
}

.question-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.13);
}

.question-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: #222;
}

.question-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

.pill-sub {
    background: #e3f0ff;
    color: #1a73e8;
}

.pill-global {
    background: #f0f0f0;
    color: #666;
}

.pill-manual {
    background: #fff3e0;
    color: #e65100;
}

.pill-status {
    background: #e8f5e9;
    color: #2e7d32;
}

.pill-status.pending,
.pill-status.fetching,
.pill-status.analyzing {
    background: #fff8e1;
    color: #f57f17;
}

.pill-status.error {
    background: #ffebee;
    color: #c62828;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 0;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    font-size: 28px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(26,115,232,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
    z-index: 20;
}

.fab:hover {
    transform: scale(1.08);
}

/* Progress section */
.progress-section {
    margin: 16px 0;
    padding: 16px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.progress-bar-container {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: #1a73e8;
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Answer content */
.answer-content {
    background: white;
    border-radius: 10px;
    padding: 24px 28px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-top: 8px;
}

.tldr-section {
    background: #f0f7ff;
    border-left: 4px solid #1a73e8;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 20px;
}

.tldr-section h3 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: #1a73e8;
}

/* Markdown rendering */
.answer-body h1,
.answer-body h2,
.answer-body h3 {
    margin-top: 1.2em;
    margin-bottom: 0.4em;
}

.answer-body h1 { font-size: 1.3rem; }
.answer-body h2 { font-size: 1.15rem; }
.answer-body h3 { font-size: 1rem; }

.answer-body p {
    margin: 0.5em 0;
    line-height: 1.5;
}

.answer-body ul,
.answer-body ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.answer-body li {
    margin: 0.3em 0;
    line-height: 1.4;
}

.answer-body strong {
    font-weight: 700;
}

.answer-body blockquote {
    border-left: 3px solid #ddd;
    padding-left: 12px;
    margin: 0.5em 0;
    color: #555;
}

/* Answer meta */
.answer-meta {
    margin-top: 16px;
    padding: 14px 16px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 0.85rem;
}

.meta-subreddits {
    margin-bottom: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.meta-posts a {
    display: block;
    color: #1a73e8;
    text-decoration: none;
    padding: 4px 0;
    font-size: 0.85rem;
}

.meta-posts a:hover {
    text-decoration: underline;
}

/* Delete button */
.delete-btn {
    margin-top: 16px;
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.delete-btn:hover {
    background: #b02a37;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: white;
    border-radius: 14px;
    padding: 24px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

/* Wizard steps */
.wizard-step {
    display: none;
}

.wizard-step.active {
    display: block;
}

.wizard-step h3 {
    margin: 0 0 16px 0;
    font-size: 1.1rem;
}

.wizard-step textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.95rem;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
}

.wizard-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    gap: 8px;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-primary {
    background: #1a73e8;
    color: white;
}

.btn-primary:hover {
    background: #1557b0;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Subreddit search */
.sub-search-container {
    position: relative;
    margin-bottom: 12px;
}

.sub-search-container input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.sub-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
}

.sub-suggestions.hidden {
    display: none;
}

.sub-suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.sub-suggestion-item:hover {
    background: #f5f8ff;
}

.sub-suggestion-item:last-child {
    border-bottom: none;
}

.sub-suggestion-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.sub-suggestion-meta {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

/* Selected subs pills */
.selected-subs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px;
    align-items: center;
}

.sub-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #e3f0ff;
    color: #1a73e8;
    border-radius: 16px;
    font-size: 0.82rem;
    font-weight: 600;
}

.sub-pill-remove {
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    opacity: 0.6;
}

.sub-pill-remove:hover {
    opacity: 1;
}

.sub-help-text {
    font-size: 0.82rem;
    color: #999;
    margin: 0;
}

/* Posts list in wizard */
.posts-list {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.post-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 6px;
    margin-bottom: 2px;
}

.post-item:hover {
    background: #f5f8ff;
}

.post-item.selected {
    background: #e3f0ff;
    border-left: 3px solid #1a73e8;
}

.post-item-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: #222;
    margin-bottom: 4px;
}

.post-item-meta {
    font-size: 0.72rem;
    color: #888;
}

.loading-text {
    text-align: center;
    color: #999;
    padding: 20px 0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 200;
    transition: opacity 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .modal {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }

    .view {
        padding: 16px 12px 80px 12px;
    }

    .view-header h1,
    .view-header h2 {
        font-size: 1.1rem;
    }

    .posts-list {
        max-height: 55vh;
    }
}
