:root {
  --bg: #000;
  --panel: #000;
  --field: #111;
  --line: #262626;
  --pink: #ff3d9a;
  --text: #f5f5f5;
  --dim: #8c8c8c;
  --ink: #12060c;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.3 Inter, system-ui, sans-serif;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- header ---------- */

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--pink);
}

h1 {
  margin: 0;
  font: 22px/1 Silkscreen, monospace;
  color: var(--pink);
  letter-spacing: 1px;
}

#tabs { display: flex; flex-wrap: wrap; gap: 6px; }

#tabs a {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  text-decoration: none;
  font: 12px/1 Silkscreen, monospace;
  white-space: nowrap;
}
#tabs a:hover { color: var(--text); border-color: var(--dim); }
#tabs a.on { background: var(--pink); border-color: var(--pink); color: var(--ink); }

/* ---------- layout ---------- */

main { flex: 1; display: flex; min-height: 0; }

#editor {
  width: 380px;
  flex: none;
  overflow-y: auto;
  padding: 14px 16px 30px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

#stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg) radial-gradient(#1a1a1a 1px, transparent 1px) 0 0 / 14px 14px;
}

#actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 0;
}

#view {
  flex: 1;
  overflow: auto;
  padding: 20px 16px 40px;
}

#fit { margin: 0 auto; transform-origin: top left; }

/* ---------- buttons ---------- */

button {
  cursor: pointer;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--pink);
  color: var(--ink);
  font: 12px/1 Silkscreen, monospace;
}
button:hover { filter: brightness(1.12); }
button.ghost {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
}
button.ghost:hover { color: var(--text); border-color: var(--dim); }
button.small { padding: 6px 10px; font-size: 11px; }

#reset { margin-top: 18px; }

/* ---------- form ---------- */

#form h3, #phoneset h3 {
  margin: 20px 0 8px;
  font: 12px/1 Silkscreen, monospace;
  color: var(--pink);
}
#form h3:first-child { margin-top: 2px; }

.f { display: block; margin-bottom: 10px; min-width: 0; }
.f > span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  text-transform: lowercase;
}

.f input[type=range] { width: 100%; accent-color: var(--pink); }

.f input[type=text], .f input[type=number], .f select, .f textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.f textarea { resize: vertical; min-height: 40px; line-height: 1.4; }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--pink); }
.f select option { background: var(--panel); }

.row { display: flex; gap: 8px; }
.row > .f { flex: 1; }

.f.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.f.toggle > span { margin: 0; font-size: 12px; }
.f.toggle input { accent-color: var(--pink); width: 16px; height: 16px; margin: 0; }
.row > .f.toggle { flex: none; padding-top: 18px; }

/* image picker */
.pic { display: flex; align-items: center; gap: 8px; }
.pic .thumb {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 8px;
  background: var(--field) center / cover;
  border: 1px solid var(--line);
}
.pic input[type=file] { display: none; }

