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

:root {
  --navy: #15314f;
  --navy-2: #1e4566;
  --navy-deep: #0e2236;
  --orange: #ef7d1a;
  --bg: #eef1f6;
  --surface: #ffffff;
  --ink: #19222e;
  --muted: #64748b;
  --border: #e2e8f0;
  --rec: #d83a3a;
  --ok: #16a34a;
}

body {
  font-family: 'Assistant', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 90% -10%, rgba(239,125,26,.08), transparent 60%),
    radial-gradient(900px 500px at -5% 110%, rgba(21,49,79,.09), transparent 55%),
    var(--bg);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.55;
  padding-bottom: 32px;
}

/* ── Top bar ── */
.topbar {
  background: linear-gradient(105deg, var(--navy-deep), var(--navy) 55%, var(--navy-2));
  color: #fff;
  padding: 18px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--orange);
  box-shadow: 0 8px 28px rgba(14,34,54,.22);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  height: 56px; width: auto; max-width: 240px; object-fit: contain;
  background: #fff; border-radius: 14px; padding: 7px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
}
.brand-text h1 { font-family: 'Frank Ruhl Libre', serif; font-size: 24px; font-weight: 900; line-height: 1.1; }
.brand-text .sub { color: #b7cbe0; font-size: 13px; margin-top: 4px; }
.top-status {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; color: #dbeafe;
  max-width: 460px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.wrap { max-width: 1180px; margin: 26px auto 0; padding: 0 22px; }

/* ── Controls ── */
.controls {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px 22px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  box-shadow: 0 10px 30px rgba(21,49,79,.06);
}
button { font-family: 'Assistant', sans-serif; cursor: pointer; }

.rec-btn {
  border: none; font-weight: 800; font-size: 17px; color: #fff;
  padding: 15px 28px; border-radius: 14px; display: flex; align-items: center; gap: 11px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  box-shadow: 0 6px 18px rgba(21,49,79,.28);
  transition: transform .12s ease, box-shadow .2s ease, background .25s ease;
  white-space: nowrap;
}
.rec-btn:hover:not(:disabled) { transform: translateY(-1px); }
.rec-btn .dot { width: 13px; height: 13px; border-radius: 50%; background: var(--orange); }
/* בזמן הקלטה: אדום + נקודה מהבהבת כסימן הקלטה — בלי הילה מזמינה (הכפתור מושבת) */
.rec-btn.recording { background: linear-gradient(135deg, var(--rec), #b62c2c); }
.rec-btn.recording .dot { background: #fff; animation: blink 1s infinite; }
.rec-btn:disabled {
  background: linear-gradient(135deg, #94a3b8, #64748b); color: #e5e7eb;
  cursor: not-allowed; box-shadow: none; transform: none; opacity: .72;
}
.rec-btn:disabled .dot { background: #cbd5e1; animation: none; }
/* הילה מזמינה ללחיצה — על "התחל" כל עוד לא התחילה הכתבה */
.rec-btn.cta-halo { animation: ctaHalo 1.7s infinite; }

.secondary-btn {
  border: 1px solid var(--border); background: #f8fafc; color: var(--navy);
  font-weight: 700; font-size: 15px; padding: 14px 18px; border-radius: 13px;
  transition: background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.secondary-btn:disabled { opacity: .45; cursor: not-allowed; }
.stop-ready { background: linear-gradient(135deg, #16a34a, #128a3e) !important; color: #fff !important; border-color: rgba(22,163,74,.45) !important; }

/* השהה — כחול רגוע בזמן הקלטה (פעולה זמינה, נבדל מהירוק של "סיום") */
.secondary-btn.pause-active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff;
  border-color: rgba(37,99,235,.45); font-weight: 800;
}
/* המשך — כתום מותג בולט + הילה, מזמין לחזור ולהמשיך */
.secondary-btn.resume-active {
  background: linear-gradient(135deg, var(--orange), #d96b10); color: #fff;
  border-color: rgba(239,125,26,.5); font-weight: 800;
  animation: ctaHalo 1.5s infinite;
}

@keyframes ctaHalo { 0% { box-shadow: 0 0 0 0 rgba(239,125,26,.55); } 70% { box-shadow: 0 0 0 16px rgba(239,125,26,0); } 100% { box-shadow: 0 0 0 0 rgba(239,125,26,0); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(216,58,58,.5); } 70% { box-shadow: 0 0 0 16px rgba(216,58,58,0); } 100% { box-shadow: 0 0 0 0 rgba(216,58,58,0); } }
@keyframes blink { 50% { opacity: .25; } }

.clock {
  font-family: 'Frank Ruhl Libre', serif; font-weight: 900; font-size: 32px; letter-spacing: 1px;
  color: var(--navy); font-variant-numeric: tabular-nums; min-width: 110px; text-align: center;
}
.clock.live { color: var(--rec); }

.mic { flex: 1 1 220px; min-width: 180px; }
.mic .lbl { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.mic-track { height: 13px; border-radius: 8px; background: #eef2f7; overflow: hidden; border: 1px solid var(--border); }
.mic-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--navy), #2f7fb5 45%, var(--orange)); border-radius: 8px; transition: width .08s linear; }

.wc { text-align: center; padding: 0 8px; min-width: 80px; }
.wc .num { font-family: 'Frank Ruhl Libre', serif; font-weight: 900; font-size: 28px; color: var(--orange); line-height: 1; }
.wc .cap { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Panels ── */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 10px 30px rgba(21,49,79,.06); display: flex; flex-direction: column;
  overflow: hidden; min-height: 520px;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 9px; background: linear-gradient(180deg, #fbfcfe, #f4f7fb); flex-wrap: wrap;
}
.panel-head .ic {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  flex: none; background: linear-gradient(135deg, var(--navy), var(--navy-2)); font-weight: 900; font-size: 13px;
}
.panel-head h2 { font-family: 'Frank Ruhl Libre', serif; font-size: 18px; font-weight: 700; color: var(--navy); margin-inline-end: auto; }

.mini-btn {
  border: 1px solid var(--border); background: #f1f5f9; color: var(--navy);
  font-weight: 800; font-size: 13px; padding: 7px 11px; border-radius: 10px; transition: .15s ease; white-space: nowrap;
}
.mini-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(21,49,79,.12); }
.mini-btn:disabled { background: #e5e7eb; color: #94a3b8; cursor: not-allowed; }
.mini-btn.word { background: linear-gradient(135deg, var(--orange), #d8650a); color: #fff; border-color: rgba(239,125,26,.5); }
.mini-btn.word:disabled { background: #e5e7eb; color: #94a3b8; }

.box {
  padding: 18px 20px; overflow-y: auto; flex: 1; white-space: pre-wrap;
  font-size: 17px; line-height: 1.9; color: #1f2937;
}
.box.editing { outline: 2px solid rgba(239,125,26,.5); background: #fffdf8; caret-color: var(--orange); }
.placeholder {
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  text-align: center; height: 100%; min-height: 360px; padding: 30px; font-size: 15px;
}

/* ── סרגל גרסאות: הקודם/הבא + שיפור ── */
.version-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: #fbfcfe;
}
.ver-btn {
  border: 1px solid var(--border); background: #fff; color: var(--navy);
  font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 9px;
  cursor: pointer; transition: .15s ease;
}
.ver-btn:hover:not(:disabled) { background: #f1f5fb; border-color: rgba(20,40,80,.25); }
.ver-btn:disabled { opacity: .4; cursor: default; }
.ver-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.refine-btn {
  margin-inline-start: auto;
  border: 1px solid rgba(239,125,26,.45);
  background: linear-gradient(135deg, rgba(239,125,26,.14), rgba(239,125,26,.04));
  color: #b85e10; font-weight: 800; font-size: 13px; padding: 6px 14px;
  border-radius: 9px; cursor: pointer; transition: .15s ease;
}
.refine-btn:hover:not(:disabled) { background: linear-gradient(135deg, rgba(239,125,26,.22), rgba(239,125,26,.08)); }
.refine-btn:disabled { opacity: .45; cursor: default; }

/* ── Loader פשוט ── */
/* יישור-לראש עם padding-top זהה ל-staged-loader, כדי שהנקודות יֵשבו באותו גובה בשני החלונות */
.loader { height: 100%; min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 20px; padding-top: 64px; }
.loader-spinner {
  width: 64px; height: 64px; border-radius: 50%;
  border: 6px solid #eef2f7; border-top-color: var(--orange); animation: spin 1s linear infinite;
}
.loader-title { font-family: 'Frank Ruhl Libre', serif; color: var(--navy); font-weight: 900; font-size: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── אנימציית ארבע נקודות (CSS טהור, ללא ספרייה חיצונית) ── */
.dots-loader { display: flex; gap: 10px; align-items: center; justify-content: center; height: 56px; }
.dots-loader span {
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--orange));
  animation: dotBounce 1.2s infinite ease-in-out both;
}
.dots-loader span:nth-child(1) { animation-delay: -0.32s; }
.dots-loader span:nth-child(2) { animation-delay: -0.16s; }
.dots-loader span:nth-child(3) { animation-delay: 0s; }
.dots-loader span:nth-child(4) { animation-delay: 0.16s; }
@keyframes dotBounce { 0%, 80%, 100% { transform: scale(0.5); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

/* ── לואדר שלבים ── */
.staged-loader {
  height: 100%; min-height: 400px; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 18px; text-align: center; padding: 64px 30px 30px;
}
.staged-title { font-family: 'Frank Ruhl Libre', serif; color: var(--navy); font-weight: 900; font-size: 24px; }
.staged-sub { color: var(--muted); font-size: 15px; font-weight: 700; }
.stage-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(100%, 460px); }
.stage-box {
  min-height: 54px; border-radius: 13px; border: 1px solid var(--border); background: #f8fafc;
  color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 8px;
  font-size: 12px; font-weight: 800; transition: .25s ease;
}
.stage-box.active {
  color: #b85e10; border-color: rgba(239,125,26,.45);
  background: linear-gradient(135deg, rgba(239,125,26,.16), rgba(239,125,26,.05));
  transform: translateY(-2px); box-shadow: 0 8px 18px rgba(239,125,26,.12);
}
.stage-box.done {
  color: #128a3e; border-color: rgba(22,163,74,.38);
  background: linear-gradient(135deg, rgba(22,163,74,.14), rgba(22,163,74,.05));
}
.stage-progress {
  width: min(100%, 460px); height: 12px; border-radius: 999px; background: #eef2f7;
  border: 1px solid var(--border); overflow: hidden;
}
.stage-progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--navy), #2f7fb5 45%, var(--orange)); transition: width .4s linear;
}

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }
.foot b { color: var(--navy); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 50%; transform: translateX(50%) translateY(80px);
  background: var(--navy-deep); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-size: 14px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  opacity: 0; transition: .35s; z-index: 50; border-inline-start: 3px solid var(--orange);
}
.toast.show { opacity: 1; transform: translateX(50%) translateY(0); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(14,34,54,.5); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 26px; max-width: 440px; width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.3); text-align: center;
}
.modal-text { font-size: 17px; color: var(--ink); margin-bottom: 22px; line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-btn { border: none; font-weight: 800; font-size: 15px; padding: 12px 22px; border-radius: 11px; }
.modal-btn.confirm { background: linear-gradient(135deg, var(--rec), #b62c2c); color: #fff; }
.modal-btn.cancel { background: #f1f5f9; color: var(--navy); border: 1px solid var(--border); }

@media (max-width: 880px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .top-status { max-width: 100%; }
  .grid { grid-template-columns: 1fr; }
}
