:root {
  --bg:        #f8f9fa;
  --surface:   #ffffff;
  --accent:    #4263eb;
  --accent-h:  #5c7cfa;
  --text:      #212529;
  --muted:     #6c757d;
  --border:    #dee2e6;
  --error:     #e03131;
  --success:   #2f9e44;
  --fav:       #fcc419;
  --hf:        #ff6b35;
  --radius:    10px;
  --shadow:    0 8px 25px rgba(0,0,0,.07);
  --font:      'Inter', sans-serif;
}
*  { box-sizing:border-box; margin:0; padding:0; }

@keyframes fadeIn {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0);   }
}
@keyframes dot-flashing {
  0%        { background: var(--accent); }
  50%,100%  { background: rgba(66,99,235,.25); }
}
@keyframes pulse {
  0%,100% { opacity:1; }
  50%     { opacity:.4; }
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
body.history-open { overflow:hidden; }

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  animation: fadeIn .7s ease-out;
  transition: transform .4s cubic-bezier(.25,.46,.45,.94);
}
body[dir="rtl"].history-open #app { transform:translateX(-380px); }

.hidden { display:none !important; }

/* ── Modal overlay ────────────────────────────────────────── */
.modal-overlay {
  position:fixed; inset:0;
  background:rgba(0,0,0,.5);
  backdrop-filter:blur(5px);
  display:flex; align-items:center; justify-content:center;
  z-index:1000;
  opacity:0; visibility:hidden;
  transition:opacity .3s, visibility .3s;
}
.modal-overlay.show { opacity:1; visibility:visible; }

.modal-content {
  background:var(--surface);
  padding:2.5rem;
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  width:90%; max-width:520px;
  text-align:center;
  animation:fadeIn .4s ease-out;
  border:1px solid var(--border);
  max-height:90vh;
  overflow-y:auto;
}
.modal-wide { max-width:700px; text-align:right; }

.modal-header-row {
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom:1.5rem;
}
.modal-header-row h2 { font-size:1.4rem; }
.close-modal-btn {
  background:none; border:none; font-size:1.4rem;
  color:var(--muted); cursor:pointer; padding:.2rem .5rem;
  border-radius:50%; transition:all .2s;
}
.close-modal-btn:hover { background:var(--bg); color:var(--text); }
.modal-footer { margin-top:1.5rem; display:flex; justify-content:flex-end; }

/* ── Modal: API key / Server config ─────────────────────── */
.hf-logo-wrap { display:flex;align-items:center;justify-content:center;gap:.5rem;margin-bottom:1.2rem; }
.hf-logo  { font-size:2.5rem; }
.hf-label { font-size:1.1rem; font-weight:700; color:var(--hf); }

.modal-content h2 { margin-bottom:.8rem; font-size:1.6rem; font-weight:700; }
.modal-content > p { color:var(--muted); margin-bottom:1.2rem; }

.server-config-section { text-align:right; }

