/* ── Shared chat shell (formerly assistant.css): message bubbles, steps, answers,
   history drawer, clarification chips & bar charts used by Lensy. Kept ahead of the
   Lensy-specific rules below so the original cascade order is preserved. ── */

/* ── Chat, SQL Cards, History Drawer & Data Visualizations ── */

/* ── Chat Messages ──────────────────────────────────────────────────────── */
.chatwrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 880px;
  width: 100%;
}
.msg-u {
  align-self: flex-end;
  max-width: 78%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  padding: 12px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.msg-a {
  display: flex;
  gap: 12px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok-fg);
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 2px;
}
.msg-a .body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  padding: 4px 0;
}
.step { display: flex; align-items: center; gap: 6px; }
.step.done { color: var(--ok-fg); font-weight: 500; }
.step.active { color: var(--brand-text); font-weight: 500; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.answer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.answer p { margin: 0 0 14px; line-height: 1.65; }
.answer-foot {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
}
.linkbtn {
  background: none;
  border: none;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 0;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  cursor: pointer;
}
.linkbtn:hover { color: var(--brand-text); }
details.sql { margin-top: 12px; }
details.sql summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
details.sql pre {
  background: var(--ink);
  color: #D9CBD0;
  padding: 14px;
  border-radius: var(--r);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  margin: 10px 0 0;
}

/* Formatted Answer Typography & Bidirectional Support */
.answer-content {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.65;
}
.answer-content[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
.answer-content[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

.ans-para {
  margin: 0 0 10px 0;
  line-height: 1.65;
}
.ans-para:last-child {
  margin-bottom: 0;
}
.ans-heading {
  margin: 10px 0 6px 0;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 700;
}
.ans-list, .ans-numbered {
  margin: 8px 0 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ans-list[dir="rtl"], .ans-numbered[dir="rtl"] {
  direction: rtl;
  text-align: right;
  padding-right: 22px;
  padding-left: 0;
}
.ans-list[dir="ltr"], .ans-numbered[dir="ltr"] {
  direction: ltr;
  text-align: left;
  padding-left: 22px;
  padding-right: 0;
}
.ans-list li, .ans-numbered li {
  line-height: 1.6;
}
.ans-para[dir="rtl"], .ans-list li[dir="rtl"], .ans-numbered li[dir="rtl"], .ans-heading[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
.ans-para[dir="ltr"], .ans-list li[dir="ltr"], .ans-numbered li[dir="ltr"], .ans-heading[dir="ltr"] {
  direction: ltr;
  text-align: left;
}
bdi {
  unicode-bidi: isolate !important;
  direction: ltr !important;
  display: inline-block;
  vertical-align: baseline;
}
.msg-u[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
.msg-u[dir="ltr"] {
  direction: ltr;
  text-align: left;
}
/* ── Chat Two-Column Layout (Main Chat + Right History Sidebar) ────── */

.chat-layout {
  display: flex;
  gap: 20px;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  position: relative;
  align-items: stretch;
  overflow: hidden;
}

.chat-main {
  flex: 1;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

.chat-main .chatwrap {
  max-width: 100%;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  padding-bottom: 16px;
  scroll-behavior: smooth;
}

[dir="rtl"] .chat-main .chatwrap {
  padding-right: 0;
  padding-left: 8px;
}

.chat-main .chatwrap::-webkit-scrollbar {
  width: 6px;
}
.chat-main .chatwrap::-webkit-scrollbar-track {
  background: transparent;
}
.chat-main .chatwrap::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

/* Fixed Bottom Area (Always visible, never pushed below fold) */
.chat-bottom {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
  position: relative;
  z-index: 5;
  width: 100%;
}

/* Right History Sidebar */
.chat-history-sidebar {
  width: 320px;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  max-height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, width 0.25s ease;
  z-index: 10;
}

.chat-history-sidebar.collapsed {
  display: none;
}

.history-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.history-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-sidebar-title h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.history-sidebar-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  transition: all 0.15s ease;
}

.history-sidebar-close:hover {
  color: var(--text);
  background: var(--line);
}

.history-sidebar-action {
  width: 100%;
  padding-bottom: 2px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  width: 100%;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  flex: 1;
  padding: 4px 4px 6px 2px;
}

[dir="rtl"] .history-list {
  padding: 4px 2px 6px 4px;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: start;
}

.history-item:hover {
  border-color: var(--brand-primary);
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.history-item.active {
  border-color: var(--brand-primary);
  background: var(--tb-brand-wash);
}

.history-item.pinned {
  border-color: rgba(234, 179, 8, 0.35);
  background: rgba(234, 179, 8, 0.03);
}
.history-item.pinned:hover {
  border-color: #eab308;
  background: rgba(234, 179, 8, 0.06);
}
.history-item.pinned.active {
  border-color: var(--brand-primary);
  background: var(--tb-brand-wash);
}

.history-item-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.history-item-icon {
  font-size: 13px;
  flex: none;
  opacity: 0.8;
  margin-top: 1px;
}

.history-pin-indicator {
  font-size: 12px;
  flex: none;
  line-height: 1;
  margin-top: 2px;
  filter: drop-shadow(0 1px 2px rgba(234, 179, 8, 0.4));
}

.history-pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--brand-primary);
  margin-inline-start: auto;
  flex: none;
  margin-top: 5px;
  box-shadow: 0 0 6px rgba(114, 37, 61, 0.7);
  animation: pulse-dot-anim 1.4s ease-in-out infinite;
}

@keyframes pulse-dot-anim {
  0% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.5; }
}

.history-item-title {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.35;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: 1;
  word-break: break-word;
}

.history-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  color: var(--text-3);
  padding-top: 4px;
  border-top: 1px dashed var(--line-soft);
}

.history-item-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-inline-start: auto;
}

.history-item-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  opacity: 0.55;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

.history-item:hover .history-item-btn {
  opacity: 0.85;
}

.history-item-btn:hover {
  opacity: 1 !important;
}

.history-item-pin:hover {
  color: #ca8a04;
  background: rgba(234, 179, 8, 0.12);
}
.history-item-pin.pinned {
  opacity: 1 !important;
  color: #ca8a04;
  background: rgba(234, 179, 8, 0.12);
}
.history-item-del:hover {
  opacity: 1 !important;
  color: var(--danger);
  background: var(--danger-bg);
}

.history-item-rename:hover {
  opacity: 1 !important;
  color: var(--brand-text);
  background: var(--tb-brand-wash);
}

.history-item-top .history-item-rename {
  opacity: 0;
  padding: 2px 4px;
  border-radius: 4px;
  margin-inline-start: 2px;
  flex-shrink: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.history-item:hover .history-item-top .history-item-rename {
  opacity: 0.75;
}

.history-item-top .history-item-rename:hover {
  opacity: 1 !important;
}

.history-rename-form {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.history-rename-input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--brand-primary);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  line-height: 1.35;
  box-shadow: 0 0 0 2px rgba(114, 37, 61, 0.15);
}

.history-rename-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.history-rename-save {
  color: var(--ok-fg);
  background: var(--ok-bg);
}

.history-rename-save:hover {
  color: var(--ok-fg);
  background: color-mix(in srgb, var(--ok-fg) 22%, transparent);
}

.history-rename-cancel {
  color: var(--text-3);
  background: var(--line-soft);
}

.history-rename-cancel:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.history-section-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 4px 4px;
}
.history-section-divider:not(:first-child) {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.history-section-divider .badge-sm {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(234, 179, 8, 0.16);
  color: #ca8a04;
}
/* Backdrop for Mobile / Tablet off-canvas */
.history-backdrop {
  display: none;
}

.bar { display: flex; align-items: center; gap: 12px; }
.bar span:first-child { width: 140px; font-size: 13px; color: var(--text-2); flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Interactive Chat Charts (Chart.js) ─────────────────────────────────── */

/* ── Clarification Chips (Interactive Turn-Based Disambiguation) ────────── */
.clarification-chips-wrapper {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px dashed var(--line-active);
  border-radius: var(--r-md, 10px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.clarification-chips-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-text);
  letter-spacing: 0.01em;
}
.clarification-chips-label svg {
  flex-shrink: 0;
}
.clarification-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.clarification-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  user-select: none;
  text-align: start;
}
.clarification-chip .chip-spark {
  color: var(--brand-text);
  font-size: 11px;
  transition: transform 0.2s ease;
}
.clarification-chip:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  color: var(--brand-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(114, 37, 61, 0.15);
}
.clarification-chip:hover:not(:disabled) .chip-spark {
  transform: scale(1.25);
}
.clarification-chip:active:not(:disabled) {
  transform: translateY(0);
}
.clarification-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.clarification-chip.chip-selected {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
  opacity: 1;
}
.clarification-chip.chip-selected .chip-spark {
  color: #ffffff;
}
.clarification-chip-custom {
  border-style: dashed;
  border-color: var(--line-active);
  color: var(--brand-text);
  background: var(--bg-hover);
}
.clarification-chip-custom:hover:not(:disabled) {
  border-style: solid;
  background: var(--bg-hover);
}
.clarification-custom-container {
  margin-top: 4px;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.clarification-custom-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--brand-primary);
  border-radius: var(--r-md, 8px);
  padding: 4px 6px 4px 12px;
  box-shadow: 0 2px 8px rgba(114, 37, 61, 0.12);
}
.clarification-custom-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.clarification-custom-input::placeholder {
  color: var(--text-dim);
}
.clarification-custom-submit {
  background: var(--brand-primary);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.clarification-custom-submit:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

/* ── Lensy view ─────────────────────────────────────────────────────────── */
/* ── Linzy AI Chat View Styles ────────────────────────────────────────────── */
/* Shares the chat shell, history drawer and typography defined above */

.view.view-lensy,
.view.view-linzy {
  max-width: 100%;
  padding: 12px 28px 14px;
  height: calc(100vh - 56px);
  max-height: calc(100vh - 56px);
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.linzy-layout {
  display: flex;
  gap: 20px;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  position: relative;
  align-items: stretch;
  overflow: hidden;
}

.linzy-main {
  flex: 1;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

.linzy-chatwrap {
  max-width: 100%;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  padding-bottom: 16px;
  scroll-behavior: smooth;
}

[dir="rtl"] .linzy-chatwrap {
  padding-right: 0;
  padding-left: 8px;
}

.linzy-chatwrap::-webkit-scrollbar {
  width: 6px;
}
.linzy-chatwrap::-webkit-scrollbar-track {
  background: transparent;
}
.linzy-chatwrap::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

/* Linzy Avatar */
.avatar.linzy-avatar {
  background: linear-gradient(135deg, var(--tb-brand), var(--tb-s-cur), var(--tb-spice));
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(114, 37, 61, 0.35);
}

/* Linzy Empty State */
.linzy-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  margin: auto;
}

/* Markdown Tables */
.table-wrap {
  margin: 12px 0;
  overflow-x: auto;
  border-radius: var(--r-sm, 6px);
  border: 1px solid var(--line);
}
.table-wrap .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table-wrap th,
.table-wrap td {
  padding: 8px 12px;
  border: 1px solid var(--line-soft);
  text-align: start;
}
.table-wrap th {
  background: var(--surface-2, rgba(0, 0, 0, 0.02));
  font-weight: 600;
  color: var(--text);
}

/* ── Linzy Option B: Claude-Style Dynamic Artifacts ──────────────────────── */
.linzy-artifact-card {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.03);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.linzy-artifact-card:hover {
  border-color: rgba(114, 37, 61, 0.35);
  box-shadow: 0 6px 22px rgba(114, 37, 61, 0.08);
}

.linzy-artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-2, rgba(0, 0, 0, 0.02));
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.linzy-artifact-title-area {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.linzy-artifact-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(114, 37, 61, 0.16), rgba(114, 37, 61, 0.16));
  color: var(--brand-text);
  flex-shrink: 0;
}

.linzy-artifact-title-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.linzy-artifact-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linzy-artifact-subtitle {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.01em;
}

.linzy-artifact-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.linzy-artifact-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--line-soft);
  padding: 2px;
  border-radius: 7px;
}

