:root {
  --berry: #e5195f;
  --berry-dark: #b30f48;
  --ink: #1a1420;
  --paper: #faf7f2;
  --panel: rgba(255,255,255,0.85);
  --shadow: 0 10px 40px rgba(60,10,40,0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: 'Bricolage Grotesque', sans-serif;
  color: var(--ink);
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, #ffe3ee 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, #e3f0ff 0%, transparent 45%),
    #f2ecf5;
}

#app { display: flex; flex-direction: column; height: 100dvh; }

/* Header */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.berry { font-size: 30px; filter: drop-shadow(0 3px 6px rgba(229,25,95,0.35)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100%{transform:translateY(0) rotate(-4deg);} 50%{transform:translateY(-4px) rotate(4deg);} }
#topbar h1 { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; line-height: 1; }
.tag { font-family: 'Space Mono', monospace; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--berry); }

.top-actions { display: flex; gap: 8px; }
.ai-btn {
  background: linear-gradient(135deg, var(--berry), #ff6f3c);
  color: #fff; border: none; font-family: inherit; font-weight: 700;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 14px;
  box-shadow: 0 6px 18px rgba(229,25,95,0.4);
  transition: transform .15s, box-shadow .15s;
}
.ai-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(229,25,95,0.5); }
.ghost-btn {
  background: #fff; border: 1.5px solid rgba(0,0,0,0.1); color: var(--ink);
  padding: 9px 14px; border-radius: 999px; cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: 14px; transition: border-color .15s;
}
.ghost-btn:hover { border-color: var(--berry); }

/* Stage */
#stage { flex: 1; display: flex; gap: 12px; padding: 14px; min-height: 0; }

/* Toolbar */
#toolbar {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--panel); backdrop-filter: blur(14px);
  padding: 12px 8px; border-radius: 20px; box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.6);
  z-index: 20;
}
.tool {
  width: 48px; height: 48px; border: none; border-radius: 14px; cursor: pointer;
  background: rgba(0,0,0,0.04); font-size: 22px; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.tool:hover { background: rgba(229,25,95,0.12); transform: scale(1.06); }
.tool.active { background: var(--berry); box-shadow: 0 4px 14px rgba(229,25,95,0.45); }
.tool.danger:hover { background: rgba(220,40,40,0.15); }
.tool-divider { width: 60%; height: 1px; background: rgba(0,0,0,0.1); margin: 4px 0; }

.swatch-wrap { width: 48px; height: 48px; border-radius: 14px; overflow: hidden; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0,0,0,0.08); }
#colorPicker { width: 200%; height: 200%; border: none; padding: 0; margin: -25%; cursor: pointer; }

.size-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; }
.size-preview { width: 44px; height: 44px; border-radius: 12px; background: rgba(0,0,0,0.04); display: flex; align-items: center; justify-content: center; }
#sizeDot { border-radius: 50%; transition: all .1s; }
#sizeSlider { writing-mode: vertical-lr; direction: rtl; width: 20px; height: 70px; accent-color: var(--berry); cursor: pointer; }

/* Canvas holder */
#canvasHolder {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  min-width: 0; border-radius: 18px; overflow: hidden;
  transition: box-shadow .2s;
}
#canvasHolder.drag-over { box-shadow: inset 0 0 0 4px var(--berry); }
#canvas, #overlay {
  position: absolute;
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  aspect-ratio: 1400 / 1000;
  border-radius: 14px;
}
#canvas {
  background: #fff;
  box-shadow: 0 12px 50px rgba(40,10,40,0.22);
}
#overlay { touch-action: none; cursor: crosshair; z-index: 2; }

#emptyHint {
  position: absolute; z-index: 3; pointer-events: none;
  font-size: 17px; color: #b9a9b4; text-align: center; padding: 0 30px;
  display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap;
}
kbd {
  font-family: 'Space Mono', monospace; font-size: 0.85em;
  background: #fff; border: 1px solid rgba(0,0,0,0.15);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink);
}

