*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root,
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --btn-primary-text: #0d1117;
  --drop-bg: #1c2128;
  --preview-bg: #0d1117;
  --code-bg: #161b22;
  --blockquote-border: #3d444d;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --radius: 8px;
  --header-h: 56px;
}

[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --btn-primary-text: #ffffff;
  --drop-bg: #f6f8fa;
  --preview-bg: #ffffff;
  --code-bg: #f6f8fa;
  --blockquote-border: #d0d7de;
}

html {
  color-scheme: light dark;
}

[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
}

html,
body {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 23, 0.75);
  border: 3px dashed var(--accent);
  pointer-events: none;
}

.drop-overlay__text {
  margin: 0;
  padding: 0.75rem 1.25rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(15, 17, 23, 0.5);
}

.drop-overlay[hidden] {
  display: none;
}

/* Header */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--header-h);
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.header__logo {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
}

.header__title {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header__filename {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent);
  color: var(--btn-primary-text);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--drop-bg);
}

.btn--secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--icon {
  padding: 0.4375rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--icon:hover {
  color: var(--text);
  background: var(--drop-bg);
}

.btn--lang {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.375rem 0.55rem;
  line-height: 1;
}

.lang-toggle-label {
  text-transform: uppercase;
  font-family: inherit;
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
}

[data-theme="dark"] .icon--sun { display: block; }
[data-theme="dark"] .icon--moon { display: none; }
[data-theme="light"] .icon--sun { display: none; }
[data-theme="light"] .icon--moon { display: block; }

.icon--chevron {
  width: 14px;
  height: 14px;
  margin-left: 0.25rem;
}

.download-menu {
  position: relative;
}

.download-menu__panel {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  min-width: 11rem;
  padding: 0.375rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 17, 23, 0.4);
  z-index: 20;
}

.download-menu__panel[hidden] {
  display: none;
}

.download-menu__item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
}

.download-menu__item:hover:not(:disabled) {
  background: var(--drop-bg);
}

.download-menu__item:disabled {
  opacity: 0.5;
  cursor: wait;
}

.download-menu__divider {
  height: 1px;
  margin: 0.375rem 0;
  background: var(--border);
}

.download-menu__item--danger {
  color: #ef4444;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.download-menu__item--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.download-menu--open .icon--chevron {
  transform: rotate(180deg);
}

/* View Mode Toggle */

.view-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.view-toggle[hidden] {
  display: none;
}

.view-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.view-toggle__btn:hover {
  color: var(--text);
}

.view-toggle__btn--active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .view-toggle__btn--active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

/* Main */

.main {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

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

/* Dropzone */

.dropzone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  margin: 1.5rem;
  border: 2px dashed var(--border);
  border-radius: calc(var(--radius) * 1.5);
  background: var(--drop-bg);
  transition: border-color 0.2s, background 0.2s;
}

.dropzone--active {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

[data-theme="light"] .dropzone--active {
  background: rgba(9, 105, 218, 0.08);
}

[data-theme="light"] .drop-overlay {
  background: rgba(255, 255, 255, 0.75);
}

[data-theme="light"] .drop-overlay__text {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .download-menu__panel {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.dropzone__content {
  text-align: center;
  max-width: 420px;
}

.dropzone__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  color: var(--text-muted);
}

.dropzone__title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.dropzone__text {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}

.dropzone__actions {
  margin: 1rem 0 1.25rem;
}

.dropzone__hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  opacity: 0.85;
}

/* Editor Container */

.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--preview-bg);
}

.editor-container[hidden] {
  display: none;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem calc(10% + 1rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.toolbar-group[hidden] {
  display: none !important;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.toolbar-btn:hover {
  color: var(--text);
  background: var(--drop-bg);
  border-color: var(--border);
}

.toolbar-btn:active {
  background: var(--bg);
}

.toolbar-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-muted) !important;
}

.toolbar-btn--highlight {
  color: var(--accent);
}

.toolbar-btn--highlight:hover {
  color: var(--accent-hover);
  background: rgba(88, 166, 255, 0.1);
}

.toolbar-btn__label {
  font-size: 0.75rem;
  font-weight: 500;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  margin: 0 0.25rem;
  background: var(--border);
}

.editor-textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 2rem calc(10% + 1rem);
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--preview-bg);
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
}

.editor-textarea::selection {
  background: rgba(88, 166, 255, 0.25);
}

[data-theme="light"] .editor-textarea::selection {
  background: rgba(9, 105, 218, 0.2);
}

