/* =========================
   THEME: CLEAN (RTL-READY)
   ========================= */

/* ——— פונט ——— */
@font-face {
  font-family: 'NarkissTam';
  src: url('/assets/fonts/NarkissTam-Semibold.otf') format('opentype');
  font-weight: 600; /* Medium */
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'NarkissTam';
  src: url('/assets/fonts/NarkissTam-Bold.otf') format('opentype');
  font-weight: 700; /* Bold */
  font-style: normal;
  font-display: swap;
}


html, body {
  font-family: 'NarkissTam', system-ui, sans-serif;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
}

/* ——— משתנים ——— */
:root{
  /* צבעי בסיס נקיים (כמו ctrl.xyz) */
  --bg-page: #f8f8f8;
  --bg-card: #eceeeb;
  --stroke: #e5e7eb;
  --ink: #111827;
  --ink-muted: #6b7280;

  /* צבעי מותג מודרניים */
  --primary: #eceeeb;
  --primary-hover: #d3d7d3;
  --primary-light: #eff6ff;
  
  --success: #059669;
  --success-light: #ecfdf5;
  
  --warning: #d97706;
  --warning-light: #fffbeb;
  
  --danger: #dc2626;
  --danger-light: #fef2f2;

  /* צבעי אינטראקציה */
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: #f3f4f6;

  /* צללים עדינים יותר */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 0px 0px rgba(0,0,0,.05);
  --shadow-md: 0 0px 0px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 0px 0px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

  /* גדלים */
  --container-w:1200px;
  --test-card-h: 400px; /* גובה כרטיסייה במבחן (שנה כאן לפי הצורך) */
  --qa-box-h: 400px; /* גובה ברירת מחדל – אפשר לשנות במקום אחד */
  /* Cloze tokens width */
  --cloze-min-w: 60px; /* רוחב מינימלי עיקרי ל-Cloze */
  
  /* גובהי שאלות ותשובות במבחן */
  --question-h: 120px;
  --answer-h: 320px;

  /* צבעי מצב ישנים - לתאימות לאחור */
  --blue-50: var(--primary-light);
  --blue-200: var(--primary-light);
  --blue-700: var(--primary);
}

/* ====== Reset עדין ====== */
*{ box-sizing:border-box; }
html,body{
  margin:0; padding:0;
  background:var(--bg-page); color:var(--ink);
}

/* ====== טיפוגרפיה מודרנית ====== */
h1, h2, h3 { 
  margin:0; 
  font-weight:700; 
  letter-spacing:-.025em; 
  line-height:1.2;
  color:var(--ink);
}

h1 { 
  font-size:24px; 
  font-weight:800;
}

h2 { 
  font-size: 21px; 
}

h3 { 
  font-size:18px; 
}

/* ====== Layout כללי ====== */
.container{ 
  max-width:var(--container-w); 
  padding:32px 20px; 
  margin:0 auto; 
}
main.container{ min-height:100dvh; }

/* ====== טופ-בר משופר ====== */
.topbar{ 
  display:flex; 
  justify-content:space-between; 
  align-items:center; 
  margin-bottom:40px;
  padding:0 0 15px 0;
  /* border-bottom:1px solid var(--stroke); */
}
.topbar h1{ 
  margin:0; 
  font-size: 28px; 
  font-weight:800; 
  letter-spacing:-.03em;
  color:var(--ink);
}
.nav{ 
  background: var(--bg-card);
  display:flex; 
  align-items: center;
  padding: 8px 12px;
  --nav-gap: 12px;
  gap: var(--nav-gap);
  flex-wrap:wrap; 
  border-radius: var(--radius-md);
}

/* separators between nav buttons - theme controlled */
.nav .btn{ position: relative; }
.nav .btn + .btn{ position: relative; /* dot lives inside the gap */ }
.nav .btn + .btn::before{
  content:"·";
  position:absolute;
  inset-inline-start: calc(var(--nav-gap) / -2); /* centered within the gap between buttons */
  top:50%; transform:translateY(-50%);
  font-size: 18px; line-height: 1;
  color: var(--ink-muted);
  pointer-events: none; user-select: none;
}
/* Tight screens: drop separators for breathing room */
@media (max-width: 520px){
  .nav{ --nav-gap: 8px; gap: var(--nav-gap); }
  .nav .btn + .btn{ padding-inline-start: 0; margin-inline-start: 0; }
  .nav .btn + .btn::before{ display:none; }
}

/* Hamburger button */
.hamburger, .backbtn{ 
  display:none; 
  width:36px; height:36px; 
  align-items:center; justify-content:center; 
  border:1px solid var(--stroke); 
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--ink);
  padding:0; margin:0;
}
.hamburger svg, .backbtn svg{ width:22px; height:22px; display:block; }

/* Mobile nav behavior */
@media (max-width: 720px){
  .topbar{ position: relative; }
  .topbar .hamburger{ display:inline-flex; }
  .topbar .backbtn{ display:inline-flex; }
  .topbar > .nav{ display:none; }
  .topbar.menu-open > .nav{ 
    display:flex; flex-direction: column; gap:10px; 
    position:absolute; top:100%; inset-inline-start:0; width:100%; 
    background:#fff; border:1px solid var(--stroke); border-radius: var(--radius-md); 
    box-shadow: var(--shadow);
    padding:10px; z-index:200;
  }
  .topbar.menu-open > .nav .btn{ justify-content:flex-start; }
  /* Test header: hide desktop back button group on mobile */
  .test-header .test-controls{ display:none; }
}

/* ====== כפתורים מודרניים ====== */
.btn{
  font-size: 13px;
  display:inline-flex; align-items:center; justify-content:center;
  gap:8px; cursor:pointer; text-decoration:none;
  border:none;
  border-radius:var(--radius-lg); 
  padding:6px 10px;
  /* background:var(--primary);  */
  color:rgb(0, 0, 0);
  font-weight:600;
  transition:all .15s ease;
}
.btn:hover{ 
  background:var(--primary-hover);
}
.btn:active{ 
  transform:translateY(0); 
}

/* סוגי כפתורים */
.btn.secondary{
  background:var(--bg-card); 
  color:var(--ink);
  border:1px solid var(--stroke);
  box-shadow:var(--shadow);
}
.btn.secondary:hover{ 
  background:var(--bg-page);
  border-color:var(--primary);
}

.btn.ghost{ 
  background:transparent; 
  color:var(--ink-muted);
  border:1px solid var(--stroke); 
  box-shadow:none;
}
.btn.ghost:hover{ 
  background:var(--bg-page);
  color:var(--ink);
}

.btn.danger{ 
  background:var(--danger); 
  color:white;
}
.btn.danger:hover{ 
  background:#dc2626;
}

.btn.success{
  background:var(--success);
  color:white;
}
.btn.success:hover{
  background:#059669;
}

.btn.small{ 
  padding:8px 14px; 
  font-size:13px; 
  border-radius:var(--radius-md);
}

.btn.icon{ 
  padding:8px; 
  width:40px; 
  height:40px; 
  border-radius:var(--radius-md);
}

