/* ============================================================
   DSTRC AI Team Chat — Portal UI
   File: assets/portal/portal.css
   ============================================================ */


.dstrc-ai-tc {
  position: relative;
  /* legacy: ранее использовалось для фиксированной высоты окна сообщений */
  --dialog-height: 300px;

  /* Content font (messages + input). Can be overridden by JS via CSS variables. */
  --content-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, Arial, sans-serif;
  --content-font-size: 16px;
  --bg: #0b1220;
  --bg2: #0f172a;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --text: #e5e7eb;
  --muted: rgba(229, 231, 235, 0.70);
  --muted2: rgba(229, 231, 235, 0.55);
  --accent: #3b82f6;
  --accent2: #f97316;

  
  --scrollbar-thumb: rgba(255,255,255,0.18);
  --scrollbar-thumb-hover: rgba(255,255,255,0.28);
  --scrollbar-track: rgba(255,255,255,0.06);
/* Portal occupies the whole viewport (ChatGPT-like) */
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  border-radius: 0;
  border: none;

  display: flex;
  flex-direction: column;

  font-family: var(--content-font-family) !important;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* While dragging the splitter: prevent accidental text selection */
body.dstrc-ai-tc--resizing {
  user-select: none;
  cursor: row-resize;
}

/* Icon buttons in topbar */
.dstrc-ai-tc__iconbtn {
  padding: 7px 7px;
  border-radius: 10px;
}

.dstrc-ai-tc__iconbtn .dstrc-ai-tc__ico {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

/* Topbar collapse/expand + layout toggles */
.dstrc-ai-tc__topbar-expander {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 20;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  display: none;
}

.dstrc-ai-tc__topbar-expander:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.09);
}

/* Exit button for focus mode (is-fullwidth) */
.dstrc-ai-tc__fullwidth-exit {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 25;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  display: none;
}

.dstrc-ai-tc__fullwidth-exit:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.09);
}

.dstrc-ai-tc.is-topbar-collapsed .dstrc-ai-tc__topbar {
  display: none;
}

.dstrc-ai-tc.is-topbar-collapsed .dstrc-ai-tc__notice {
  display: none !important;
}

.dstrc-ai-tc.is-topbar-collapsed .dstrc-ai-tc__topbar-expander {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dstrc-ai-tc.is-sidebar-collapsed .dstrc-ai-tc__layout {
  grid-template-columns: 1fr;
}

.dstrc-ai-tc.is-sidebar-collapsed .dstrc-ai-tc__sidebar {
  display: none;
}

.dstrc-ai-tc.is-fullwidth {
  /* "Focus" mode: скрываем UI, оставляя только чат (как в ChatGPT) */
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  border-radius: 0;
}

.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__topbar,
.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__notice,
.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__topbar-expander,
.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__sidebar,
.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__settings,
.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__panel,
.dstrc-ai-tc.is-fullwidth #dstrc-ai-tc-prompts-panel,
.dstrc-ai-tc.is-fullwidth #dstrc-ai-tc-image-modal {
  display: none !important;
}

.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__layout {
  grid-template-columns: 1fr;
}

/* Light theme */
.dstrc-ai-tc[data-theme="light"] {
  --bg: #f4f6fb;
  --bg2: #ffffff;
  --card: rgba(15, 23, 42, 0.04);
  --card2: rgba(15, 23, 42, 0.06);
  --border: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --muted: rgba(15, 23, 42, 0.72);
  --muted2: rgba(15, 23, 42, 0.55);
  --accent: #2563eb;
  --accent2: #ea580c;

  
  --scrollbar-thumb: rgba(15,23,42,0.18);
  --scrollbar-thumb-hover: rgba(15,23,42,0.28);
  --scrollbar-track: rgba(15,23,42,0.06);
color: var(--text);
  background: var(--bg);
  border: none;
}

/* Topbar */
.dstrc-ai-tc__topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
}

.dstrc-ai-tc__topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.dstrc-ai-tc__theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dstrc-ai-tc__theme-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__theme-icon {
  background: rgba(15,23,42,0.05);
}

.dstrc-ai-tc__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dstrc-ai-tc__logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(59,130,246,0.40), rgba(249,115,22,0.25));
  border: 1px solid rgba(255,255,255,0.16);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.dstrc-ai-tc__brand-title {
  font-weight: 800;
  line-height: 1.1;
}

.dstrc-ai-tc__brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.dstrc-ai-tc__user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.dstrc-ai-tc__btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: 0.15s ease;
  font-weight: 600;
}

.dstrc-ai-tc__btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.09);
}

.dstrc-ai-tc__btn--primary {
  border-color: rgba(59,130,246,0.55);
  background: rgba(59,130,246,0.20);
}

.dstrc-ai-tc__btn--primary:hover {
  background: rgba(59,130,246,0.28);
}

