.banana-chat-reference-editor {
  position: fixed;
  inset: 0;
  z-index: 2100;
  padding: 12px;
  display: grid;
  place-items: center;
  background: rgba(11,12,13,.76);
  backdrop-filter: blur(16px) saturate(112%);
  opacity: 0;
  transition: opacity .18s ease;
}

.banana-chat-reference-editor.is-visible { opacity: 1; }

.banana-chat-reference-editor-card {
  --bg: #f7f7f2;
  --surface: #ffffff;
  --text: #1f2329;
  --muted: #737b85;
  --line: #d9dcd6;
  --soft: #eceee9;
  --blue: #ffd451;
  width: min(1180px, calc(100vw - 48px));
  height: min(900px, calc(100dvh - 24px));
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0,1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(255,212,81,.25);
  border-radius: 30px;
  background: #f7f7f2;
  color: #1f2329;
  box-shadow: 0 36px 100px rgba(0,0,0,.4);
  transform: translateY(12px) scale(.985);
  transition: transform .28s cubic-bezier(.2,.9,.18,1);
}

.banana-chat-reference-editor.is-visible .banana-chat-reference-editor-card { transform: translateY(0) scale(1); }

.banana-chat-reference-editor-head,
.banana-chat-reference-editor-footer {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  background: rgba(255,255,255,.82);
}

.banana-chat-reference-editor-head strong { font-size: 17px; font-weight: 900; }
.banana-chat-reference-editor-footer > span { color: #7b828b; font-size: 12px; }

.banana-chat-reference-editor-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eeefe9;
  color: #505762;
  cursor: pointer;
}

.banana-chat-reference-editor-close svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.banana-chat-reference-editor-tabs {
  justify-self: center;
  margin: 10px 0 12px;
  padding: 4px;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  border: 1px solid rgba(32,33,36,.08);
  border-radius: 999px;
  background: #eceee9;
}

.banana-chat-reference-editor-tabs button {
  height: 38px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #707781;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .16s ease, background .22s ease, color .22s ease, box-shadow .22s ease;
}

.banana-chat-reference-editor-tabs button[aria-selected="true"] {
  background: #ffd451;
  color: #16130a;
  box-shadow: inset 0 -1px 0 rgba(139,94,0,.12), 0 6px 14px rgba(205,145,0,.12);
}

.banana-chat-reference-editor-tabs button:active,
.banana-chat-reference-editor-footer button:active { transform: scale(.96); }

.banana-chat-reference-editor-workspace {
  min-height: 0;
  padding: 0 22px 16px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(125,132,142,.45) transparent;
}

.banana-chat-reference-editor-workspace::-webkit-scrollbar { width: 8px; }
.banana-chat-reference-editor-workspace::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(125,132,142,.42);
  background-clip: padding-box;
}

.banana-chat-crop-tool,
.banana-chat-reference-editor-workspace .annotate-editor { height: 100%; min-height: 0; }