/* ====== כפתורי אייקון מקצועיים ====== */
.icon-btn{
  width:28px; height:28px; border-radius:6px; display:inline-flex; align-items:center; justify-content:center;
  background:transparent; border:1px solid var(--stroke); color:inherit; cursor:pointer;
  transition:background .12s ease;
}
.icon-btn:hover{ background:#fafafd; }
.icon-btn:disabled{ opacity:0.7; cursor:not-allowed; }
.icon-btn.processing{ opacity:0.7; cursor:not-allowed; pointer-events:none; }
.icon-btn svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.6; pointer-events:none; }
.icon-btn.danger{ border-color:#f2c6c6 !important; color:#a40000 !important; }
.icon-btn.danger:hover{ background:#fff2f2; }
.icon-btn.danger:disabled{ border-color:#f2c6c6 !important; color:#a40000 !important; opacity:0.7; cursor:not-allowed; }
.icon-btn.danger.processing{ border-color:#f2c6c6 !important; color:#a40000 !important; opacity:0.7; cursor:not-allowed; pointer-events:none; }

/* ====== רשת מודרנית עם רווחים גדולים ====== */
.grid{ 
  display:grid; 
  gap:32px; 
  grid-template-columns:repeat(3,1fr); 
  margin-top:32px;
}
@media (max-width:1000px){ 
  .grid{ 
    grid-template-columns:repeat(2,1fr); 
    gap:24px;
  } 
}
@media (max-width:560px){ 
  .grid{ 
    grid-template-columns:1fr; 
    gap:20px;
  } 
}

/* ====== מבנה קטגוריות ותת-קטגוריות ====== */
.category-card{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.title{
  font-size:20px;
  font-weight:700;
  color:var(--ink);
  text-decoration:none;
  line-height:1;
  letter-spacing: -0.025em;
  transition:all .2s ease;
}

/* תת-קטגוריות */
.subcategories{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.subcard{
  background: var(--bg-card);
  /* border:1px solid var(--stroke); */
  border-radius:8px;
  padding:8px 12px;
  transition:background .2s ease;
  position:relative;
  display:flex;
  align-items:center;
  gap:12px;
}

.subcard:hover{
  transform:none;
  box-shadow:none;
}

.subcard-main{
  flex:1;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.subcard-title{
  font-size:14px;
  font-weight:500;
  color:var(--ink);
  text-decoration:none;
  line-height:1.4;
}

.subcard-title:hover{
  opacity:0.7;
}

.subcard-actions{
  display:flex;
  align-items:center;
  gap:4px;
  position:relative;
}

/* ====== כרטיסיות צבעוניות (כמו בתמונה) ====== */
.card{
  position:relative; 
  overflow:visible;
  background:#9dc4f5; /* כחול בהיר כברירת מחדל */
  border:none;
  border-radius:24px;
  padding: 16px 20px;
  display:flex; 
  flex-direction:column; 
  gap:20px;
  min-height:100px;
  justify-content: space-between;
  transition:all .2s ease;
}

/* צבעים מותאמים אישית או מחזוריים */
.card[data-color="pink"] { background: #ffcadc; } /* ורוד עדין */
.card[data-color="yellow"] { background: #fbe74e; } /* צהוב */
.card[data-color="blue"] { background: #9dc4f5; } /* כחול בהיר */
.card[data-color="green"] { background: #c2ddc2; } /* ירוק עדין */
.card[data-color="red"] { background: #ed6f60; } /* אדום */

/* גיבוי - צבעים מוצקים כמו בתמונה (למקרה שאין data-color) */
.card:nth-child(5n+1):not([data-color]) { background: #ffcadc; } /* ורוד עדין */
.card:nth-child(5n+2):not([data-color]) { background: #fbe74e; } /* צהוב */
.card:nth-child(5n+3):not([data-color]) { background: #9dc4f5; } /* כחול בהיר */
.card:nth-child(5n+4):not([data-color]) { background: #c2ddc2; } /* ירוק עדין */
.card:nth-child(5n+5):not([data-color]) { background: #ed6f60; } /* אדום */

.card{ outline-offset: -2px; /* keep non-empty; no visual change unless outlined */ }
.card .bg{ display:none; }

.card-top{
  display:flex; 
  align-items:flex-start; 
  justify-content:space-between;
  gap:16px;
}
.card-top-left{ 
  display:flex; 
  align-items: center; 
  gap:8px; 
  flex:1;
  min-width:0;
}

/* תגית גדולה עם טקסט שחור */
.card .title a{
  color:black;
  text-decoration:none;
  font-weight:700;
  font-size:24px;

  display:inline-block;
  transition:all .2s ease;
}
.card .title a:hover{
  opacity:0.7;
}

/* אייקון גדול יותר */
.iconwrap{
  /* width:48px; 
  height:48px;  */
  border-radius:50%; 
  border:none; 
  background:transparent;
  display:flex; 
  align-items:center; 
  justify-content:center; 
  box-shadow:none;
  flex-shrink:0;
}
.iconwrap img, .iconwrap svg{ 
  width:32px; 
  height:32px; 
  opacity:1;
  color:black;
  filter:none;
}

/* נקודת צבע נסתרת */
.colordot{
  display:none;
}

/* כפתור תפריט יחיד */
.card .actions{
  display:flex; 
  gap:8px; 
  align-items:flex-start;
  flex-shrink:0;
  position:relative;
}

.card .menu-btn{ 
  background:rgba(0,0,0,0.1);
  border:none;
  color:black;
  width:24px;
  height:24px;
  border-radius:20%;
  cursor:pointer;
  transition:all .2s ease;
  display:flex;
  align-items:center;
  justify-content:center;
}
.card .menu-btn svg{
  width:20px;
  height:20px;
  fill:currentColor;
}
.card .menu-btn:hover{
  background:rgba(0,0,0,0.2);
}

/* תפריט נפתח */
.card .menu-dropdown{
  position:absolute;
  top:calc(100% + 4px);
  right:0;
  background:white;
  border:1px solid var(--stroke);
  border-radius:8px;
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
  padding:4px;
  display:none;
  z-index:1000;
  width:auto;
  overflow:visible;
}
.card .menu-dropdown a,
.card .menu-dropdown button{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:0;
  padding:6px;
  border-radius:20%;
  cursor:pointer;
  transition:background .2s ease;
  color:var(--ink);
  text-decoration:none;
  border:none;
  background:none;
  width:24px;
  height:24px;
}
.card .menu-dropdown a svg,
.card .menu-dropdown button svg{
  width:16px;
  height:16px;
  flex-shrink:0;
}
.card .menu-dropdown a:hover,
.card .menu-dropdown button:hover{
  background:var(--bg-page);
}
.card .menu-dropdown .danger{
  color:var(--danger);
}
.card .menu-dropdown .danger:hover{
  background:var(--danger-light);
}

/* תפריטים של תת-קטגוריות - כפתורים קטנים */
.subcard .menu-dropdown{
  padding:2px;
  min-width:80px;
}

.subcard .menu-dropdown a,
.subcard .menu-dropdown button{
  width:20px;
  height:20px;
  padding:2px;
  border-radius:3px;
}

.subcard .menu-dropdown a svg,
.subcard .menu-dropdown button svg{
  width:8px;
  height:8px;
}

/* שורה תחתונה - רק כפתור מבחן */
.card-bottom{ 
  display: flex; 
  align-items: center; 
  justify-content: flex-end;
}

/* הסתרת המידע רק בעמוד הראשי */
.template-flashcards .card .sub{ 
  display:none;
}

/* כפתור מבחן גדול יותר במרכז רק בעמוד הראשי */
.template-flashcards .card .card-bottom .icon-btn{ 
  background:rgba(255,255,255,0.3);
  border:none;
  color:black;
  width:40px;
  height:40px;
  border-radius:10%;
  transition: all .2s ease;
}
.template-flashcards .card .card-bottom .icon-btn:hover{
  background:rgba(255,255,255,0.5);
  transform:scale(1.1);
}

/* עריכה inline על רקע לבן */
.card .editrow{
  background:rgba(255,255,255,0.95);
  border-radius:16px;
  padding:16px;
  backdrop-filter:blur(10px);
  display:none;
  flex-direction:column;
  gap:12px;
}

.card .editrow.show{
  display:flex;
}

.edit-field{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.edit-field label{
  font-size:12px;
  font-weight:600;
  color:var(--ink-muted);
}

.edit-field input,
.edit-field select{
  background:white;
  border:1px solid var(--stroke);
  border-radius:8px;
  padding:8px 12px;
  color:var(--ink);
  font-size:14px;
  transition: all 0.2s ease;
}

.edit-field select {
  /* הסתרת החץ הברירת מחדל ברק ב-edit-field */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  padding: 8px 32px 8px 12px; /* מקום לחץ */
  cursor: pointer;
  
  /* חץ מותאם אישית */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: left 8px center;
  background-size: 14px;
}

.edit-field input:focus,
.edit-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(236, 238, 235, 0.1);
}

.edit-actions{
  display:flex;
  gap:8px;
  margin-top:8px;
}

/* בוחר צבעים */
.color-picker{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.color-option{
  width:32px;
  height:32px;
  border-radius:50%;
  border:2px solid transparent;
  cursor:pointer;
  transition:all .2s ease;
  position:relative;
}

.color-option:hover{
  transform:scale(1.1);
  border-color:var(--ink-muted);
}

.color-option.selected{
  border-color:var(--ink);
  transform:scale(1.1);
}

.color-option.selected::after{
  content:'✓';
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  color:var(--ink);
  font-weight:bold;
  font-size:14px;
}

/* בוחר אייקונים */
.icon-picker{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  max-height:120px;
  overflow-y:auto;
}

.icon-option{
  width:40px;
  height:40px;
  border:2px solid var(--stroke);
  border-radius:8px;
  cursor:pointer;
  transition:all .2s ease;
  display:flex;
  align-items:center;
  justify-content:center;
  background:white;
}

.icon-option:hover{
  border-color:var(--ink-muted);
  transform:scale(1.05);
}

.icon-option.selected{
  border-color:var(--primary);
  background:var(--primary-light);
}

.icon-option img{
  width:24px;
  height:24px;
  object-fit:contain;
}

.icon-option span{
  font-size:10px;
  color:var(--ink-muted);
  text-align:center;
}

/* ====== עריכה אינליין בכרטיס ====== */
.editrow{
  display:none; grid-column:1/-1; position:relative; z-index:3;
  margin-top:6px; padding-top:12px; border-top:1px dashed var(--stroke);
  gap:8px; align-items:center; flex-wrap:wrap;
}
.editrow.show{ display:flex; }
.editrow input[type=text]{
  border:1px solid var(--stroke); background:#fff; border-radius:10px; padding:8px 10px; min-width:220px;
}

/* ====== פאנלים/קופסאות מידע ====== */
.panel{
  /* border:1px solid var(--stroke); */
   border-radius:var(--radius-lg); padding:16px; background:var(--bg-card);
  box-shadow:var(--shadow); margin-bottom:16px;
}
@media (max-width: 768px){
  .stats-panel{ padding:8px; margin-bottom:12px; }
  .stats-panel .row{ gap:6px; }
  .stats-panel .kpi{ padding:3px 6px; border-radius:8px; font-size:13px; }
  .stats-panel .kpi strong{ font-size:14px; }
}
.row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.kpi{
  display:flex; gap:8px; align-items:center;
  border-radius:10px; padding:6px 10px; background:#fff;
}

/* ====== פיקרים (צבעים/אייקונים) ====== */
.picker{ display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.grad{
  width:36px; height:24px; border:1px solid var(--stroke); border-radius:6px;
  cursor:pointer; background:#eee;
}
.grad.selected{ outline:2px solid #000; }
.svgopt{
  width:36px; height:36px; border:1px solid var(--stroke); border-radius:8px; background:#fff;
  display:flex; align-items:center; justify-content:center; cursor:pointer; box-shadow:inset 0 0 0 1px var(--stroke);
}
.svgopt.selected{ outline:2px solid #000; }
.svgopt svg{ width:20px; height:20px; }

/* ====== חיפוש וצ'יפים (רשות) ====== */
.searchbar{
  display:flex; align-items:center; gap:8px;
  background:var(--bg-card); border:1px solid var(--stroke);
  box-shadow:var(--shadow); border-radius:999px; padding:10px 14px; margin:12px 0 20px 0;
}
.searchbar input{
  border:0; outline:0; background:transparent; width:100%;
  font-size:15px; color:var(--ink);
}

.chips{ display:flex; gap:10px; overflow:auto; padding-bottom:4px; }
.chip{
  display:inline-flex; align-items:center; gap:8px;
  color:#fff; font-weight:700; letter-spacing:.01em;
  border-radius:999px; padding:8px 14px; white-space:nowrap;
  box-shadow:var(--shadow); border:0; background:#7c3aed;
}
.chip .ico{ width:18px; height:18px; display:inline-flex; align-items:center; justify-content:center; }

/* ====== טפסים כלליים ====== */
.field{ display:grid; gap:8px; margin-bottom:14px; }
label{ font-weight:600; }
input[type="text"], input[type="number"], textarea{
  border:1px solid var(--stroke); border-radius:10px; padding:10px; background:#fff; color:var(--ink);
}
textarea{ min-height:120px; }

/* ====== Utilities ====== */
.muted{ color:var(--ink-muted); }
.hidden{ display:none !important; }

/* ====== כיווניות ====== */
html[dir="rtl"] .grid{ direction:rtl; }

/* =========================================================
   TEST PAGE (test.php)
   ========================================================= */
.test-header { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.test-controls { display:flex; gap:8px; flex-wrap:wrap; }
.test-info { 
  color: var(--ink-muted); 
  font-size:13px; 
  display:flex; 
  gap:12px; 
  flex-wrap:wrap; 
  justify-content: space-between; 
  margin-bottom: 12px; /* Added gap between test-info and progress bar */
}
.test-deck {
   border-radius:16px; padding:16px;
  background: var(--bg-card); box-shadow: var(--shadow);
}
.card-stage { display:grid; gap:12px; }

.test-card{
  position:relative;
  border:0;
  border-radius:0;
  padding:0;
  background:transparent;
  display:block;
  text-align:inherit;
  cursor:default;
  user-select:text; /* אפשור בחירת טקסט */
  min-height: 400px; /* גובה מינימלי קבוע לשמירת פרופורציות */
}

.test-card .face {
  height: 100%;
  width: 100%;
  overflow: auto;              /* גלילה פנימית כשצריך */
  display: flex;
  align-items: flex-start;     /* שינוי מ-center ל-flex-start */
  justify-content: center;
  line-height: 1.6;
  padding: 20px 0;            /* הוספת padding למעלה ולמטה */
}

.test-card .face > * {
  width: 100%;
}

/* כללים ספציפיים לתוכן בתוך .face */
.test-card .face .answer-display,
.test-card .face #aHtml {
  width: 100%;
  text-align: right;
}

/* אל תכפה display:block על אלמנטים – נאפשר לתוכן מהעורך לשמור על התצוגה המקורית */

/* תמונות בתוכן המבחן */
#qHtml img, #aHtml img, .answer-display img, .question-section img {
  /* הצגת תמונות כמו שצריך */
  max-width: 100% !important;
  height: auto !important;
  border-radius: 4px !important;
  /* משפרות את הצגת התמונה */
  object-fit: contain !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
  /* שמירה על הסגנונות המקוריים מהעורך */
}

/* תמיכה ב-figure elements מ-CKEditor */
#qHtml figure, #aHtml figure, .answer-display figure, .question-section figure {
  /* שמירה על הסגנונות המקוריים של figure */
  max-width: 100% !important;
}

/* כיתוב תמונה (caption) מתחת לתמונות כמו בעורך */
#qHtml figcaption, #aHtml figcaption, .answer-display figcaption, .question-section figcaption {
  font-size: 0.9em;
  color: var(--ink-muted);
  text-align: center;
  margin-top: 6px;
}

/* תמונות בצד ימין (image-style-side) - כבוד לגדלים של המשתמש */
#qHtml figure.image-style-side, #aHtml figure.image-style-side, 
.answer-display figure.image-style-side, .question-section figure.image-style-side {
  float: right !important;
  margin: 0 0 16px 16px !important;
  clear: both !important;
  /* אל תעקוף את הגדלים - תן למשתמש לקבוע */
}

/* וודא שהתמונות בתוך figure.image-style-side מותאמות נכון (כבוד לרוחב מהעורך) */
#qHtml figure.image-style-side img, #aHtml figure.image-style-side img,
.answer-display figure.image-style-side img, .question-section figure.image-style-side img {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
}

/* תמונות במרכז (image-style-block) */
#qHtml figure.image-style-block, #aHtml figure.image-style-block,
.answer-display figure.image-style-block, .question-section figure.image-style-block {
  display: block !important;
  margin: 16px auto !important;
  text-align: center !important;
}

/* תמונות inline */
#qHtml figure.image-style-inline, #aHtml figure.image-style-inline,
.answer-display figure.image-style-inline, .question-section figure.image-style-inline {
  display: inline-block !important;
  margin: 0 8px !important;
}

/* clearfix לאחרי אלמנטים עם תמונות מרחפות */
#qHtml:after, #aHtml:after, .answer-display:after, .question-section:after {
  content: "";
  display: table;
  clear: both;
}

.test-card .face .answer-display ul,
.test-card .face .answer-display ol,
.test-card .face #aHtml ul,
.test-card .face #aHtml ol {
  display: block !important;
  list-style-position: inside;
}

.test-card .face .answer-display li,
.test-card .face #aHtml li {
  display: list-item !important;
  margin-bottom: 4px;
}

.test-card .face .answer-display span,
.test-card .face #aHtml span {
  display: inline !important;
}

/* עיצוב נכון לפסקאות בשאלות */
.test-card .face p {
  margin: 0 0 12px 0;
}

.test-card .face p:last-child {
  margin-bottom: 0;
}

.test-card .face br {
  display: block;
  margin-bottom: 8px;
}

.test-card .face ul, .test-card .face ol {
  margin: 8px 0;
  padding-right: 20px;
  text-align: right;
  display: block;
}

.test-card .face li {
  margin-bottom: 4px;
  display: list-item;
  text-align: right;
}

.test-card .face h1, .test-card .face h2, .test-card .face h3, 
.test-card .face h4, .test-card .face h5, .test-card .face h6 {
  margin: 16px 0 8px 0;
}

.test-card .face blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-right: 4px solid var(--blue-200);
  background: var(--blue-50);
}

.test-card .answer { display:none; }
.test-card.revealed .answer { display:block; }
.test-card.revealed .question { display:none; }
.test-actions {
  display:flex; gap:8px; flex-wrap:wrap; justify-content:center; margin-top:8px;
}
.test-actions .btn { min-width:90px; }
.test-nav { display:flex; align-items:center; justify-content:space-between; margin-top:10px; }

/* ===== עיצוב לכרטיסיות Flipcard (מערכת ישנה) ===== */
.flipcard {
  min-height: 400px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: right !important; /* יישור לימין */
  direction: rtl !important; /* כיוון RTL */
  cursor: pointer;
  user-select: text;
  line-height: 1.6;
  transition: transform 0.2s ease;
}

.flipcard:hover {
  transform: translateY(-2px);
}

.flipcard > div {
  width: 100%;
  text-align: right !important; /* יישור התוכן לימין */
  direction: rtl !important;
}

/* תמונות בתוך flipcard */
.flipcard img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 4px !important;
  object-fit: contain !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}

/* תמונות בצד ימין בתוך flipcard - כבוד לגדלים של המשתמש */
.flipcard figure.image-style-side {
  float: right !important;
  margin: 0 0 16px 16px !important;
  clear: both !important;
  /* אל תעקוף את הגדלים - תן למשתמש לקבוע */
}

/* וודא שהתמונות בתוך flipcard figure.image-style-side מותאמות נכון (לא לעקוף inline width) */
.flipcard figure.image-style-side img {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
}

/* תמונות במרכז בתוך flipcard */
.flipcard figure.image-style-block {
  display: block !important;
  margin: 16px auto !important;
  text-align: center !important;
}

/* clearfix לאחרי flipcard */
.flipcard:after {
  content: "";
  display: table;
  clear: both;
}

/* ===== Separated Q&A Layout ===== */
.qa-container {
  height: 620px; /* גובה קבוע */
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

/* הכרטיס מתפרס על כל הגובה */
.qa-container .test-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* אזור השאלה - 30% מהגובה */
.qa-container .question-section {
  height: 20%; /* 30% מ-620px = 186px */
  flex-shrink: 0;
  overflow: auto;
  padding: 16px;
  /* מרכז את תוכן השאלה מבלי לשנות את יישור הטקסט */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* אזור התשובה - 70% מהגובה */
.qa-container .interaction-area {
  height: 70%; /* 70% מ-620px = 434px */
  flex-shrink: 0;
  overflow: auto;
  /* מרכז את תיבות התשובה מבלי לשנות את יישור הטקסט */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.controls-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}

.controls-container .quality-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.controls-container .test-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
}

/* ===== Test page button theming (subtle, scoped) ===== */
.test-deck .btn:not(.quality-bad):not(.quality-mid):not(.quality-good){
  background:#fff;
  border:1px solid var(--stroke);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.test-deck .btn:not(.quality-bad):not(.quality-mid):not(.quality-good):hover{
  background: var(--bg-page);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.test-deck .btn:not(.quality-bad):not(.quality-mid):not(.quality-good):active{
  transform: translateY(0);
}
/* Make ghost buttons readable on test background */
.test-deck .btn.ghost{
  background:#fff;
  color: var(--ink);
}
/* True/False small refinement */
.tf-option{
  border:1px solid var(--stroke);
}
.tf-option:hover{ border-color: var(--primary); }
/* Focus ring for keyboard users */
.test-deck .btn:focus-visible{ outline:2px solid var(--primary); outline-offset:2px; }

/* Mobile tweaks for test page */
@media (max-width: 600px){
  .test-deck{ padding:12px; }
  .test-card{ min-height: 340px; }
  .test-card .face{ padding: 12px 0; }
  .controls-container{ padding: 10px; margin-top:12px; }
  .controls-container .test-nav{ 
    display:grid; grid-template-columns: auto 1fr auto; align-items:center; gap:8px; 
  }
  .controls-container #prev, .controls-container #next{ white-space:nowrap; padding:8px 10px; }
  .controls-container .quality-row{ justify-content:center; flex-wrap:nowrap; gap:8px; }
  .controls-container .quality-row .btn{ 
    flex:1 1 0; min-width:0; 
    padding:8px 10px; font-size:13px; 
  }
  /* Keep a real height so vertical centering still works on mobile */
  .qa-container .interaction-area{ height: 50שvh; min-height: 280px; }
}
@media (max-width: 360px){
  .test-card{ min-height: 300px; }
  .controls-container .quality-row{ gap:6px; }
  .controls-container .quality-row .btn{ padding:6px 8px; font-size:12px; }
}

/* ===== Interactive Question Areas ===== */
.question-section {
  user-select: text; /* אפשור בחירת טקסט בשאלות */
  line-height: 1.6;
}

/* עיצוב נכון לפסקאות בשאלות */
.question-section p {
  margin: 0 0 12px 0;
  text-align: right; /* ברירת מחדל ב־RTL; inline styles מהעורך יעקפו */
}

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

/* כיווניות RTL גלובלית לתוכן, מבלי לעקוף יישור שהמשתמש הגדיר בעורך */
#qHtml, #aHtml, .answer-display, .question-section {
  direction: rtl;
}

.question-section br {
  display: block;
  margin-bottom: 8px;
}

.question-section ul, .question-section ol {
  margin: 8px 0;
  padding-right: 20px;
  text-align: right;
}

.question-section li {
  margin-bottom: 4px;
}

.question-section h1, .question-section h2, .question-section h3, 
.question-section h4, .question-section h5, .question-section h6 {
  margin: 16px 0 8px 0;
}

.question-section blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-right: 4px solid var(--blue-200);
  background: var(--blue-50);
}

/* הסרתי את ההגדרה הישנה של interaction-area כיוון שיש חדשה יותר מוגדרת */

/* תיבות תשובה מרוכזות בתוך qa-container */
.qa-container .interaction-area .answer-display,
.qa-container .interaction-area .mc-options,
.qa-container .interaction-area .tf-buttons,
.qa-container .interaction-area .result-display {
  margin: 0 auto; /* מרכז את התיבות מבלי להגביל רוחב */
}

/* תוכן השאלה מרוכז בתוך qa-container */
.qa-container .question-section #qHtml,
.qa-container .question-section > * {
  margin: 0 auto; /* מרכז את תוכן השאלה מבלי להגביל רוחב */
}

/* שאלות פתוחות - כפתור הצג תשובה במקום התשובה */
.qa-container .free-interaction {
  gap: 12px;
  /* יירש את המיקום המרכזי מה-parent (.interaction-area) */
}

.qa-container .free-interaction #flip {
  margin: 0 auto;
}

/* כשהתשובה מוצגת (לא מוסתרת), הכפתור flip נעלם */
.qa-container .free-interaction .answer-display:not(.answer-hidden) ~ #flip {
  display: none;
}

/* התשובה מוסתרת כברירת מחדל */
.qa-container .free-interaction .answer-display.answer-hidden {
  display: none;
}

/* כאשר התשובה לא מוסתרת - התשובה מופיעה */
.qa-container .free-interaction .answer-display:not(.answer-hidden) {
  display: block;
}

/* כפתור flip נעלם כשהתשובה מוצגת */
.qa-container .free-interaction .answer-display:not(.answer-hidden) ~ #flip {
  display: none !important;
}

/* אם התשובה לא מוסתרת, הכפתור flip נעלם */
.qa-container .free-interaction:has(.answer-display:not(.answer-hidden)) #flip {
  display: none !important;
}

/* כשהתשובה מוצגת, הכפתור flip נעלם רק באותו אלמנט */
.qa-container .free-interaction.answer-shown #flip {
  display: none;
}

/* עמוד סיום ממורכז בגובה */
.qa-container.test-deck.finish-container {
  height: 620px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.qa-container.test-deck.finish-container .test-card-stats {
  width: 100%;
}

/* אינטראקציות ספציפיות ממורכזות בגובה */
.qa-container .mc-interaction,
.qa-container .tf-interaction,
.qa-container .cloze-interaction {
  gap: 20px;
  /* יירש את המיקום המרכזי מה-parent */
}

/* הסרתי הגדרה כפולה של free-interaction */

/* שאלה פתוחה */

.answer-display {
  position: relative; /* עבור מיקום הכפתור הקטן */
  border-radius: 12px;
  padding: 16px;
  background: #fff;
  margin-top: 12px;
  user-select: text; /* אפשור בחירת טקסט בתשובות */
  line-height: 1.6;
}

/* כפתור קטן להסתרת תשובה בפינה */
.qa-container .answer-display .hide-answer-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.1);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.2s ease;
  color: #666;
}

.qa-container .answer-display .hide-answer-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,0.2);
  transform: scale(1.1);
}

/* הכפתור הקטן נעלם כשהתשובה מוסתרת */
.qa-container .answer-display.answer-hidden .hide-answer-btn {
  display: none;
}

.answer-display > * {
  max-width: 100%;
}

/* עיצוב נכון לפסקאות בתשובות */
.answer-display p {
  margin: 0 0 12px 0;
}

.answer-display p:last-child {
  margin-bottom: 0;
}

.answer-display br {
  display: block;
  margin-bottom: 8px;
}

.answer-display ul, .answer-display ol {
  margin: 8px 0;
  padding-right: 20px;
  display: block;
}

.answer-display li {
  margin-bottom: 4px;
  display: list-item;
  text-align: right;
}

.answer-display h1, .answer-display h2, .answer-display h3, 
.answer-display h4, .answer-display h5, .answer-display h6 {
  margin: 16px 0 8px 0;
}

.answer-display blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-right: 4px solid var(--blue-200);
  background: var(--blue-50);
}

/* עיצוב ספציפי ל-aHtml */
#aHtml {
  line-height: 1.6;
  width: 100%;
}

#aHtml > * {
  max-width: 100%;
}

#aHtml p {
  margin: 0 0 12px 0;
  display: block;
}

#aHtml p:last-child {
  margin-bottom: 0;
}