/* Preview */

.preview {
  flex: 1;
  overflow: auto;
  padding: 2rem 0;
  background: var(--preview-bg);
  scroll-behavior: smooth;
}

/* Markdown body — GitHub-inspired */

.markdown-body {
  width: 80%;
  margin: 0 auto;
  font-size: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  font-weight: 600;
  line-height: 1.25;
}

.markdown-body h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1em; }

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
  margin-top: 0;
  margin-bottom: 1em;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body code {
  padding: 0.2em 0.4em;
  font-size: 0.875em;
  font-family: var(--font-mono);
  background: var(--code-bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.markdown-body pre {
  padding: 1rem;
  overflow: auto;
  font-size: 0.875rem;
  line-height: 1.45;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.markdown-body pre code {
  padding: 0;
  background: none;
  border: none;
  font-size: inherit;
}

.markdown-body pre.mermaid {
  padding: 1rem 0;
  overflow-x: auto;
  background: transparent;
  border: none;
  text-align: center;
}

.markdown-body pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

.markdown-body blockquote {
  padding: 0 1em;
  color: var(--text-muted);
  border-left: 4px solid var(--blockquote-border);
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 2em;
}

.markdown-body li + li {
  margin-top: 0.25em;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.markdown-body th,
.markdown-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.markdown-body th {
  font-weight: 600;
  background: var(--surface);
}

.markdown-body tr:nth-child(even) {
  background: rgba(22, 27, 34, 0.35);
}

[data-theme="light"] .markdown-body tr:nth-child(even) {
  background: rgba(246, 248, 250, 0.9);
}

.markdown-body hr {
  height: 1px;
  margin: 1.5em 0;
  background: var(--border);
  border: 0;
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Frontmatter Metadata Card in Preview */
.frontmatter-block {
  margin: 0 0 1.75rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.frontmatter-block:hover {
  border-color: var(--accent);
}

.frontmatter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  background: var(--code-bg);
  border-bottom: 1px solid transparent;
  list-style: none;
}

.frontmatter-summary::-webkit-details-marker {
  display: none;
}

.frontmatter-block[open] .frontmatter-summary {
  border-bottom-color: var(--border);
}

.frontmatter-summary__left {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.frontmatter-summary__icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
  flex-shrink: 0;
}

.frontmatter-summary__badge {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  font-size: 0.6875rem;
  color: var(--accent);
}

.frontmatter-summary__count {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.frontmatter-summary__hint {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  opacity: 0.75;
}

.frontmatter-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin: 0 !important;
  background: transparent;
}

.frontmatter-table tr,
.markdown-body .frontmatter-table tr {
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.frontmatter-table tr:last-child,
.markdown-body .frontmatter-table tr:last-child {
  border-bottom: none;
}

.frontmatter-key,
.markdown-body .frontmatter-table th.frontmatter-key {
  width: 25%;
  min-width: 110px;
  max-width: 220px;
  padding: 0.4rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(0, 0, 0, 0.02);
  vertical-align: top;
  border: none;
  border-right: 1px solid var(--border);
  text-align: left;
}

[data-theme="dark"] .frontmatter-key,
[data-theme="dark"] .markdown-body .frontmatter-table th.frontmatter-key {
  background: rgba(255, 255, 255, 0.02);
}

.frontmatter-val,
.markdown-body .frontmatter-table td.frontmatter-val {
  padding: 0.4rem 0.875rem;
  color: var(--text);
  font-family: var(--font-sans);
  border: none;
  word-break: break-word;
}

.frontmatter-tag {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  margin: 0.1rem 0.25rem 0.1rem 0;
  border-radius: 4px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-size: 0.6875rem;
  color: var(--accent);
  font-family: var(--font-mono);
}

.frontmatter-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.75rem;
}

.frontmatter-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.frontmatter-link:hover {
  color: var(--accent-hover);
}

/* Footer */

.footer {
  padding: 0.75rem 1.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.footer p {
  margin: 0;
}

.footer p + p {
  margin-top: 0.375rem;
}

.footer__link {
  color: var(--accent);
  text-decoration: none;
}

.footer__link:hover {
  text-decoration: underline;
}

.footer__suite {
  font-size: 0.75rem;
}

.footer__credit {
  font-size: 0.6875rem;
  opacity: 0.85;
}

/* Responsive */

@media (max-width: 600px) {
  .header__filename {
    display: none;
  }

  .markdown-body {
    width: 92%;
  }

  .dropzone {
    margin: 1rem;
    padding: 1.5rem;
  }

  .editor-textarea {
    padding: 1rem 4%;
  }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  z-index: 1000;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast--show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.markdown-body h1[id]:target,
.markdown-body h2[id]:target,
.markdown-body h3[id]:target,
.markdown-body h4[id]:target,
.markdown-body h5[id]:target,
.markdown-body h6[id]:target {
  animation: highlightTarget 1.5s ease-out;
}

@keyframes highlightTarget {
  0% {
    background-color: rgba(88, 166, 255, 0.25);
  }
  100% {
    background-color: transparent;
  }
}

/* Modal Dialog */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 23, 0.75);
  backdrop-filter: blur(4px);
  padding: 1rem;
}

[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.4);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.25);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: modalScale 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.modal__close {
  padding: 0 0.375rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s;
}

.modal__close:hover {
  color: var(--text);
}

.modal__body {
  padding: 1.25rem;
  max-height: calc(85vh - 120px);
  overflow-y: auto;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--accent);
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.625rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.modal__body .modal__footer {
  margin: 1.25rem -1.25rem -1.25rem -1.25rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.modal--wide {
  max-width: 760px;
}

.input-with-badge {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-badge .form-control {
  padding-right: 5rem;
}

.search-badge {
  position: absolute;
  right: 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
}

.input-with-extension {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-extension .form-control {
  padding-right: 4.5rem;
}

.file-extension-badge {
  position: absolute;
  right: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
  padding: 0.125rem 0.4rem;
  border-radius: 4px;
  pointer-events: none;
  user-select: none;
}

.form-help-text {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-group--checkbox {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.modal__footer--space-between {
  justify-content: space-between;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* File Management Modal */

.file-modal__actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.file-modal__action-btn {
  flex: 1 1 180px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

.file-modal__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.file-modal__section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.file-modal__count-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  color: var(--text-muted);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.file-list__empty {
  text-align: center;
  padding: 2.25rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}

.file-item:hover {
  border-color: var(--accent);
}

.file-item--active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.file-item__info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.file-item__icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.file-item__details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.125rem;
}

.file-item__name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-item__name {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item__active-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  padding: 0.0625rem 0.375rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.file-item__dirty-badge {
  font-size: 0.6875rem;
  color: #f59e0b;
  font-weight: 600;
}

.file-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-item__actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.file-item__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) * 0.75);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.file-item__btn:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.file-item__btn--primary {
  color: var(--accent);
}

.file-item__btn--primary:hover {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
}

.file-item__btn--danger:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Git Integration Styles */

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-group--flex-1 {
  flex: 1;
  min-width: 0;
}

.form-group--flex-2 {
  flex: 2;
  min-width: 0;
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.375rem;
}

.form-actions-row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.form-actions-inline {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.input-with-action {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}

.input-with-action .form-control {
  flex: 1;
}

.btn--sm {
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
}

.git-tree-container {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.git-tree-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.git-tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.git-tree-item:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.git-tree-item__info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.git-tree-item__path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.git-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  max-height: 180px;
  overflow-y: auto;
}

.git-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.git-account-card__info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  flex: 1;
}

.badge--provider {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge--github {
  background: rgba(36, 41, 47, 0.2);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge--gitlab {
  background: rgba(226, 67, 41, 0.15);
  color: #fc6d26;
}

.git-account-card__name {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text);
}

.git-account-card__host {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.git-account-form-container {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.form-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.git-meta-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.git-meta-row {
  display: flex;
  font-size: 0.8125rem;
  gap: 0.5rem;
}

.git-meta-label {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 90px;
}

.git-meta-value {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.file-item__git-badge {
  font-size: 0.6875rem;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.12);
  padding: 0.0625rem 0.375rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.toolbar-btn--git {
  color: #8b5cf6;
}

.toolbar-btn--git:hover {
  color: #7c3aed;
  background: rgba(139, 92, 246, 0.12);
}

.download-menu__item--git {
  color: #8b5cf6;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.download-menu__item--git:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.12);
  color: #7c3aed;
}

/* Custom Alert, Confirm & Branch Modals */

.modal--dialog {
  max-width: 440px;
}

.dialog-content {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.dialog-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dialog-icon .icon--lg {
  width: 22px;
  height: 22px;
}

.dialog-icon--success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.dialog-icon--danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.dialog-icon--warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.dialog-icon--info {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.dialog-message {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
  word-break: break-word;
  padding-top: 0.25rem;
}

.branch-select-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.branch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.branch-item:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent);
}

.branch-item--active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
}

.btn--danger {
  background: #ef4444;
  color: #fff;
  border: 1px solid transparent;
}

.btn--danger:hover {
  background: #dc2626;
}

/* Mermaid Diagram Zoom & Pan Container */

/* Mermaid Diagram Zoom & Pan Container */

.mermaid-wrapper {
  position: relative;
  margin: 1.5rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

/* Standalone diagram / pure .mmd file full-screen layout for high-res monitors */
.markdown-body--mermaid,
.preview:has(.mermaid-wrapper:only-child) .markdown-body,
.markdown-body:has(> .mermaid-wrapper:only-child) {
  width: 98% !important;
  max-width: 100% !important;
  padding: 0 !important;
}

.markdown-body--mermaid > .mermaid-wrapper,
.markdown-body > .mermaid-wrapper:only-child,
.preview:has(.mermaid-wrapper:only-child) .mermaid-wrapper {
  width: 100% !important;
  max-width: 100% !important;
  min-height: calc(100vh - 120px) !important;
  height: calc(100vh - 120px) !important;
  margin: 0 !important;
}

.mermaid-zoom-toolbar {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.mermaid-wrapper:hover .mermaid-zoom-toolbar {
  opacity: 1;
}

.mermaid-zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) * 0.75);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mermaid-zoom-btn:hover {
  color: var(--text);
  background: var(--drop-bg);
}

.mermaid-zoom-badge {
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}

.mermaid-viewport {
  width: 100%;
  height: 100%;
  min-height: 480px;
  flex: 1;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  touch-action: none;
  position: relative;
}

.mermaid-viewport:active {
  cursor: grabbing;
}

.mermaid-viewport .mermaid {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mermaid-viewport svg {
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  display: block;
  margin: auto;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
}

/* AI Assistant Button in Header & Toolbar */
.btn--ai {
  position: relative;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  gap: 0.375rem;
}

.btn--ai:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--ai.btn--ai-active {
  background: rgba(88, 166, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="light"] .btn--ai.btn--ai-active {
  background: rgba(9, 105, 218, 0.1);
}

.icon--spark {
  color: #e3b341;
}

[data-theme="light"] .icon--spark {
  color: #b08800;
}

.toolbar-btn--ai {
  color: var(--text);
}

.toolbar-btn--ai:hover,
.toolbar-btn--ai.toolbar-btn--active {
  color: var(--accent);
  border-color: var(--accent);
}

/* AI Sidebar */
.ai-sidebar {
  width: 410px;
  min-width: 320px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  position: relative;
  z-index: 25;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  transition: width 0.2s ease, transform 0.2s ease;
}

.ai-sidebar[hidden] {
  display: none !important;
}

.ai-sidebar__header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-sidebar__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-sidebar__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.ai-sidebar__actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ai-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.ai-btn-icon:hover {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.ai-sidebar__status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.ai-badge--model {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.ai-badge--local {
  background: rgba(46, 160, 67, 0.15);
  border: 1px solid rgba(46, 160, 67, 0.35);
  color: #3fb950;
}

[data-theme="light"] .ai-badge--local {
  background: rgba(31, 136, 61, 0.12);
  color: #1a7f37;
  border-color: rgba(31, 136, 61, 0.3);
}

.ai-badge--external {
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: var(--accent);
}

.ai-sidebar__notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  font-size: 0.75rem;
  background: rgba(210, 153, 34, 0.12);
  border-bottom: 1px solid rgba(210, 153, 34, 0.25);
  color: #e3b341;
}

[data-theme="light"] .ai-sidebar__notice {
  background: rgba(154, 103, 0, 0.1);
  border-bottom-color: rgba(154, 103, 0, 0.2);
  color: #8c5d00;
}

.ai-sidebar__notice .icon {
  flex-shrink: 0;
}

/* Chat Messages */
.ai-sidebar__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  scroll-behavior: smooth;
}

.ai-welcome {
  text-align: center;
  padding: 1rem 0.5rem;
  margin: auto 0;
}

.ai-welcome__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.ai-welcome__icon svg {
  width: 24px;
  height: 24px;
}

.ai-welcome__title {
  margin: 0 0 0.375rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.ai-welcome__text {
  margin: 0 0 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.ai-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  text-align: left;
}

.ai-quick-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.ai-quick-btn:hover {
  background: var(--drop-bg);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Message Bubbles */
.ai-message {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-message--user {
  align-self: flex-end;
  max-width: 88%;
}

.ai-message--user .ai-message__bubble {
  background: var(--accent);
  color: var(--btn-primary-text);
  padding: 0.625rem 0.875rem;
  border-radius: 14px 14px 2px 14px;
  font-size: 0.875rem;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.45;
}

[data-theme="dark"] .ai-message--user .ai-message__bubble {
  background: #1f6feb;
  color: #ffffff;
}

.ai-message--assistant {
  align-self: flex-start;
  width: 100%;
}

.ai-message--assistant .ai-message__bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.875rem;
  border-radius: 14px 14px 14px 2px;
  font-size: 0.875rem;
  color: var(--text);
  word-break: break-word;
  line-height: 1.5;
}

.ai-message--assistant .ai-message__bubble p:first-child {
  margin-top: 0;
}

.ai-message--assistant .ai-message__bubble p:last-child {
  margin-bottom: 0;
}

.ai-message--assistant .ai-message__bubble pre {
  margin: 0.625rem 0;
  padding: 0.625rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  overflow-x: auto;
  font-size: 0.8125rem;
}

.ai-message--assistant .ai-message__bubble table {
  width: 100%;
  margin: 0.625rem 0;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.ai-message--assistant .ai-message__bubble th,
.ai-message--assistant .ai-message__bubble td {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
}

.ai-message--assistant .ai-message__bubble th {
  background: var(--surface);
}

.ai-message--assistant .ai-message__bubble ul,
.ai-message--assistant .ai-message__bubble ol {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.ai-message__time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  padding: 0 0.25rem;
}

.ai-message--user .ai-message__time {
  text-align: right;
}

/* Assistant Message Actions */
.ai-msg-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.625rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-action-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--btn-primary-text);
}

.ai-action-btn--primary {
  background: rgba(88, 166, 255, 0.15);
  border-color: rgba(88, 166, 255, 0.35);
  color: var(--accent);
}

/* Code block toolbar inside chat */
.ai-code-wrapper {
  position: relative;
  margin: 0.625rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
}

.ai-code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.625rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.ai-code-actions {
  display: flex;
  gap: 0.25rem;
}

.ai-code-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.4rem;
  font-size: 0.6875rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-code-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--accent);
}

.ai-code-wrapper pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
}

/* Loading Dots */
.ai-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.5rem 0.25rem;
}

.ai-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: aiBounce 1.4s infinite ease-in-out both;
}

.ai-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Context bar */
.ai-sidebar__context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 1rem;
  font-size: 0.75rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.ai-context-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  user-select: none;
}

.ai-context-label input {
  accent-color: var(--accent);
  cursor: pointer;
}

.ai-context-text {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-context-meta {
  font-size: 0.6875rem;
  opacity: 0.8;
}

/* Input Area */
.ai-sidebar__input-area {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.ai-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.375rem 0.5rem;
  transition: border-color 0.15s;
}

.ai-input-wrap:focus-within {
  border-color: var(--accent);
}

.ai-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 140px;
  min-height: 24px;
  padding: 0.2rem 0.25rem;
  box-sizing: border-box;
}

.ai-textarea::placeholder {
  color: var(--text-muted);
}

.ai-send-btn,
.ai-stop-btn {
  padding: 0.4rem;
  width: 32px;
  height: 32px;
  border-radius: calc(var(--radius) - 2px);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-stop-btn {
  background: #ef4444;
  color: #fff;
  border: none;
}

.ai-stop-btn:hover {
  background: #dc2626;
}

/* AI Settings Modal Helpers */
.input-with-button {
  display: flex;
  gap: 0.5rem;
}

.input-with-button .form-control {
  flex: 1;
}

.input-with-datalist {
  position: relative;
}

.form-range {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.dialog-tip {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ai-test-status {
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.ai-test-status--ok {
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.3);
}

[data-theme="light"] .ai-test-status--ok {
  background: rgba(31, 136, 61, 0.12);
  color: #1a7f37;
  border-color: rgba(31, 136, 61, 0.3);
}

.ai-test-status--err {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.ai-test-status--loading {
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.3);
}

/* Responsive */
@media (max-width: 900px) {
  .ai-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
    z-index: 50;
  }
}

@media (max-width: 600px) {
  .btn-ai__label {
    display: none;
  }
  .ai-sidebar {
    max-width: 100%;
  }
}