.dstrc-ai-tc__btn--ghost {
  background: transparent;
}

/* Compact controls (settings / small tool buttons) */
.dstrc-ai-tc__btn--sm {
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.dstrc-ai-tc__select--sm {
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
}

/* Notice */
.dstrc-ai-tc__notice {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}

/* Main containers (auth/app) occupy the available viewport height */
.dstrc-ai-tc__auth,
.dstrc-ai-tc__app {
  flex: 1 1 auto;
  min-height: 0;
}

/* Auth */
.dstrc-ai-tc__auth {
  padding: 18px;
  display: grid;
  place-items: center;
  min-height: 0;
}

.dstrc-ai-tc__auth-card {
  width: min(520px, 100%);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.dstrc-ai-tc__auth-title {
  margin: 0 0 8px 0;
  font-size: 20px;
}

.dstrc-ai-tc__auth-hint {
  margin: 0 0 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.dstrc-ai-tc__label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.dstrc-ai-tc__label--inline {
  margin: 0;
  font-size: 12px;
}

.dstrc-ai-tc__input,
.dstrc-ai-tc__select,
.dstrc-ai-tc__textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  font-family: var(--content-font-family) !important;
}
/* Dark theme: make native select dropdowns much darker for readability */
.dstrc-ai-tc[data-theme="dark"] .dstrc-ai-tc__input,
.dstrc-ai-tc[data-theme="dark"] .dstrc-ai-tc__select,
.dstrc-ai-tc[data-theme="dark"] .dstrc-ai-tc__textarea {
  background: rgba(0,0,0,0.82);
  border-color: rgba(255,255,255,0.16);
}

.dstrc-ai-tc[data-theme="dark"] .dstrc-ai-tc__select {
  color-scheme: dark;
}

.dstrc-ai-tc[data-theme="dark"] .dstrc-ai-tc__select option {
  background: #05070c;
  color: #e5e7eb;
}


.dstrc-ai-tc__textarea {
  resize: vertical;
  font-family: var(--content-font-family) !important;
  font-size: var(--content-font-size);
  line-height: 1.45;
}

.dstrc-ai-tc__input:focus,
.dstrc-ai-tc__select:focus,
.dstrc-ai-tc__textarea:focus {
  border-color: rgba(59,130,246,0.60);
}

.dstrc-ai-tc__auth-error {
  margin-top: 10px;
  color: #fecaca;
}

/* Layout */
.dstrc-ai-tc__layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 0;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}

.dstrc-ai-tc__sidebar {
  border-right: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dstrc-ai-tc__sidebar-top {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.dstrc-ai-tc__sidebar-title {
  font-weight: 800;
  margin-bottom: 10px;
}

.dstrc-ai-tc__sidebar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dstrc-ai-tc__chatlist {
  padding: 10px;
  overflow: auto;
  flex: 1;
}

.dstrc-ai-tc__chatitem {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  white-space: normal;
}

.dstrc-ai-tc__chatitem:hover {
  background: rgba(255,255,255,0.07);
}

.dstrc-ai-tc__chatitem.is-active {
  border-color: rgba(59,130,246,0.55);
  background: rgba(59,130,246,0.12);
}

.dstrc-ai-tc__chatitem-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.dstrc-ai-tc__chatitem-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;

  /* Wrap long titles neatly into two lines (no overflow into соседние секции) */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dstrc-ai-tc__chatitem-badge {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: rgba(233, 213, 255, 0.95);
  margin-top: 1px;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__chatitem-badge {
  background: rgba(168, 85, 247, 0.10);
  border-color: rgba(168, 85, 247, 0.35);
  color: rgba(88, 28, 135, 0.95);
}


/* Inline rename */
.dstrc-ai-tc__chatitem-edit {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  padding: 8px 10px;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.2;
  outline: none;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__chatitem-edit {
  background: rgba(255,255,255,0.80);
  border-color: rgba(15,23,42,0.18);
}

.dstrc-ai-tc__chatitem-edit:focus {
  border-color: rgba(59,130,246,0.60);
}

.dstrc-ai-tc__sidebar-bottom {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.dstrc-ai-tc__limits-row {
  font-size: 12px;
  color: var(--muted);
}

/* Main chat */
.dstrc-ai-tc__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;

  /* Chat area padding (comfortable, responsive) */
  padding: clamp(14px, 2.2vw, 25px);
  box-sizing: border-box;
}

.dstrc-ai-tc__chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0;
  border: none;
  background: transparent;
  /* Spacing between the settings panel and the chat window */
  margin-bottom: 20px;
}

.dstrc-ai-tc__chat-titlewrap {
  min-width: 240px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: nowrap;
  max-width: 100%;
}

.dstrc-ai-tc__chat-title {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dstrc-ai-tc__chat-meta {
  flex: 0 0 auto;
  margin-top: 0;
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--muted);
}

/* One collapsible settings panel (details/summary) */
.dstrc-ai-tc__settings {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 8px 10px;
  box-sizing: border-box;
}

.dstrc-ai-tc__settings-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  list-style: none;
}

.dstrc-ai-tc__settings-summary::-webkit-details-marker {
  display: none;
}

.dstrc-ai-tc__settings-title {
  font-size: 12px;
  font-weight: 800;
}

.dstrc-ai-tc__settings-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dstrc-ai-tc__settings-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dstrc-ai-tc__settings-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.dstrc-ai-tc__settings-row--tools {
  gap: 8px;
}

.dstrc-ai-tc__chat-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.dstrc-ai-tc__select-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dstrc-ai-tc__tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dstrc-ai-tc__chat-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  gap: 12px;
}

/* Left turn navigation (visible in fullwidth/focus mode only) */
.dstrc-ai-tc__turnnav {
  display: none;
  flex: 0 0 56px;
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  align-self: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 6px;
  border-right: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.10);
  border-radius: 14px;
}

.dstrc-ai-tc.is-fullwidth .dstrc-ai-tc__turnnav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dstrc-ai-tc__turnbtn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.86;
  transition: 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dstrc-ai-tc__turnbtn:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.dstrc-ai-tc__turnbtn:active {
  transform: scale(0.96);
}

.dstrc-ai-tc__turnbtn.is-user {
  background: rgba(168,85,247,0.28);
  border-color: rgba(168,85,247,0.55);
}

.dstrc-ai-tc__turnbtn.is-assistant {
  background: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.55);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__turnnav {
  border-right-color: rgba(15,23,42,0.12);
  background: rgba(255,255,255,0.78);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__turnbtn {
  border-color: rgba(15,23,42,0.16);
  background: rgba(255,255,255,0.90);
  color: #0f172a;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__turnbtn.is-user {
  background: rgba(168,85,247,0.16);
  border-color: rgba(168,85,247,0.45);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__turnbtn.is-assistant {
  background: rgba(239,68,68,0.14);
  border-color: rgba(239,68,68,0.45);
}

/* Chat column holds messages + splitter + composer, and provides the "outer" scroll. */
.dstrc-ai-tc__chatcol {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;

  /* Additional vertical scroll for the whole chat section (messages + input)
     so resizing one does NOT squeeze the other. */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

/* Messages wrapper: holds the scrollable area + floating buttons */
.dstrc-ai-tc__messageswrap {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}


.dstrc-ai-tc__messages {
  padding: 10px 20px;
  overflow: auto;
  box-sizing: border-box;

  /* Fixed, independently resizable height.
     This prevents the messages area from being "squeezed" when the input grows.
     Default height is set by JS on first load (and persisted in localStorage). */
  height: var(--messages-panel-height, 420px);
  min-height: 240px;
  max-height: none;

  /* Allow manual vertical resize (like textarea) */
  resize: vertical;

  /* Make the chat window itself feel like a field */
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
}


.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__messages {
  background: #ffffff;
  border: 1px solid rgba(15,23,42,0.14);
}

/* Light theme: chat window as a white "3D" field */
/* Light theme: keep subtle 3D look */
.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__messages {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.92),
    inset 0 -2px 6px rgba(15,23,42,0.05),
    0 10px 28px rgba(15,23,42,0.10);
}

/* Floating scroll tools (up/down) */
.dstrc-ai-tc__scrolltools {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  pointer-events: none; /* enable per-button */
}

.dstrc-ai-tc__scrollbtn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0.78;
  transition: 0.15s ease;
}

.dstrc-ai-tc__scrollbtn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.dstrc-ai-tc__scrollbtn:active {
  transform: scale(0.96);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__scrollbtn {
  background: rgba(255,255,255,0.78);
  border-color: rgba(15,23,42,0.14);
}

.dstrc-ai-tc__scrollbtn .dstrc-ai-tc__ico {
  width: 18px;
  height: 18px;
}

/* Splitter between messages and composer (drag to resize) */
.dstrc-ai-tc__splitter {
  height: 12px;
  margin: 10px 0 10px;
  border-radius: 999px;
  cursor: row-resize;
  position: relative;
  background: transparent;
}

.dstrc-ai-tc__splitter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 86px;
  height: 4px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.10);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__splitter::before {
  background: rgba(15,23,42,0.08);
  border-color: rgba(15,23,42,0.12);
}

.dstrc-ai-tc__empty {
  color: var(--muted);
  padding: 20px;
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
}

.dstrc-ai-tc__msg {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.dstrc-ai-tc__msg.is-user {
  border-color: rgba(249,115,22,0.35);
  background: rgba(249,115,22,0.08);
}

.dstrc-ai-tc__msg.is-assistant {
  border-color: rgba(59,130,246,0.35);
  background: rgba(59,130,246,0.08);
}

/* Light theme: user/bot borders with subtle neon glow for readability */
.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__msg {
  background: #ffffff;
  border-color: rgba(15,23,42,0.12);
  box-shadow: 0 8px 18px rgba(15,23,42,0.08);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__msg.is-user {
  border-color: rgba(124,58,237,0.75); /* purple */
  background: rgba(124,58,237,0.03);
  box-shadow:
    0 0 0 1px rgba(124,58,237,0.32),
    0 0 16px rgba(124,58,237,0.18),
    0 10px 22px rgba(15,23,42,0.08);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__msg.is-assistant {
  border-color: rgba(139,0,0,0.62); /* burgundy */
  background: rgba(139,0,0,0.025);
  box-shadow:
    0 0 0 1px rgba(139,0,0,0.26),
    0 0 16px rgba(139,0,0,0.16),
    0 10px 22px rgba(15,23,42,0.08);
}

.dstrc-ai-tc__msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.dstrc-ai-tc__msg-role {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.dstrc-ai-tc__msg-meta {
  font-size: 11px;
  color: var(--muted2);
}

.dstrc-ai-tc__msg-body {
  font-family: var(--content-font-family) !important;
  font-size: var(--content-font-size);
  line-height: 1.55;
}

.dstrc-ai-tc__msg-tools {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dstrc-ai-tc__msg-tool.is-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dstrc-ai-tc__msg-tool svg {
  width: 16px;
  height: 16px;
}

/* Chat title inline edit */
.dstrc-ai-tc__chatitem-title.is-editing {
  cursor: text;
}

.dstrc-ai-tc__chatitem-edit {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  padding: 8px 10px;
  font-weight: 700;
  font-size: 13px;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__chatitem-edit {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.14);
}

/* Chat list context menu */
.dstrc-ai-tc__ctxmenu {
  position: absolute;
  z-index: 9999999;
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(10,15,25,0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.35);
  padding: 6px;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxmenu {
  background: rgba(255,255,255,0.98);
  box-shadow: 0 14px 40px rgba(15,23,42,0.18);
}

.dstrc-ai-tc__ctxitem {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  font-weight: 800;
}

.dstrc-ai-tc__ctxitem:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxitem:hover {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.10);
}

.dstrc-ai-tc__ctxitem--danger {
  color: #fecaca;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxitem--danger {
  color: #b91c1c;
}

/* Typography blocks rendered from Markdown-ish */
.dstrc-ai-tc__h1,
.dstrc-ai-tc__h2,
.dstrc-ai-tc__h3,
.dstrc-ai-tc__h4,
.dstrc-ai-tc__h5,
.dstrc-ai-tc__h6 {
  margin: 0 0 10px 0;
  font-weight: 950;
  line-height: 1.18;
}

.dstrc-ai-tc__h1 { font-size: 1.45em; }
.dstrc-ai-tc__h2 { font-size: 1.25em; }
.dstrc-ai-tc__h3 { font-size: 1.12em; }
.dstrc-ai-tc__h4 { font-size: 1.05em; }
.dstrc-ai-tc__h5 { font-size: 1.00em; }
.dstrc-ai-tc__h6 { font-size: 0.95em; opacity: 0.92; }

.dstrc-ai-tc__list {
  margin: 0 0 12px 0;
  padding-left: 22px;
}

.dstrc-ai-tc__olist {
  list-style: decimal;
}

.dstrc-ai-tc__msg-tool {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}

.dstrc-ai-tc__msg-tool:hover {
  background: rgba(255,255,255,0.06);
}

.dstrc-ai-tc__msg-tool .dstrc-ai-tc__ico {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: -2px;
  margin-right: 6px;
}

/* Context menu */
.dstrc-ai-tc__ctxmenu {
  position: absolute;
  z-index: 999999;
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(10,15,25,0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.35);
  overflow: hidden;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxmenu {
  background: rgba(255,255,255,0.95);
  box-shadow: 0 14px 40px rgba(15,23,42,0.12);
}

.dstrc-ai-tc__ctxitem {
  width: 100%;
  display: block;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}

.dstrc-ai-tc__ctxitem:last-child {
  border-bottom: none;
}

.dstrc-ai-tc__ctxitem:hover {
  background: rgba(255,255,255,0.06);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxitem:hover {
  background: rgba(15,23,42,0.05);
}

.dstrc-ai-tc__ctxitem--danger {
  color: #fecaca;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxitem--danger {
  color: #b91c1c;
}

.dstrc-ai-tc__p {
  margin: 0 0 10px 0;
}

.dstrc-ai-tc__spacer {
  height: 10px;
}

/* Code block wrapper + header (language + copy) */
.dstrc-ai-tc__codewrap {
  margin: 8px 0 12px;
}

.dstrc-ai-tc__codehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px 12px 0 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-bottom: none;
  background: rgba(0,0,0,0.26);
  color: var(--muted);
  font-size: 12px;
}

.dstrc-ai-tc__codelang {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.dstrc-ai-tc__codecopy {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dstrc-ai-tc__codecopy:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.09);
}

.dstrc-ai-tc__codecopy:active {
  transform: scale(0.96);
}

.dstrc-ai-tc__codecopy .dstrc-ai-tc__ico {
  width: 16px;
  height: 16px;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__codehead {
  border-color: rgba(15,23,42,0.14);
  background: rgba(15,23,42,0.04);
  color: rgba(15,23,42,0.55);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__codecopy {
  border-color: rgba(15,23,42,0.14);
  background: rgba(15,23,42,0.04);
}

.dstrc-ai-tc__code {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 10px;
  border-radius: 14px;
  overflow: auto;
}

/* If there is a code header above - merge radii and borders */
.dstrc-ai-tc__codewrap .dstrc-ai-tc__code {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin: 0;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__code {
  background: rgba(15,23,42,0.03);
  border-color: rgba(15,23,42,0.14);
}

.dstrc-ai-tc__icode {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 1px 6px;
  font-size: 0.95em;
}

/* Tables */
.dstrc-ai-tc__tablewrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  margin: 8px 0 12px;
}

.dstrc-ai-tc__tabletools {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(10px);
}

.dstrc-ai-tc__tablebtn {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease, border-color 0.12s ease;
  user-select: none;
}

.dstrc-ai-tc__tablebtn:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.24);
}

.dstrc-ai-tc__tablebtn:active {
  transform: scale(0.98);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__tablewrap {
  background: rgba(15,23,42,0.035);
  border-color: rgba(15,23,42,0.10);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__tabletools {
  background: rgba(255,255,255,0.82);
  border-bottom-color: rgba(15,23,42,0.10);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__tablebtn {
  background: rgba(255,255,255,0.92);
  border-color: rgba(15,23,42,0.14);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__tablebtn:hover {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.22);
}

.dstrc-ai-tc__table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.dstrc-ai-tc__table th,
.dstrc-ai-tc__table td {
  border-bottom: 1px solid rgba(255,255,255,0.10);
  padding: 8px 10px;
  font-size: 13px;
}

.dstrc-ai-tc__table th {
  background: rgba(255,255,255,0.06);
  font-weight: 800;
}

/* Composer */
.dstrc-ai-tc__composer {
  margin-top: 0;
  border-top: none;
  background: transparent;
  /* Side padding so the input "bubble" is not glued to the edges */
  padding: 0 20px 10px 20px;

  /* Do not allow shrinking — if input is resized taller, the chat-body scrolls */
  flex: 0 0 auto;
  flex-shrink: 0;
}

/* Footer status (small text): chat settings + AI state */
.dstrc-ai-tc__footstatus {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 0 2px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
  user-select: text;
}

.dstrc-ai-tc__footstatus-left,
.dstrc-ai-tc__footstatus-right {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dstrc-ai-tc__footstatus-right {
  text-align: right;
}


/* Light theme: input field ("Напишите запрос") as a white 3D field with purple neon border */
.dstrc-ai-tc[data-theme="light"] #dstrc-ai-tc-input {
  background: #ffffff;
  color: var(--text);
  border: 1px solid rgba(124,58,237,0.72);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 0 -2px 6px rgba(15,23,42,0.06),
    0 0 0 1px rgba(124,58,237,0.30),
    0 0 14px rgba(124,58,237,0.18),
    0 10px 28px rgba(15,23,42,0.10);
}

.dstrc-ai-tc[data-theme="light"] #dstrc-ai-tc-input:focus {
  border-color: rgba(124,58,237,0.88);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 0 -2px 6px rgba(15,23,42,0.06),
    0 0 0 1px rgba(124,58,237,0.35),
    0 0 18px rgba(124,58,237,0.22),
    0 12px 32px rgba(15,23,42,0.12);
}

.dstrc-ai-tc__composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/*
 * Hidden file inputs
 * Some WordPress themes/plugins apply aggressive global styles like
 * `input{display:block !important}` which can unexpectedly reveal our internal
 * <input type="file"> controls as "Выберите файлы" fields.
 *
 * We force-hide them here.
 */
.dstrc-ai-tc__hidden-file-input {
  display: none !important;
}

/* Compose mode switch (Text / Images) */
.dstrc-ai-tc__modeswitch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
}

.dstrc-ai-tc__segbtn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  line-height: 1;
  transition: 0.15s ease;
}

.dstrc-ai-tc__segbtn:hover {
  background: rgba(255,255,255,0.08);
}

.dstrc-ai-tc__segbtn.is-active {
  background: rgba(59,130,246,0.25);
}

/* Image options (thin collapsible block under composer) */
.dstrc-ai-tc__imgopts {
  margin-top: 8px;
}

.dstrc-ai-tc__imgopts-details {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
}

.dstrc-ai-tc__imgopts-summary {
  cursor: pointer;
  font-weight: 900;
  font-size: 12px;
  color: var(--text);
  list-style: none;
}

.dstrc-ai-tc__imgopts-summary::-webkit-details-marker {
  display: none;
}

.dstrc-ai-tc__imgopts-body {
  margin-top: 10px;
}

.dstrc-ai-tc__imgopts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.dstrc-ai-tc__imgopts-grid--secondary {
  margin-top: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dstrc-ai-tc__imgopts-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .dstrc-ai-tc__imgopts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .dstrc-ai-tc__imgopts-grid,
  .dstrc-ai-tc__imgopts-grid--secondary {
    grid-template-columns: 1fr;
  }
}

.dstrc-ai-tc__inputwrap {
  position: relative;
}

.dstrc-ai-tc__textarea--composer {
  /* User can resize the input field vertically */
  resize: vertical;
  padding-right: 58px; /* space for the send/stop icon inside the field */
  /* Default height +100% (was ~56px) */
  min-height: 112px;
  /* Allow comfortable manual resizing */
  max-height: none;
  overflow: auto;
}

.dstrc-ai-tc__iconaction {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.15s ease;
}

.dstrc-ai-tc__iconaction:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.09);
}

.dstrc-ai-tc__iconaction:active {
  transform: scale(0.96);
}

.dstrc-ai-tc__iconaction .dstrc-ai-tc__ico {
  width: 18px;
  height: 18px;
}

.dstrc-ai-tc__iconaction--send {
  border-color: rgba(59,130,246,0.55);
  background: rgba(59,130,246,0.20);
}

.dstrc-ai-tc__iconaction--stop {
  border-color: rgba(249,115,22,0.55);
  background: rgba(249,115,22,0.18);
}

.dstrc-ai-tc__composer-hint {
  font-size: 12px;
  color: var(--muted);
}

.dstrc-ai-tc__composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.dstrc-ai-tc__send-status {
  font-size: 12px;
  color: var(--muted);
}

/* Prompts panel */
.dstrc-ai-tc__panel {
  position: fixed;
  right: 14px;
  top: 82px;
  width: min(420px, calc(100% - 28px));
  max-height: calc(100vh - 110px);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(10,15,25,0.92);
  backdrop-filter: blur(10px);
  z-index: 99999;
}

.dstrc-ai-tc__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.dstrc-ai-tc__panel-title {
  font-weight: 900;
}

.dstrc-ai-tc__panel-body {
  padding: 12px;
  overflow: auto;
  max-height: calc(100vh - 180px);
}

.dstrc-ai-tc__panel-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.dstrc-ai-tc__prompt-group {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 10px;
}

.dstrc-ai-tc__prompt-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: none;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.dstrc-ai-tc__prompt-plus {
  width: 20px;
  height: 20px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.25);
}

.dstrc-ai-tc__prompt-group-body {
  padding: 10px;
}

.dstrc-ai-tc__prompt-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  margin-bottom: 8px;
  font-weight: 700;
}

.dstrc-ai-tc__prompt-item:hover {
  background: rgba(255,255,255,0.07);
}

/* Image modal */
.dstrc-ai-tc__modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
}

.dstrc-ai-tc__modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.dstrc-ai-tc__modal-card {
  position: relative;
  width: min(720px, calc(100% - 28px));
  margin: 60px auto;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(10,15,25,0.95);
  backdrop-filter: blur(10px);
  overflow: hidden;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}


.dstrc-ai-tc__modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.dstrc-ai-tc__modal-title {
  font-weight: 900;
}

.dstrc-ai-tc__modal-body {
  padding: 12px;
  overflow-y: auto;
  min-height: 0;
}

.dstrc-ai-tc__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0;
}

.dstrc-ai-tc__modal-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.dstrc-ai-tc__image-results {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}

.dstrc-ai-tc__imgbulk {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.dstrc-ai-tc__imgbulk--msg {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* Image card (modal + inline in messages) */
.dstrc-ai-tc__imgcard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dstrc-ai-tc__imgactions {
  display: flex;
  justify-content: flex-end;
}

.dstrc-ai-tc__imgdl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 800;
  font-size: 12px;
}

.dstrc-ai-tc__imgdl:hover {
  filter: brightness(1.08);
}

.dstrc-ai-tc__imglink {
  display: block;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
}

.dstrc-ai-tc__img {
  width: 100%;
  height: auto;
  display: block;
}

/* Message "copy" icon */
.dstrc-ai-tc__ico {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: -2px;
}

.dstrc-ai-tc__msg-tool--copy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Context menu (chat list right-click) */
.dstrc-ai-tc__ctxmenu {
  position: absolute;
  z-index: 999999;
  min-width: 190px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(10,15,25,0.96);
  backdrop-filter: blur(10px);
  overflow: hidden;
  box-shadow: 0 18px 55px rgba(0,0,0,0.40);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxmenu {
  background: rgba(255,255,255,0.96);
  box-shadow: 0 18px 55px rgba(15,23,42,0.18);
}

.dstrc-ai-tc__ctxitem {
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxitem {
  border-bottom-color: rgba(15,23,42,0.10);
}

.dstrc-ai-tc__ctxitem:last-child {
  border-bottom: none;
}

.dstrc-ai-tc__ctxitem:hover {
  background: rgba(255,255,255,0.06);
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__ctxitem:hover {
  background: rgba(15,23,42,0.06);
}

.dstrc-ai-tc__ctxitem--danger {
  color: #fecaca;
}

@media (max-width: 980px) {
  .dstrc-ai-tc__layout {
    grid-template-columns: 1fr;
  }
  .dstrc-ai-tc__sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .dstrc-ai-tc__panel {
    right: 10px;
    left: 10px;
    width: auto;
  }
}

@media (max-width: 520px) {
  .dstrc-ai-tc__grid {
    grid-template-columns: 1fr;
  }
  .dstrc-ai-tc__image-results {
    grid-template-columns: 1fr;
  }
}


/* ===== Thin, аккуратные скроллбары (messages, chat section, sidebar) ===== */
.dstrc-ai-tc__messages,
.dstrc-ai-tc__chatcol,
.dstrc-ai-tc__turnnav,
.dstrc-ai-tc__chatlist {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.dstrc-ai-tc__messages::-webkit-scrollbar,
.dstrc-ai-tc__chatcol::-webkit-scrollbar,
.dstrc-ai-tc__turnnav::-webkit-scrollbar,
.dstrc-ai-tc__chatlist::-webkit-scrollbar {
  width: 8px;
}

.dstrc-ai-tc__messages::-webkit-scrollbar-track,
.dstrc-ai-tc__chatcol::-webkit-scrollbar-track,
.dstrc-ai-tc__turnnav::-webkit-scrollbar-track,
.dstrc-ai-tc__chatlist::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}

.dstrc-ai-tc__messages::-webkit-scrollbar-thumb,
.dstrc-ai-tc__chatcol::-webkit-scrollbar-thumb,
.dstrc-ai-tc__turnnav::-webkit-scrollbar-thumb,
.dstrc-ai-tc__chatlist::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent; /* makes it look thinner */
  background-clip: content-box;
}

.dstrc-ai-tc__messages::-webkit-scrollbar-thumb:hover,
.dstrc-ai-tc__chatcol::-webkit-scrollbar-thumb:hover,
.dstrc-ai-tc__turnnav::-webkit-scrollbar-thumb:hover,
.dstrc-ai-tc__chatlist::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
}

@media (max-height: 720px) {
  .dstrc-ai-tc__modal-card {
    margin: 14px auto;
    max-height: calc(100vh - 28px);
  }
}


/* ============================
   Files attachments (portal)
============================ */

.dstrc-ai-tc__attachments {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 0;
  overflow: hidden;
}

.dstrc-ai-tc__attachments-details > summary.dstrc-ai-tc__attachments-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  user-select: none;
}

.dstrc-ai-tc__attachments-details > summary::-webkit-details-marker {
  display: none;
}

.dstrc-ai-tc__attachments-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dstrc-ai-tc__attachments-title {
  font-weight: 600;
  font-size: 12px;
  line-height: 1.2;
}

.dstrc-ai-tc__attachments-count {
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card2);
  opacity: 0.9;
  flex: 0 0 auto;
}

.dstrc-ai-tc__attachments-chevron {
  display: inline-flex;
  opacity: 0.7;
  transition: transform 120ms ease;
}

.dstrc-ai-tc__attachments-details[open] .dstrc-ai-tc__attachments-chevron {
  transform: rotate(180deg);
}

.dstrc-ai-tc__attachments-body {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
}

.dstrc-ai-tc__attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  max-height: 120px;
  overflow-y: auto;
  padding-right: 2px;
}

.dstrc-ai-tc__file-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card2);
  max-width: 100%;
}