#aHtml ul, #aHtml ol {
  margin: 8px 0;
  padding-right: 20px;
  display: block;
}

#aHtml li {
  margin-bottom: 4px;
  display: list-item;
  text-align: right;
}

#aHtml h1, #aHtml h2, #aHtml h3, 
#aHtml h4, #aHtml h5, #aHtml h6 {
  margin: 16px 0 8px 0;
  display: block;
}

#aHtml blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-right: 4px solid var(--blue-200);
  background: var(--blue-50);
  display: block;
}

#aHtml span {
  display: inline;
}

#aHtml br {
  display: block;
  margin-bottom: 8px;
}

.answer-hidden { visibility:hidden; pointer-events:none; }

/* שאלה אמריקאית */
.mc-interaction {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

/* ריכוז כפתורי "בדוק תשובות" */
.mc-interaction #mcSubmit,
.tf-interaction #tfSubmit,
.cloze-interaction #clozeSubmit {
  display: block;
  margin: 0 auto;
  text-align: center;
}

.mc-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  width: 100%;
}

.mc-option {
  border-radius: 8px;
  padding: 12px 16px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mc-option:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
}

.mc-option.selected {
  background: var(--blue-200);
  border-color: var(--blue-700);
  color: var(--blue-700);
}

.mc-option.correct {
  background: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.mc-option.incorrect {
  background: #f8d7da;
  border-color: #dc3545;
  color: #721c24;
}

/* נכון/לא נכון */
.tf-interaction {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.tf-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.tf-option {
  min-width: 120px;
  padding: 12px 24px;
}

.tf-option.correct {
  background: #28a745;
  color: white;
  border-color: #28a745;
}

.tf-option.incorrect {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

.tf-option.selected {
  background: var(--blue-200);
  border-color: var(--blue-700);
  color: var(--blue-700);
  font-weight: bold;
}

.tf-option.result-correct {
  background: #d4edda !important;
  border-color: #28a745 !important;
  color: #155724 !important;
}

.tf-option.result-incorrect {
  background: #f8d7da !important;
  border-color: #dc3545 !important;
  color: #721c24 !important;
}

/* השלמה (Cloze) */
.cloze-interaction {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  text-align: center;
}

/* תוצאות */
.result-display {
  border-radius: 12px;
  padding: 16px;
  background: var(--blue-50);
  margin-top: 12px;
  text-align: center;
  user-select: text; /* אפשור בחירת טקסט בתוצאות */
}

.result-correct {
  background: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.result-incorrect {
  background: #f8d7da;
  border-color: #dc3545;
  color: #721c24;
}

.qa{ display:grid; gap:12px; }

.question-box,
.answer-box{
  border-radius:16px;
  padding:16px;
  background:#fff;
  height: var(--qa-box-h);            /* גובה קבוע */
  box-shadow: var(--shadow);
  text-align: right;
  overflow: auto;                     /* גלילה אם התוכן גדול */
}

.question-box > *,
.answer-box > *{
  width: 100%;
}

/* השאלה – תמיד למעלה, בלי קופסה, גובה קבוע וגלילה במידת הצורך */
.question-area{
  height: var(--question-h);
  overflow: auto;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* התשובה – קופסה קבועה בגובה, התוכן ממורכז */
.answer-box{
  border-radius:12px;
  background:#fff;
  height:var(--answer-h);
  overflow:hidden;               /* הגלילה תהיה בתוך #aHtml */
  display:flex;
  align-items:center;
  justify-content:center;
  padding:12px;
}

/* עטיפה פנימית שנגללת ובתוכה התשובה */
#aHtml{
  max-height: 100%;
  width: 100%;
  height: 100%;
  overflow: auto;
  line-height: 1.6;
}

/* עיצוב נכון לפסקאות בתשובות */
#aHtml p {
  margin: 0 0 12px 0;
}

#aHtml p:last-child {
  margin-bottom: 0;
}

#aHtml br {
  display: block;
  margin-bottom: 8px;
}

#aHtml ul, #aHtml ol {
  margin: 8px 0;
  padding-right: 20px;
  text-align: right;
}

