mark {
  background: rgba(34, 197, 94, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

:root {
  --primary: #4ade80;
  --bg: #09090b;
  --card: #18181b;
  --border: #27272a;
  --text: #fafafa;
  --input-bg: #000000;
  --hover: #27272a;
  --white: #ffffff;
  --grey: #a1a1aa;
  --ai-purple: #c084fc;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.spinning {
  animation: spin 2s linear infinite;
}

.hidden {
  display: none !important;
}

.flex {
  display: flex !important;
}

.block {
  display: block !important;
}

/* Dark Scrollbar Styling */
* {
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 var(--bg);
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.custom-note:focus {
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
  outline: none;
  border-color: var(--primary);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.mobile-nav {
  display: none;
  background: var(--card);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
}

button#sidebarToggle {
  width: auto !important;
  padding: 0 16px !important;
  height: 34px;
  min-height: 34px;
}

button#sidebarToggle .icon-sm {
  width: 16px;
  height: 16px;
}

.mobile-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
  display: flex;
  align-items: center;
}

.container {
  background: var(--card);
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  width: calc(100% - 40px);
  /* Equal margins */
  max-width: 1400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: calc(100vh - 40px);
  margin: 20px auto;
  /* Equal margins */
  overflow: hidden;
  position: relative;
}

h1 {
  color: var(--white);
  margin-top: 0;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 20px;
}

.brand-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.github-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--card);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.github-mobile {
  display: none;
}

.github-link:hover {
  background: var(--hover);
  border-color: var(--primary);
}

.subtitle {
  color: #a1a1aa;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 600px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.template-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.template-row .template-select {
  flex: 1;
  margin-bottom: 0;
}

button,
input,
select,
textarea {
  font-size: 16px !important;
  /* Prevent iOS zoom */
}

@media (min-width: 1024px) {

  button,
  input,
  select,
  textarea {
    font-size: 0.9rem !important;
  }
}

button {
  height: 38px;
  min-height: 38px;
  background: var(--white);
  color: #000;
  border: none;
  font-weight: 700;
  border-radius: 0.6rem;
  padding: 0 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

button.icon-only {
  width: 38px;
  padding: 0;
  justify-content: center;
}

/* New Chat Button behavior: Icon-only on mobile, full on tablet/desktop */
@media (min-width: 601px) {
  #aiNewChatBtn.icon-only {
    width: auto !important;
    padding: 0 16px !important;
  }
}

/* Download Badges */
.action-buttons button {
  position: relative;
}

.badge {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--primary);
  color: #000;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 4px;
  border-radius: 4px;
  text-transform: uppercase;
  z-index: 5;
}

@media (max-width: 768px) {
  .badge {
    display: block;
  }
}

button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

button:active {
  transform: scale(0.98);
}

.output-container {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.output-tabs {
  display: flex;
  gap: 2px;
  background: var(--card);
  padding: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  width: 100%;
  flex-wrap: nowrap;
}

.output-tabs::-webkit-scrollbar {
  height: 4px;
}

.output-tabs::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.tab-item {
  height: 36px;
  min-height: 36px;
  background: transparent;
  color: var(--grey);
  border: none;
  font-size: 0.85rem;
  padding: 0 15px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}

.tab-item.active {
  background: var(--border);
  color: var(--primary);
}

.highlights-container {
  position: relative;
  flex: 1;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  overflow: hidden;
  display: flex;
}

.highlights-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
  font-family: "Fira Code", monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: transparent;
  pointer-events: none;
  overflow-y: auto;
  box-sizing: border-box;
}

.highlights-layer mark {
  background: rgba(34, 197, 94, 0.4) !important;
  color: transparent !important;
  border-radius: 2px;
}

textarea#output {
  width: 100%;
  flex: 1;
  background: transparent !important;
  border: none !important;
  color: #10b981;
  font-family: "Fira Code", monospace;
  padding: 16px;
  font-size: 14px;
  outline: none;
  resize: none;
  line-height: 1.6;
  position: relative;
  z-index: 2;
  white-space: pre-wrap;
  word-break: break-all;
  box-sizing: border-box;
  overflow-y: auto;
}

.highlights-layer::-webkit-scrollbar,
textarea#output::-webkit-scrollbar {
  display: none;
}

.highlight {
  background-color: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  font-weight: bold;
  border-radius: 2px;
}

#status {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 5px;
}

#status span {
  color: var(--grey);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(5, 46, 22, 0.2);
  border-radius: 50%;
  border-top-color: #052e16;
  animation: spin 0.8s linear infinite;
}

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

