/* The editor: one screen. Top bar, preview, tab bar, panel. Laid out for a
   phone (390 px) first; on a wide screen the same column sits in the middle.
   The drawing tools keep their styles from design.css. */
html:has(> .editor) { overflow: hidden; }
.editor { height: 100dvh; min-height: 0; max-width: 620px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(180px, 38dvh) auto minmax(0, 1fr); overflow: hidden; background: var(--bg); }
.editor svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.ed-top { display: flex; align-items: center; gap: 4px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--card); }
.ed-logo { display: block; line-height: 0; margin-right: 4px; }
.ed-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.ed-status.bad { color: var(--danger); }
.ed-icon { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); }
.ed-icon:hover { background: var(--accent-soft); }
.ed-icon:disabled { opacity: .35; cursor: default; background: transparent; }
.ed-icon[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.ed-icon:focus-visible, .ed-tab:focus-visible, .seg button:focus-visible, .chips button:focus-visible, .add-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.editor .ed-send { min-height: 40px; padding: 0 18px; margin-left: 4px; background: var(--ink); color: var(--bg); box-shadow: none; }
.editor .ed-send:hover:not(:disabled) { background: var(--accent-ink); }

/* ---------- Preview ---------- */
.ed-preview { min-height: 0; display: flex; flex-direction: column; background: var(--preview); border-bottom: 1px solid var(--line); }
.ed-switch { display: flex; align-items: center; gap: 4px; padding: 8px 12px 0; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); margin-right: auto; }
.seg button { border: 0; border-radius: 999px; padding: 7px 14px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px #0002; }
.ed-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 10px 16px 14px; }
.editor .ed-stage .qr-paper { height: 100%; width: auto; max-width: 100%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 6px; transform: rotate(-1.3deg); box-shadow: 0 10px 30px #192b3a26; }
.editor .ed-stage .qr-paper canvas { width: 100%; height: 100%; border-radius: 6px; }
.phone { height: 100%; aspect-ratio: 9 / 17; max-width: 100%; box-sizing: content-box; border: 5px solid var(--ink); border-radius: 22px; overflow: hidden; background: var(--ink); box-shadow: 0 10px 30px #192b3a33; }
.phone iframe { display: block; width: 375px; height: 100%; border: 0; background: #192b3a; transform-origin: 0 0; }
.editor .studio-error { margin: 0; padding: 0 14px 6px; text-align: center; }
.editor .studio-error:empty { display: none; }
.editor.enlarged { grid-template-rows: auto minmax(0, 1fr) 0 0; }
.editor.enlarged .ed-tabs, .editor.enlarged .ed-panel { display: none; }

/* ---------- Tabs ---------- */
.ed-tabs { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; background: var(--card); border-bottom: 1px solid var(--line); }
.ed-tabs::-webkit-scrollbar { display: none; }
.ed-tab { flex: none; min-height: 38px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-size: 14px; font-weight: 500; white-space: nowrap; }
.ed-tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .ed-tab[aria-pressed="true"] { color: var(--bg); }
.ed-plus { display: grid; place-items: center; width: 38px; padding: 0; border-style: dashed; border-color: var(--kraft); color: var(--accent-ink); }

/* ---------- Panel ---------- */
.ed-panel { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px calc(18px + env(safe-area-inset-bottom)); }
.ed-loading { padding: 40px 0; text-align: center; color: var(--muted); }
.design-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.editor .editing-area { display: flex; flex-direction: row; min-height: 0; border: 1px solid var(--line); border-radius: 14px 14px 0 0; background: var(--card); overflow: hidden; }
.editor .tool-rail { order: 0; flex: none; width: auto; flex-direction: column; justify-content: flex-start; gap: 6px; padding: 10px 8px; border: 0; border-right: 1px solid var(--line); background: var(--accent-soft); }
.editor .canvas-outer { order: 1; flex: 1; min-width: 0; padding: 12px; display: flex; align-items: center; justify-content: center; }
.editor .canvas-mat { border: 2px solid var(--ink); }
.editor .canvas-bottom { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 14px 14px; background: var(--card); }
.editor .placement { margin: 0; gap: 10px; font-size: 12px; color: var(--muted); }
.editor .tool.active, .editor .tool[aria-pressed="true"] { background: var(--card); color: var(--accent-ink); border-color: var(--kraft); }

.el-fields { display: grid; gap: 16px; }
.el-fields .field + .field { margin-top: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.flow-error { font-size: 13px; color: var(--danger); min-height: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 40px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font-size: 14px; }
.chips button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.el-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.el-actions .danger { margin-left: auto; }
.media-pick { display: grid; place-items: center; min-height: 110px; padding: 10px; border: 1.5px dashed var(--kraft); border-radius: 14px; background: var(--accent-soft); }
.media-pick img, .media-pick video { max-width: 100%; max-height: 180px; border-radius: 10px; }
.media-pick audio { width: 100%; }

/* ---------- Sheets: the + menu, settings, sign-in gate, Ready ---------- */
.editor .ed-sheet { width: min(560px, 100%); max-width: 100%; margin: auto auto 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; max-height: 88dvh; }
.editor .ed-sheet .dialog-head { margin-bottom: 14px; }
.ed-sheet h3 { margin: 20px 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ed-sheet h3:first-of-type { margin-top: 0; }
#sheetBody { display: grid; gap: 14px; }
#cogLock { display: grid; gap: 14px; }
.question { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--accent-soft); }
.editor .link-settings { padding: 0; border: 0; font-size: 13px; }
.editor .qr-settings { margin-top: 14px; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-item { display: grid; gap: 4px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); text-align: left; }
.add-item span { font-size: 12.5px; color: var(--muted); }
.add-item:disabled { opacity: .45; cursor: default; }
.add-item:hover:not(:disabled) { border-color: var(--accent); }
.theme-chip::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 50%; vertical-align: -2px; border: 1px solid #0002; background: var(--dot, #192b3a); }
.theme-console { --dot: linear-gradient(135deg, #192b3a 50%, #ffd23f 50%); } .theme-paper { --dot: linear-gradient(135deg, #fdf7ea 50%, #3a556c 50%); }
.theme-night { --dot: linear-gradient(135deg, #14121f 50%, #ffd23f 50%); } .theme-mint { --dot: linear-gradient(135deg, #eef8f2 50%, #1f9d63 50%); }
.theme-blush { --dot: linear-gradient(135deg, #fdf1f3 50%, #e0496b 50%); } .theme-sky { --dot: linear-gradient(135deg, #eef5fc 50%, #2f7fd8 50%); }
.theme-sun { --dot: linear-gradient(135deg, #fff8e6 50%, #e08a00 50%); }
.btn.wide { width: 100%; }
.editor .ready-qr { width: min(240px, 70%); margin: 0 auto; transform: none; box-shadow: 0 10px 30px #192b3a26; }
.ready-link { text-align: center; font: 500 17px var(--mono); color: var(--accent-ink); overflow-wrap: anywhere; }
.ready-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#sheetBody > .hint { text-align: center; }
@media (min-width: 700px) { .editor { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } .editor .ed-sheet { margin: auto; border-radius: 22px; } }
