/* ═══════════════════════════════════════════════════════════════
   OPTREM Academy AI Assistant — Dark / Light Theme Stylesheet
   Approved Palette: #F28C28 (Primary Orange), #D96B12 (Secondary Orange),
                     #172033 (Dark Navy), #F5F7FA (Light Background)
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  --bg-primary: #172033;
  --bg-secondary: #111827;
  --bg-tertiary: #1e293b;
  --bg-hover: #263449;
  --bg-active: #334155;
  --surface: rgba(255, 255, 255, .04);
  --surface-hover: rgba(255, 255, 255, .08);
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .18);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #F28C28;
  --accent-hover: #D96B12;
  --accent-glow: rgba(242, 140, 40, .25);
  --user-bubble: #263449;
  --assistant-bg: transparent;
  --scrollbar-bg: #111827;
  --scrollbar-thumb: #334155;
  --danger: #ef4444;
  --success: #22c55e;
  --code-bg: #0f172a;
  --modal-overlay: rgba(15, 23, 42, .70);
}

[data-theme="light"] {
  --bg-primary: #F5F7FA;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e2e8f0;
  --bg-hover: #cbd5e1;
  --bg-active: #94a3b8;
  --surface: rgba(23, 32, 51, .03);
  --surface-hover: rgba(23, 32, 51, .06);
  --border: rgba(23, 32, 51, .10);
  --border-strong: rgba(23, 32, 51, .18);
  --text-primary: #172033;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #F28C28;
  --accent-hover: #D96B12;
  --accent-glow: rgba(242, 140, 40, .20);
  --user-bubble: #fff7ed;
  --assistant-bg: transparent;
  --scrollbar-bg: #e2e8f0;
  --scrollbar-thumb: #94a3b8;
  --danger: #dc2626;
  --success: #16a34a;
  --code-bg: #ffffff;
  --modal-overlay: rgba(23, 32, 51, .45);
}

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

html {
  font-size: 16px;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  transition: background .3s, color .3s;
}

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* ── Utility buttons ───────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), width .3s;
  z-index: 100;
}

.sidebar.hidden {
  transform: translateX(-100%);
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text-primary);
}

.logo span {
  color: var(--accent);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 8px 12px;
  padding: 10px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: none;
  color: var(--text-secondary);
  font-size: .875rem;
  cursor: pointer;
  transition: all .2s;
}

.new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-secondary);
  transition: background .15s, color .15s;
  position: relative;
}

.conv-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.conv-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.conv-item .conv-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item .conv-delete {
  opacity: 0;
  transition: opacity .15s;
  font-size: .75rem;
  color: var(--danger);
}

.conv-item:hover .conv-delete {
  opacity: 1;
}

.sidebar-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS PANEL
   ═══════════════════════════════════════════════════════════════ */
.settings-panel {
  position: fixed;
  left: 260px;
  bottom: 60px;
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s, opacity .25s;
  z-index: 200;
}

.settings-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.settings-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.settings-panel-header h3 {
  font-size: .95rem;
  font-weight: 600;
}

.settings-group {
  margin-bottom: 14px;
}

.settings-group label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.settings-group label span {
  color: var(--accent);
  font-weight: 600;
}

.settings-group input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  outline: none;
}

.settings-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 6px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════════════════
   MAIN AREA
   ═══════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Top bar ───────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-spacer {
  flex: 1;
}

.model-select {
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
}

.model-select:focus {
  border-color: var(--accent);
}

.model-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ── Messages ──────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  scroll-behavior: smooth;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  text-align: center;
  color: var(--text-secondary);
  animation: fadeUp .6s ease-out;
}

.welcome-icon {
  font-size: 3rem;
  animation: pulse 3s infinite;
}

.welcome h2 {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-primary);
}

.welcome p {
  font-size: .9rem;
  max-width: 380px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1)
  }

  50% {
    transform: scale(1.1)
  }
}