.copy-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--primary);
  color: #052e16;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: bold;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-sm {
  width: 18px;
  height: 18px;
}

.icon-xs {
  width: 14px;
  height: 14px;
}

/* File Tree Styles */
.file-tree-container {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.file-tree {
  flex: 0 0 320px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: visible;
  /* Allow floating close button */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

#fileTree {
  flex: 1;
  min-height: 0;
  /* Crucial for nested flex scrolling */
  overflow-y: auto;
  margin-bottom: 10px;
}

.tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.root-dir-display {
  font-size: 0.8rem;
  color: var(--primary);
  margin-bottom: 12px;
  font-family: "Fira Code", monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-header h3 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
}

.tree-controls {
  display: flex;
  gap: 4px;
}

.tree-controls button {
  padding: 0;
  width: 20px !important;
  height: 20px !important;
  min-height: 20px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--grey);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: -36px;
  width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  z-index: 1110;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  color: var(--white) !important;
}

@media (max-width: 1023px) {
  .file-tree.active .sidebar-close-btn {
    display: flex !important;
  }
}

.tree-controls button .icon-xs {
  width: 12px;
  height: 12px;
}

.tree-controls button:hover {
  background: var(--hover);
  color: var(--primary);
  border-color: var(--primary);
}

.v-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
  align-self: center;
  opacity: 0.6;
}

.language-stats {
  margin-top: auto;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: #a1a1aa;
}

.tree-item {
  padding: 0;
  margin: 0;
  user-select: none;
}

.tree-item-row {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 0;
}

.tree-item-row:hover {
  background: var(--hover);
  border-radius: 4px;
  padding-left: 4px;
  padding-right: 4px;
}

.tree-children {
  margin-left: 0;
  padding-left: 0;
}

.tree-item input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--white);
}

.tree-item-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-folder {
  font-weight: 600;
  color: var(--grey);
}

.tree-file {
  color: var(--white);
}

.tree-indent {
  display: inline-block;
  width: 10px;
}

.tree-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  margin-right: 4px;
  color: #71717a;
}

.tree-toggle.collapsed {
  transform: rotate(-90deg);
}

.tree-spacer {
  display: inline-flex;
  width: 16px;
  margin-right: 4px;
}

.tree-item-label.match {
  color: #a7f3d0;
  font-weight: bold;
}

.output-preview {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 12px;
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #a1a1aa;
}

.output-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.output-preview.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #52525b;
  font-style: italic;
}

.file-count {
  font-size: 0.75rem;
  color: #a1a1aa;
  margin-left: 8px;
}

.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.action-buttons button {
  flex: 1;
  justify-content: center;
  height: 44px;
}

.chunk-controls {
  margin-top: 15px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chunk-info {
  font-size: 0.85rem;
  color: var(--grey);
  text-align: center;
}

.chunk-nav {
  display: flex;
  gap: 8px;
  width: 100%;
}

.chunk-nav button {
  flex: 1;
  height: 36px;
  font-size: 0.8rem;
  background: var(--bg);
  /* Darker background */
  color: var(--white);
  border: 1px solid var(--border);
}

.chunk-nav button:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--primary);
}

#nextChunkBtn {
  justify-content: flex-end;
  padding-right: 16px !important;
}

#prevChunkBtn {
  justify-content: flex-start;
  padding-left: 16px !important;
}

#copyBtn,
#mainBtn {
  background: var(--primary);
  color: #052e16;
}

#copyBtn:hover,
#mainBtn:hover {
  background: #22c55e;
}

#askAiBtn {
  background: #c084fc !important;
  color: #2e1065 !important;
  margin-left: 10px;
  white-space: nowrap;
}

#askAiBtn:hover {
  background: #a855f7 !important;
}

.ai-response-content {
  background: #000;
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: 8px;
  max-height: 500px;
  overflow: auto;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
}

.code-block-wrapper {
  position: relative;
  margin: 1.5rem 0;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 10px;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 10;
}

.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.code-copy-btn.copied {
  border-color: #22c55e;
  color: #22c55e;
}

.ai-response-content pre {
  margin: 0;
}

.ai-response-content code {
  background: var(--card);
  padding: 2px 5px;
  border-radius: 4px;
}

