:root {
    --bg: #f7f5ff;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b6b85;
    --primary: #6c4ff6;
    --primary-dark: #5539e0;
    --accent: #ff8a5c;
    --success: #2fbf71;
    --error: #ff5c5c;
    --border: #e5e1f5;
    --shadow: 0 8px 24px rgba(108, 79, 246, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
}

[data-theme="dark"] {
    --bg: #14121f;
    --bg-card: #1e1b2e;
    --text: #f0eefb;
    --text-muted: #a29fc4;
    --primary: #8f7bff;
    --primary-dark: #7360f0;
    --border: #2c2843;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s, color 0.3s;
}

.site-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.2rem;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.1rem;
}

main {
    flex: 1;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

.site-footer {
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.site-footer a {
    color: var(--primary);
    text-decoration: none;
}

h1 {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

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

.field {
    margin-bottom: 18px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

input[type="text"], textarea, select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

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

.lang-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.lang-row select { flex: 1; }

.swap-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 20px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-box {
    background: rgba(255, 92, 92, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: none;
}

/* Flashcard */
.flashcard-wrap {
    perspective: 1200px;
    margin-bottom: 24px;
}

.flashcard {
    position: relative;
    width: 100%;
    min-height: 280px;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.flashcard.flipped { transform: rotateY(180deg); }

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid var(--border);
}

.card-back { transform: rotateY(180deg); }

.card-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 14px;
}

.card-word {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.card-translit {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 16px;
}

.card-example {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 12px;
    font-style: italic;
}

.card-note {
    margin-top: 14px;
    font-size: 0.85rem;
    background: rgba(108, 79, 246, 0.08);
    padding: 8px 12px;
    border-radius: 8px;
}

.flip-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.tts-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
    cursor: pointer;
    margin-top: 14px;
}

/* Quiz */
.quiz-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.quiz-box h3 { margin-top: 0; font-size: 1.05rem; }

.quiz-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.95rem;
}

.quiz-option.correct { border-color: var(--success); background: rgba(47, 191, 113, 0.12); }
.quiz-option.wrong { border-color: var(--error); background: rgba(255, 92, 92, 0.12); }

/* Share buttons */
.share-row {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.share-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff;
}

.share-whatsapp { background: #25d366; }
.share-telegram { background: #229ed9; }

.cta-box {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius);
    color: #fff;
    margin-top: 8px;
}

.cta-box h3 { margin-top: 0; }

.cta-box a {
    display: inline-block;
    margin-top: 10px;
    background: #fff;
    color: var(--primary-dark);
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 700;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

.views-badge {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 16px;
}
