.cj-context-panel {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 1000;
}

.cj-context-panel[hidden] {
  display: none;
}

.cj-context-panel__backdrop {
  background: rgba(20, 18, 20, .48);
  inset: 0;
  opacity: 0;
  pointer-events: auto;
  position: absolute;
  transition: opacity .24s ease;
}

.cj-context-panel__surface {
  background: var(--white, #fff);
  border-left: 1px solid var(--line, #f0d9dc);
  box-shadow: -20px 0 60px rgba(53, 36, 63, .2);
  color: var(--ink, #141214);
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  margin-left: auto;
  max-width: 480px;
  overflow-y: auto;
  padding: 28px;
  pointer-events: auto;
  transform: translateX(100%);
  transition: transform .24s ease;
  width: min(100%, 480px);
}

.cj-context-panel[data-state="open"] .cj-context-panel__backdrop {
  opacity: 1;
}

.cj-context-panel[data-state="open"] .cj-context-panel__surface {
  transform: translateX(0);
}

.cj-context-panel__header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.cj-context-panel__heading {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.cj-context-panel__icon {
  align-items: center;
  background: var(--rose, #ffe9ee);
  border-radius: 999px;
  color: var(--violet, #d95f7b);
  display: inline-flex;
  font-size: 1.25rem;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.cj-context-panel__title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 4vw, 2rem);
  line-height: 1.1;
  margin: 0;
}

.cj-context-panel__description {
  color: var(--muted, #685d61);
  line-height: 1.6;
  margin: 0;
}

.cj-context-panel__close {
  align-items: center;
  background: var(--cream, #fff9f5);
  border: 1px solid var(--line, #f0d9dc);
  border-radius: 999px;
  color: var(--ink, #141214);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 1.5rem;
  height: 42px;
  justify-content: center;
  line-height: 1;
  width: 42px;
}

.cj-context-panel__close:hover,
.cj-context-panel__close:focus-visible {
  background: var(--rose, #ffe9ee);
}

.cj-context-panel__content {
  color: var(--ink, #141214);
  display: grid;
  gap: 14px;
  line-height: 1.6;
}

.cj-context-panel__navigation {
  display: flex;
  gap: 8px;
}

.cj-context-panel__navigation[hidden] {
  display: none;
}

.cj-context-panel__history {
  background: var(--cream, #fff9f5);
  border: 1px solid var(--line, #f0d9dc);
  border-radius: 999px;
  color: var(--ink, #141214);
  cursor: pointer;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  min-height: 44px;
  padding: 7px 14px;
}

.cj-context-panel__history:disabled {
  cursor: default;
  opacity: .45;
}

.cj-context-panel__history:not(:disabled):hover,
.cj-context-panel__history:focus-visible {
  background: var(--rose, #ffe9ee);
}

.cj-context-panel__content[data-view-transition="forward"],
.cj-context-panel__actions[data-view-transition="forward"] {
  animation: cj-context-view-forward .18s ease;
}

.cj-context-panel__content[data-view-transition="back"],
.cj-context-panel__actions[data-view-transition="back"] {
  animation: cj-context-view-back .18s ease;
}

.cj-context-panel__content[data-view-transition="replace"],
.cj-context-panel__actions[data-view-transition="replace"] {
  animation: cj-context-view-replace .18s ease;
}

@keyframes cj-context-view-forward {
  from { opacity: 0; transform: translateX(12px); }
}

@keyframes cj-context-view-back {
  from { opacity: 0; transform: translateX(-12px); }
}

@keyframes cj-context-view-replace {
  from { opacity: 0; }
}

.cj-context-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
}

.cj-context-panel__action {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  text-decoration: none;
}

.cj-context-panel__action--primary {
  background: var(--coral, #e56f88);
  color: var(--white, #fff);
}

.cj-context-panel__action--secondary {
  background: var(--white, #fff);
  border-color: var(--line, #f0d9dc);
  color: var(--ink, #141214);
}

.cj-context-panel__action--danger {
  background: var(--danger, #b94256);
  color: var(--white, #fff);
}

.cj-context-panel__action:focus-visible,
.cj-context-panel__history:focus-visible,
.cj-context-panel__close:focus-visible,
.cj-context-panel__surface:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--violet, #d95f7b) 55%, transparent);
  outline-offset: 3px;
}

body.cj-context-panel-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .cj-context-panel {
    align-items: flex-end;
    display: flex;
  }

  .cj-context-panel__surface {
    border-left: 0;
    border-radius: 18px 18px 0 0;
    border-top: 1px solid var(--line, #f0d9dc);
    height: auto;
    max-height: min(88vh, 760px);
    max-width: none;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    width: 100%;
  }

  .cj-context-panel[data-state="open"] .cj-context-panel__surface {
    transform: translateY(0);
  }

  .cj-context-panel__actions,
  .cj-context-panel__action {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cj-context-panel__backdrop,
  .cj-context-panel__surface {
    transition-duration: .001ms;
  }

  .cj-context-panel__content,
  .cj-context-panel__actions {
    animation-duration: .001ms !important;
  }
}
