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

:root {
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #f59e0b;
    --secondary-light: #fcd34d;
    --accent: #06b6d4;
    --accent-pink: #ec4899;
    --success: #10b981;
    --error: #ef4444;
    --bg: #fef3c7;
    --bg2: #ede9fe;
    --card: #ffffff;
    --text: #1e1b4b;
    --text-muted: #6b7280;
    --border: #e9d5ff;
    --radius: 20px;
    --shadow: 0 8px 32px rgba(124, 58, 237, 0.15);
    --shadow-btn: 0 4px 0 #5b21b6;
}

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg2) 50%, #fce7f3 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
}

.bg-shapes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.35;
}

.shape-1 {
    width: 280px; height: 280px;
    background: var(--secondary-light);
    top: -80px; right: -60px;
    animation: float 8s ease-in-out infinite;
}

.shape-2 {
    width: 200px; height: 200px;
    background: var(--accent);
    bottom: 10%; left: -50px;
    animation: float 10s ease-in-out infinite reverse;
}

.shape-3 {
    width: 150px; height: 150px;
    background: var(--accent-pink);
    top: 40%; left: 60%;
    animation: float 7s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
}

.app-header {
    text-align: center;
    padding: 1.25rem 0 0.75rem;
}

.logo-badge {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
    animation: bounce 2s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.app-header h1 {
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.header-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.progress-wrap {
    background: rgba(255,255,255,0.7);
    border-radius: 999px;
    height: 14px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 2px solid var(--border);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--accent-pink), var(--primary));
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(.4,0,.2,1);
    width: 0%;
}

.step-indicator {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
}

.quiz-main {
    flex: 1;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1rem, 4vw, 2rem);
    margin: 0.75rem 0;
    border: 3px solid var(--border);
}

.quiz-footer {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 1rem;
}

.step-title {
    font-size: clamp(1.1rem, 3.5vw, 1.35rem);
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-weight: 800;
}

.step-desc {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 1rem;
    font-family: inherit;
    background: #faf5ff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.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(124, 58, 237, 0.2);
}

.range-group { padding: 0.5rem 0; }

.range-value {
    text-align: center;
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

input[type="range"] {
    width: 100%;
    height: 12px;
    accent-color: var(--primary);
    cursor: pointer;
}

.options-group {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.options-group-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #faf5ff;
    min-height: 52px;
}

.option-item:hover {
    border-color: var(--primary-light);
    background: #f3e8ff;
    transform: translateY(-1px);
}

.option-item:has(input:checked) {
    border-color: var(--primary);
    background: linear-gradient(135deg, #f3e8ff, #fce7f3);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.option-item-image {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
}

.option-item-image input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
}

.option-item-image label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    width: 100%;
}