.dstrc-ai-tc__file-pill-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.2;
}

.dstrc-ai-tc__file-pill-meta {
  opacity: 0.75;
  font-size: 11px;
  line-height: 1.2;
}

.dstrc-ai-tc__file-pill-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
  color: inherit;
}

.dstrc-ai-tc__file-pill-remove:hover {
  opacity: 1;
}

.dstrc-ai-tc__attachments-hint {
  font-size: 11px;
  line-height: 1.35;
  opacity: 0.75;
  color: var(--muted);
}


/* ============================================================
 * Project mode (ZIP) UI
 * ============================================================ */

.dstrc-ai-tc__input--sm,
.dstrc-ai-tc__textarea--sm {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.dstrc-ai-tc__textarea--sm {
  line-height: 1.4;
}

.dstrc-ai-tc__project {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}

.dstrc-ai-tc__project-details > summary.dstrc-ai-tc__project-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  user-select: none;
}

.dstrc-ai-tc__project-details > summary::-webkit-details-marker {
  display: none;
}

.dstrc-ai-tc__project-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dstrc-ai-tc__project-title {
  font-weight: 600;
  font-size: 12px;
  line-height: 1.2;
}

.dstrc-ai-tc__project-zip {
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card2);
  opacity: 0.92;
  max-width: 55vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dstrc-ai-tc__project-chevron {
  display: inline-flex;
  opacity: 0.7;
  transition: transform 120ms ease;
}

