/* ==========================================================================
   Millisa AI - ChatGPT Visual Refresh Layer
   Loaded last. Visual-only overrides (color, spacing, radius, type).
   Never changes `display` of elements that JS shows/hides.
   ========================================================================== */

:root {
  --bg-canvas: #212121;
  --bg-sidebar: #181818;
  --bg-pill: #303030;
  --bg-pill-hover: #3a3a3a;
  --bg-surface: #2a2a2a;
  --bg-surface-hover: #2a2a2a;
  --bg-surface-active: #303030;
  --bg-modal: #2f2f2f;
  --bg-menu: #353535;
  --bg-menu-hover: #424242;
  --bg-code: #171717;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(255, 255, 255, 0.2);

  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --text-tertiary: #8f8f8f;
  --text-muted: #6b6b6b;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --menu-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

html, body {
  font-family: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.003em;
}

::selection {
  background: rgba(255, 255, 255, 0.18);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

/* ──────────────────────────────────────────────────────────────────────────
   SIDEBAR
   ────────────────────────────────────────────────────────────────────────── */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
  padding: 0 0.6rem 0 0.85rem;
}

.sidebar .icon-btn {
  color: var(--text-tertiary);
  border-radius: 8px;
}

.sidebar .icon-btn:hover {
  background: #2a2a2a;
  color: var(--text-primary);
}

/* New chat + nav rows: flat ChatGPT rows instead of bordered boxes */
.new-chat-btn,
#btn-plugins,
.sidebar-nav-action-btn {
  margin: 0 0.5rem 1px !important;
  width: calc(100% - 1rem) !important;
  padding: 0.5rem 0.65rem !important;
  border: none !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: var(--text-primary) !important;
  font-size: 0.875rem !important;
  font-weight: 400 !important;
  min-height: 36px;
  transition: background 0.12s ease !important;
}

.new-chat-btn {
  margin-top: 0.15rem !important;
}

.new-chat-btn:hover,
#btn-plugins:hover,
.sidebar-nav-action-btn:hover {
  background: #2a2a2a !important;
}

.new-chat-btn .shortcut-badge {
  opacity: 0;
  transition: opacity 0.12s ease;
}

.new-chat-btn:hover .shortcut-badge {
  opacity: 1;
}

.sidebar-nav-action-btn .sidebar-action-left,
.new-chat-left {
  gap: 0.7rem !important;
}

.sidebar-nav-action-btn .sidebar-action-left span {
  color: var(--text-primary) !important;
  font-size: 0.875rem !important;
  font-weight: 400 !important;
}

/* Monochrome icons like ChatGPT */
.new-chat-btn svg,
.sidebar-nav-action-btn .sidebar-action-left svg {
  stroke: currentColor;
  color: var(--text-primary) !important;
  width: 18px;
  height: 18px;
}

/* Neutral count pills */
#active-plugins-badge,
#install-device-pill,
#training-count-badge,
.interpreter-live-pill {
  color: var(--text-secondary) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  font-weight: 500 !important;
}

.sidebar-history {
  padding: 0.85rem 0.5rem 0.75rem;
  gap: 1px;
}

.history-section-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 0.85rem 0.65rem 0.35rem;
}

.chat-history-item {
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  font-size: 0.875rem;
  color: var(--text-primary);
  min-height: 36px;
}

.chat-history-item:hover {
  background: #2a2a2a;
}

.chat-history-item.active,
.chat-history-item.menu-open {
  background: #303030;
  font-weight: 400;
}

.chat-item-menu-btn {
  border-radius: 8px;
  color: var(--text-secondary);
}

/* Footer / account */
.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.5rem;
}

.user-profile-btn {
  padding: 0.5rem 0.55rem;
  border-radius: 10px;
}

.user-profile-btn:hover {
  background: #2a2a2a;
}

.user-avatar-circle {
  font-weight: 600;
}

.user-display-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.sidebar-guest-card {
  background: transparent;
  border: none;
  padding: 0.5rem 0.55rem 0.75rem;
}

.guest-card-title {
  font-size: 0.95rem;
}

.guest-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-guest-login,
.btn-guest-signup {
  border-radius: 9999px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
}

.btn-guest-signup:hover {
  transform: none;
}

/* ──────────────────────────────────────────────────────────────────────────
   POPOVERS & MENUS (profile, model, context, attach)
   ────────────────────────────────────────────────────────────────────────── */
.profile-popover-menu,
.model-selector-dropdown,
.chat-context-menu-popover {
  background: var(--bg-menu);
  border: none;
  border-radius: 16px;
  box-shadow: var(--menu-shadow);
  padding: 6px;
}

.attach-popover-menu {
  background: var(--bg-menu) !important;
  border: none !important;
  border-radius: 18px !important;
  box-shadow: var(--menu-shadow) !important;
}

.attach-menu-item {
  border-radius: 10px !important;
  height: 40px !important;
  min-height: 40px !important;
}

.attach-menu-item:hover,
.attach-menu-item:focus-visible {
  background: var(--bg-menu-hover) !important;
}

.popover-item,
.model-option,
.context-menu-item {
  border-radius: 10px;
}

.popover-item:hover,
.model-option:hover,
.model-option.active,
.context-menu-item:hover {
  background: var(--bg-menu-hover);
}

.popover-item-title {
  font-weight: 400;
  font-size: 0.875rem;
}

.popover-divider,
.context-menu-divider {
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 8px;
}

.model-selector-dropdown {
  width: 320px;
  top: 50px;
}

.model-option {
  padding: 0.6rem 0.75rem;
}

.model-option-title {
  font-weight: 500;
  font-size: 0.875rem;
}