.option-item-image:has(input:checked) {
    border-color: var(--secondary);
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.opt-num {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    background: #ede9fe;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
    margin-top: 0.3rem;
    accent-color: var(--primary);
    flex-shrink: 0;
    width: 20px; height: 20px;
}

.option-item label {
    cursor: pointer;
    flex: 1;
    font-weight: 500;
}

.grouped-option {
    border: 2px solid var(--border);
    border-radius: 14px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.grouped-option-header {
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, #ede9fe, #fce7f3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.grouped-children {
    padding: 0.5rem 1rem 0.75rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.child-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.875rem;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 999px;
    font-size: 0.875rem;
    cursor: pointer;
}

.child-chip:has(input:checked) {
    background: #f3e8ff;
    border-color: var(--primary);
    font-weight: 600;
}

.question-card {
    margin-bottom: 1.75rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #faf5ff 0%, #fff 100%);
    border-radius: 16px;
    border: 2px solid var(--border);
}

.question-card:last-child { margin-bottom: 0; }

.question-text {
    font-weight: 700;
    margin-bottom: 1rem;
    font-size: 1.05rem;
    line-height: 1.8;
}

.code-preview {
    background: #1e1b4b;
    color: #e0e7ff;
    padding: 1rem;
    border-radius: 12px;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.question-img {
    max-width: 100%;
    width: 100%;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 2px solid var(--border);
}

.option-img {
    max-width: 100%;
    width: 100%;
    height: auto;
    max-height: 180px;
    object-fit: contain;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border-radius: 14px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
    min-height: 48px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    color: #fff;
    box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #5b21b6;
}

.btn-primary:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #5b21b6;
}

.btn-outline {
    background: #fff;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: #faf5ff;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.875rem; font-size: 0.875rem; min-height: auto; }

.alert {
    padding: 0.875rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--error);
    border: 2px solid #fecaca;
}

.success-screen {
    text-align: center;
    padding: 2rem 0;
}

.success-icon {
    font-size: clamp(3rem, 12vw, 5rem);
    margin-bottom: 1rem;
    animation: bounce 1s ease infinite;
}

.success-screen h2 {
    color: var(--primary);
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    margin-bottom: 0.5rem;
}

.other-input {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
}

.test-header {
    background: linear-gradient(135deg, #ede9fe, #fce7f3);
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    border: 2px solid var(--border);
}

.test-header h3 {
    color: var(--primary);
    font-weight: 800;
}

/* ─── Admin ─── */
.admin-body {
    background: linear-gradient(135deg, #f8fafc, #ede9fe);
    min-height: 100vh;
}

.login-box {
    position: relative;
    z-index: 1;
    max-width: 420px;
    margin: 3rem auto;
    background: var(--card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 3px solid var(--border);
}

.login-box h1 {
    text-align: center;
    color: var(--primary);
    font-weight: 800;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
}

.admin-header {
    background: var(--card);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    box-shadow: var(--shadow);
    border-bottom: 3px solid var(--border);
}

.admin-header h1 {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: var(--primary);
    font-weight: 800;
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.admin-main {
    max-width: 960px;
    margin: 1.5rem auto;
    padding: 0 0.75rem 2rem;
}

.results-count {
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-weight: 600;
}

.results-table-wrap {
    overflow-x: auto;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 2px solid var(--border);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.results-table th,
.results-table td {
    padding: 0.875rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.results-table th {
    background: linear-gradient(135deg, #ede9fe, #fce7f3);
    font-weight: 700;
    color: var(--primary);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.detail-section {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: 1.25rem;
    border: 2px solid var(--border);
}

.detail-section h2 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 800;
    border-bottom: 2px dashed var(--border);
    padding-bottom: 0.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.info-grid > div {
    background: #faf5ff;
    padding: 0.75rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.answer-block {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #faf5ff;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.page-block h3 {
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.field-row {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border);
}

.field-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.field-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.field-value { font-weight: 600; }

.picked-list {
    list-style: none;
    padding: 0;
}

.picked-list li {
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.muted { color: var(--text-muted); font-weight: 400; }

.question-block h4 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.q-number {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.625rem;
}

.option-card {
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.option-card.user-pick {
    border-color: var(--primary);
    background: #f3e8ff;
}

.option-card.is-correct {
    border-color: var(--success);
    background: #ecfdf5;
}

.option-card.is-wrong {
    border-color: var(--error);
    background: #fef2f2;
}

.option-card.user-pick.is-correct {
    border-color: var(--success);
    background: #d1fae5;
}

.option-card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.option-letter {
    background: #ede9fe;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

.option-text {
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.option-img-lg {
    max-width: 100%;
    width: 100%;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
}

.badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
}

.badge-user { background: var(--primary); color: #fff; }
.badge-correct { background: var(--success); color: #fff; }

.warn-note {
    margin-top: 0.5rem;
    color: var(--error);
    font-size: 0.85rem;
    font-weight: 600;
}

.code-block {
    background: #1e1b4b;
    color: #e0e7ff;
    padding: 1rem;
    border-radius: 10px;
    direction: ltr;
    text-align: left;
    font-size: 0.82rem;
    margin-bottom: 0.75rem;
    overflow-x: auto;
}

.score-line {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.score-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
    color: #78350f;
    font-weight: 800;
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.95rem;
}

.test-block {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 3px dashed var(--border);
}

.test-block:last-child { border-bottom: none; }

.test-block h3 {
    color: var(--primary);
    font-weight: 800;
    margin-bottom: 0.5rem;
}

/* ─── Mobile ─── */
@media (max-width: 600px) {
    .app-container { padding: 0.5rem; }
    .quiz-main { padding: 1rem; border-radius: 16px; }
    .quiz-footer { flex-direction: column-reverse; gap: 0.5rem; }
    .btn { width: 100%; }
    .options-group-images { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .option-img { max-height: 140px; }
    .question-card { padding: 1rem; }
    .admin-header { flex-direction: column; align-items: flex-start; }
    .options-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
    .options-group-images { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
}