/* color */
.color { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.color input[type=color] {
  width: 40px;
  height: 32px;
  padding: 2px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}
.swatch.on { border-color: var(--text); }

/* lists */
.item {
  position: relative;
  margin-bottom: 8px;
  padding: 10px 10px 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.item.me { border-left: 3px solid var(--pink); }
.item-bar {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  margin: -4px -4px 4px 0;
}
.item-bar button {
  padding: 3px 7px;
  background: none;
  color: var(--dim);
  font: 13px/1 Inter, sans-serif;
}
.item-bar button:hover { color: var(--pink); }
.adds { display: flex; gap: 6px; margin-bottom: 10px; }

/* ---------- phones ---------- */

@media (max-width: 800px) {
  body { overflow: auto; height: auto; }
  main { flex-direction: column-reverse; }
  #editor { width: auto; border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  #view { overflow: hidden; }
}

/* ---------- click-to-type on the preview ---------- */

#fit [data-e] { outline: none; cursor: text; border-radius: 3px; min-width: .5em; }
#fit [data-e]:hover { box-shadow: 0 0 0 1.5px rgba(255, 61, 154, .75); }
#fit [data-e]:focus { box-shadow: 0 0 0 2px #ff3d9a; }
#fit [data-e]:empty::before { content: attr(data-ph); opacity: .38; }
#fit [data-img] { cursor: pointer; }
#fit [data-img]:hover { outline: 2px dashed #ff3d9a; outline-offset: -2px; }
#fit.exporting [data-e] { box-shadow: none !important; }
#fit.exporting [data-e]:empty::before { content: none; }
#fit.exporting [data-img] { outline: none !important; }

/* symbols + fonts tabs (copypaste/ in a frame) */
#extra { display: none; flex: 1; min-height: 0; }
#extra iframe { flex: 1; width: 100%; border: 0; background: #000; }
body.extra-on main { display: none; }
body.extra-on #extra { display: flex; }
#tabs a.extra { border-color: var(--pink); color: var(--pink); }
#tabs a.extra.on { color: var(--ink); }

/* ---------- undo / random / export options ---------- */

#actions { flex-wrap: wrap; align-items: center; }
.acts-left, .acts-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.acts-left { margin-right: auto; }
.acts-opts { margin-right: 6px; }
button:disabled { opacity: .35; cursor: default; filter: none; }
button.opt.on { color: var(--pink); border-color: var(--pink); }

/* presets */
.presets { margin-bottom: 14px; }
.pre-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pre-row select {
  flex: 1 1 70px;
  min-width: 0;
  padding: 6px 8px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.pre-row select:focus { border-color: var(--pink); }
.pre-row button { padding: 6px 8px; }
.pre-row select option { background: var(--panel); }

/* drag to reorder list cards */
.grip {
  width: 10px;
  height: 15px;
  margin: 2px auto 0 4px;
  padding: 2px 6px;
  box-sizing: content-box;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle, var(--dim) 1.3px, transparent 1.7px) 0 0 / 5px 5px content-box;
  opacity: .85;
}
.grip:hover { opacity: 1; }
.item.drag { border-color: var(--pink); box-shadow: 0 6px 18px rgba(255, 61, 154, .25); }
.list.dragging, .list.dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- phone frame (goes in the png too) ---------- */

.pframe {
  position: relative;
  width: 418px;
  padding: 14px;
  border-radius: 68px;
  background: #0b0b0d;
  box-shadow: inset 0 0 0 2px #34343a, inset 0 0 0 5px #050505;
}
.pf-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 390px;
  min-height: 844px;
  border-radius: 54px;
  overflow: hidden;
  background: #000;
}
.pf-island {
  position: absolute;
  top: 11px;
  left: 50%;
  width: 124px;
  height: 36px;
  margin-left: -62px;
  border-radius: 20px;
  background: #000;
  z-index: 30;
}
.pf-sbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 4px 30px 0 50px;
  font-family: Inter, -apple-system, 'Noto Color Emoji', sans-serif;
}
.pf-time { font-size: 17px; font-weight: 600; letter-spacing: -.01em; min-width: 2em; outline: none; }
.pf-icons { display: flex; align-items: center; gap: 6px; }
.pf-icons svg { display: block; fill: currentColor; }
.pf-body { position: relative; flex: none; margin: 0 auto; overflow: hidden; }
.pframe.mid .pf-body { margin: auto; }
.pframe.mid .pf-screen { padding-bottom: 54px; }
.pf-scale { width: max-content; transform-origin: top left; }
.pf-home {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 134px;
  height: 5px;
  margin-left: -67px;
  border-radius: 3px;
  background: currentColor;
  z-index: 30;
}
.pframe.bar-light .pf-sbar, .pframe.bar-light .pf-home { color: #fff; }
.pframe.bar-dark .pf-sbar, .pframe.bar-dark .pf-home { color: #000; }
#fit [data-pe] { cursor: text; border-radius: 3px; }
#fit [data-pe]:hover { box-shadow: 0 0 0 1.5px rgba(255, 61, 154, .75); }
#fit [data-pe]:focus { box-shadow: 0 0 0 2px #ff3d9a; }
#fit.exporting [data-pe] { box-shadow: none !important; }
#phoneset[hidden] { display: none; }