/* single message row */
.msg {
  display: flex;
  gap: 14px;
  padding: 14px 5%;
  max-width: 860px;
  margin: 0 auto;
  animation: msgIn .35s ease-out;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.msg.user .msg-avatar {
  background: var(--accent);
  color: #fff;
}

.msg.assistant .msg-avatar {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.msg-avatar.avatar-fis,
.msg-avatar.avatar-optrem {
  background: linear-gradient(135deg, #F28C28, #D96B12);
  color: #fff;
  font-weight: 800;
  font-size: .7rem;
  letter-spacing: .02em;
}

.msg-avatar.avatar-fis.loading,
.msg-avatar.avatar-optrem.loading {
  position: relative;
}

.msg-avatar.avatar-fis.loading::after,
.msg-avatar.avatar-optrem.loading::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinner 1s linear infinite;
}

.msg-avatar.avatar-error {
  background: #b91c1c;
  box-shadow: 0 0 12px rgba(185, 28, 28, .4);
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: .925rem;
  line-height: 1.65;
  word-wrap: break-word;
  position: relative;
}

.msg.user .msg-bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.msg.assistant .msg-bubble {
  background: var(--assistant-bg);
}

.msg.assistant.typing .msg-bubble {
  border: 1px dashed var(--border-strong);
  background: var(--surface);
}

.msg-bubble img {
  max-width: 260px;
  border-radius: 10px;
  margin-top: 6px;
}

/* message actions */
.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity .2s;
}

.msg:hover .msg-actions {
  opacity: 1;
}

.msg-action-btn {
  font-size: .7rem;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}

.msg-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Typing indicator */
.thinking-bubble {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thinking-bubble.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}

.typing-status {
  font-size: .8rem;
  color: var(--text-secondary);
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .3;
  animation: dotPulse 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: .2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: .4s;
}

@keyframes dotPulse {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: .3;
  }

  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* ── Markdown inside bubbles ──────────────────────────────────── */
.msg-bubble p {
  margin-bottom: 8px;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble ul,
.msg-bubble ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.msg-bubble a {
  color: var(--accent);
  text-decoration: underline;
}

.msg-bubble strong {
  font-weight: 600;
}

.msg-bubble pre {
  background: var(--code-bg);
  border-radius: 10px;
  padding: 14px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.5;
  position: relative;
}

.msg-bubble code {
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: .84em;
}

.msg-bubble :not(pre)>code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: .65rem;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}

.code-copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: .85rem;
}

.msg-bubble th,
.msg-bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.msg-bubble th {
  background: var(--surface);
  font-weight: 600;
}

/* ── Input area ────────────────────────────────────────────────── */
.input-area {
  padding: 0 5% 12px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.input-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  overflow: visible;
  position: relative;
  transition: border-color .2s, box-shadow .2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.image-preview {
  padding: 10px 14px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.image-preview img {
  max-height: 80px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.remove-img {
  background: var(--danger);
  color: #fff;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 8px;
}

.stt-wrapper {
  position: relative;
}

.stt-btn.recording {
  color: var(--danger);
  animation: recPulse 1.2s infinite;
}

.stt-menu {
  position: absolute;
  bottom: 110%;
  right: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  padding: 6px;
  min-width: 180px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  transform: translateY(6px);
  z-index: 400;
}

.stt-wrapper.open .stt-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.stt-menu button {
  border: none;
  background: none;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
  font-size: .85rem;
  color: var(--text-primary);
  cursor: pointer;
}

.stt-menu button:hover {
  background: var(--surface-hover);
}

#chatInput {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: .925rem;
  padding: 6px 8px;
  max-height: 200px;
  line-height: 1.5;
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .15s;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.06);
}

.send-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}

.stt-btn.recording {
  color: var(--danger);
  animation: recPulse 1s infinite;
}

@keyframes recPulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .4
  }
}

.video-btn:hover {
  color: var(--accent);
}

.disclaimer {
  text-align: center;
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL (video generation)
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  width: 480px;
  max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  transform: translateY(20px);
  transition: transform .3s;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

.modal-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.avatar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--surface);
  transition: all .2s;
}

.avatar-card:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.avatar-card.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.avatar-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
}

.avatar-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
}

.avatar-card span {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.file-drop-area {
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: all .2s;
  position: relative;
  margin-bottom: 12px;
}

.file-drop-area:hover,
.file-drop-area.dragover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.file-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: .8;
}

