/* WASecret code generator (Bloom look from ../shared/theme.css). */
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.ad-brand span:last-child { color: var(--muted); font-weight: 650; }
.mode-tabs { margin-left: 8px; }
.bar-note { margin-left: auto; font-size: 12px; font-weight: 650; color: #0f766e; background: #e6fbf6; border: 1px solid #b7efe2; padding: 4px 10px; border-radius: 999px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn.small { padding: 5px 10px; font-size: 13px; }
h2 { font-size: 16px; margin: 0; }

/* ---------- three columns: widgets | settings | preview + code ---------- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 236px minmax(320px, 390px) minmax(0, 1fr); gap: 16px; padding: 16px; }
.layout > * { min-width: 0; min-height: 0; }
.layout[data-mode="ai"] { grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); }
.layout[data-mode="ai"] .picker { display: none; }
.picker, .settings, .output { overflow: auto; overscroll-behavior: contain; }
.output { display: flex; flex-direction: column; gap: 16px; padding-bottom: 4px; }

.picker-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 6px 10px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick { display: grid; grid-template-columns: 36px 1fr; gap: 2px 10px; align-items: center; text-align: left; width: 100%; padding: 9px 10px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--fg); font: inherit; cursor: pointer; transition: background .15s, border-color .15s, transform .15s var(--ease); }
.pick:hover { background: #fff; border-color: var(--line); }
.pick[aria-pressed="true"] { background: #fff; border-color: var(--sel); box-shadow: 0 0 0 3px rgba(91, 76, 240, .12); }
.pick:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
.pick-icon { grid-row: span 2; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: #efedff; color: var(--accent); }
.pick[aria-pressed="true"] .pick-icon { background: var(--grad); color: #fff; }
.pick-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pick-name { font-weight: 650; font-size: 14px; line-height: 1.2; }
.pick-blurb { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* ---------- settings form ---------- */
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.settings-head h2 { font-size: 18px; }
.blurb { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.warnings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.warnings:empty { display: none; }
.warnings li { background: #fff7e6; border: 1px solid #ffd99a; color: #7a4b00; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.opts { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: #39405a; }
.field .ad-input { width: 100%; font-weight: 400; color: var(--fg); }
.field textarea.ad-input { resize: vertical; min-height: 64px; }
.field .ad-input:focus { outline: 2px solid rgba(91, 76, 240, .35); border-color: var(--accent); }
.help { font-weight: 400; font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: #39405a; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.color-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.color-row input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid #d9dcea; border-radius: 10px; background: #fff; cursor: pointer; }
.color-row .ad-input { width: 96px; font-family: ui-monospace, monospace; font-size: 13px; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 7px; border: 1px solid rgba(27, 33, 51, .18); cursor: pointer; padding: 0; }
.swatch:hover { transform: scale(1.12); }
.group { border-top: 1px solid var(--line); padding-top: 10px; }
.group > summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 4px 0 8px; list-style-position: inside; }
.group[open] > summary { margin-bottom: 4px; }
.group-body { display: flex; flex-direction: column; gap: 12px; }
.items { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.items > legend { font-size: 13px; font-weight: 700; color: #39405a; padding: 0; margin-bottom: 8px; }
.item { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; background: #fbfbfe; display: flex; flex-direction: column; gap: 9px; margin: 0; }
.item > legend { display: contents; }
.item-head { display: flex; align-items: center; gap: 4px; }
.item-head b { flex: 1; font-size: 13px; }
.item-head button { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 28px; cursor: pointer; font-size: 14px; color: var(--muted); }
.item-head button:hover:not(:disabled) { color: var(--accent); border-color: #cfc9ff; }
.item-head button:disabled { opacity: .35; cursor: default; }
.item.compact { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.item.compact .field { flex: 1 1 90px; }
.item.compact .day { flex-basis: 100%; font-weight: 700; font-size: 13px; }
.add-item { align-self: flex-start; }
.image-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.image-pick img, .image-pick .noimg { width: 64px; height: 40px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f1f2f8; }
.image-pick .noimg { display: grid; place-items: center; font-size: 11px; color: var(--muted); font-weight: 400; }
.image-pick label.btn { font-weight: 600; font-size: 13px; padding: 5px 10px; }
.image-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.image-pick input[type=file]:focus-visible + label { outline: 2px solid var(--sel); outline-offset: 2px; }

/* ---------- preview and code ---------- */
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin-right: auto; }
.ad-tabs button[aria-pressed="true"], .ad-tabs button.on { background: #fff; color: var(--fg); box-shadow: 0 1px 4px rgba(27, 33, 51, .12); }
.frame-wrap { position: relative; border-radius: 14px; background: repeating-conic-gradient(#f4f5fa 0% 25%, #fbfbfd 0% 50%) 0 0 / 22px 22px; border: 1px solid var(--line); padding: 14px; display: flex; justify-content: center; overflow: hidden; }
#preview { display: block; width: 100%; height: 420px; border: 0; border-radius: 10px; background: #fff; box-shadow: 0 4px 16px rgba(27, 33, 51, .08); transition: width .25s var(--ease), height .2s var(--ease); }
.frame-wrap.phone #preview { width: 390px; max-width: 100%; }
.frame-empty { margin: 60px 0; color: var(--muted); }
.code-size { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.actions .btn { flex: none; }
.code { margin: 0; max-height: 440px; overflow: auto; background: #12162b; color: #d6dbf5; border-radius: 12px; padding: 14px 16px; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; }
.code:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
.code .t { color: #8fb4ff; }
.code .a { color: #f2b97c; }
.code .s { color: #9be3b0; }
.code .c { color: #7c84a8; }
.code .x { color: #7c84a8; font-style: italic; }

/* ---------- AI mode ---------- */
.ai-form { display: flex; flex-direction: column; gap: 10px; }
.ai-form .btn { align-self: flex-start; }
.ai-status { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.ai-status.error { color: #b42318; }
#backToTemplates { align-self: flex-start; }
.ad-toast.show { animation: toast-in .25s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- tablets: widget chips on top ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .layout[data-mode="ai"] { grid-template-rows: minmax(0, 1fr); }
  .picker { grid-column: 1 / -1; overflow: visible; }
  .picker-title { display: none; }
  .pick-list { flex-direction: row; overflow-x: auto; scrollbar-width: thin; padding: 2px 2px 6px; }
  .pick { width: auto; flex: none; grid-template-columns: 28px auto; padding: 6px 12px 6px 6px; border-color: var(--line); background: #fff; border-radius: 999px; }
  .pick-icon { width: 28px; height: 28px; border-radius: 50%; grid-row: auto; }
  .pick-icon svg { width: 16px; height: 16px; }
  .pick-blurb { display: none; }
}

/* ---------- phones: one column, preview first, actions in a bottom bar ---------- */
@media (max-width: 640px) {
  body { height: auto; overflow: auto; display: block; }
  .ad-bar { position: relative; gap: 6px; padding: 8px 10px; }
  .ad-brand { font-size: 0; gap: 0; }
  .ad-brand-mark { font-size: 16px; width: 32px; height: 32px; }
  .mode-tabs { margin-left: 4px; }
  .mode-tabs button { padding: 7px 10px; font-size: 12.5px; }
  .bar-note { display: none; }
  .layout, .layout[data-mode="ai"] { display: flex; flex-direction: column; gap: 12px; padding: 10px 10px calc(84px + env(safe-area-inset-bottom)); height: auto; }
  .picker, .settings, .output { overflow: visible; }
  .output { display: contents; }
  .picker { order: 0; margin: 0 -10px; }
  .pick-list { padding: 2px 10px 6px; scrollbar-width: none; }
  .pick-list::-webkit-scrollbar { display: none; }
  .preview-panel { order: 1; }
  .settings { order: 2; }
  .code-panel { order: 3; }
  .ad-panel { padding: 12px; border-radius: 14px; }
  .frame-wrap { padding: 8px; }
  #preview { height: 380px; }
  .device-tabs { display: none; }
  .actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; padding: 10px 10px max(10px, env(safe-area-inset-bottom)); flex-wrap: nowrap; overflow-x: auto; background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(27, 33, 51, .08); scrollbar-width: none; }
  .actions::-webkit-scrollbar { display: none; }
  .actions .btn { flex: 1 0 auto; padding: 10px 12px; }
  .code { max-height: 320px; font-size: 12px; }
  .ad-toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .ad-input, select.ad-input, textarea.ad-input { font-size: 16px; }
}

/* ---------- inside the shared editor frame (../shared/editor-shell.js) ---------- */
html.ad-shell-on body > .ad-bar { display: none !important; }
html.ad-shell-on .layout { overflow: auto; height: auto; background: #eef0f4; }
.ad-shell:not(.ads-collapsed) .layout .picker { display: none; }
.ad-shell:not(.ads-collapsed) .layout { grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); }
.cg-bar { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cg-bar .mode-tabs { margin: 0; }
.cg-bar .actions { margin: 0; flex-wrap: nowrap; gap: 6px; }
.cg-bar .btn { padding: 6px 12px; font-size: 13px; }
.cg-sep { width: 1px; height: 24px; background: var(--line, #e3e5ee); flex: none; margin: 0 2px; }
.cg-h3 { font: 700 14px/1.2 system-ui, sans-serif; margin: 14px 0 8px; }
.cg-hint { font-size: 12.5px; color: var(--muted, #5b6175); margin: 0 0 8px; }
.cg-tool { display: block; width: 100%; text-align: left; margin: 0 0 6px; padding: 10px 12px; border: 1px solid var(--line, #e3e5ee); border-radius: 10px; background: #fff; cursor: pointer; font: 600 13.5px system-ui, sans-serif; color: #1b2133; }
.cg-tool:hover { border-color: #5b4cf0; }
.cg-palgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cg-pal { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px; border: 1px solid var(--line, #e3e5ee); border-radius: 10px; background: #fff; cursor: pointer; color: #1b2133; }
.cg-pal .dots { display: flex; }
.cg-pal .dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.cg-pal .dots i + i { margin-left: -5px; }
.cg-pal small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cg-pal.on, .cg-pal:hover { border-color: #5b4cf0; }
.cg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-chip { border: 1px solid var(--line, #e3e5ee); border-radius: 999px; background: #fff; padding: 6px 11px; font: 600 12.5px/1.2 system-ui, sans-serif; color: #1b2133; cursor: pointer; }
.cg-chip.on, .cg-chip:hover { border-color: #5b4cf0; color: #3f31c9; background: #f4f3ff; }
@media (max-width: 1180px) { html.ad-shell-on .layout { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); } }
@media (max-width: 759.98px) {
  html.ad-shell-on body { height: 100dvh; overflow: hidden; display: block; }
  html.ad-shell-on .layout, html.ad-shell-on .layout[data-mode="ai"] { display: flex; flex-direction: column; padding: 10px 10px 24px; }
  /* The frame gives .layout a fixed height: without this the chip row and the settings shrink (min-height 0) and the
     preview panel is drawn on top of the widget chips. The column scrolls instead. */
  html.ad-shell-on .layout > *, html.ad-shell-on .layout .output > * { flex-shrink: 0; }
  html.ad-shell-on .ad-shell .layout .picker { display: block; }
  html.ad-shell-on .cg-bar .actions { position: static; padding: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none; }
  html.ad-shell-on .cg-bar .device-tabs { display: none; }
  html.ad-shell-on .cg-bar .actions .btn { flex: none; padding: 7px 10px; }
  html.ad-shell-on .ad-toast { bottom: 140px; }
}

/* ---------- round 2: tablet preview, show/hide code, ideas, versions ---------- */
.frame-wrap.tablet #preview { width: 768px; max-width: 100%; }
.layout[data-code="hidden"] .code-panel { display: none; }
.ai-ideas { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.ai-ideas h3 { margin: 4px 0 0; font-size: 15px; }
.idea-row { display: flex; gap: 8px; flex-wrap: wrap; }
.idea-matches, .idea-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.idea { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; }
.idea span { overflow-wrap: anywhere; }
.cg-row { display: flex; gap: 8px; margin: 0 0 8px; }
.cg-wide { width: 100%; }
.cg-versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cg-version { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line, #e3e5ee); border-radius: 10px; background: #fff; }
.cg-version small { color: var(--muted, #5b6175); font-size: 12px; }
.cg-acts { display: flex; gap: 6px; margin-top: 6px; }

/* ---------- round 3: My code, full-screen preview, drop a picture ---------- */
.layout[data-mode="own"] { grid-template-columns: minmax(340px, 520px) minmax(0, 1fr); }
.layout[data-mode="own"] .picker { display: none; }
.ad-shell:not(.ads-collapsed) .layout[data-mode="own"] { grid-template-columns: minmax(340px, 520px) minmax(0, 1fr); }
@media (max-width: 1180px) { .layout[data-mode="own"] { grid-template-rows: minmax(0, 1fr); } }
@media (max-width: 640px) { .layout[data-mode="own"] { display: flex; flex-direction: column; } }
.own-code { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 340px; white-space: pre; tab-size: 2; resize: vertical; }
#ownWarnings:empty { display: none; }
#ownWarnings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#ownWarnings li { background: #fff7e6; border: 1px solid #ffd99a; color: #7a4b00; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.image-pick.drop { outline: 2px dashed #5b4cf0; outline-offset: 3px; border-radius: 10px; }
.cg-preview { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #eef0f4; }
.cg-preview[open] { display: flex; flex-direction: column; }
.cg-preview::backdrop { background: rgba(15, 18, 34, .5); }
.cg-pv-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line, #e3e5ee); }
.cg-pv-bar b { margin-right: auto; }
.cg-pv-stage { flex: 1; min-height: 0; display: flex; justify-content: center; padding: 16px; overflow: auto; }
.cg-pv-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 10px; box-shadow: 0 10px 40px rgba(27, 33, 51, .18); }
.cg-pv-stage[data-size="tablet"] iframe { width: 768px; max-width: 100%; }
.cg-pv-stage[data-size="phone"] iframe { width: 390px; max-width: 100%; }

/* Drags from the left-rail panels: the preview frame lets the drop reach the editor */
.ads-dragging #preview { pointer-events: none; }