.ai-response-content h1,
.ai-response-content h2,
.ai-response-content h3 {
  color: var(--primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.ai-response-content p {
  margin-bottom: 1rem;
}

.assistant-content ul,
.assistant-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.assistant-content li {
  margin-bottom: 0.4rem;
}

.assistant-content li:last-child {
  margin-bottom: 0;
}

.ai-response-content pre {
  margin: 0;
}

.ai-response-content code {
  background: var(--card);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: "Fira Code", monospace;
  font-size: 0.85rem;
  color: #10b981;
}

.ai-response-content pre {
  background: #111;
  padding: 15px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.ai-response-content pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
}

.ai-response-content ul,
.ai-response-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.ai-response-content li {
  margin-bottom: 0.5rem;
}

.ai-follow-up {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.ai-follow-up-input {
  flex: 1;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 24px;
  outline: none;
  font-size: 16px;
  transition: all 0.2s;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  line-height: 24px;
  font-family: inherit;
}

.graph-node-info {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(9, 9, 11, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-width: 250px;
  z-index: 100;
  pointer-events: none;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

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

.ai-follow-up-input:focus {
  outline: none;
  border-color: var(--primary);
}

.ai-follow-up-btn,
.preview-ai-send-btn,
.ai-btn-purple {
  background: var(--ai-purple);
  color: #2e1065;
  border: none;
  padding: 0.8rem 1.2rem;
  border-radius: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ai-follow-up-btn:hover,
.preview-ai-send-btn:hover,
.ai-btn-purple:hover {
  background: #a855f7;
  transform: translateY(-1px);
}

.ai-follow-up-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Consolidated Mobile Adaptations */
@media (max-width: 1023px) {
  body {
    overflow-y: auto;
    padding: 0;
  }

  .mobile-nav {
    display: flex;
  }

  .container {
    padding: 15px;
    margin: 15px;
    /* Equal margins on mobile */
    width: calc(100% - 30px);
    height: auto;
    min-height: calc(100vh - 88px);
    border-radius: 1rem;
    border: 1px solid var(--border);
    gap: 15px;
    max-width: none;
  }

  .header-row h1,
  .header-row .github-link:not(.github-mobile) {
    display: none !important;
  }

  .header-row {
    margin-bottom: 1rem;
  }

  .github-mobile {
    display: flex !important;
    padding: 8px !important;
    border-radius: 50% !important;
  }

  .controls {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
  }

  button#mainBtn {
    flex: 0 0 auto;
    /* Compact on tablet/mobile */
  }

  select#formatSelect {
    flex: 1;
    /* Fluid on tablet/mobile */
  }

  .template-row {
    display: flex !important;
    gap: 10px;
  }

  button#askAiBtn {
    flex: 0 0 auto;
  }

  .template-row .template-select {
    flex: 1;
  }

  @media (max-width: 480px) {
    .controls {
      flex-direction: row !important;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
    }

    button#mainBtn {
      flex: 0 0 auto;
      /* Keep compact even on smaller screens */
    }

    select#formatSelect {
      flex: 1;
      /* Fill remaining space */
    }

    .settings-btn {
      flex: 0 0 auto !important;
      width: 44px;
      padding: 0;
      justify-content: center;
    }
  }

  .file-tree {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 1100;
    transform: translateX(-100%);
    border-radius: 0;
    background: var(--card);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
  }

  .file-tree.active {
    transform: translateX(0);
  }

  .file-tree.active .sidebar-close-btn {
    display: flex !important;
  }

  .output-tabs {
    position: relative;
    /* Remove sticky on mobile to avoid overlap */
    top: 0;
    margin-bottom: 5px;
  }

  .preview-modal-content {
    width: calc(100% - 30px);
    height: calc(100% - 40px);
    margin: 20px auto;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
  }

  .preview-split-container {
    flex-direction: column;
    overflow-y: auto;
  }

  .preview-ai-section {
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 20px;
  }

  .preview-metadata {
    flex-direction: column;
    gap: 5px;
  }

  button#previewAskAiBtn {
    padding: 0 12px !important;
  }

  @media (max-width: 600px) {
    .btn-label {
      display: none !important;
    }

    button {
      gap: 0 !important;
    }

    button svg {
      margin-right: 0 !important;
    }

    button#mainBtn,
    button#sidebarToggle {
      padding: 0 12px !important;
    }

    .subtitle {
      font-size: 16px !important;
    }
  }

  /* Reset body/html for better scrolling on mobile */
  html,
  body {
    overflow: auto;
    height: auto;
    min-height: 100%;
  }

  .container {
    height: auto;
    min-height: calc(100vh - 88px);
    /* Allow container to grow if content overflows */
    overflow: visible;
    /* Important for mobile flow */
  }
}

/* New Styles */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
  color: var(--primary);
}

.overlay.active {
  display: flex;
}