.model-option-desc {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.shortcut-badge {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   TOP HEADER
   ────────────────────────────────────────────────────────────────────────── */
.chat-top-header {
  background: var(--bg-canvas);
}

.chat-top-header .icon-btn,
.btn-header-new-chat {
  color: var(--text-secondary) !important;
  border: none !important;
  border-radius: 8px !important;
}

.chat-top-header .icon-btn:hover,
.btn-header-new-chat:hover {
  background: #2f2f2f !important;
  color: var(--text-primary) !important;
}

.model-selector-btn {
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: 10px;
}

.model-selector-btn svg {
  color: var(--text-tertiary);
}

.model-selector-btn:hover {
  background: #2f2f2f;
}

/* Header pills: quiet ghost buttons */
.btn-new-chat-top-pill,
.btn-share-pill {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text-primary) !important;
  font-weight: 500 !important;
  border-radius: 9999px !important;
}

.btn-new-chat-top-pill:hover,
.btn-share-pill:hover {
  background: #2f2f2f !important;
  border-color: transparent !important;
  transform: none !important;
}

.btn-developer-api-pill {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: none;
}

.btn-developer-api-pill:hover {
  background: #2f2f2f;
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  transform: none;
  box-shadow: none;
}

.pulse-emerald-dot {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

/* ChatGPT guest buttons: white "Log in", dark "Sign up" */
.nav-auth-btn-login {
  background: #ffffff;
  border: 1px solid #ffffff;
  color: #0d0d0d;
  font-weight: 500;
}

.nav-auth-btn-login:hover {
  background: #e8e8e8;
  border-color: #e8e8e8;
}

.nav-auth-btn-signup {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-primary);
  font-weight: 500;
}

.nav-auth-btn-signup:hover {
  background: #2f2f2f;
  transform: none;
}

@media (min-width: 769px) {
  .chat-top-header {
    height: 56px;
    padding: 0 0.75rem;
  }

  .model-selector-btn {
    padding: 0.4rem 0.7rem;
  }

  .btn-new-chat-top-pill,
  .btn-share-pill,
  .btn-developer-api-pill,
  .nav-auth-btn-login,
  .nav-auth-btn-signup {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
  }

  .chat-top-header-right,
  .nav-guest-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: nowrap;
    align-items: center;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   EMPTY STATE HERO
   ────────────────────────────────────────────────────────────────────────── */
.hero-logo-img {
  filter: none;
}

.hero-title {
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.suggestion-chip {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 0.85rem 1rem;
}

.suggestion-chip:hover {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.1);
  transform: none;
}

.suggestion-chip-title {
  font-weight: 500;
  font-size: 0.875rem;
}

.suggestion-chip-sub {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

@media (min-width: 769px) {
  .hero-title {
    font-size: 1.85rem;
    margin-bottom: 1.75rem;
  }

  .hero-logo-img {
    height: 56px;
  }

  .suggestion-chips-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.25rem;
  }

  /* ChatGPT-style centered start screen: greeting + composer sit together
     in the middle of the page until the first message is sent. */
  .main-viewport:has(.conversation-thread:not(.active)) .chat-scroll-area {
    flex: 0 1 auto;
    margin-top: auto;
  }

  .main-viewport:has(.conversation-thread:not(.active)) .input-dock-container {
    margin-bottom: auto !important;
    padding-bottom: 6vh !important;
  }

  .main-viewport:has(.conversation-thread:not(.active)) .empty-state-hero {
    flex: 0 0 auto;
    padding-bottom: 0.5rem;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   CONVERSATION THREAD
   ────────────────────────────────────────────────────────────────────────── */
.conversation-thread {
  gap: 1.75rem;
}

.user-bubble {
  background: #303030;
  border-radius: 22px;
  line-height: 1.6;
}

.user-bubble-meta .message-time {
  color: rgba(255, 255, 255, 0.4);
}

.assistant-content-wrapper,
.markdown-body {
  color: #ececec;
}

/* ChatGPT shows no avatar beside replies; keep custom agent emoji avatars */
img.assistant-avatar-icon {
  display: none;
}

.assistant-action-bar {
  gap: 2px;
  margin-top: 0.5rem;
  margin-left: -6px;
}

.action-pill-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-secondary);
}

.action-pill-btn:hover {
  background: #2f2f2f;
  color: var(--text-primary);
}

.action-pill-btn svg {
  width: 16px;
  height: 16px;
}

.assistant-message-time {
  color: var(--text-muted);
}

.assistant-model-badge,
.sources-toggle-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  color: var(--text-tertiary);
}

.assistant-model-badge:hover,
.sources-toggle-btn:hover {
  background: #2f2f2f;
}

.chat-date-badge {
  background: rgba(33, 33, 33, 0.85);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-secondary);
}

/* Reasoning accordion: neutral like ChatGPT "Thought for Xs" */
.thinking-accordion {
  background: transparent;
  border: none;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  padding: 0.15rem 0 0.15rem 0.85rem;
}

.thinking-header {
  color: var(--text-secondary);
  font-weight: 500;
}

.thinking-content {
  border-top: none;
  color: var(--text-tertiary);
}

