* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* iOS: מסיר את ה-highlight האפור בלחיצה על כפתורים */
    -webkit-tap-highlight-color: transparent;
}

/* iOS: מסיר סטיילינג אוטומטי של Safari */
input[type="text"],
input[type="email"],
input[type="number"],
textarea,
select,
button {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0; /* Safari מעגל פינות אוטומטית */
}
/* שמירה על כדורים ב-radio ו-checkbox */
input[type="radio"]  { -webkit-appearance: radio;    appearance: auto; }
input[type="checkbox"] { -webkit-appearance: checkbox; appearance: auto; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    /* iOS: תמיכה ב-safe area (notch + home indicator) */
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.header #site-logo {
    margin-top: -15px;
    margin-bottom: 5px;
}

.header p {
    margin-top: -20px;
    font-size: 1em;
    opacity: 0.9;
}

.content {
    padding: 0 25px 25px;
}

.step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
}

.step {
    text-align: center;
    flex: 1;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 5px;
    font-weight: bold;
    font-size: 0.9em;
}

.step.active .step-number {
    background: #667eea;
    color: white;
}

.step.completed .step-number {
    background: #10b981;
    color: white;
}

.step-name {
    font-size: 0.9em;
    color: #666;
}

.main-content {
    min-height: 200px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 15px;
}

.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #fee;
    border: 1px solid #fcc;
    padding: 15px;
    border-radius: 8px;
    color: #c33;
    margin-bottom: 20px;
}

.success {
    background: #efe;
    border: 1px solid #cfc;
    padding: 15px;
    border-radius: 8px;
    color: #3c3;
    margin-bottom: 20px;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    align-items: center;
    justify-content: center;
}