.banana-chat-reference-editor-workspace .sb-canvas-crop {
  min-height: 100%;
  height: auto;
  display: grid;
  grid-template-rows: auto auto minmax(180px,1fr) auto auto;
  gap: 10px;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-ratios {
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-ratio {
  border-color: rgba(32,33,36,.1);
  background: #eceee9;
  color: #69717b;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-ratio.active {
  border-color: transparent;
  background: #ffd451;
  color: #16130a;
  box-shadow: inset 0 -1px 0 rgba(139,94,0,.12), 0 6px 14px rgba(205,145,0,.12);
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-hint {
  color: #7b828b;
  font-size: 12px;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-stage {
  min-height: 180px;
  height: auto;
  border: 0;
  border-radius: 22px;
  background: #111214;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-footer {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-main-actions { display: flex; }
.banana-chat-reference-editor-workspace .sb-canvas-crop-main-actions [data-crop-apply] { display: none; }

.banana-chat-reference-editor-workspace .sb-canvas-crop-icon-btn,
.banana-chat-reference-editor-workspace .sb-canvas-crop-btn {
  border-color: rgba(32,33,36,.1);
  background: #eceee9;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-status {
  min-height: 18px;
  color: #7b828b;
  text-align: center;
}

.banana-chat-reference-editor-workspace .sb-canvas-crop-slider { accent-color: #ffbd16; }

.banana-chat-crop-tool { display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 10px; }
.banana-chat-editor-tool-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.banana-chat-editor-tool-row strong { font-size: 13px; }
.banana-chat-editor-tool-row span { color: #858b94; font-size: 12px; }

.banana-chat-crop-stage,
.banana-chat-reference-editor-workspace .annotate-canvas-wrap {
  position: relative;
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background: #111214;
}

.banana-chat-crop-stage canvas,
.banana-chat-reference-editor-workspace .annotate-canvas { max-width: 100%; max-height: 62vh; touch-action: none; }
.banana-chat-crop-stage canvas { display: block; cursor: crosshair; }
.banana-chat-editor-loading { position: absolute; inset: 0; display: none; place-items: center; background: rgba(17,18,20,.82); color: #fff; font-size: 13px; }
.banana-chat-editor-loading.is-visible { display: grid; }
.banana-chat-editor-loading.is-error { color: #ff777a; }
.banana-chat-editor-status { min-height: 18px; color: #777e88; font-size: 12px; }

.banana-chat-reference-editor-workspace .annotate-toolbar,
.banana-chat-reference-editor-workspace .annotate-controls,
.banana-chat-reference-editor-workspace .annotate-footer { justify-content: center; }
.banana-chat-reference-editor-workspace .crop-btn.active { background: #ffd451; color: #16130a; }
.banana-chat-reference-editor-workspace .annotate-color-btn.active::after { border-color: #ffd451; }
.banana-chat-reference-editor-workspace input[type="range"] { accent-color: #ffbd16; }
.banana-chat-reference-editor-workspace [data-annotate-apply],
.banana-chat-reference-editor-workspace .annotate-footer { display: none; }

.banana-chat-reference-editor-footer > div { display: flex; gap: 10px; }
.banana-chat-reference-editor-footer button { height: 42px; padding: 0 20px; border: 0; border-radius: 999px; font-weight: 900; cursor: pointer; }
.banana-chat-reference-editor-cancel { background: #eceee9; color: #59616b; }
.banana-chat-reference-editor-save {
  min-width: 116px;
  background: linear-gradient(180deg,#ffd84a 0%,#ffbd16 58%,#f5a900 100%);
  color: #16130a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 10px 22px rgba(205,145,0,.22);
}
.banana-chat-reference-editor-save:disabled { cursor: wait; opacity: .72; }

html.theme-dark .banana-chat-reference-editor {
  background: rgba(4,5,6,.82);
}

html.theme-dark .banana-chat-reference-editor-card {
  --bg: #191a1c;
  --surface: #242529;
  --text: #f4f3ee;
  --muted: #a2a7af;
  --line: #3b3d42;
  --soft: #2b2d31;
  background: #191a1c;
  color: #f4f3ee;
  border-color: rgba(255,212,81,.18);
  box-shadow: 0 38px 110px rgba(0,0,0,.62);
}

html.theme-dark .banana-chat-reference-editor-head,
html.theme-dark .banana-chat-reference-editor-footer {
  background: rgba(35,36,39,.94);
}

html.theme-dark .banana-chat-reference-editor-footer {
  border-top: 1px solid rgba(255,255,255,.06);
}

html.theme-dark .banana-chat-reference-editor-footer > span {
  color: #9ca2ab;
}

html.theme-dark .banana-chat-reference-editor-close,
html.theme-dark .banana-chat-reference-editor-cancel {
  background: #303236;
  color: #d6d8dd;
}

html.theme-dark .banana-chat-reference-editor-tabs {
  border-color: rgba(255,255,255,.08);
  background: #2a2c30;
}

html.theme-dark .banana-chat-reference-editor-tabs button {
  color: #a9afb8;
}

html.theme-dark .banana-chat-reference-editor-tabs button[aria-selected="true"] {
  color: #16130a;
}

html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-ratio {
  border-color: rgba(255,255,255,.08);
  background: #292b2f;
  color: #a9afb8;
}

html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-ratio.active {
  border-color: transparent;
  background: #ffd451;
  color: #16130a;
}

html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-hint,
html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-label,
html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-percent,
html.theme-dark .banana-chat-reference-editor-workspace .annotate-control,
html.theme-dark .banana-chat-reference-editor-workspace .annotate-status {
  color: #a2a7af;
}

html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-icon-btn,
html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-btn,
html.theme-dark .banana-chat-reference-editor-workspace .crop-btn {
  border-color: rgba(255,255,255,.08);
  background: #2b2d31;
  color: #d4d7dc;
}

html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-status {
  color: #a2a7af;
}

html.theme-dark .banana-chat-reference-editor-workspace::-webkit-scrollbar-thumb {
  background: rgba(210,214,221,.32);
  background-clip: padding-box;
}

html.theme-dark .banana-chat-reference-editor-workspace .crop-btn.active {
  background: #ffd451;
  color: #16130a;
}

html.theme-dark .banana-chat-reference-editor-workspace .sb-canvas-crop-slider {
  background: #4a4d53;
}

@media (max-width: 720px) {
  .banana-chat-reference-editor { padding: 0; }
  .banana-chat-reference-editor-card { width: 100vw; height: 100dvh; min-height: 0; border-radius: 0; }
  .banana-chat-reference-editor-head,
  .banana-chat-reference-editor-footer { padding: 13px 14px; }
  .banana-chat-reference-editor-workspace { padding: 0 12px 10px; }
  .banana-chat-reference-editor-footer > span { display: none; }
  .banana-chat-reference-editor-tabs { margin: 7px 0 9px; }
  .banana-chat-crop-stage,
  .banana-chat-reference-editor-workspace .annotate-canvas-wrap { min-height: 280px; border-radius: 16px; }
  .banana-chat-reference-editor-workspace .sb-canvas-crop {
    min-height: 0;
    grid-template-rows: auto auto minmax(150px,1fr) auto auto;
  }
  .banana-chat-reference-editor-workspace .sb-canvas-crop-stage { min-height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .banana-chat-reference-editor,
  .banana-chat-reference-editor-card { transition: opacity .12s ease; transform: none; }
}
