/* chat/editor — full-screen doodle + draw-on-photo editor. All selectors are .ved-namespaced. */

.ved {
  position: fixed; inset: 0; z-index: 8000;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  background:
    radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--me, #f0679a) 22%, transparent), transparent 60%),
    #1b1216;
  color: #fff; font-family: var(--text, sans-serif);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) 0 env(safe-area-inset-left, 0);
  animation: ved-in .22s ease-out both;
  outline: none; overscroll-behavior: contain; user-select: none; -webkit-user-select: none;
}
.ved.closing { animation: ved-out .16s ease-in both; pointer-events: none; }
@keyframes ved-in { from { opacity: 0; transform: scale(.985); } }
@keyframes ved-out { to { opacity: 0; transform: scale(.985); } }
.ved [hidden] { display: none !important; }
.ved button { font: inherit; -webkit-tap-highlight-color: transparent; }
.ved :focus-visible { outline: 3px solid var(--me, #f0679a); outline-offset: 2px; }

/* top bar */
.ved-top { display: flex; align-items: center; gap: 6px; padding: 10px 12px 6px; min-width: 0; }
.ved-title {
  flex: 1; min-width: 0; font-family: var(--display, sans-serif); font-size: 1.12rem; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; color: #fff;
  text-shadow: 0 2px 10px color-mix(in srgb, var(--me, #f0679a) 55%, transparent);
}
.ved-hist { display: flex; gap: 2px; }
.ved-done { gap: 6px; padding-inline: 16px 18px; flex: none; }
.ved-done svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.ved-ibtn {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: #fff; transition: background .15s, color .15s, transform .12s;
}
.ved-ibtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ved-ibtn:hover { background: rgba(255, 255, 255, .1); }
.ved-ibtn:active { transform: scale(.92); }
.ved-ibtn:disabled { opacity: .3; cursor: default; background: transparent; transform: none; }
.ved-ibtn[aria-pressed="true"] {
  background: #fff; color: var(--me, #f0679a);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--me, #f0679a) 45%, #000), 0 6px 18px color-mix(in srgb, var(--me, #f0679a) 45%, transparent);
}

/* stage */
.ved-stage { position: relative; overflow: hidden; touch-action: none; min-height: 0; min-width: 0; }
.ved-wrap {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); overflow: hidden; border-radius: 14px; touch-action: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 18px 50px rgba(0, 0, 0, .55);
}
.ved-canvas { display: block; touch-action: none; cursor: crosshair; }
.ved[data-tool="text"] .ved-canvas { cursor: text; }
.ved[data-tool="sticker"] .ved-canvas { cursor: default; }
.ved-items { position: absolute; inset: 0; pointer-events: none; }
.ved-item {
  position: absolute; left: 0; top: 0; pointer-events: none; touch-action: none; transform-origin: 50% 50%;
  border-radius: 10px;
}
.ved-item canvas { display: block; pointer-events: none; }
.ved[data-tool="text"] .ved-item, .ved[data-tool="sticker"] .ved-item { pointer-events: auto; cursor: grab; }
.ved-item.sel { outline: 2px dashed rgba(255, 255, 255, .95); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(0, 0, 0, .18); }
.ved-item-del {
  display: none; position: absolute; top: -14px; right: -14px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff;
  background: var(--me, #f0679a); color: #fff; padding: 0; place-items: center; cursor: pointer; box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}
.ved-item-del svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.ved-item.sel .ved-item-del { display: grid; }

/* bottom panel */
.ved-panel {
  display: grid; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(180deg, rgba(27, 18, 22, 0), rgba(27, 18, 22, .9) 30%);
}
.ved-ctx { min-height: 40px; display: flex; justify-content: center; min-width: 0; }
.ved-palette, .ved-stickers {
  display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 9px 10px; max-width: 100%;
  scroll-snap-type: x proximity;
}
.ved-palette::-webkit-scrollbar, .ved-stickers::-webkit-scrollbar, .ved-tools::-webkit-scrollbar { display: none; }
.ved-swatch {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: var(--c);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85), 0 2px 6px rgba(0, 0, 0, .35); transition: transform .15s var(--spring, ease);
}
.ved-swatch[aria-pressed="true"] { transform: scale(1.12); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85), 0 0 0 2px #1b1216, 0 0 0 4px #fff; }
.ved-sticker {
  flex: none; width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .08); cursor: pointer;
  font-size: 1.5rem; line-height: 1; display: grid; place-items: center; padding: 0; transition: transform .12s, background .12s;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.ved-sticker:hover { background: rgba(255, 255, 255, .16); }
.ved-sticker:active { transform: scale(.88); }

.ved-sizerow { display: flex; align-items: center; gap: 12px; padding: 0 8px; max-width: 520px; width: 100%; justify-self: center; }
.ved-dot {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; position: relative; font-size: 18px; line-height: 1;
}
.ved-dot::before {
  content: ""; width: var(--s, 10px); height: var(--s, 10px); border-radius: 50%; background: var(--c, #fff);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .7), 0 2px 6px rgba(0, 0, 0, .4); transition: width .1s, height .1s;
}
.ved-dot.is-eraser::before { background: transparent; box-shadow: 0 0 0 2px #fff; border: 2px dashed rgba(255, 255, 255, .5); }
.ved-dot.is-item::before { display: none; }
.ved-range {
  flex: 1; min-width: 0; height: 28px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; margin: 0;
}
.ved-range::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, rgba(255, 255, 255, .25), rgba(255, 255, 255, .6)); }
.ved-range::-moz-range-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, rgba(255, 255, 255, .25), rgba(255, 255, 255, .6)); }
.ved-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--me, #f0679a) 70%, transparent), 0 2px 8px rgba(0, 0, 0, .4);
}
.ved-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px color-mix(in srgb, var(--me, #f0679a) 70%, transparent); }
.ved-papers { display: flex; gap: 6px; flex: none; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .15); }
.ved-paper {
  width: 26px; height: 26px; border-radius: 8px; border: 0; padding: 0; cursor: pointer; background: var(--c);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .5); transition: transform .15s;
}
.ved-paper[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .15), 0 0 0 2px #1b1216, 0 0 0 4px var(--me, #f0679a); transform: scale(1.08); }

.ved-tools {
  display: flex; align-items: center; justify-content: center; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 6px; border-radius: 99px; background: rgba(255, 255, 255, .07); max-width: 560px; width: 100%; justify-self: center;
}
.ved-sep { flex: none; width: 1px; height: 24px; background: rgba(255, 255, 255, .18); margin: 0 2px; }

/* text entry sheet */
.ved-textsheet {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: calc(80px + env(safe-area-inset-top, 0)) 20px 20px; background: rgba(20, 12, 16, .55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.ved.ved-typing .ved-panel { position: relative; z-index: 3; }
.ved.ved-typing .ved-tools, .ved.ved-typing .ved-sizerow { visibility: hidden; }
.ved .ved-text-input {
  width: min(100%, 560px); min-height: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; text-align: center; outline: none;
  font: 400 clamp(1.7rem, 7vw, 2.6rem)/1.3 var(--display, sans-serif); color: #fff; caret-color: var(--me, #f0679a);
  -webkit-text-stroke: 6px var(--outline, #fff); paint-order: stroke fill;
  padding: 8px 4px; user-select: text; -webkit-user-select: text;
}
.ved .ved-text-input::placeholder { color: rgba(255, 255, 255, .5); -webkit-text-stroke: 0; }
.ved-text-hint { margin-top: 10px; font-size: .8rem; color: rgba(255, 255, 255, .7); text-align: center; }

.ved.busy .ved-stage { opacity: .7; pointer-events: none; }

@media (max-width: 380px) {
  .ved-ibtn { width: 38px; height: 38px; }
  .ved-ibtn svg { width: 20px; height: 20px; }
  .ved-top { padding-inline: 8px; gap: 2px; }
  .ved-tools { gap: 2px; padding: 4px; }
  .ved-swatch { width: 27px; height: 27px; }
  .ved-palette { gap: 5px; }
}
@media (min-width: 900px) {
  .ved-panel { padding-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .ved, .ved.closing { animation: none; }
}
.ved .ved-text-input:focus { border: 0; box-shadow: none; }