.input-group        { display:flex; margin:1.2rem 0; }
.input-group input  { flex:1; border-top-left-radius:0; border-bottom-left-radius:0; border-left:none; }
.input-group button { border-top-right-radius:0; border-bottom-right-radius:0; background:var(--accent); color:#fff; white-space:nowrap; }
.input-group button:hover { background:var(--accent-h); }

.status-message        { min-height:22px; font-weight:500; margin-top:.8rem; font-size:.95rem; }
.status-message.success{ color:var(--success); }
.status-message.error  { color:var(--error);   }
.api-key-link          { font-size:.9rem; color:var(--muted); }
.api-key-link a        { color:var(--hf); text-decoration:none; font-weight:500; }
.api-key-link a:hover  { text-decoration:underline; }

/* ── Server status badge ──────────────────────────────── */
.server-badge {
  display:flex; align-items:center; gap:.4rem;
  padding:.3rem .75rem; border-radius:20px;
  font-size:.78rem; font-weight:600;
  border:1px solid var(--border);
  background:var(--surface);
  transition:all .3s;
}
.server-badge.online  { border-color:#2f9e44; background:#f0fdf4; color:#2f9e44; }
.server-badge.offline { border-color:#f59f00; background:#fffbeb; color:#d97706; }

.badge-dot {
  width:8px; height:8px; border-radius:50%;
  background:var(--muted);
}
.badge-dot.online  { background:#2f9e44; animation:pulse 2s infinite; }
.badge-dot.offline { background:#f59f00; }

/* ── Settings modal ──────────────────────────────────────── */
.settings-section { margin-bottom:1.8rem; }
.settings-section h3 { font-size:1.1rem; margin-bottom:.8rem; }
.settings-hint { font-size:.88rem; color:var(--muted); margin-bottom:.8rem; }

.rounds-input-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.rounds-input-row label {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
}
#rounds-input {
  width: 90px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .4rem .7rem;
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  transition: border-color .2s;
}
#rounds-input:focus { outline: none; border-color: var(--accent); }
#rounds-input::placeholder { color: var(--muted); font-size: .85rem; }
.rounds-hint {
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
}

.persona-row {
  display:flex; flex-direction:column; gap:.5rem;
  padding:.9rem 1rem; border:1px solid var(--border);
  border-radius:var(--radius); margin-bottom:.75rem;
  background:var(--bg);
}
.persona-model-label { font-weight:700; font-size:.95rem; }
.persona-select      { width:100%; }
.custom-persona-area { margin-top:.4rem; }
.custom-persona-input{ width:100%; min-height:80px; resize:vertical; }

/* ── Header ──────────────────────────────────────────────── */
.main-header {
  display:flex; justify-content:space-between; align-items:flex-start;
  margin-bottom:2.5rem; padding-bottom:1.5rem;
  border-bottom:1px solid var(--border);
  flex-wrap:wrap; gap:.75rem;
}
.header-controls     { display:flex; gap:.6rem; order:1; }
.header-text-content { order:2; text-align:right; flex:1; }
.main-header h1      { font-size:2.1rem; font-weight:700; margin-bottom:.2rem; }
.main-header p       { font-size:1rem; color:var(--muted); }

.icon-btn {
  background:transparent; border:1px solid var(--border);
  color:var(--muted); border-radius:50%;
  width:42px; height:42px;
  display:flex; align-items:center; justify-content:center;
  padding:0; cursor:pointer; flex-shrink:0;
  transition:all .2s;
}
.icon-btn:hover:not(:disabled) {
  background:var(--surface); color:var(--accent);
  border-color:var(--accent); transform:translateY(-2px);
  box-shadow:0 4px 10px rgba(66,99,235,.12);
}
.icon-btn:disabled { opacity:.4; cursor:not-allowed; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background:var(--surface); padding:2rem;
  border-radius:var(--radius); margin-bottom:1.5rem;
  border:1px solid var(--border); box-shadow:var(--shadow);
}

/* ── Setup section ───────────────────────────────────────── */
#setup-section h2 { margin-bottom:1.5rem; font-size:1.4rem; }

.topic-mode-row { display:flex; gap:.75rem; margin-bottom:1.5rem; flex-wrap:wrap; }
.topic-mode-btn {
  flex:1; padding:.7rem 1.2rem;
  border:2px solid var(--border); border-radius:var(--radius);
  background:var(--surface); color:var(--muted);
  font-size:.95rem; font-weight:500; cursor:pointer; transition:all .2s;
}
.topic-mode-btn:hover  { border-color:var(--accent); color:var(--text); }
.topic-mode-btn.active { background:var(--accent); color:#fff; border-color:var(--accent); }

.topic-suggestions-grid {
  display:flex; flex-direction:column; gap:.5rem; margin-top:.5rem;
}
.topic-suggestion-btn {
  text-align:right; padding:.65rem 1rem;
  border:1.5px solid var(--border); border-radius:var(--radius);
  background:var(--bg); color:var(--text); cursor:pointer;
  font-size:.95rem; transition:all .2s;
}
.topic-suggestion-btn:hover  { border-color:var(--accent); color:var(--accent); }
.topic-suggestion-btn.chosen { border-color:var(--accent); background:rgba(66,99,235,.08); color:var(--accent); font-weight:600; }

/* ── File Upload ─────────────────────────────────────────── */
.file-drop-zone {
  border:2px dashed var(--border);
  border-radius:var(--radius);
  padding:1.5rem;
  text-align:center;
  cursor:pointer;
  transition:all .2s;
  background:var(--bg);
  position:relative;
}
.file-drop-zone:hover,
.file-drop-zone.drag-over {
  border-color:var(--accent);
  background:rgba(66,99,235,.04);
}
.file-drop-zone.drag-over { transform:scale(1.01); }

.file-drop-icon { font-size:2rem; margin-bottom:.5rem; }
.file-drop-text { font-size:.95rem; color:var(--muted); margin-bottom:.3rem; }
.file-drop-sub  { font-size:.78rem; color:var(--muted); opacity:.7; }
.file-browse-link {
  color:var(--accent); font-weight:600;
  cursor:pointer; text-decoration:underline;
}

.uploaded-files-list {
  display:flex; flex-direction:column; gap:.4rem;
  margin-top:.75rem;
}
.uploaded-file-item {
  display:flex; align-items:center; gap:.6rem;
  padding:.5rem .8rem;
  background:var(--bg); border:1px solid var(--border);
  border-radius:8px;
  font-size:.88rem;
}
.file-icon { font-size:1.1rem; }
.file-name { flex:1; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.file-size { color:var(--muted); font-size:.8rem; white-space:nowrap; }
.file-remove-btn {
  background:none; border:none; color:var(--muted); cursor:pointer;
  padding:.2rem .4rem; border-radius:50%; font-size:.85rem;
  transition:all .2s;
}
.file-remove-btn:hover { background:#fee2e2; color:var(--error); }

/* File context badge (in chat) */
.file-context-badge {
  display:flex; align-items:center; gap:.5rem;
  padding:.5rem 1rem; margin-bottom:.75rem;
  background:#f0f4ff; border:1px solid #c5d0e6;
  border-radius:8px; font-size:.88rem; color:#3b5bdb;
  font-weight:500;
}

/* ── Model chip selector ─────────────────────────────────── */
.form-group { display:flex; flex-direction:column; }
label       { margin-bottom:.5rem; font-weight:500; color:var(--muted); font-size:.9rem; }

/* Category tabs */
.model-category-tabs {
  display:flex; flex-wrap:wrap; gap:.3rem; margin-bottom:.5rem;
}
.cat-tab {
  padding:.3rem .75rem;
  border:1px solid var(--border); border-radius:20px;
  background:var(--surface); color:var(--muted);
  font-size:.78rem; font-weight:500; cursor:pointer;
  transition:all .15s;
}
.cat-tab:hover  { border-color:var(--accent); color:var(--accent); }
.cat-tab.active { background:var(--accent); color:#fff; border-color:var(--accent); }

/* Model search */
.model-search-wrap { margin-bottom:.25rem; }

.model-chips-area {
  display:flex; flex-wrap:wrap; gap:.4rem;
  padding:.75rem; border:1px solid var(--border);
  border-radius:var(--radius); background:var(--bg);
  max-height:200px; overflow-y:auto;
  margin-bottom:.75rem;
}
.model-chip {
  padding:.35rem .8rem; border:1.5px solid var(--border);
  border-radius:20px; background:var(--surface);
  color:var(--muted); font-size:.82rem; cursor:pointer;
  transition:all .15s; white-space:nowrap;
}
.model-chip:hover    { border-color:var(--accent); color:var(--accent); }
.model-chip.selected { background:var(--accent); color:#fff; border-color:var(--accent); }
.model-chip:disabled { opacity:.4; cursor:not-allowed; }

.selected-models-list { display:flex; flex-wrap:wrap; gap:.4rem; min-height:28px; }
.selected-tag {
  display:inline-flex; align-items:center; gap:.3rem;
  padding:.3rem .75rem; border:1.5px solid;
  border-radius:20px; font-size:.82rem; font-weight:500;
  background:var(--surface);
}
.tag-remove { cursor:pointer; opacity:.7; font-size:.8rem; }
.tag-remove:hover { opacity:1; }

/* ── Setup actions ───────────────────────────────────────── */
.setup-actions {
  display:flex; gap:.75rem; margin-top:1.5rem; flex-wrap:wrap;
}

/* ── Inputs/Selects ──────────────────────────────────────── */
input[type="text"], input[type="password"], select, textarea {
  width:100%; padding:.75rem 1rem;
  border:1px solid var(--border); border-radius:var(--radius);
  font-family:var(--font); font-size:1rem;
  background:var(--bg); color:var(--text);
  transition:border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  outline:none; border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(66,99,235,.18);
}
textarea { min-height:80px; resize:vertical; }

/* ── Buttons ─────────────────────────────────────────────── */
button, .cta-button {
  padding:.8rem 1.6rem;
  border:1px solid var(--border); border-radius:var(--radius);
  font-family:var(--font); font-size:1rem; font-weight:500;
  cursor:pointer; transition:all .2s;
  background:var(--surface); color:var(--muted);
}
button:hover:not(:disabled), .cta-button:hover:not(:disabled) {
  transform:translateY(-2px); border-color:#c0c9d4; color:var(--text);
}
button:disabled { cursor:not-allowed; opacity:.45; }

.cta-button {
  background:var(--accent); color:#fff; font-weight:700;
  border:none; box-shadow:0 4px 15px rgba(66,99,235,.15);
}
.cta-button:hover:not(:disabled) {
  background:var(--accent-h);
  box-shadow:0 6px 20px rgba(66,99,235,.25);
  color:#fff; border:none;
}

.stop-btn {
  border: none;
  font-weight: 700;
  animation: fadeIn .3s ease;
  transition: background .2s, transform .15s, box-shadow .2s;
}
/* אדום — עצור שיחה */
.stop-btn--stop {
  background: #e03131;
  color: #fff;
  box-shadow: 0 4px 12px rgba(224,49,49,.25);
}
.stop-btn--stop:hover:not(:disabled) {
  background: #c92a2a;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(224,49,49,.35);
}
/* תכלת — המשך שיחה */
.stop-btn--resume {
  background: #1098ad;
  color: #fff;
  box-shadow: 0 4px 12px rgba(16,152,173,.3);
}
.stop-btn--resume:hover:not(:disabled) {
  background: #0c8599;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16,152,173,.4);
}

/* ── Chat ────────────────────────────────────────────────── */
#chat-section { animation:fadeIn .5s ease-out; }

.chat-header {
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom:1.2rem; padding:0 .5rem; flex-wrap:wrap; gap:.5rem;
}
.chat-header-right { display:flex; align-items:center; gap:.75rem; flex-wrap:wrap; }
#chat-title         { font-size:1.35rem; font-weight:700; }
#progress-indicator {
  font-size:.88rem; font-weight:500;
  background:var(--surface); color:var(--muted);
  padding:.35rem .9rem; border-radius:20px;
  border:1px solid var(--border);
}

#chat-container {
  height:62vh; overflow-y:auto;
  display:flex; flex-direction:column; gap:1rem;
  padding:1.4rem;
  background:var(--bg); border:1px solid var(--border);
  border-radius:var(--radius);
}

.chat-message {
  display:flex; align-items:flex-start; gap:.9rem;
  animation:fadeIn .4s ease-out;
  max-width:85%;
}

.avatar {
  width:44px; height:44px; border-radius:50%; flex-shrink:0;
  background:var(--surface);
  display:flex; align-items:center; justify-content:center;
  font-size:1.7rem;
  border:2px solid var(--border);
  box-shadow:0 2px 4px rgba(0,0,0,.05);
}

.message-content { padding:.75rem 1.1rem; border-radius:var(--radius); flex:1; min-width:0; overflow:hidden; background:var(--surface); border:1px solid var(--border); }
.message-author  { font-weight:700; margin-bottom:.3rem; font-size:.88rem; }
.message-text    { white-space:normal; word-wrap:break-word; overflow-wrap:break-word; font-size:.97rem; line-height:1.6; }

/* alternate alignment for variety */
.chat-message:nth-child(even) { align-self:flex-end; flex-direction:row-reverse; }

/* Thinking dots */
.thinking-indicator { display:flex; align-items:center; justify-content:center; padding:8px 0; }
.dot-flashing {
  position:relative; width:8px; height:8px; border-radius:50%;
  background:var(--accent); animation:dot-flashing 1s infinite linear alternate; animation-delay:.5s;
}
.dot-flashing::before,.dot-flashing::after {
  content:''; position:absolute; top:0; width:8px; height:8px; border-radius:50%;
  background:var(--accent);
}
.dot-flashing::before { left:-15px; animation:dot-flashing 1s infinite alternate; animation-delay:0s; }
.dot-flashing::after  { left:15px;  animation:dot-flashing 1s infinite alternate; animation-delay:1s; }

/* ── Chat controls ───────────────────────────────────────── */
.chat-controls-container {
  display:flex; flex-wrap:wrap; gap:.6rem;
  margin-top:1.2rem; justify-content:center;
}
#continue-chat-btn { background:var(--accent); color:#fff; border:none; }
#continue-chat-btn:hover:not(:disabled) { background:var(--accent-h); box-shadow:0 4px 12px rgba(66,99,235,.2); }

.save-menu { position:relative; }
.save-options {
  display:none; position:absolute; bottom:110%; left:50%; transform:translateX(-50%);
  background:var(--surface); min-width:175px;
  box-shadow:var(--shadow); z-index:20;
  border-radius:var(--radius); overflow:hidden;
  margin-bottom:6px; border:1px solid var(--border);
  animation:fadeIn .2s ease-out;
}
.save-options a {
  color:var(--muted); padding:11px 16px; text-decoration:none;
  display:block; text-align:right; font-size:.93rem; transition:all .2s;
}
.save-options a:hover { background:var(--bg); color:var(--accent); }
.save-menu:hover .save-options { display:none; }
.save-menu.open .save-options { display:block; }

/* ── History panel ───────────────────────────────────────── */
#history-panel-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,.3); z-index:100;
}
#history-panel {
  position:fixed; top:0; left:0; width:380px; max-width:90vw; height:100%;
  background:var(--surface); box-shadow:0 0 40px rgba(0,0,0,.15);
  z-index:101; display:flex; flex-direction:column;
  transform:translateX(-100%);
  transition:transform .4s cubic-bezier(.25,.46,.45,.94);
}
body[dir="rtl"] #history-panel { left:auto; right:0; transform:translateX(100%); }
#history-panel.open { transform:translateX(0); }

.history-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:1rem 1.4rem; border-bottom:1px solid var(--border); flex-shrink:0;
}
.history-header h2 { font-size:1.2rem; }
#close-history-btn { background:none; border:none; font-size:1.8rem; color:var(--muted); cursor:pointer; }

#history-list { flex:1; overflow-y:auto; padding:.8rem; }
.empty-history-message { text-align:center; padding:2rem; color:var(--muted); }

.history-item {
  display:flex; gap:.75rem; padding:.9rem;
  border-bottom:1px solid var(--border); cursor:pointer;
  transition:background .2s;
}
.history-item:hover { background:var(--bg); }
.history-item:last-child { border-bottom:none; }
.history-item.favorite  { background:#fff9e6; }
body[dir="rtl"] .history-item.favorite       { border-right:4px solid var(--fav); }
body:not([dir="rtl"]) .history-item.favorite { border-left:4px solid var(--fav); }

.history-item-main { flex:1; }
.history-item-main h3 { font-size:.95rem; font-weight:700; margin-bottom:.2rem; }
.history-item-date    { font-size:.78rem; color:var(--muted); margin-bottom:.4rem; }
.history-item-preview { font-size:.83rem; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:220px; }
.history-item-actions { display:flex; flex-direction:column; gap:.4rem; align-items:center; }
.history-action-btn   { background:none; border:none; color:var(--muted); padding:.3rem; border-radius:50%; cursor:pointer; font-size:1rem; }
.history-action-btn:hover { color:var(--text); background:var(--bg); }
.history-action-btn.favorite-btn.is-favorite { color:var(--fav); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width:768px) {
  body { font-size:15px; }
  #app { padding:1.4rem .9rem; }
  .main-header { flex-direction:column-reverse; align-items:flex-end; gap:.75rem; }
  .header-text-content { align-self:flex-end; }
  .main-header h1 { font-size:1.7rem; }
  .card { padding:1.2rem; }
  .chat-controls-container { flex-direction:column; }
  .chat-controls-container > *, .save-menu { width:100%; }
  .chat-message { max-width:95%; }
  #chat-container { height:58vh; }
  .model-category-tabs { gap:.2rem; }
  .cat-tab { font-size:.72rem; padding:.25rem .6rem; }
}

/* ── Think block (collapsible reasoning) ────────────────────── */
.think-block {
  margin-bottom: .75rem;
  border: 1px dashed var(--border, #ddd);
  border-radius: 8px;
  background: var(--bg, #f8f8f8);
  overflow: hidden;
}
.think-toggle {
  cursor: pointer;
  padding: .45rem .75rem;
  font-size: .8rem;
  color: var(--muted, #888);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 500;
}
.think-toggle::-webkit-details-marker { display: none; }
.think-toggle::before { content: '▶'; font-size: .65rem; transition: transform .2s; }
details[open] .think-toggle::before { transform: rotate(90deg); }
.think-content {
  padding: .6rem .9rem;
  font-size: .82rem;
  color: var(--muted, #888);
  border-top: 1px dashed var(--border, #ddd);
  max-height: 260px;
  overflow-y: auto;
  direction: ltr;
  font-family: 'Courier New', monospace;
  line-height: 1.5;
}
.think-content p { margin: 0 0 .4rem; }

/* ── Response text formatting ───────────────────────────────── */
.response-text {
  line-height: 1.7;
  font-size: 1rem;
}
.response-text p {
  margin: 0 0 .6rem;
}
.response-text p:last-child { margin-bottom: 0; }
.response-text strong { font-weight: 700; }
.response-text em { font-style: italic; }
.message-text { white-space: normal !important; }

/* ── Modal X close button ──────────────────────────────────── */
.modal-x-btn {
  position: absolute;
  top: .9rem;
  left: .9rem;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--muted, #888);
  cursor: pointer;
  line-height: 1;
  padding: .2rem .45rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.modal-x-btn:hover {
  background: var(--border, #e0e0e0);
  color: var(--text, #222);
}
.modal-content { position: relative; }

/* ── Token Counter ──────────────────────────────────────────── */
.token-counter {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .9rem;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  color: var(--muted, #888);
  background: var(--card-bg, rgba(255,255,255,.06));
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 10px;
  padding: .4rem .9rem;
  margin-bottom: .6rem;
}
.token-counter span { white-space: nowrap; }
.token-sep { opacity: .35; }

/* ── Podcast button ─────────────────────────────────────────── */
.save-options #save-podcast {
  color: #b45309;
  font-weight: 600;
  border-top: 1px solid var(--border, #eee);
  margin-top: .2rem;
  padding-top: .5rem;
}
.save-options #save-podcast:hover { background: #fef3c7; }

/* ── Podcast floating panel ─────────────────────────────────── */
#podcast-panel {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  width: 340px;
  background: linear-gradient(145deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
  border: 1px solid rgba(99,102,241,.35);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(99,102,241,.1),
              inset 0 1px 0 rgba(255,255,255,.07);
  z-index: 9000;
  overflow: hidden;
  transition: opacity .3s cubic-bezier(.4,0,.2,1), transform .3s cubic-bezier(.4,0,.2,1);
}
#podcast-panel.hidden {
  opacity: 0; pointer-events: none; transform: translateX(30px) scale(.95);
}

.podcast-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.1rem;
  background: rgba(99,102,241,.15);
  border-bottom: 1px solid rgba(99,102,241,.2);
}
.podcast-panel-title {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 700; font-size: .95rem; color: #e2e8f0;
  letter-spacing: .01em;
}
.podcast-panel-title .mic-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.podcast-panel-close {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  cursor: pointer;
  color: #94a3b8;
  font-size: .9rem;
  line-height: 1;
  padding: .3rem .5rem;
  border-radius: 8px;
  transition: all .15s;
}
.podcast-panel-close:hover {
  background: rgba(239,68,68,.2);
  border-color: rgba(239,68,68,.4);
  color: #fca5a5;
}

.podcast-panel-body { padding: 1.2rem 1.1rem 1.1rem; }

/* ── Progress state ── */
.podcast-progress-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: .3rem 0 .4rem;
}
.podcast-ring-wrap {
  position: relative; width: 90px; height: 90px;
}
.podcast-ring-svg { width: 90px; height: 90px; transform: rotate(-90deg); }
.podcast-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,.07);
  stroke-width: 7;
}
.podcast-ring-fill {
  fill: none;
  stroke: url(#podcastGrad);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 226;
  stroke-dashoffset: 226;
  transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1);
}
.podcast-pct-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 1.35rem; font-weight: 800;
  color: #e2e8f0; line-height: 1;
}
.podcast-pct-label small {
  font-size: .65rem; font-weight: 500; color: #94a3b8; margin-top: 2px;
}
.podcast-progress-text {
  font-size: .82rem; color: #94a3b8;
  text-align: center; line-height: 1.5;
  max-width: 260px;
}
.podcast-status-dots {
  display: flex; gap: 5px; margin-top: .1rem;
}
.podcast-status-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #6366f1;
  animation: podDot 1.4s ease-in-out infinite;
}
.podcast-status-dots span:nth-child(2) { animation-delay: .2s; }
.podcast-status-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes podDot {
  0%,80%,100% { opacity:.2; transform:scale(.7); }
  40%          { opacity:1;  transform:scale(1); }
}

/* ── Audio state ── */
.podcast-audio-wrap { display: flex; flex-direction: column; gap: .75rem; }
.podcast-done-header {
  display: flex; align-items: center; gap: .5rem;
  font-size: .88rem; font-weight: 700; color: #86efac;
  margin-bottom: .1rem;
}
#podcast-player {
  width: 100%; border-radius: 10px;
  filter: invert(1) hue-rotate(190deg) brightness(.9);
}
#podcast-download-btn {
  width: 100%;
  padding: .7rem;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  border: none; border-radius: 12px;
  font-size: .95rem; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99,102,241,.4);
  transition: transform .15s, box-shadow .15s;
  letter-spacing: .01em;
}
#podcast-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,.55);
}
#podcast-download-btn:active { transform: translateY(0); }

/* ── Error state ── */
.podcast-error-wrap {
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  padding: .4rem 0;
  text-align: center;
}
.podcast-error-icon { font-size: 2rem; }
.podcast-error-msg { font-size: .83rem; color: #fca5a5; line-height: 1.5; }

/* ── Topic input with inline file button ─────────────────── */
.topic-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.topic-input-wrap input[type="text"] {
  flex: 1;
  padding-left: 2.6rem !important;
}
.topic-file-upload-btn {
  position: absolute;
  left: .5rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: .35rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  z-index: 2;
}
.topic-file-upload-btn:hover {
  background: rgba(66,99,235,.10);
  color: var(--accent);
}

/* ── Dev mode button ─────────────────────────────────────── */
.topic-mode-btn.dev-mode-btn {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-color: #0f3460;
  color: #7ec8e3;
  font-weight: 600;
}
.topic-mode-btn.dev-mode-btn:hover {
  border-color: #7ec8e3;
  color: #fff;
}
.topic-mode-btn.dev-mode-btn.active {
  background: linear-gradient(135deg, #0f3460 0%, #533483 100%);
  color: #fff;
  border-color: #7ec8e3;
  box-shadow: 0 0 16px rgba(126,200,227,.25);
}

/* ── Dev mode area ───────────────────────────────────────── */
#dev-mode-area {
  margin-bottom: 1.25rem;
  animation: fadeIn .3s ease-out;
}
.dev-mode-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid #0f3460;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.dev-mode-badge {
  background: linear-gradient(135deg, #0f3460, #533483);
  color: #7ec8e3;
  font-weight: 700;
  font-size: .85rem;
  padding: .3rem .7rem;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid #7ec8e3;
  letter-spacing: .02em;
}
.dev-mode-desc {
  color: #a0b4c8;
  font-size: .88rem;
  line-height: 1.5;
}
#dev-mode-area label {
  font-weight: 600;
  color: var(--text);
  font-size: .9rem;
  margin-bottom: .4rem;
}
#dev-task-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  font-family: var(--font);
  font-size: .95rem;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s;
  direction: rtl;
}
#dev-task-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(66,99,235,.12);
}
.dev-file-row {
  margin-bottom: .8rem;
}
.dev-file-label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--accent);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  padding: .4rem .75rem;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: rgba(66,99,235,.05);
  transition: all .2s;
  user-select: none;
}
.dev-file-label:hover {
  background: rgba(66,99,235,.12);
}
.dev-roles-hint {
  background: rgba(66,99,235,.06);
  border: 1px solid rgba(66,99,235,.18);
  border-radius: 8px;
  padding: .6rem .9rem;
  font-size: .85rem;
  color: var(--muted);
  margin-top: .5rem;
  line-height: 1.7;
}
.dev-roles-hint strong {
  color: var(--text);
  margin-left: .4rem;
}
.dev-role-tag {
  display: inline-block;
  font-weight: 600;
  font-size: .82rem;
  background: rgba(66,99,235,.07);
  border-radius: 5px;
  padding: .1rem .4rem;
  margin: .1rem .2rem;
  border: 1px solid currentColor;
  opacity: .85;
}

