* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-nav button {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.header-nav button:hover {
    background: rgba(255,255,255,0.25);
}

.header-nav button.active {
    background: white;
    color: var(--primary);
    font-weight: 600;
}

/* Container */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.125rem;
    margin-bottom: 16px;
    color: var(--text);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg);
}

/* Auth page */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.auth-card h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text);
}

.auth-card p {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 24px;
    font-size: 0.9375rem;
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 0.875rem;
    color: var(--text-light);
}

.auth-toggle a {
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Tags */
.tag {
    display: inline-block;
    padding: 4px 10px;
    background: #eff6ff;
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin: 2px;
}

/* Progress */
.progress-bar-wrapper {
    background: var(--border);
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    border-radius: 20px;
    transition: width 0.5s ease;
}

/* Tag card for progress */
.tag-card {
    cursor: pointer;
    transition: all 0.2s;
}

.tag-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.tag-card .tag-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.tag-card .tag-stats {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* Question card */
.question-card {
    position: relative;
}

.question-card .question-text {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.5;
}

.question-card .question-image {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 12px;
    max-height: 300px;
    object-fit: contain;
}

.question-card .answers-list {
    list-style: none;
}

.question-card .answer-item {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9375rem;
}

.question-card .answer-item:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

.question-card .answer-item.correct {
    border-color: var(--success);
    background: #f0fdf4;
    color: var(--success);
    font-weight: 600;
}

.question-card .answer-item.wrong {
    border-color: var(--danger);
    background: #fef2f2;
    color: var(--danger);
}

.question-card .answer-item.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Admin */
.admin-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-toolbar input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
}

.admin-toolbar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.question-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 1.25rem;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Answer builder */
.answer-builder {
    margin-bottom: 16px;
}

.answer-builder .answer-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.answer-builder .answer-row input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
}

.answer-builder .answer-row input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.answer-builder .answer-row label {
    font-size: 0.8125rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Tags select */
.tags-select {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tags-select .tag-option {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.2s;
    user-select: none;
}

.tags-select .tag-option.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Grid */
.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state .emoji {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 640px) {
    .header {
        padding: 0 16px;
    }

    .header h1 {
        font-size: 1rem;
        display: none;
    }

    .container {
        padding: 16px 12px;
    }

    .auth-card {
        margin: 16px;
        padding: 24px;
    }

    .tags-grid {
        grid-template-columns: 1fr;
    }

    .admin-toolbar {
        flex-direction: column;
    }
}

/* Checkbox styling */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Completed tag */
.tag-card.completed {
    border-left: 4px solid var(--success);
}

.tag-card.in-progress {
    border-left: 4px solid var(--warning);
}

.tag-card.not-started {
    border-left: 4px solid var(--border);
}

.tag-card.quiz-card {
    border-left: 4px solid var(--primary);
    background: linear-gradient(135deg, #f0f4ff 0%, #ffffff 100%);
}

.tag-card.quiz-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

/* Navigation indicator */
.nav-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.875rem;
    margin-bottom: 16px;
    padding: 6px 0;
    border: none;
    background: none;
    font-weight: 500;
}

.nav-back:hover {
    color: var(--primary);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Fullscreen Question */
.fullscreen-question {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
}

.fq-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.fq-counter {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.fq-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.fq-text {
    font-size: 1.4rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.5;
    color: var(--text);
}

.fq-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-bottom: 24px;
    object-fit: contain;
}

.fq-answers {
    list-style: none;
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fq-answer-item {
    padding: 16px 20px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    text-align: center;
}

.fq-answer-item:hover:not(.disabled) {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.fq-answer-item.correct {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
    color: #166534;
    font-weight: 600;
}

.fq-answer-item.wrong {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: #991b1b;
}

.fq-answer-item.disabled {
    pointer-events: none;
    opacity: 0.85;
}

.fq-footer {
    display: flex;
    justify-content: center;
    padding: 24px 0;
}

.fq-footer .btn {
    min-width: 180px;
    font-size: 1rem;
    padding: 12px 24px;
}

/* Paywall */
.paywall {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}

.paywall-card {
    text-align: center;
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
}

.paywall-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.paywall-card h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--text);
}

.paywall-card p {
    color: var(--text-light);
    margin-bottom: 24px;
    line-height: 1.6;
}

.paywall-price {
    margin-bottom: 28px;
}

.price-amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.price-period {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-left: 4px;
}

.paywall-expired {
    margin-top: 16px;
    font-size: 0.8125rem;
    color: var(--danger);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.1rem;
    border-radius: 12px;
}

@media (max-width: 640px) {
    .paywall-card {
        margin: 16px;
        padding: 32px 24px;
    }

    .price-amount {
        font-size: 2rem;
    }
}
