.aipkit_code_block {
  position: relative;
}

.acdt-preview,
.acdt-edit {
  position: absolute;
  top: 6px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(33, 33, 33, 0.82);
  color: #cfcfcf;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
  z-index: 20;
  touch-action: manipulation;
}

.acdt-preview {
  right: 42px;
}

.acdt-edit {
  right: 82px;
}

.acdt-preview:hover,
.acdt-edit:hover {
  background: #2a2a2a;
  color: #fff;
}

#acdt-preview {
  position: fixed;
  right: 0;
  top: 0;
  width: min(60vw, 1120px);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #0d1117;
  z-index: 2147483000;
  transform: translateX(100%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -18px 0 34px rgba(0, 0, 0, 0.28);
}

#acdt-preview.open {
  transform: translateX(0);
}

#acdt-preview.acdt-fullscreen-mode,
#acdt-preview:fullscreen {
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  transform: none !important;
}

.acdt-header {
  flex: 0 0 auto;
  min-height: 52px;
  background: #212121;
  color: #fff;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.acdt-header span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acdt-tools {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.acdt-tools button {
  background: transparent;
  border: none;
  color: #cfcfcf;
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  touch-action: manipulation;
}

.acdt-tools button:hover {
  background: #2a2a2a;
  color: #fff;
}

.CodeMirror {
  height: 40% !important;
  min-height: 170px;
  background: #0d1117 !important;
  color: #e6edf3 !important;
  font-family: Consolas, ui-monospace, SFMono-Regular, monospace;
  font-size: 14px;
  line-height: 1.5;
  flex: 0 0 auto;
}

.CodeMirror-gutters {
  background: #0d1117;
  border-right: 1px solid #30363d;
}

.CodeMirror-linenumber {
  color: #6e7681;
}

.CodeMirror span.cm-variable-2 {
  color: #7ee787 !important;
}

.CodeMirror span.cm-property,
.CodeMirror span.cm-atom {
  color: #79c0ff !important;
}

.CodeMirror span.cm-number {
  color: #e6edf3 !important;
}

.CodeMirror span.cm-def {
  color: #d2a8ff !important;
}

.CodeMirror span.cm-string {
  color: #facc15 !important;
}

.CodeMirror span.cm-keyword {
  color: #ff7b72 !important;
}

.CodeMirror span.cm-comment {
  color: #8b949e !important;
}

#acdt-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: none;
  background: #ffffff;
}

body.acdt-panel-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  #acdt-preview {
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    transform: translateX(100%);
    box-shadow: none;
  }

  #acdt-preview.open {
    transform: translateX(0);
  }

  .acdt-header {
    min-height: 56px;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    position: sticky;
    top: 0;
    z-index: 3;
  }

  .acdt-tools {
    gap: 4px;
  }

  .acdt-tools button {
    width: 42px;
    height: 42px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.04);
  }

  .CodeMirror {
    height: 44% !important;
    min-height: 220px;
    font-size: 13px;
  }

  .acdt-preview,
  .acdt-edit {
    top: 6px;
    width: 34px;
    height: 34px;
    background: transparent;
  }

  .acdt-preview {
    right: 46px;
  }

  .acdt-edit {
    right: 86px;
  }
}

@media (max-width: 420px) {
  .acdt-tools button {
    width: 38px;
    height: 38px;
  }

  .acdt-header span {
    max-width: 42vw;
  }
}