/* ══════════════════════════════════════════════════════════════
   CODE BLOCKS
   ══════════════════════════════════════════════════════════════ */
.code-block-wrap {
  direction: ltr;
  margin: .9rem 0;
  border-radius: 10px;
  overflow: hidden;          /* clip children — scrollbar lives inside .code-block-pre */
  border: 1px solid #2d2d3a;
  background: #1e1e2e;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
  font-size: .88rem;
  width: 100%;               /* fill message bubble */
  max-width: 100%;           /* never exceed parent */
  box-sizing: border-box;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .9rem;
  background: #2a2a3d;
  border-bottom: 1px solid #3a3a50;
  gap: .5rem;
}

.code-block-lang {
  font-size: .78rem;
  font-weight: 700;
  color: #a78bfa;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
}

.code-block-actions {
  display: flex;
  gap: .4rem;
}

.code-action-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .28rem .65rem;
  border: 1px solid #4a4a60;
  border-radius: 6px;
  background: #1e1e2e;
  color: #a0a0c0;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}
.code-action-btn:hover {
  background: #2d2d4a;
  border-color: #7c7cf0;
  color: #c5c5ff;
}
.code-action-btn.copied {
  border-color: #34d399;
  color: #34d399;
  background: rgba(52,211,153,.1);
}