.file-msg {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.file-sub {
  font-size: .75rem;
  color: var(--text-muted);
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-selected-name {
  font-size: .85rem;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-selected-name::before {
  content: "📎";
}

.api-type-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.api-type-option {
  flex: 1;
  cursor: pointer;
}

.api-type-option input[type="radio"] {
  display: none;
}

.api-type-card {
  padding: 14px;
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  transition: all .2s;
}

.api-type-option input[type="radio"]:checked+.api-type-card {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.api-type-card:hover {
  border-color: var(--accent);
}

.api-type-title {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.api-type-desc {
  font-size: .75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.sentiment-selector {
  margin-bottom: 16px;
}

.modal-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: .875rem;
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
}

.modal-select:focus {
  border-color: var(--accent);
}

.modal-textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: .875rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color .2s;
}

.modal-textarea:focus {
  border-color: var(--accent);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.btn-secondary,
.btn-primary {
  padding: 8px 18px;
  border-radius: 10px;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.btn-secondary {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.video-result {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.progress-indicator {
  text-align: center;
  padding: 12px;
}

.progress-status {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.progress-detail {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.success-msg {
  color: #10b981;
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 6px;
  text-align: center;
}

.error-msg {
  color: var(--danger);
  font-weight: 500;
  font-size: .9rem;
  padding: 10px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 6px;
  border-left: 3px solid var(--danger);
}

.video-result strong {
  display: block;
  font-size: .85rem;
  color: var(--text-secondary);
  margin-top: 12px;
  margin-bottom: 6px;
}

.video-result a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  font-size: .85rem;
}

.video-result a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════
   VOICE MODAL (Grok-style)
   ═══════════════════════════════════════════════════════════════ */
.voice-modal {
  background: var(--bg-primary);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.voice-modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.voice-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.voice-badge.gemini {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}

.voice-badge.openai {
  background: rgba(244, 114, 182, 0.12);
  border-color: rgba(244, 114, 182, 0.35);
  color: #f472b6;
}

.voice-modal-header h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.voice-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.voice-transcripts {
  margin-top: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-transcript {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.voice-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
  margin-top: 20px;
}

.voice-label:first-child {
  margin-top: 0;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.voice-card {
  padding: 14px;
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.voice-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.voice-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.voice-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.voice-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.voice-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.voice-select:focus {
  border-color: var(--accent);
}

.voice-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-strong);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  margin-top: 8px;
}

.voice-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.2s;
}

.voice-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.voice-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  transition: transform 0.2s;
}

.voice-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.voice-status {
  margin-top: 24px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 2s infinite;
}

.voice-indicator.recording {
  background: var(--danger);
  animation: pulse-fast 1s infinite;
}

.voice-indicator.processing {
  background: var(--accent);
  animation: pulse-fast 0.8s infinite;
}

#voiceStatusText {
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex: 1;
}

.voice-timer {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  background: rgba(148, 163, 184, 0.08);
  min-width: 54px;
  text-align: center;
  opacity: 0.6;
}

.voice-timer.active {
  opacity: 1;
}

.voice-timer.warn {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
}

.voice-timer.danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
}

.voice-modal-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.voice-mic-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.voice-mic-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.voice-mic-btn:active {
  transform: scale(0.95);
}

.voice-mic-btn.recording {
  background: var(--danger);
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset: 0;
    width: 280px;
    min-width: 0;
    transform: translateX(-100%);
    z-index: 300;
  }

  .sidebar.visible {
    transform: translateX(0);
  }

  .settings-panel {
    left: 12px;
    width: calc(100% - 24px);
  }

  .msg {
    padding: 10px 4%;
  }

  .input-area {
    padding: 0 3% 10px;
  }
}

/* ── Inline error ──────────────────────────────────────────────── */
.msg-error {
  color: var(--danger);
  font-size: .85rem;
  font-style: italic;
}

/* ── Toast notifications ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: .85rem;
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .3);
  animation: toastIn .3s ease-out, toastOut .3s ease-in 2s forwards;
  z-index: 9999;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

/* -- Markdown Rendering Styles --------------------------- */
.message-content h1 {
  font-size: 1.4em;
  margin: 0.8em 0 0.4em;
  font-weight: 700;
}

.message-content h2 {
  font-size: 1.2em;
  margin: 0.7em 0 0.3em;
  font-weight: 600;
}

.message-content h3 {
  font-size: 1.1em;
  margin: 0.6em 0 0.3em;
  font-weight: 600;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--border-color, #333);
  margin: 1em 0;
}

.message-content strong {
  font-weight: 700;
}

.message-content em {
  font-style: italic;
}

.message-content .table-wrapper {
  overflow-x: auto;
  margin: 0.8em 0;
}

.message-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
}

.message-content th,
.message-content td {
  border: 1px solid var(--border-color, #444);
  padding: 0.5em 0.8em;
  text-align: right;
}

.message-content th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.message-content tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.message-content ul,
.message-content ol {
  padding-right: 1.5em;
  margin: 0.5em 0;
}

.message-content li {
  margin: 0.3em 0;
  line-height: 1.6;
}

.message-content .code-block {
  margin: 0.8em 0;
  border-radius: 8px;
  overflow: hidden;
  background: #1e1e1e;
}

.message-content .code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4em 0.8em;
  background: #2d2d2d;
  font-size: 0.8em;
  color: #aaa;
}

.message-content .code-header .copy-btn {
  background: none;
  border: 1px solid #555;
  color: #aaa;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
}

.message-content .code-header .copy-btn:hover {
  background: #444;
  color: #fff;
}

.message-content pre {
  margin: 0;
  padding: 1em;
  overflow-x: auto;
}

.message-content pre code {
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9em;
  color: #d4d4d4;
}

.message-content .inline-code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9em;
}

/* RTL support for Arabic content */
.message-content[dir='rtl'] table th,
.message-content[dir='rtl'] table td {
  text-align: right;
}

.message-content[dir='rtl'] ul,
.message-content[dir='rtl'] ol {
  padding-right: 1.5em;
  padding-left: 0;
}