.dstrc-ai-tc__project-details[open] .dstrc-ai-tc__project-chevron {
  transform: rotate(180deg);
}

.dstrc-ai-tc__project-bodywrap {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.dstrc-ai-tc__project-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.dstrc-ai-tc__select-group--project {
  min-width: 240px;
  max-width: 520px;
}

.dstrc-ai-tc__select-group--project .dstrc-ai-tc__select {
  min-width: 240px;
}

.dstrc-ai-tc__project-body {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.dstrc-ai-tc__project-tree-wrap {
  flex: 0 0 38%;
  min-width: 260px;
  max-width: 460px;
}

.dstrc-ai-tc__project-editor {
  flex: 1 1 auto;
  min-width: 280px;
}

.dstrc-ai-tc__project-tree-title,
.dstrc-ai-tc__project-preview-title,
.dstrc-ai-tc__project-instruction-title,
.dstrc-ai-tc__project-diff-title {
  font-weight: 600;
  font-size: 12px;
  margin: 10px 0 6px;
  color: var(--muted);
}

.dstrc-ai-tc__project-tree-search {
  width: 100%;
  margin-bottom: 8px;
}

.dstrc-ai-tc__project-tree {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: var(--bg2);
  font-size: 12px;
}

.dstrc-ai-tc__project-tree-status {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.85;
  color: var(--muted);
}

.dstrc-ai-tc__project-tree details {
  margin-left: 10px;
}

.dstrc-ai-tc__project-tree summary {
  cursor: pointer;
  user-select: none;
  color: var(--text);
}

.dstrc-ai-tc__project-tree button.dstrc-ai-tc__project-file {
  display: block;
  width: 100%;
  text-align: left;
  padding: 3px 6px;
  margin: 1px 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
}

.dstrc-ai-tc__project-tree button.dstrc-ai-tc__project-file:hover {
  background: var(--card2);
}

.dstrc-ai-tc__project-tree button.dstrc-ai-tc__project-file.is-active {
  background: rgba(59,130,246,0.18);
  border: 1px solid rgba(59,130,246,0.30);
  padding: 2px 5px;
  font-weight: 700;
}

.dstrc-ai-tc[data-theme="light"] .dstrc-ai-tc__project-tree button.dstrc-ai-tc__project-file.is-active {
  background: rgba(37,99,235,0.12);
  border-color: rgba(37,99,235,0.28);
}

.dstrc-ai-tc__project-selected {
  margin-bottom: 6px;
  font-size: 12px;
  opacity: 0.92;
  color: var(--muted);
}

.dstrc-ai-tc__project-selected code {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
}

.dstrc-ai-tc__project-preview,
.dstrc-ai-tc__project-diff {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg2);
  max-height: 280px;
  overflow: auto;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.dstrc-ai-tc__project-instruction {
  width: 100%;
  margin-top: 6px;
}

.dstrc-ai-tc__project-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.dstrc-ai-tc__project-apply-status {
  font-size: 11px;
  opacity: 0.9;
  color: var(--muted);
}

@media (max-width: 980px) {
  .dstrc-ai-tc__project-body {
    flex-direction: column;
  }
  .dstrc-ai-tc__project-tree-wrap {
    max-width: 100%;
  }
}


/* Disabled button/links */
.dstrc-ai-tc__btn.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}


/* Attachments empty state */
.dstrc-ai-tc__attachments-empty {
  font-size: 11px;
  line-height: 1.35;
  opacity: 0.75;
  color: var(--muted);
  padding: 2px 0;
}

.dstrc-ai-tc__attachments-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 6px;
}