#aHtml li {
  margin-bottom: 4px;
}

#aHtml h1, #aHtml h2, #aHtml h3, 
#aHtml h4, #aHtml h5, #aHtml h6 {
  margin: 16px 0 8px 0;
}

#aHtml blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-right: 4px solid var(--blue-200);
  background: var(--blue-50);
}

#aHtml .answer-inner{
  width: auto;                /* לא למתוח לרוחב מלא, כדי לאפשר מרכוז אמיתי */
  margin: auto;               /* ממקם במרכז גם כשהרוחב משתנה */
}

/* הסתרת התוכן (הקופסה נשארת בגובה קבוע) */
.answer-hidden{ visibility:hidden; pointer-events:none; }

.answer-box[style*="display: none"]{
  min-height:0;
  padding-top:0;
  padding-bottom:0;
  border-width:0;
  box-shadow:none;
  background:transparent;
}

/* כפתורי איכות מודרניים */
.quality-row { 
  display:flex; 
  gap:12px; 
  justify-content:center; 
  flex-wrap:wrap; 
  transition: opacity 0.3s ease;
}
.quality-row .btn { 
  border-radius:var(--radius-lg);
  padding:12px 12px;
  font-weight:600;
  min-width:120px;
}
.quality-bad   { 
  background:var(--danger-light); 
  color:var(--danger); 
  border-color:var(--danger);
}
.quality-bad:hover {
  background:var(--danger);
  color:white;
}
.quality-mid   { 
  background:var(--warning-light); 
  color:var(--warning); 
  border-color:var(--warning);
}
.quality-mid:hover {
  background:var(--warning);
  color:white;
}
.quality-good  { 
  background:var(--success-light); 
  color:var(--success); 
  border-color:var(--success);
}
.quality-good:hover {
  background:var(--success);
  color:white;
}