.image-modal img {
    max-width: 95%;
    max-height: 95%;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(255,255,255,0.3);
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.image-modal-close:hover {
    color: #bbb;
}

/* ===== רספונסיביות למובייל ===== */

/* Step indicator — scroll אופקי במובייל */
@media (max-width: 600px) {
    body {
        padding: 8px;
    }
    .container {
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    }
    .header {
        padding: 14px 12px;
    }
    .header #site-logo svg {
        width: 240px;
        height: 48px;
    }
    .header p {
    margin-top: -20px;
        font-size: 0.85em;
    }
    .content {
        padding: 12px;
    }
    .step-indicator {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 2px;
        padding: 8px 4px;
        scrollbar-width: none;
    }
    .step-indicator::-webkit-scrollbar {
        display: none;
    }
    .step {
        min-width: 32px;
        flex-shrink: 0;
    }
    .step-number {
        width: 24px;
        height: 24px;
        font-size: 0.7em;
    }
    .step-name {
        font-size: 0.65em;
    }
    /* מסתיר את ה-step-indicator המקורי במובייל */
    .step-indicator {
        display: none !important;
    }
    .main-content {
        padding: 14px;
        margin-bottom: 10px;
    }
    .btn {
        padding: 12px 20px;
        font-size: 1em;
        width: 100%;
        min-height: 48px;
    }

    /* שלב 6 — עמודות → stack */
    .step7-layout {
        flex-direction: column !important;
    }
    .step7-panel {
        position: relative !important;
        top: auto !important;
        max-height: none !important;
        flex: none !important;
        max-width: 100% !important;
        width: 100% !important;
        margin-bottom: 16px !important;
    }
    .step7-writing {
        flex: none !important;
        width: 100% !important;
    }
    /* כפתור לפתיחת/סגירת הפאנל במובייל */
    .panel-toggle {
        display: block !important;
    }
    .step7-panel.collapsed {
        display: none !important;
    }

    /* שלב 7 — grid אינדיקטורים → עמודה אחת */
    .step8-indicators {
        grid-template-columns: 1fr !important;
    }

    /* Textarea — גובה מינימלי גדול יותר למובייל */
    textarea {
        min-height: 280px !important;
        font-size: 16px !important; /* מונע zoom ב-iOS */
    }
    /* M3: מונע zoom אוטומטי ב-iOS בכל שדות קלט */
    input[type="text"],
    input[type="email"],
    input[type="number"] {
        font-size: 16px !important;
    }

    /* כפתורים — רוחב מלא */
    .action-buttons {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .action-buttons button {
        width: 100% !important;
    }

    /* M2: Touch targets מינימום 44px */
    /* כפתורי פילטר שלב 1 */
    .q-filter {
        min-height: 44px !important;
        padding: 10px 16px !important;
        display: inline-flex !important;
        align-items: center !important;
    }
    /* checkbox ו-radio labels — שלב 5, שלב 4 AL */
    input[type="checkbox"] + label,
    input[type="radio"] + label,
    .concept-chip label {
        min-height: 44px !important;
        padding: 12px 16px !important;
        display: flex !important;
        align-items: center !important;
        box-sizing: border-box;
    }

    /* M7: כרטיסי שאלות — עמודה אחת */
    .questions-grid {
        grid-template-columns: 1fr !important;
    }

    /* M8: מפריד "|" — מוסתר במובייל */
    .filter-separator {
        display: none !important;
    }

    /* M9: כפתורי פועל הוראה — רוחב מלא, padding גדול */
    .verb-btn {
        width: 100% !important;
        padding: 14px 24px !important;
        font-size: 1.05em !important;
        min-height: 44px !important;
    }

    /* M10: radio labels פירוק שאלה — 44px מינימום */
    .decomp-label {
        min-height: 44px !important;
        padding: 10px 14px !important;
        align-items: center !important;
    }

    /* M12: concept chips — עמודה אחת, גדולים יותר */
    .concept-chip {
        width: 100% !important;
        min-height: 44px !important;
        border-radius: 10px !important;
        font-size: 0.97em !important;
        padding: 10px 16px !important;
    }

    /* M20: Paywall כרטיסי מחיר — עמודה אחת */
    #pw-content-student > div[style*="grid"],
    #pw-content-teacher > div[style*="grid"],
    #pw-content-school > div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }

    /* M13: skeleton wizard dots — גדולים יותר */
    .skel-dot {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.9em !important;
    }
    /* M13: back button — רוחב מלא במובייל */
    .skel-nav-back {
        width: 100% !important;
        max-width: 340px !important;
    }

    /* M14: textarea כתיבה — גובה מינימלי גדול יותר */
    #main-content textarea {
        min-height: 300px !important;
    }

    /* M15: feedback cards — font-size מינימום */
    .feedback-strength,
    .feedback-weakness {
        font-size: 0.92em !important;
    }

    /* M16: anchoring_check — word-break למובייל */
    .anchoring-row {
        word-break: break-word !important;
    }

    /* M17: lifeline accordion headers — touch target 44px */
    .lifeline-header {
        min-height: 44px !important;
        padding: 14px 18px !important;
    }

    /* M18: accordion שאלה+מקור — sticky במובייל */
    .question-accordion-wrap {
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        background: white !important;
        padding-top: 4px !important;
    }

    /* M19: source-touch-hint — גלוי רק במובייל */
    .source-touch-hint {
        display: inline !important;
    }

    /* M19: source-line — highlight בלחיצה */
    .source-line {
        display: inline;
        border-radius: 4px;
        transition: background 0.15s;
        cursor: pointer;
    }
    .source-line:active {
        background: #dbeafe;
    }
}

/* טאבלט */
@media (min-width: 601px) and (max-width: 768px) {
    body {
        padding: 12px;
    }
    .content {
        padding: 16px;
    }
    .step7-panel {
        flex: 0 0 35% !important;
        max-width: 35% !important;
    }
}

/* M19: hint העתקה — מוסתר בדסקטופ */
.source-touch-hint {
    display: none;
}

/* כפתור toggle — מוסתר בדסקטופ */
.panel-toggle {
    display: none;
    width: 100%;
    background: #f0f4ff;
    border: 1.5px solid #c7d2fe;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
    font-size: 0.92em;
    font-weight: bold;
    color: #667eea;
    cursor: pointer;
    text-align: center;
}

/* M6: טיימר במובייל — תחתית, safe-area לאייפון */
@media (max-width: 600px) {
    #timer-widget {
        top: auto !important;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        min-width: 70px !important;
        padding: 6px 10px !important;
        opacity: 0.9;
    }
}
/* Mobile progress bar — מוצג תמיד */
.mobile-progress {
    display: block;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 10px;
}
.mobile-progress-label {
    font-size: 0.92em;
    font-weight: bold;
    color: #374151;
    margin-bottom: 8px;
    text-align: center;
}
.mobile-progress-bar {
    background: #e5e7eb;
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
}
.mobile-progress-fill {
    background: linear-gradient(135deg, #667eea, #764ba2);
    height: 100%;
    border-radius: 20px;
    transition: width 0.5s ease;
}

/* TTS buttons hidden until Edge TTS implemented */
button[onclick*="_speakText"] { display:none !important; }