.linzy-artifact-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.linzy-artifact-tab:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.linzy-artifact-tab.active {
  background: var(--surface);
  color: var(--brand-text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.linzy-artifact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.linzy-artifact-btn:hover {
  color: var(--brand-text);
  border-color: rgba(114, 37, 61, 0.35);
  background: var(--tb-brand-wash);
}

.linzy-artifact-pane {
  width: 100%;
}

.linzy-artifact-frame {
  width: 100%;
  height: 330px;
  border: none;
  display: block;
  background: transparent;
}

.linzy-artifact-code-pane {
  background: #090d16;
  position: relative;
}

.linzy-code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.linzy-code-lang {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #AE9AA2;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.linzy-copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #EFE9EB;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.linzy-copy-code-btn:hover {
  background: rgba(114, 37, 61, 0.35);
  border-color: #72253D;
}

.linzy-artifact-code {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  max-height: 330px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  color: #E3D8DC;
  white-space: pre;
}

/* Fullscreen Popout Modal */
.linzy-artifact-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.linzy-artifact-modal.open {
  display: flex;
}

.linzy-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}

.linzy-modal-window {
  position: relative;
  z-index: 1;
  width: 90vw;
  max-width: 1100px;
  height: 85vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.linzy-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2, rgba(255, 255, 255, 0.03));
  border-bottom: 1px solid var(--line-soft);
}