.overlay-content {
  text-align: center;
  pointer-events: none;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  /* Ensure above top nav */
  backdrop-filter: blur(2px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 24px;
  width: 90%;
  max-width: 500px;
  margin: 40px auto;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content.large {
  max-width: 1200px;
  width: 95%;
}

.settings-input {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 0.8rem 1rem;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  margin-top: 8px;
  transition: all 0.2s;
}

.settings-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}

.preview-modal-content {
  max-width: 800px;
  width: 90%;
  transition: max-width 0.3s ease;
}

.preview-modal-content.split-view {
  max-width: 1200px;
}

.preview-metadata {
  font-size: 0.8rem;
  color: var(--grey);
  margin-top: 4px;
  display: flex;
  gap: 15px;
}

.preview-metadata span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.preview-split-container {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.preview-code-section {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.preview-ai-section {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

.preview-ai-section .chat-input-container {
  display: flex;
  gap: 10px;
  padding: 15px 0;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.preview-ai-section .chat-input {
  flex: 1;
  height: 48px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 15px;
  color: var(--text);
  font-size: 0.9rem;
}

.preview-ai-section #previewAiSendBtn {
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-ai-section.hidden {
  display: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.confirmation-modal {
  z-index: 3000;
}

.confirmation-modal-content {
  max-width: 480px;
  animation: confirmSlideIn 0.2s ease-out;
}

@keyframes confirmSlideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

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

.preview-content {
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 15px;
  border-radius: 8px;
  flex: 1;
  overflow: auto;
  font-size: 0.85rem;
  color: #10b981;
  margin: 0;
  font-family: "Fira Code", monospace;
}

.close-btn {
  padding: 6px 12px !important;
  font-weight: bold;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-box {
  margin-bottom: 10px;
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  padding-left: 32px;
  border-radius: 6px;
  font-size: 0.85rem;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.custom-note:focus {
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
  outline: none;
  border-color: var(--primary);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #71717a;
  width: 14px;
  height: 14px;
}

button#mainBtn {
  height: 38px;
  min-height: 38px;
  padding: 0 16px;
  font-size: 0.85rem !important;
}

select#formatSelect {
  height: 38px;
  font-size: 0.85rem !important;
  padding: 0 32px 0 12px;
}

select.format-select,
select.template-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px;
  padding-right: 32px;
  /* Fix for chevron touching edge */
  border-radius: 0.6rem;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23fafafa' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  transition: border-color 0.2s;
  height: 48px;
  /* Same as buttons */
}

select.format-select:hover,
select.template-select:hover,
.custom-note:hover {
  border-color: var(--primary);
}

select.format-select:focus,
select.template-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.settings-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.settings-help {
  margin: 0 0 8px 0;
  font-size: 0.8rem;
  color: #a1a1aa;
}

.settings-input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px;
  border-radius: 6px;
  font-family: "Fira Code", monospace;
  font-size: 0.85rem;
}

.token-pill {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  margin-left: 8px;
}

.instruction-box {
  color: var(--primary);
  font-style: italic;
  margin-bottom: 1rem;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 0.5rem;
}

/* Template & Note Styles */
.template-select {
  margin-bottom: 12px;
  width: 100%;
}

/* Usage Dashboard */
.usage-dashboard {
  margin-top: auto;
  padding: 15px;
  background: rgba(24, 24, 27, 0.5);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.usage-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--grey);
}

.usage-value {
  color: var(--primary);
  font-weight: 600;
  font-family: inherit;
}

/* Switches */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked+.slider {
  background-color: var(--primary);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Pills */
.secondary-pill {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.secondary-pill:hover {
  background: var(--hover);
  color: var(--primary);
}

/* Graph Styles */
#graphContainer {
  width: 100%;
  height: 100%;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.packs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.pack-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
}

.pack-item:hover {
  border-color: var(--primary);
  background: var(--hover);
}

.pack-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pack-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.pack-count {
  font-size: 0.75rem;
  color: var(--grey);
}

.pack-actions {
  display: flex;
  gap: 8px;
}

.custom-note {
  background: var(--bg);
  /* Match output textarea background */
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  color: var(--text);
  padding: 12px;
  width: 100%;
  min-height: 60px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 12px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.custom-note:focus {
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
  outline: none;
  border-color: var(--primary);
}

.output-section {
  flex: 1;
  font-size: 16px;
  transition: all 0.2s;
}

.ai-follow-up-input:focus {
  border-color: var(--ai-purple);
  box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.2);
}

.chat-input {
  flex: 1;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  outline: none;
  font-size: 16px;
  transition: all 0.2s;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  line-height: 24px;
  font-family: inherit;
}