/* בורר גודל חפיסה */
.test-size { 
  display: flex; 
  gap: 4px; 
  align-items: center; 
  flex-wrap: wrap;
  background: white;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.test-size .chip {
  padding: 12px 16px;
  cursor: pointer;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  transition: all 0.15s ease;
  border-radius: 8px;
  min-width: 44px;
  text-align: center;
  border-bottom: 1px solid transparent;
}

.test-size .chip:hover {
  background-color: var(--primary-light);
}

.test-size .chip[aria-pressed="true"] { 
  background-color: var(--primary);
  color: var(--ink);
  font-weight: 600;
}

/* תת-כותרות */
.hint { color: var(--ink-muted); font-size:12px; }

/* ===== Test card: Question always on top, answer collapsible ===== */
.test-card .qa{
  display:flex;
  flex-direction:column;
  gap:12px;
  width:100%;
  height:100%;
  overflow:auto;
  text-align:right;
}

.test-card .question-box{
  padding:8px 10px;
}

.test-card .answer-box{
  border-top:1px dashed var(--stroke);
  padding:12px 10px;
  display:none;              /* מוסתרת כברירת מחדל */
  text-align:right;
}

.test-card.show-answer .answer-box{
  display:block;             /* מוצגת כאשר הכרטיס במצב show-answer */
}

/* כפתור הצגת/הסתרת תשובה */
.reveal-btn.btn.small{
  align-self:flex-start;
  margin-bottom:8px;
}


/* =========================================================
   STATS PAGE (stats.php)
   ========================================================= */
.stats-grid { display:grid; gap:16px; grid-template-columns: repeat(3, 1fr); }
@media (max-width:1000px){ .stats-grid{ grid-template-columns: repeat(2, 1fr);} }
@media (max-width:640px){ .stats-grid{ grid-template-columns: 1fr; } }

.kpi-card {
  border:1px solid var(--stroke); border-radius:16px; padding:14px; background:#fff; box-shadow:var(--shadow);
  display:flex; flex-direction:column; gap:6px;
}
.kpi-label { font-size:13px; color: var(--ink-muted); }
.kpi-value { font-size:22px; font-weight:800; letter-spacing:-.01em; }
.kpi-trend { font-size:12px; color: var(--ink-muted); }

/* טבלת סטטיסטיקות */
.stats-table { width:100%; border-collapse: separate; border-spacing:0; border:1px solid var(--stroke); border-radius:16px; overflow:hidden; background:#fff; }
.stats-table thead th {
  background:#fafafa; text-align:right; font-weight:700; padding:10px 12px; border-bottom:1px solid var(--stroke);
}
.stats-table td { padding:10px 12px; border-bottom:1px solid #eee; font-size:14px; }
.stats-table tr:last-child td { border-bottom:none; }
.badge {
  display:inline-block; border:1px solid var(--stroke); border-radius:999px; padding:2px 8px; font-size:12px; background:#fff;
}

/* פילטרים / טווחי זמן */
.stats-filters { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:12px; }
.stats-filters .btn.small { padding:4px 10px; border-radius:10px; font-size:12px; }
.stats-filters .btn[aria-pressed="true"] { background:#000; color:#fff; }

/* =========================================================
   CATEGORY NEW PAGE (category-new.php)
   ========================================================= */
.form-panel {
  border:1px solid var(--stroke); border-radius:16px; padding:16px; background:#fff; box-shadow:var(--shadow);
}
.form-row { display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; }
.field { display:flex; flex-direction:column; gap:6px; }
.field label { font-size:13px; color: var(--ink-muted); }
.field input[type="text"], .field select, .field textarea {
  border:1px solid var(--stroke); 
  border-radius:12px; 
  padding:10px 12px; 
  background:#fff; 
  min-width:240px;
  font: inherit;
  transition: all 0.2s ease;
}

.field select {
  /* הסתרת החץ הברירת מחדל */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  padding: 10px 12px 10px 12px; /* מקום לחץ מותאם אישית */
  cursor: pointer;
  
  /* חץ מותאם אישית */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: left 12px center; /* מותאם לRTL */
  background-size: 16px;
}

.field input[type="text"]:focus, 
.field select:focus, 
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(236, 238, 235, 0.1);
}

.field select:hover {
  border-color: var(--primary-hover);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.helper { font-size:12px; color: var(--ink-muted); }
.icon-picker, .color-picker { display:flex; gap:8px; flex-wrap:wrap; }
.icon-chip {
  width:36px; height:36px; display:inline-flex; align-items:center; justify-content:center;
  border:1px solid var(--stroke); border-radius:10px; background:#fff; cursor:pointer;
}
.icon-chip.selected { outline:2px solid #000; }
.color-chip {
  width:32px; height:24px; border:1px solid var(--stroke); border-radius:6px; cursor:pointer;
}
.color-chip.selected { outline:2px solid #000; }

/* =========================================================
   ADD CARD PAGE (add.php)
   ========================================================= */
.section { margin: 16px 0; }
.row { display:flex; gap:12px; align-items:flex-start; flex-wrap:wrap; }

.add-form { border:1px solid var(--stroke); border-radius:16px; padding:16px; background:#fff; box-shadow:var(--shadow); }
.add-grid { display:grid; gap:14px; grid-template-columns:1fr; }
@media (min-width:900px){ .add-grid { grid-template-columns: 1fr 1fr; } }

.add-field { display:flex; flex-direction:column; gap:6px; }
.add-field label { font-size:13px; color: var(--ink-muted); }
.add-field select, .add-field input[type="text"] {
  border:1px solid var(--stroke); border-radius:12px; padding:10px 12px; background:#fff; font:inherit;
}

.field {
  width: 100%;
  border:1px solid var(--stroke);
  border-radius:12px;
  padding:10px 12px;
  background:#fff;
  font: inherit;
}
label { font-size:13px; color: var(--ink-muted); display:block; margin-bottom:6px; }

.actions, .add-actions { display:flex; gap:8px; align-items:center; margin: 0px 0; }

/* ===== Toolbar (אחיד בכל האתר) ===== */
.toolbar{
  display:flex; gap:6px; flex-wrap:wrap; align-items:center;
}
.toolbar .btn{
  display:inline-flex; align-items:center; justify-content:center;
  height:36px; min-width:36px; padding:6px 10px;
  border:1px solid var(--stroke);
  border-radius:10px; background:#fff; color:#111; cursor:pointer;
}
.toolbar .btn.ghost{ background:transparent; }
.toolbar svg{ display:inline-block !important; }
.toolbar .btn svg{ width:18px !important; height:18px !important; }
.toolbar .btn svg, .toolbar .btn svg *{
  stroke:currentColor !important; fill:none !important;
  stroke-width:2 !important; stroke-linecap:round !important; stroke-linejoin:round !important;
  vector-effect: non-scaling-stroke;
}
.toolbar input[type="color"]{
  -webkit-appearance:none; appearance:none;
  border:1px solid var(--stroke); border-radius:8px;
  width:36px; height:28px; padding:0; cursor:pointer;
}
.toolbar input[type="color"]::-webkit-color-swatch-wrapper{ padding:0; }
.toolbar input[type="color"]::-webkit-color-swatch{ border:none; border-radius:6px; }

/* ===== RTE (עורך טקסט) ===== */
.rte{
  min-height: 140px;
  border:1px solid var(--stroke);
  border-radius:12px;
  padding:12px;
  background:#fff;
  outline:none;
  line-height:1.5;
}
.rte:focus{ outline:2px solid #0002; }
.rte:empty:before{ content:'כתוב כאן…'; color:#999; }

/* ===== שאלות אמריקאיות ===== */
.options{ display:flex; flex-direction:column; gap:8px; }
.optrow{
  display:grid; grid-template-columns: 1fr auto auto; gap:8px; align-items:center;
}
@media (max-width:700px){ .optrow{ grid-template-columns: 1fr; } }
.optrow .field{ margin:0; }

/* ===== מצבי הודעות ===== */
.form-msg { font-size:13px; color: var(--ink-muted); margin-top:6px; }
.form-msg.error { color:#c62828; }
.form-msg.ok    { color:#2e7d32; }

/* ===== Toolbar SVG icons (חיזוק נראות) ===== */
.toolbar .btn .ico { width:18px; height:18px; display:block; }
.toolbar .btn .ico, .toolbar .btn .ico * {
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

/* בידול ויזואלי לפקד צבע טקסט מול היילייט */
.toolbar .swatch {
  width:18px; height:18px; border-radius:4px;
  box-shadow: inset 0 0 0 1px var(--stroke);
}
.toolbar .swatch-fore { background: linear-gradient(45deg, #111 50%, #fff 50%); }
.toolbar .swatch-back {
  background:
    linear-gradient(45deg, #ffd54f 0 50%, #fff 50% 100%),
    repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0/8px 8px;
  /* נותן תחושת "מרקר" + דמוי משבצות מתחת */
}


/* תוכן CKEditor – מראה עקבי בכל האתר */
.ck-content {
  font: inherit;
  line-height: 1.6;
  color: var(--ink);
  direction: rtl;
  text-align: right;
}
.ck-content h1,.ck-content h2,.ck-content h3 { margin: .6em 0 .4em; font-weight: 800; letter-spacing: -.01em; }
.ck-content p { margin: .5em 0; }
.ck-content ul, .ck-content ol { padding-inline-start: 1.2em; margin: .5em 0; }
.ck-content table { width: 100%; border-collapse: collapse; margin: .6em 0; }
.ck-content table td, .ck-content table th { border: 1px solid var(--stroke); padding: 6px 8px; }
/* תמונות בעורך CKEditor - רק לא בשאלות ותשובות */
.ck-content img:not(.test-card *):not(.answer-display *):not(#aHtml *):not(.question-section *) { 
  max-width: 100%; height: auto; display: block; margin: 8px auto; border-radius: 8px; 
}

/* אין כללים מיוחדים לתמונות ו-figures בשאלות ותשובות */

/* ===== Cloze blanks (numbered underline) ===== */
.cloze-blank{
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  gap: 0;
  min-width: var(--cloze-min-w);
  width: var(--cloze-min-w);
  padding-inline: 0 2px;
  border-bottom: 1.2px solid var(--ink, #0b0f19);
  line-height: 1;
}

.cloze-blank sup{
  position: absolute;
  top: -0.9em;
  inset-inline-start: 0;
  font-size: 10px;
  color: var(--ink-muted, #667085);
  line-height: 1;
  pointer-events: none;
}

.cloze-blank input{
  border: 0;
  outline: 0;
  background: transparent;
  text-align: center;
  min-width: 0;
  width: 100%;
  flex: 1 1 auto;
  box-sizing: border-box;
  font: inherit;
  color: inherit;
  padding: 0 2px 2px;
}

.cloze-blank input::placeholder{ color: #c3c7d0; }

/* Cloze token styling (editor + preview) */
.ck-content .cloze-token, .cloze-token {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  margin: 0 2px;
  vertical-align: baseline;
}
.ck-content .cloze-token[contenteditable="false"],
.cloze-token[contenteditable="false"] {
  cursor: default;
  user-select: none;
}
.ck-content .cloze-token .cloze-num, .cloze-token .cloze-num {
  font-size: 11px;
  line-height: 1;
  opacity: .75;
  margin-inline-start: 2px;
  position: relative;
  top: -0.2em;
}
.ck-content .cloze-token .cloze-underline, .cloze-token .cloze-underline {
  display: inline-block;
  min-width: var(--cloze-min-w); /* אפשר לשנות אורך קו ברירת־מחדל */
  width: var(--cloze-min-w);
  height: 0.9em;
  border-bottom: 2px solid currentColor;
}

/* Narrower blanks on small screens */
@media (max-width: 480px){
  :root{ --cloze-min-w: 40px; }
}

/* תיוג על תמונה */
.label-answer-box {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
}

.label-answer-box:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transform: translateY(-1px);
}

.label-answer-box input {
  width: 100%;
  box-sizing: border-box;
  outline: none;
}

.label-answer-box input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* מצבי תוצאות לתיוג */
.label-answer-box input[disabled] {
  cursor: not-allowed;
  opacity: 0.9;
}

@media (max-width: 640px){
  :root{ --test-card-h: 320px; }
  
  .label-answer-box {
    min-width: 80px;
    font-size: 11px;
  }
  
  .label-answer-box input {
    font-size: 11px;
    padding: 3px;
  }

  .qa-container {
    height: 500px;
  }

}

/* ===== Compact inline panel: Add Subcategory (on main page) ===== */
[data-add-sub-panel].panel {
  padding: 8px;
  margin-top: 8px;
}
[data-add-sub-panel] .form-row {
  gap: 6px;
  align-items: center;
}
[data-add-sub-panel] .field {
  margin: 0;
}
[data-add-sub-panel] .field label {
  font-size: 12px;
  margin-bottom: 4px;
}
[data-add-sub-panel] input[type="text"] {
  padding: 6px 8px;
  height: 32px;
  font-size: 13px;
}
[data-add-sub-panel] .btn {
  padding: 6px 10px;
  height: 32px;
  font-size: 12px;
}
[data-add-sub-panel] .form-msg {
  font-size: 12px;
  margin-inline-start: 8px;
}

/* ——— עיצוב select מודרני ——— */
select {
  /* הסתרת החץ הברירת מחדל */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  /* עיצוב בסיסי */
  background: white;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 12px 40px 12px 16px; /* מקום לחץ מותאם אישית */
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  
  /* חץ מותאם אישית */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: left 12px center; /* מותאם לRTL */
  background-size: 16px;
}

select:hover {
  border-color: var(--primary-hover);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(236, 238, 235, 0.1);
}

select:disabled {
  background-color: var(--bg-page);
  color: var(--ink-muted);
  cursor: not-allowed;
}

/* עיצוב אפשרויות */
select option {
  background: white;
  color: var(--ink);
  padding: 8px;
}

select option:hover {
  background-color: var(--primary-light);
}

select option:checked {
  background-color: var(--primary);
  color: var(--ink);
}

/* עיצוב מיוחד לselect קטן */
select.compact {
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  background-size: 14px;
  background-position: left 8px center;
}

/* ——— Dropdown מותאם אישית ——— */
.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
}

.custom-select-trigger {
  background: white;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px 10px 12px;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 240px;
  
  /* חץ מותאם אישית */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 16px;
}

.custom-select-trigger:hover {
  border-color: var(--primary-hover);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.custom-select-trigger:focus,
.custom-select.open .custom-select-trigger {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(236, 238, 235, 0.1);
}

.custom-select.open .custom-select-trigger {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M18 15l-6-6-6 6'/%3e%3c/svg%3e");
}

.custom-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  margin-top: 4px;
}

.custom-select.open .custom-select-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-select-option {
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid var(--stroke);
  font-size: 14px;
  color: var(--ink);
}

.custom-select-option:last-child {
  border-bottom: none;
}

.custom-select-option:hover {
  background-color: var(--primary-light);
}

.custom-select-option.selected {
  background-color: var(--primary);
  color: var(--ink);
  font-weight: 600;
}

.custom-select-option.disabled {
  color: var(--ink-muted);
  cursor: not-allowed;
  background-color: var(--bg-page);
}

.custom-select-option.disabled:hover {
  background-color: var(--bg-page);
}

/* עיצוב לניתוח נוח */
.custom-select-placeholder {
  color: var(--ink-muted);
}