.code-block-pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;          /* horizontal scroll INSIDE the block */
  overflow-y: auto;
  background: transparent;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: #4a4a60 #2a2a3d;
  max-height: 520px;
  width: 100%;
  box-sizing: border-box;
}
.code-block-pre::-webkit-scrollbar { height: 6px; width: 6px; }
.code-block-pre::-webkit-scrollbar-track { background: #2a2a3d; }
.code-block-pre::-webkit-scrollbar-thumb { background: #5a5a7a; border-radius: 4px; }
.code-block-pre::-webkit-scrollbar-thumb:hover { background: #7c7cf0; }

.code-block-code {
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'JetBrains Mono', monospace;
  font-size: .85rem;
  color: #cdd6f4;
  white-space: pre;
  display: block;
}

/* ── Inline code ──────────────────────────────────────────── */
.inline-code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: .83em;
  background: rgba(66,99,235,.12);
  color: #5c7cfa;
  border: 1px solid rgba(66,99,235,.2);
  border-radius: 4px;
  padding: .1em .35em;
  direction: ltr;
  display: inline;
}

/* ══════════════════════════════════════════════════════════════
   MID-CHAT CONTROLS  (שינויים 3 + 4)
   ══════════════════════════════════════════════════════════════ */

/* כפתורי control קטנים ליד "המשך שיחה" */
.mid-ctrl-btn {
  font-size: 1.1rem;
  padding: .4rem .6rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all .18s;
}
.mid-ctrl-btn:hover {
  background: rgba(66,99,235,.08);
  border-color: var(--accent);
}

/* ── Panel: מודלים פעילים ── */
#mid-chat-models {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: .8rem;
  animation: fadeIn .25s ease-out;
}
.mid-chat-models-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: .92rem;
  margin-bottom: .75rem;
  color: var(--text);
}
.mid-chat-active-list {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-bottom: .85rem;
  min-height: 2rem;
}
.mid-active-model-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem;
  border: 2px solid;
  border-radius: 20px;
  font-size: .84rem;
  font-weight: 600;
  background: var(--bg);
}
.mid-remove-model {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .8rem;
  padding: 0 .1rem;
  border-radius: 50%;
  transition: all .15s;
  line-height: 1;
}
.mid-remove-model:hover { color: var(--error); background: #fee2e2; }
.mid-remove-model:disabled { opacity: .3; cursor: not-allowed; }

.mid-chat-add-row { display: flex; flex-direction: column; gap: .5rem; }
#mid-chat-search {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .45rem .75rem;
  font-size: .88rem;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
#mid-chat-search:focus { outline: none; border-color: var(--accent); }
.mid-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  max-height: 130px;
  overflow-y: auto;
}
.mid-add-chip {
  padding: .3rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
  transition: all .15s;
}
.mid-add-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(66,99,235,.07);
}

/* ── User mid-conversation input (שינוי 4) ── */
.user-mid-input-area {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: .75rem;
  margin-bottom: .8rem;
  animation: fadeIn .25s ease-out;
  box-shadow: 0 0 0 3px rgba(66,99,235,.1);
}
.user-mid-input-wrap {
  display: flex;
  gap: .6rem;
  align-items: flex-end;
}
#user-mid-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .55rem .8rem;
  font-family: var(--font);
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.5;
  transition: border-color .2s;
}
#user-mid-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(66,99,235,.12);
}
.send-mid-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .18s;
}
.send-mid-btn:hover { background: var(--accent-h); transform: scale(1.05); }
.send-mid-btn:active { transform: scale(.97); }

/* ── Token reset info ── */
.token-reset-info {
  color: var(--accent);
  font-weight: 600;
}