/* Code blocks */
.code-block-container {
  background: var(--bg-code);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.code-block-header {
  background: #2a2a2a;
  border-bottom: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.45rem 0.9rem;
}

.btn-copy-code {
  color: var(--text-secondary);
  border-radius: 6px;
}

.markdown-body :not(pre) > code {
  background: #424242;
  color: #f4f4f4;
  border: none;
  border-radius: 6px;
  padding: 0.12em 0.4em;
  font-size: 0.875em;
}

.markdown-body h1 {
  border-bottom: none;
}

/* Tables: neutralize the HTML border="1" attribute, keep soft row rules */
.table-container {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

.table-actions {
  background: transparent;
}

.markdown-table {
  border: none;
}

.markdown-table th,
.markdown-table td,
.assistant-content-wrapper .markdown-table th,
.assistant-content-wrapper .markdown-table td {
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.markdown-table th {
  background: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.16);
}

.markdown-table tbody tr:nth-child(even) {
  background: transparent;
}

.markdown-body hr {
  border-color: rgba(255, 255, 255, 0.1);
}

@media (min-width: 769px) {
  .conversation-thread {
    padding: 1rem 1.5rem 3rem;
  }

  .user-bubble {
    max-width: 70%;
    padding: 0.65rem 1.15rem 0.4rem;
    font-size: 1rem;
  }

  .assistant-content-wrapper,
  .markdown-body {
    font-size: 1rem;
    line-height: 1.75;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   COMPOSER (input dock)
   ────────────────────────────────────────────────────────────────────────── */
.floating-pill-box {
  background: #303030 !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  border-radius: 28px !important;
  padding: 10px 12px !important;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.25) !important;
}

.floating-pill-box:focus-within {
  border-color: rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.6), 0 10px 30px rgba(0, 0, 0, 0.35) !important;
}

.prompt-textarea {
  color: #ececec !important;
}

.prompt-textarea::placeholder {
  color: #9b9b9b !important;
}

.btn-dock-tool {
  color: #d0d0d0 !important;
}

#btn-dock-interpreter {
  color: #10b981 !important;
}

.btn-dock-tool:hover {
  background: #424242 !important;
  color: #ffffff !important;
}

.btn-think-toggle {
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #d0d0d0 !important;
}

.btn-think-toggle:hover {
  background: #424242 !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}

.btn-think-toggle.active {
  background: rgba(72, 170, 255, 0.14) !important;
  border-color: rgba(72, 170, 255, 0.35) !important;
  color: #8cc8ff !important;
}

.btn-dock-send {
  width: 36px !important;
  height: 36px !important;
  background: #ffffff !important;
  color: #0d0d0d !important;
}

.btn-dock-send:not(:disabled):hover {
  background: #d9d9d9 !important;
  transform: none !important;
}

.btn-dock-send:disabled {
  background: #676767 !important;
  color: #2f2f2f !important;
}

.dock-attachments-strip {
  border-bottom: none !important;
}

.attached-file-chip {
  background: #3a3a3a !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  border-radius: 14px !important;
}

.dock-mode-tag {
  background: rgba(72, 170, 255, 0.12);
  border: none;
  color: #8cc8ff;
  padding: 0.3rem 0.65rem;
}

.dock-disclaimer {
  color: #8f8f8f !important;
  font-size: 0.75rem !important;
}

.dock-disclaimer a {
  color: #b4b4b4 !important;
}

@media (min-width: 769px) {
  .input-dock-container {
    max-width: 800px !important;
    padding: 0 1.5rem 0.75rem !important;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   MODALS
   ────────────────────────────────────────────────────────────────────────── */
.modal-backdrop-overlay {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: none;
}

.search-modal-card,
.plugins-modal-card,
.share-modal-card {
  background: var(--bg-modal);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

/* ──────────────────────────────────────────────────────────────────────────
   PHONES & SMALL TABLETS
   ────────────────────────────────────────────────────────────────────────── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior: none;
}

@media (max-width: 768px) {
  .chat-top-header {
    height: calc(52px + env(safe-area-inset-top, 0px));
    gap: 0.25rem;
  }

  .header-left {
    min-width: 0;
    gap: 0.15rem;
  }

  .chat-top-header-right {
    gap: 0.25rem;
  }

  .model-selector-btn {
    font-size: 1rem;
  }

  .active-agent-pill-name {
    max-width: 90px;
  }

  .conversation-thread {
    gap: 1.4rem;
  }

  .assistant-action-bar {
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }

  /* Comfortable tap targets */
  .chat-history-item,
  .popover-item,
  .context-menu-item,
  .model-option {
    min-height: 42px;
  }

  .chat-history-item .chat-item-actions {
    display: flex;
  }

  /* Dialogs: edge-to-edge width with breathing room */
  .modal-backdrop-overlay {
    padding: 12px;
  }

  .search-modal-card {
    align-self: flex-start;
    margin-top: calc(8px + env(safe-area-inset-top, 0px)) !important;
  }

  .plugins-modal-card {
    max-height: calc(100dvh - 24px);
  }

  .plugins-grid {
    grid-template-columns: 1fr;
  }

  /* Training Studio & Live Interpreter take the full screen on phones */
  #training-studio-modal,
  #interpreter-modal {
    padding: 0 !important;
  }

  .training-studio-card,
  .interpreter-modal-card {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh !important;
    margin: 0 !important;
    border: none;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .training-studio-header,
  .interpreter-modal-header {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .training-studio-header > div:first-child {
    min-width: 0;
  }

  .training-studio-subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .training-studio-body {
    flex: 1;
    max-height: none;
    padding: 1rem;
  }

  .studio-section-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .studio-templates-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .studio-template-chip {
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 0.85rem;
  }

  .studio-template-chip:hover {
    transform: none;
  }

  .template-chip-icon {
    flex-shrink: 0;
  }

  .template-chip-info {
    flex: 1;
    min-width: 0;
  }

  .template-use-btn {
    flex-shrink: 0;
  }

  .studio-editor-nav {
    gap: 0.5rem;
  }

  .studio-back-btn {
    flex-shrink: 0;
    padding: 0.4rem;
  }

  .studio-back-btn span {
    display: none;
  }

  .studio-editor-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
  }

  .btn-studio-save-top {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Section title + side note rows stack instead of squeezing */
  .studio-form-card > div:has(> .studio-form-card-title) {
    flex-wrap: wrap;
    gap: 0.15rem 0.75rem;
  }

  /* Interpreter */
  .interpreter-header-title {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    gap: 0.5rem;
  }

  .interpreter-header-title > span:not(.interpreter-header-badge) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .interpreter-header-badge {
    display: none;
  }

  #btn-interpreter-header-reset {
    padding: 0.4rem 0.55rem !important;
  }

  #btn-interpreter-header-reset span {
    display: none;
  }

  .interpreter-controls-bar {
    padding: 0.75rem 1rem;
    gap: 0.6rem;
  }

  .interpreter-lang-selector-group {
    width: 100%;
    flex-wrap: nowrap;
  }

  .interpreter-lang-select {
    flex: 1;
    min-width: 0;
    font-size: 16px;
  }

  .interpreter-body {
    padding: 1rem;
    gap: 1rem;
  }

  .interpreter-footer-actions {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .interpreter-footer-actions > div {
    width: 100%;
  }

  .interpreter-footer-actions .btn-interpreter-action {
    flex: 1;
    justify-content: center;
    white-space: nowrap;
  }

  /* Shorter label for the footer reset button on narrow screens */
  .interpreter-footer-actions .btn-interpreter-reset-danger span {
    display: none;
  }

  .interpreter-footer-actions .btn-interpreter-reset-danger::after {
    content: "Reset";
  }

  /* Prevent iOS zoom-on-focus in every form field */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  .chat-top-header {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  .btn-header-new-chat {
    display: none !important;
  }
}

/* Model picker is Super Admin only: everyone else sees a plain "Millisa" title */
.model-selector-btn.model-selector-locked {
  cursor: default;
  pointer-events: none;
}

.model-selector-btn.model-selector-locked svg {
  display: none;
}

/* ──────────────────────────────────────────────────────────────────────────
   SOURCE CHIPS under live-news answers (ChatGPT-style)
   ────────────────────────────────────────────────────────────────────────── */
.source-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.85rem;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
  padding: 4px 10px 4px 6px;
  border-radius: 9999px;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.source-chip:hover {
  background: #353535;
  color: var(--text-primary);
}

.source-chip img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  background: #ffffff;
}

.source-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-chip-more {
  padding-left: 10px;
  font-family: inherit;
}

/* ──────────────────────────────────────────────────────────────────────────
   RESUME STUDIO (details form → Overleaf-style code + PDF + ATS score)
   ────────────────────────────────────────────────────────────────────────── */
.resume-studio-card {
  position: relative;
  width: min(1320px, 96vw);
  height: min(900px, 92vh);
  height: min(900px, 92dvh);
  background: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.rs-header-title { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.rs-header-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(245, 158, 11, 0.12); color: #f59e0b;
}
.rs-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.rs-subtitle { font-size: 0.78rem; color: var(--text-tertiary); }
.rs-header-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

.rs-select, .rs-input {
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  outline: none;
}
.rs-select { max-width: 240px; }
.rs-input { width: 100%; }
.rs-input:focus, .rs-textarea:focus { border-color: rgba(255, 255, 255, 0.25); }

.rs-body { flex: 1; overflow-y: auto; padding: 1.25rem; }
.rs-form { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 0.5rem; }
.rs-label { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); margin-top: 0.6rem; }
.rs-required { color: #f87171; }
.rs-optional { font-weight: 400; color: var(--text-tertiary); }

.rs-textarea {
  width: 100%;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 0.8rem 0.9rem;
  resize: vertical;
  outline: none;
}
.rs-details { min-height: 230px; }
.rs-jd { min-height: 110px; }

.rs-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.rs-upload-row { display: flex; }
.rs-build-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.rs-price-note { font-size: 0.8rem; color: var(--text-tertiary); }

.rs-btn-primary, .rs-btn-secondary {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border-radius: 9999px; font-family: inherit; font-size: 0.84rem; font-weight: 500;
  padding: 0.5rem 1rem; cursor: pointer; white-space: nowrap;
  transition: background 0.12s ease;
}
.rs-btn-primary { background: #ffffff; color: #0d0d0d; border: 1px solid #ffffff; }
.rs-btn-primary:hover { background: #e5e5e5; }
.rs-btn-secondary { background: transparent; color: var(--text-primary); border: 1px solid rgba(255, 255, 255, 0.14); }
.rs-btn-secondary:hover { background: #2f2f2f; }

/* Editor */
.rs-editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.rs-toolbar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.rs-doc-title { flex: 1; min-width: 0; font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-toolbar-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.rs-toolbar .rs-btn-primary, .rs-toolbar .rs-btn-secondary { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.rs-tabs { display: none; }
.rs-panes {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 300px;
}
.rs-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid rgba(255, 255, 255, 0.07); }
.rs-pane:last-child { border-right: none; }
.rs-pane-label {
  font-size: 0.72rem; color: var(--text-tertiary); padding: 0.4rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-family: 'JetBrains Mono', monospace;
}
.rs-code {
  flex: 1; width: 100%; border: none; outline: none; resize: none;
  background: #171717; color: #e4e4e7;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.6;
  padding: 0.8rem; tab-size: 2; white-space: pre; overflow: auto;
}
.rs-pdf-frame { flex: 1; width: 100%; border: none; background: #525659; }
.rs-pane-ats { overflow-y: auto; }
.rs-ats { padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.rs-ats-empty { color: var(--text-tertiary); font-size: 0.85rem; }
.rs-ats-score { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem; border-radius: 14px; background: #2a2a2a; }
.rs-ats-number {
  width: 58px; height: 58px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; font-weight: 700; border: 3px solid currentColor;
}
.rs-ats-good .rs-ats-number { color: #34d399; }
.rs-ats-ok .rs-ats-number { color: #fbbf24; }
.rs-ats-low .rs-ats-number { color: #f87171; }
.rs-ats-title { font-weight: 600; font-size: 0.88rem; }
.rs-ats-caption { font-size: 0.74rem; color: var(--text-tertiary); margin-top: 2px; }
.rs-ats-row-head { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 4px; }
.rs-ats-bar { height: 6px; border-radius: 9999px; background: #333; overflow: hidden; }
.rs-ats-bar > div { height: 100%; border-radius: 9999px; background: #10a37f; }
.rs-ats-sub { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); margin-top: 0.4rem; text-transform: uppercase; letter-spacing: 0.04em; }
.rs-ats-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.rs-ats-chips span { font-size: 0.74rem; padding: 2px 8px; border-radius: 9999px; background: rgba(248, 113, 113, 0.12); color: #fca5a5; border: 1px solid rgba(248, 113, 113, 0.25); }
.rs-ats-tips { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.45; }

/* Loading overlay */
.rs-loading {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.9rem;
  background: rgba(23, 23, 23, 0.82); backdrop-filter: blur(2px);
}
.rs-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: #ffffff;
  animation: rsSpin 0.8s linear infinite;
}
@keyframes rsSpin { to { transform: rotate(360deg); } }
.rs-loading-text { font-size: 0.9rem; color: var(--text-primary); }

/* Tablets: code + PDF side by side, ATS via tab */
@media (max-width: 1100px) {
  .rs-tabs {
    display: flex; gap: 0.25rem; padding: 0.4rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }
  .rs-tab {
    flex: 1; padding: 0.45rem; border-radius: 9999px; border: none; background: transparent;
    color: var(--text-secondary); font-family: inherit; font-size: 0.82rem; font-weight: 500; cursor: pointer;
  }
  .rs-tab.active { background: #2f2f2f; color: var(--text-primary); }
  .rs-panes { display: block; position: relative; }
  .rs-pane { display: none; height: 100%; border-right: none; }
  .rs-pane.active { display: flex; }
}

/* Phones: full screen, stacked form, compact toolbar */
@media (max-width: 768px) {
  #resume-studio-modal { padding: 0 !important; }
  .resume-studio-card {
    width: 100%; height: 100vh; height: 100dvh; border-radius: 0; border: none;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .rs-subtitle { display: none; }
  .rs-select { max-width: 140px; }
  .rs-body { padding: 1rem; }
  .rs-grid-2 { grid-template-columns: 1fr; }
  .rs-build-row { flex-direction: column; align-items: stretch; }
  .rs-build-row .rs-btn-primary { justify-content: center; }
  .rs-toolbar { flex-wrap: wrap; }
  .rs-doc-title { order: -1; flex-basis: 100%; }
  .rs-toolbar > .rs-btn-secondary { order: 0; }
  .rs-toolbar-actions { flex: 1; justify-content: flex-end; flex-wrap: wrap; }
  .rs-toolbar-actions .rs-btn-secondary span { display: none; }
  .rs-code { font-size: 12px; }
}
.rs-ats-improved { font-size: 0.78rem; color: #34d399; background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.25); border-radius: 10px; padding: 0.45rem 0.7rem; }
.rs-orig { font-size: 0.82rem; color: var(--text-secondary); }
.rs-orig-number { font-weight: 700; font-size: 0.95rem; }
.rs-orig.rs-ats-good .rs-orig-number { color: #34d399; }
.rs-orig.rs-ats-ok .rs-orig-number { color: #fbbf24; }
.rs-orig.rs-ats-low .rs-orig-number { color: #f87171; }

/* ──────────────────────────────────────────────────────────────────────────
   WORD DOCUMENTS: post-build checklist + real page preview
   ────────────────────────────────────────────────────────────────────────── */
.docx-checklist {
  margin-top: 0.75rem; padding: 0.7rem 0.85rem; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08);
}
.docx-checklist-title { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); margin-bottom: 0.35rem; }
.docx-checklist ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; }
.docx-checklist li.ok { color: #6ee7b7; }
.docx-checklist li.bad { color: #fca5a5; }
.docx-checklist li.warn { color: #fcd34d; }
.docx-placeholders { margin-top: 0.5rem; font-size: 0.78rem; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.docx-placeholders span { background: #fde047; color: #111; border-radius: 4px; padding: 0 5px; font-size: 0.74rem; }

.word-real-preview-card {
  width: min(960px, 96vw); height: min(920px, 92vh); height: min(920px, 92dvh);
  background: #1f1f1f; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 18px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.word-real-preview-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; padding: 0.85rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.word-real-preview-title { font-weight: 600; font-size: 0.95rem; }
.word-real-preview-note { font-size: 0.76rem; color: var(--text-tertiary); margin-top: 2px; }
.word-real-preview-body { flex: 1; overflow: auto; background: #3a3a3a; }
.word-real-preview-pages { min-height: 100%; }
.word-real-preview-pages .mw-docx-wrapper { background: #3a3a3a !important; padding: 20px !important; }
.word-real-preview-pages .mw-docx-wrapper > section.mw-docx { box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45) !important; margin-bottom: 20px !important; }
.word-real-preview-loading { color: var(--text-secondary); padding: 2rem; text-align: center; font-size: 0.9rem; }
@media (max-width: 768px) {
  #word-real-preview-modal { padding: 0 !important; }
  .word-real-preview-card { width: 100%; height: 100vh; height: 100dvh; border-radius: 0; border: none; }
  .word-real-preview-pages .mw-docx-wrapper { padding: 8px !important; }
  .word-real-preview-pages .mw-docx-wrapper > section.mw-docx { transform-origin: top left; zoom: 0.45; }
}

/* ── Master template documents (Training Studio agents) ───────────────────── */
.tpl-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.6rem; margin: 0.85rem 0 0.3rem; }
.tpl-input { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.76rem; color: var(--text-secondary); }
.tpl-input.wide { grid-column: 1 / -1; }
.tpl-input input, .tpl-input textarea {
  width: 100%; box-sizing: border-box; padding: 0.5rem 0.65rem; border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.12)); background: var(--bg-input, rgba(255,255,255,0.04));
  color: var(--text-primary); font: inherit; font-size: 0.85rem; resize: vertical;
}
.tpl-input input:placeholder-shown { border-style: dashed; }
.tpl-input input:disabled, .tpl-input textarea:disabled { opacity: 0.7; }
.tpl-setup-note { font-size: 0.78rem; color: var(--text-tertiary); line-height: 1.5; grid-column: 1 / -1; }
.tpl-action-line { font-size: 0.86rem; color: var(--text-primary); margin-bottom: 0.4rem; }
.tpl-progress-list { list-style: none; margin: 0.7rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--text-secondary); }
.tpl-progress-list li.done { color: #10b981; }
.tpl-progress-list li.error { color: #ef4444; }
.tpl-progress-list li.waiting { opacity: 0.6; }
.tpl-citations { margin-top: 0.6rem; font-size: 0.78rem; color: #f59e0b; }
.tpl-citations ul { margin: 0.3rem 0 0; padding-left: 1.1rem; color: var(--text-secondary); }
.tpl-setup { display: flex; flex-direction: column; gap: 0.45rem; width: 100%; }
.tpl-setup-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-primary); }
.tpl-setup-head .tpl-setup-btn { margin-left: auto; }
.tpl-setup-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); margin-top: 0.35rem; }
.tpl-setup-btn { padding: 0.3rem 0.7rem; border-radius: 7px; border: 1px solid rgba(245,158,11,0.4); background: rgba(245,158,11,0.14); color: #f59e0b; font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.tpl-setup-btn.ghost { background: transparent; border-color: var(--border-color, rgba(255,255,255,0.15)); color: var(--text-secondary); align-self: flex-start; }
.tpl-field-row, .tpl-section-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tpl-field-label { width: 150px; max-width: 100%; padding: 0.3rem 0.5rem; border-radius: 6px; border: 1px solid var(--border-color, rgba(255,255,255,0.12)); background: transparent; color: var(--text-primary); font-size: 0.78rem; }
.tpl-field-values { display: flex; flex-wrap: wrap; gap: 0.3rem; flex: 1; min-width: 0; }
.tpl-value-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.45rem; border-radius: 999px; background: rgba(245,158,11,0.12); color: #f59e0b; font-size: 0.74rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tpl-value-chip button, .tpl-row-remove { background: none; border: none; color: inherit; cursor: pointer; font-size: 0.9rem; line-height: 1; padding: 0 0.15rem; opacity: 0.7; }
.tpl-row-remove { color: var(--text-tertiary); }
.tpl-section-title { flex: 1; min-width: 0; font-size: 0.8rem; color: var(--text-primary); }
.tpl-section-row select { padding: 0.25rem 0.45rem; border-radius: 6px; border: 1px solid var(--border-color, rgba(255,255,255,0.12)); background: var(--bg-input, #1f1f1f); color: var(--text-primary); font-size: 0.76rem; }
@media (max-width: 600px) {
  .tpl-form { grid-template-columns: 1fr; }
  .tpl-field-label { width: 100%; }
}
.tpl-fix-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0 0.15rem 1.1rem; }
.tpl-pdf-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; padding: 0.55rem 0.7rem; margin-bottom: 0.5rem; border-radius: 8px; background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.25); color: var(--text-secondary); }
.tpl-pdf-note span { flex-basis: 100%; font-size: 0.74rem; color: var(--text-tertiary); }
.tpl-content-preview { margin: 0.75rem 0 0.2rem; padding: 0.55rem 0.7rem; border-left: 3px solid rgba(59,130,246,0.5); background: rgba(255,255,255,0.03); border-radius: 6px; font-size: 0.8rem; color: var(--text-secondary); white-space: pre-wrap; max-height: 7.5rem; overflow: hidden; }
.docx-checklist li.pending { color: var(--text-tertiary); }

/* ── Code in chat ───────────────────────────────────────────────────────── */
.code-row { justify-content: stretch; }
.code-card { width: 100%; max-width: 820px; margin-left: auto; border: 1px solid var(--border-color, rgba(255,255,255,0.12)); border-radius: 14px; background: var(--bg-secondary, #1b1b1f); overflow: hidden; box-shadow: 0 4px 18px rgba(0,0,0,0.18); }
.code-card-head { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08)); background: rgba(255,255,255,0.03); flex-wrap: wrap; }
.code-card-icon { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; color: #60a5fa; font-weight: 700; padding: 0 0.2rem; }
.code-lang-select { background: var(--bg-input, rgba(255,255,255,0.05)); color: var(--text-primary); border: 1px solid var(--border-color, rgba(255,255,255,0.14)); border-radius: 7px; padding: 0.25rem 0.4rem; font-size: 0.8rem; }
.code-head-spacer { flex: 1; }
.code-note { font-size: 0.72rem; color: #f59e0b; }
.code-head-btn { background: transparent; border: 1px solid transparent; color: var(--text-secondary); font-size: 0.75rem; padding: 0.22rem 0.45rem; border-radius: 6px; cursor: pointer; }
.code-head-btn:hover { border-color: var(--border-color, rgba(255,255,255,0.14)); color: var(--text-primary); }
.code-run-btn { background: #16a34a; color: #fff; border: none; border-radius: 8px; padding: 0.32rem 0.85rem; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.code-run-btn:hover { background: #15803d; }
.code-run-btn.stop { background: #dc2626; }
.code-card .CodeMirror { height: auto; min-height: 120px; max-height: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86rem; line-height: 1.55; background: transparent; color: var(--text-primary); }
.code-card .CodeMirror-scroll { min-height: 120px; max-height: 420px; }
.code-card .CodeMirror-gutters { background: transparent; border-right: 1px solid var(--border-color, rgba(255,255,255,0.08)); }
.code-card .CodeMirror-linenumber { color: var(--text-tertiary); }
.code-card .CodeMirror-cursor { border-left-color: var(--text-primary); }
.code-card .CodeMirror-selected, .code-card .CodeMirror-focused .CodeMirror-selected { background: rgba(96,165,250,0.25); }
.code-card .CodeMirror .cm-keyword { color: #c084fc; } .code-card .CodeMirror .cm-def, .code-card .CodeMirror .cm-variable-2 { color: #60a5fa; }
.code-card .CodeMirror .cm-string, .code-card .CodeMirror .cm-string-2 { color: #4ade80; } .code-card .CodeMirror .cm-number { color: #fb923c; }
.code-card .CodeMirror .cm-comment { color: #9ca3af; font-style: italic; } .code-card .CodeMirror .cm-builtin, .code-card .CodeMirror .cm-type { color: #22d3ee; }
.code-card .CodeMirror .cm-tag { color: #f87171; } .code-card .CodeMirror .cm-attribute, .code-card .CodeMirror .cm-property { color: #fbbf24; } .code-card .CodeMirror .cm-operator { color: var(--text-secondary); }
.code-card .CodeMirror .cm-variable, .code-card .CodeMirror .cm-variable-3 { color: var(--text-primary); } .code-card .CodeMirror .cm-meta, .code-card .CodeMirror .cm-qualifier { color: #f472b6; } .code-card .CodeMirror .cm-atom { color: #fb923c; } .code-card .CodeMirror .cm-bracket { color: var(--text-secondary); }
.code-card-editor { width: 100%; min-height: 140px; box-sizing: border-box; border: none; background: transparent; color: var(--text-primary); font-family: ui-monospace, Menlo, monospace; font-size: 0.86rem; padding: 0.6rem; resize: vertical; }
.code-stdin { border-top: 1px solid var(--border-color, rgba(255,255,255,0.08)); padding: 0.4rem 0.6rem; }
.code-stdin summary { cursor: pointer; font-size: 0.76rem; color: var(--text-secondary); font-weight: 600; }
.code-stdin summary span { font-weight: 400; color: var(--text-tertiary); }
.code-stdin-box { width: 100%; box-sizing: border-box; margin-top: 0.35rem; background: var(--bg-input, rgba(255,255,255,0.04)); color: var(--text-primary); border: 1px solid var(--border-color, rgba(255,255,255,0.12)); border-radius: 8px; padding: 0.4rem 0.55rem; font-family: ui-monospace, Menlo, monospace; font-size: 0.82rem; resize: vertical; }
.code-output { border-top: 1px solid var(--border-color, rgba(255,255,255,0.08)); background: #0b0d10; padding: 0.55rem 0.7rem 0.7rem; max-height: 420px; overflow: auto; }
.code-status { display: inline-block; font-size: 0.74rem; font-weight: 600; margin-bottom: 0.35rem; color: #9ca3af; }
.code-status.ok { color: #4ade80; } .code-status.bad { color: #f87171; }
.code-out-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, monospace; font-size: 0.84rem; color: #e5e7eb; }
.code-out-err { color: #fca5a5; }
.code-out-empty { font-size: 0.8rem; color: #6b7280; }
.code-html-preview { width: 100%; height: 320px; border: none; border-radius: 8px; background: #fff; }
.code-sql-table-wrap { overflow-x: auto; margin-bottom: 0.6rem; }
.code-sql-table { border-collapse: collapse; font-size: 0.8rem; color: #e5e7eb; }
.code-sql-table th, .code-sql-table td { border: 1px solid #374151; padding: 0.3rem 0.6rem; text-align: left; white-space: nowrap; }
.code-sql-table th { background: #1f2937; font-weight: 600; }
.code-sql-count { font-size: 0.72rem; color: #6b7280; margin-top: 0.2rem; }
.code-ask { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0.6rem; border-top: 1px solid var(--border-color, rgba(255,255,255,0.08)); }
.code-ask button { background: transparent; border: 1px solid var(--border-color, rgba(255,255,255,0.16)); color: var(--text-secondary); border-radius: 999px; padding: 0.25rem 0.75rem; font-size: 0.76rem; cursor: pointer; }
.code-ask button:hover { color: var(--text-primary); border-color: #60a5fa; }
.code-ask .code-del { margin-left: auto; border-color: transparent; color: var(--text-tertiary); }
.code-card-full { position: fixed; inset: 0; z-index: 1200; max-width: none; border-radius: 0; display: flex; flex-direction: column; }
.code-card-full .CodeMirror, .code-card-full .CodeMirror-scroll { max-height: none; }
.code-card-full .CodeMirror { flex: 1; min-height: 40vh; }
.code-card-full .code-output { max-height: 35vh; }
.btn-run-code { background: #16a34a; color: #fff; border: none; border-radius: 6px; padding: 0.15rem 0.6rem; font-size: 0.74rem; font-weight: 600; cursor: pointer; margin-left: auto; margin-right: 0.4rem; }
.btn-run-code:hover { background: #15803d; }
.btn-dock-code { color: #60a5fa; }
@media (max-width: 600px) {
  .code-card { border-radius: 10px; }
  .code-card .CodeMirror { font-size: 0.8rem; }
  .code-head-btn { padding: 0.2rem 0.3rem; }
}

/* ── File conversion in chat ────────────────────────────────────────────── */
.convert-card { width: 100%; max-width: 760px; border: 1px solid var(--border-color, rgba(255,255,255,0.12)); border-radius: 14px; background: var(--bg-secondary, #1b1b1f); padding: 0.85rem 1rem; box-shadow: 0 4px 18px rgba(0,0,0,0.15); }
.cv-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.55rem; }
.cv-icon { width: 28px; height: 28px; border-radius: 8px; background: rgba(245,158,11,0.15); color: #f59e0b; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.cv-title { font-weight: 600; font-size: 0.92rem; color: var(--text-primary); }
.cv-files { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.7rem; }
.cv-file { font-size: 0.78rem; padding: 0.25rem 0.55rem; border-radius: 8px; background: rgba(255,255,255,0.05); color: var(--text-secondary); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-file small { color: var(--text-tertiary); margin-left: 0.2rem; }
.cv-file.gone { opacity: 0.55; text-decoration: line-through; }
.cv-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.55rem; }
.cv-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.74rem; color: var(--text-secondary); }
.cv-field input, .cv-field select { padding: 0.45rem 0.55rem; border-radius: 8px; border: 1px solid var(--border-color, rgba(255,255,255,0.14)); background: var(--bg-input, rgba(255,255,255,0.04)); color: var(--text-primary); font-size: 0.84rem; }
.cv-hint { font-size: 0.74rem; color: var(--text-tertiary); margin-top: 0.55rem; }
.cv-note { font-size: 0.78rem; color: #f59e0b; margin-top: 0.5rem; }
.cv-link { background: none; border: none; color: #60a5fa; cursor: pointer; text-decoration: underline; font-size: inherit; padding: 0; }
.cv-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.cv-btn { border: 1px solid var(--border-color, rgba(255,255,255,0.16)); background: transparent; color: var(--text-primary); border-radius: 9px; padding: 0.42rem 0.85rem; font-size: 0.82rem; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-btn.primary { background: #f59e0b; border-color: #f59e0b; color: #111; font-weight: 600; }
.cv-btn:disabled { opacity: 0.6; cursor: default; }
.cv-status { margin-top: 0.55rem; font-size: 0.8rem; color: var(--text-secondary); }
.cv-ok { color: #4ade80; } .cv-err { color: #f87171; } .cv-sub { color: var(--text-tertiary); }
.cv-snippet { margin: 0.5rem 0 0; max-height: 180px; overflow: auto; background: #0b0d10; color: #e5e7eb; border-radius: 8px; padding: 0.5rem 0.65rem; font-size: 0.78rem; white-space: pre-wrap; }
@media (max-width: 600px) { .convert-card { padding: 0.75rem; } .cv-row { grid-template-columns: 1fr; } }

/* ── Live interpreter: phrase by phrase ─────────────────────────────────── */
.interp-pending { color: var(--text-tertiary, #9ca3af); }
.interp-speaking { background: rgba(56,189,248,0.16); border-radius: 4px; box-shadow: 0 0 0 2px rgba(56,189,248,0.16); }
.btn-interp-mode.earphones { border-color: rgba(16,185,129,0.5); color: #10b981; }

/* ── Live Translate (simple screen) ─────────────────────────────────────── */
.lt-card { width: min(760px, 96vw); height: min(860px, 94vh); display: flex; flex-direction: column; gap: 0.75rem; background: var(--bg-secondary, #18181b); border: 1px solid var(--border-color, rgba(255,255,255,0.1)); border-radius: 20px; padding: 1rem 1.1rem 1.1rem; box-shadow: 0 20px 60px rgba(0,0,0,0.45); box-sizing: border-box; }
.lt-top { display: flex; align-items: center; justify-content: space-between; }
.lt-title { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.lt-top-actions { display: flex; gap: 0.3rem; align-items: center; }
.lt-icon-btn { width: 34px; height: 34px; border-radius: 10px; border: none; background: transparent; color: var(--text-secondary); font-size: 1.05rem; cursor: pointer; }
.lt-icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.lt-menu-wrap { position: relative; }
.lt-menu { display: none; position: absolute; right: 0; top: 38px; z-index: 5; min-width: 230px; background: var(--bg-secondary, #202024); border: 1px solid var(--border-color, rgba(255,255,255,0.12)); border-radius: 12px; padding: 0.3rem; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.lt-menu.show { display: block; }
.lt-menu button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text-primary); padding: 0.55rem 0.7rem; border-radius: 8px; font-size: 0.86rem; cursor: pointer; }
.lt-menu button:hover { background: rgba(255,255,255,0.06); }
.lt-menu button.danger { color: #f87171; }
.lt-langs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.5rem; align-items: center; }
.lt-select { width: 100%; padding: 0.7rem 0.8rem; border-radius: 12px; border: 1px solid var(--border-color, rgba(255,255,255,0.14)); background: var(--bg-input, rgba(255,255,255,0.04)); color: var(--text-primary); font-size: 0.95rem; }
.lt-swap { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border-color, rgba(255,255,255,0.14)); background: transparent; color: #38bdf8; font-size: 1.1rem; cursor: pointer; }
.lt-output { flex: 1; min-height: 0; overflow-y: auto; background: rgba(0,0,0,0.22); border-radius: 16px; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.lt-placeholder { margin: auto; text-align: center; color: var(--text-tertiary); font-size: 0.95rem; line-height: 1.6; max-width: 420px; }
.lt-para { opacity: 0.72; transition: opacity 0.2s; }
.lt-para.lt-latest { opacity: 1; }
.lt-tgt { font-size: 1.32rem; line-height: 1.5; color: var(--text-primary); font-weight: 500; }
.lt-src { font-size: 0.85rem; line-height: 1.45; color: var(--text-tertiary); margin-top: 0.2rem; }
.lt-caption .lt-tgt { font-size: 1.22rem; }
.lt-caption .lt-tgt::before { content: '♪ '; color: #c084fc; }
.lt-interim { color: var(--text-tertiary); opacity: 0.75; }
.lt-wait { color: var(--text-tertiary); }
.lt-speaking { background: rgba(56,189,248,0.18); border-radius: 5px; box-shadow: 0 0 0 3px rgba(56,189,248,0.18); }
.lt-switches { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; }
.lt-switch { border: 1px solid var(--border-color, rgba(255,255,255,0.14)); background: transparent; color: var(--text-secondary); border-radius: 999px; padding: 0.42rem 0.9rem; font-size: 0.85rem; cursor: pointer; }
.lt-switch.on { border-color: rgba(16,185,129,0.55); color: #10b981; background: rgba(16,185,129,0.08); }
#lt-music-toggle.on { border-color: rgba(192,132,252,0.6); color: #c084fc; background: rgba(192,132,252,0.08); }
.lt-source { display: inline-flex; border: 1px solid var(--border-color, rgba(255,255,255,0.14)); border-radius: 999px; overflow: hidden; }
.lt-source button { border: none; background: transparent; color: var(--text-secondary); padding: 0.42rem 0.8rem; font-size: 0.82rem; cursor: pointer; }
.lt-source button.on { background: rgba(192,132,252,0.15); color: #c084fc; }
.lt-status { min-height: 1.1em; text-align: center; font-size: 0.78rem; color: #f59e0b; }
.lt-listen { align-self: center; display: inline-flex; align-items: center; gap: 0.65rem; padding: 0.95rem 2.4rem; border-radius: 999px; border: none; cursor: pointer; font-size: 1.05rem; font-weight: 600; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); box-shadow: 0 8px 26px rgba(79,70,229,0.4); }
.lt-listen.on { background: linear-gradient(135deg, #dc2626, #9333ea); }
.lt-listen-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.lt-listen.on .lt-listen-dot { animation: lt-pulse 1.1s ease-in-out infinite; }
@keyframes lt-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: 0.45; } }
@media (max-width: 600px) {
  .lt-card { width: 100vw; height: 100dvh; border-radius: 0; padding: 0.8rem 0.8rem calc(0.9rem + env(safe-area-inset-bottom)); }
  .lt-tgt { font-size: 1.18rem; }
  .lt-listen { width: 100%; justify-content: center; }
}

/* ── Browser extension page ─────────────────────────────────────────────── */
.ext-card { width: min(620px, 96vw); max-height: 92vh; overflow-y: auto; background: var(--bg-secondary, #18181b); border: 1px solid var(--border-color, rgba(255,255,255,0.1)); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.45); }
.ext-head { display: flex; gap: 0.75rem; align-items: center; padding: 1rem 1.1rem; border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08)); }
.ext-head .lt-icon-btn { margin-left: auto; }
.ext-logo { width: 40px; height: 40px; flex: none; border-radius: 11px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }
.ext-title { font-weight: 600; color: var(--text-primary); } .ext-sub { font-size: 0.8rem; color: var(--text-tertiary); }
.ext-body { padding: 1rem 1.2rem 1.3rem; color: var(--text-secondary); font-size: 0.88rem; line-height: 1.55; }
.ext-steps { padding-left: 1.2rem; margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.ext-steps code { background: rgba(255,255,255,0.07); padding: 1px 5px; border-radius: 5px; }
.ext-btn { display: inline-block; margin-top: 0.4rem; padding: 0.5rem 1rem; border-radius: 10px; border: 1px solid var(--border-color, rgba(255,255,255,0.15)); background: transparent; color: var(--text-primary); text-decoration: none; cursor: pointer; font-size: 0.86rem; }
.ext-btn.primary { background: linear-gradient(135deg, #2563eb, #7c3aed); border: none; color: #fff; font-weight: 600; }
.ext-status { font-size: 0.8rem; color: #10b981; margin-left: 0.4rem; }
.ext-how ul { margin: 0.4rem 0 0.7rem; padding-left: 1.1rem; }
.ext-note { background: rgba(245,158,11,0.1); color: #f59e0b; border-radius: 10px; padding: 0.55rem 0.75rem; font-size: 0.8rem; }