#objControls {
  position: absolute; z-index: 10; display: flex; gap: 6px;
}
#objControls button {
  font-family: inherit; font-weight: 700; font-size: 12px; border: none; cursor: pointer;
  padding: 6px 12px; border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
#flattenBtn { background: var(--berry); color: #fff; }
#deleteObjBtn { background: #fff; color: #c0392b; }

/* Hint banner */
.hint-banner {
  position: fixed; bottom: 54px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; display: flex; align-items: center; gap: 10px; z-index: 40;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3); max-width: 92vw;
  animation: slideUp .5s ease; transition: opacity .3s, transform .3s;
}
.hint-banner.gone { opacity: 0; transform: translate(-50%, 20px); pointer-events: none; }
.hint-banner kbd { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.3); }
.hint-banner button { background: none; border: none; color: #fff; cursor: pointer; font-size: 15px; opacity: 0.7; }
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 30px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Footer */
#footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px; font-size: 12px; background: var(--panel);
  border-top: 1px solid rgba(0,0,0,0.06); z-index: 15;
}
#footMsg { font-family: 'Space Mono', monospace; color: #8a7a85; }
#footer a { color: var(--berry); font-weight: 700; text-decoration: none; }
#footer a:hover { text-decoration: underline; }

/* AI Panel */
.ai-panel {
  position: fixed; top: 0; right: 0; height: 100dvh; width: 380px; max-width: 90vw;
  background: var(--paper); z-index: 60; box-shadow: -10px 0 50px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
  animation: slideIn .3s ease; overflow-y: auto;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.ai-panel.hidden { display: none; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid rgba(0,0,0,0.08); position: sticky; top: 0; background: var(--paper); z-index: 2; }
.ai-head h2 { font-size: 20px; font-weight: 800; }
.ai-head button { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; }
.ai-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 22px; }
.ai-section h3 { font-size: 15px; font-weight: 800; margin-bottom: 3px; }
.ai-desc { font-size: 11px; font-family: 'Space Mono', monospace; color: #9a8a95; margin-bottom: 8px; }
.ai-section textarea {
  width: 100%; min-height: 60px; resize: vertical; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid rgba(0,0,0,0.12); font-family: inherit; font-size: 14px; background: #fff;
}
.ai-section textarea:focus { outline: none; border-color: var(--berry); }
.ai-run {
  margin-top: 8px; width: 100%; background: var(--ink); color: #fff; border: none;
  padding: 11px; border-radius: 12px; font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: background .15s;
}
.ai-run:hover { background: var(--berry); }
.ai-surprise {
  width: 100%; background: linear-gradient(135deg, #ff6f3c, var(--berry)); color: #fff; border: none;
  padding: 11px; border-radius: 12px; font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.surprise-out { margin-top: 10px; font-size: 13px; color: var(--berry-dark); min-height: 18px; font-style: italic; }

.ai-loader {
  position: absolute; inset: 0; background: rgba(250,247,242,0.94); z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.ai-loader.hidden { display: none; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(229,25,95,0.2); border-top-color: var(--berry); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#aiLoaderMsg { font-family: 'Space Mono', monospace; font-size: 13px; color: var(--berry-dark); }

#aiBackdrop { position: fixed; inset: 0; background: rgba(20,10,25,0.4); z-index: 55; }
#aiBackdrop.hidden { display: none; }

.hidden { display: none; }

/* Mobile */
@media (max-width: 720px) {
  #stage { flex-direction: column-reverse; padding: 8px; gap: 8px; }
  #toolbar { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 8px; border-radius: 16px; }
  .tool-divider { width: 1px; height: 40px; margin: 0 2px; }
  .size-wrap { flex-direction: row; }
  #sizeSlider { writing-mode: horizontal-tb; direction: ltr; width: 70px; height: 20px; }
  .size-preview { width: 40px; height: 40px; }
  #topbar h1 { font-size: 18px; }
  .ai-btn, .ghost-btn { padding: 8px 12px; font-size: 13px; }
  .hint-banner { bottom: auto; top: 66px; font-size: 12px; }
}
</parameter>
</invoke>