.linzy-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.linzy-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.linzy-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.linzy-modal-btn:hover {
  color: var(--brand-text);
  border-color: rgba(114, 37, 61, 0.35);
}

.linzy-modal-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.linzy-modal-close:hover {
  color: var(--text);
}

.linzy-modal-body {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

@media (max-width: 640px) {
  .linzy-artifact-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .linzy-artifact-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* ── Collapsible Raw Data Table (when Artifact Card is active) ──────────── */
.linzy-raw-table-details {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.linzy-raw-table-details[open] {
  border-color: var(--line-active);
}

.linzy-raw-table-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2, rgba(0, 0, 0, 0.02));
  transition: color 0.15s ease, background 0.15s ease;
  list-style: none;
}

.linzy-raw-table-summary::-webkit-details-marker {
  display: none;
}

.linzy-raw-table-summary:hover {
  color: var(--text);
  background: var(--surface-3, rgba(0, 0, 0, 0.04));
}

.linzy-raw-table-summary svg {
  transition: transform 0.2s ease;
}

.linzy-raw-table-details[open] .linzy-raw-table-summary svg {
  transform: rotate(90deg);
}

.linzy-raw-table-body {
  padding: 10px 12px;
  overflow-x: auto;
}

.linzy-raw-table-body .table-wrap {
  margin: 0;
  border: none;
  border-radius: 0;
}

/* ── Clarification Chips (Interactive Turn-Based Disambiguation) ────────── */
.clarification-chips-wrapper {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--tb-brand-wash);
  border: 1px dashed rgba(114, 37, 61, 0.35);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.clarification-chips-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-text);
  letter-spacing: 0.01em;
}
.clarification-chips-label svg {
  flex-shrink: 0;
}
.clarification-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.clarification-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  user-select: none;
  text-align: start;
}
.clarification-chip .chip-spark {
  color: var(--brand-text);
  font-size: 11px;
  transition: transform 0.2s ease;
}
.clarification-chip:hover:not(:disabled) {
  background: var(--tb-brand-wash);
  border-color: #9B3558;
  color: var(--brand-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(114, 37, 61, 0.25);
}
.clarification-chip:hover:not(:disabled) .chip-spark {
  transform: scale(1.25);
  color: #F2B33D;
}
.clarification-chip:active:not(:disabled) {
  transform: translateY(0);
}
.clarification-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.clarification-chip.chip-selected {
  background: linear-gradient(135deg, var(--tb-brand), var(--tb-s-cur));
  border-color: #9B3558;
  color: #ffffff;
  opacity: 1;
}
.clarification-chip.chip-selected .chip-spark {
  color: #ffffff;
}

.clarification-chip-custom {
  border-style: dashed;
  border-color: rgba(114, 37, 61, 0.5);
  color: var(--brand-text);
  background: var(--tb-brand-wash);
}
.clarification-chip-custom:hover:not(:disabled) {
  border-style: solid;
  border-color: #9B3558;
  background: rgba(114, 37, 61, 0.18);
  color: var(--brand-text);
}
.clarification-custom-container {
  margin-top: 4px;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.clarification-custom-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid rgba(114, 37, 61, 0.6);
  border-radius: 8px;
  padding: 4px 6px 4px 12px;
  box-shadow: 0 2px 10px rgba(114, 37, 61, 0.2);
}
.clarification-custom-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.clarification-custom-input::placeholder {
  color: var(--text-dim);
}
.clarification-custom-submit {
  background: linear-gradient(135deg, var(--tb-brand), var(--tb-s-cur));
  color: #ffffff;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.clarification-custom-submit:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}

