/* 3. Native long-press text selection (Copy / Paste / Select All) */
  .chat-box, .msg, .msg *, input, textarea, .arcane-floating-pill, .arcane-floating-pill * {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
  }

  /* 1. Clean Markdown styling */
  .msg.arcane {
    white-space: normal !important;
    padding-bottom: 38px !important;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .arcane-md { max-width: 100%; overflow-wrap: anywhere; }
  .arcane-md p { margin: 0 0 10px 0; }
  .arcane-md p:last-child { margin-bottom: 0; }
  .arcane-md strong { color: #f8fafc; font-weight: 600; }
  .arcane-md em { font-style: italic; color: #e2e8f0; }
  .arcane-md h1, .arcane-md h2, .arcane-md h3 {
    margin: 12px 0 6px 0; font-weight: 600; color: #f8fafc; line-height: 1.3;
  }
  .arcane-md h1 { font-size: 1.2em; }
  .arcane-md h2 { font-size: 1.1em; }
  .arcane-md h3 { font-size: 1.02em; }
  .arcane-md ul, .arcane-md ol { margin: 6px 0 10px 20px; padding: 0; }
  .arcane-md li { margin-bottom: 4px; }
  .arcane-md code {
    background: rgba(255, 255, 255, 0.09);
    padding: 2px 6px; border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em; color: #93c5fd;
  }
  .arcane-md pre {
    background: #0d111a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px; padding: 12px;
    overflow-x: auto; margin: 8px 0;
  }
  .arcane-md pre code { background: transparent; padding: 0; color: #e2e8f0; }
  .arcane-md .arcane-table-wrap {
    overflow-x: auto; margin: 10px 0;
    border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.1);
  }
  .arcane-md table {
    width: 100%; border-collapse: collapse;
    font-size: 13.5px; text-align: left;
  }
  .arcane-md th {
    background: rgba(255, 255, 255, 0.06);
    color: #f8fafc; font-weight: 600;
    padding: 8px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }
  .arcane-md td {
    padding: 8px 12px; color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: top;
  }
  .arcane-md tr:last-child td { border-bottom: none; }

  /* 2. Minimal Gemini-style 2-rectangle Copy button */
  .msg.arcane button:not(.arcane-copy-icon):not(.arcane-code-icon-btn),
  .msg.arcane .copy-btn:not(.arcane-copy-icon),
  .msg.arcane [class*="copy"]:not(.arcane-copy-icon) {
    display: none !important;
  }
  .msg.arcane .copy-btn,
  .msg.arcane button[class*="copy"],
  .arcane-copy-icon {
    position: absolute !important;
    bottom: 6px !important;
    left: 10px !important;
    right: auto !important;
    background: transparent !important;
    border: none !important;
    color: #94a3b8 !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background 0.15s, color 0.15s;
  }
  .msg.arcane .copy-btn:hover,
  .arcane-copy-icon:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #f8fafc !important;
  }

  /* 5. Edit button & inline editor on user messages */
  .msg.user {
    position: relative !important;
  }
  .arcane-edit-btn {
    position: absolute;
    left: -34px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
  }
  .arcane-edit-btn:hover {
    opacity: 1;
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.14);
  }
  .arcane-edit-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: min(220px, 68vw);
    width: 100%;
  }
  .arcane-edit-box textarea {
    width: 100%;
    min-height: 64px;
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(56, 189, 248, 0.45);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    resize: vertical;
  }
  .arcane-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
  }
  .arcane-edit-actions button {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
  }
  .arcane-edit-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
  }
  .arcane-edit-save {
    background: #2563eb;
    color: #ffffff;
  }

  /* 4. Stop button state */
  .arcane-send-circle.is-stop {
    background: linear-gradient(135deg, #334155, #1e293b) !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.6) !important;
  }

.chat-box, .msg, .msg *, input, textarea, .arcane-floating-pill textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
  }

.arcane-hist-header-row {
    display: flex; align-items: center; justify-content: space-between;
    margin: 10px 2px 6px 2px;
  }
  .arcane-mass-toggle {
    background: transparent; border: none; color: #38bdf8;
    font-size: 12px; font-weight: 500; cursor: pointer; padding: 2px 6px;
    border-radius: 6px;
  }
  .arcane-mass-toggle:hover { background: rgba(56, 189, 248, 0.12); }
  .arcane-mass-bar {
    display: flex; gap: 6px; margin-bottom: 8px;
  }
  .arcane-mass-btn {
    flex: 1; padding: 6px 8px; border-radius: 8px; font-size: 12px; font-weight: 500;
    background: rgba(255, 255, 255, 0.08); color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.1); cursor: pointer;
  }
  .arcane-mass-btn.danger {
    background: rgba(239, 68, 68, 0.18); color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
  }
  .arcane-mass-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  .arcane-hist-item { gap: 6px !important; }
  .arcane-hist-item.pinned { border-color: rgba(56, 189, 248, 0.28) !important; }
  .arcane-hist-cb { width: 15px; height: 15px; accent-color: #38bdf8; flex-shrink: 0; cursor: pointer; }
  .arcane-hist-actions {
    display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0;
  }
  .arcane-hist-act {
    background: transparent; border: none; color: #94a3b8;
    width: 30px; height: 30px; min-width: 30px; min-height: 30px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; cursor: pointer; padding: 0;
  }
  .arcane-hist-act:hover { background: rgba(255, 255, 255, 0.1); color: #f8fafc; }
  .arcane-hist-act.is-pinned { color: #38bdf8; }
  .arcane-hist-act.del:hover { color: #f87171; background: rgba(239, 68, 68, 0.14); }

  .arcane-modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(4px); z-index: 100000;
    display: flex; align-items: center; justify-content: center; padding: 16px;
  }
  .arcane-modal-card {
    width: min(340px, 100%); background: #171a23;
    border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 18px;
    padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
    color: #f1f5f9; font-family: inherit;
  }
  .arcane-modal-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
  .arcane-modal-msg { font-size: 13.5px; color: #94a3b8; line-height: 1.45; margin-bottom: 14px; }
  .arcane-modal-input {
    width: 100%; box-sizing: border-box; background: #0d111a; color: #f8fafc;
    border: 1px solid rgba(56, 189, 248, 0.45); border-radius: 10px;
    padding: 9px 11px; font-size: 14px; outline: none; margin-bottom: 14px;
  }
  .arcane-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
  .arcane-modal-btn {
    padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
    border: none; cursor: pointer;
  }
  .arcane-modal-btn.cancel { background: rgba(255, 255, 255, 0.1); color: #cbd5e1; }
  .arcane-modal-btn.primary { background: #2563eb; color: #ffffff; }
  .arcane-modal-btn.danger { background: #dc2626; color: #ffffff; }
  .arcane-pin-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.14);
    margin: 8px 4px;
  }
