/* Colour and type follow Vercel's Geist (same tokens as the Prism panel):
   its gray scale, 6/8/12px radii, Geist Sans + Mono. */
:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #1a1a1a;
  --line: #1f1f1f;
  --text: #ededed;
  --muted: #8f8f8f;
  --dim: #3d3d3d;
  --thumb: #ededed;
  --track: #1a1a1a;
  --pill: #2e2e2e;
  --stage: #000000;       /* the paper goes dark with the room */
  --stage-line: #1f1f1f;
  --ink: #ededed;         /* what the text, and the sprouting buds, are drawn in */
  --radius: 12px;
}
:root[data-theme="light"] {
  --bg: #fafafa;
  --panel: #ffffff;
  --panel-2: #f2f2f2;
  --line: #ebebeb;
  --text: #171717;
  --muted: #8f8f8f;
  --dim: #d1d1d1;
  --thumb: #a1a1a1;
  --track: #f2f2f2;
  --pill: #fcfcfc;
  --stage: #ffffff;
  --stage-line: #ebebeb;
  --ink: #111111;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Geist, Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.app {
  max-width: 1680px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) 72px; /* the same breath above and below the stage */
}

/* header and footer sit on the page's centre line, like Touch the Cloud */
.top { position: relative; display: flex; align-items: center; justify-content: center; }
.title { font-size: 10px; letter-spacing: 0.5em; text-transform: uppercase; color: var(--muted); user-select: none; padding-left: 0.5em; }
.top .right { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; color: var(--muted); }
.top .right button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.top .right button:hover { color: var(--text); background: var(--panel); }
.top .right svg { width: 16px; height: 16px; stroke-width: 1.6; }
.icon-off { display: none; }
.app.no-side .side { display: none; }
.app.no-side .main { grid-template-columns: minmax(0, 1fr); }
.app.no-side #side-toggle { color: var(--text); }
.app.no-side #side-toggle .icon-on { display: none; }
.app.no-side #side-toggle .icon-off { display: inline; }
:root[data-theme="light"] #theme .icon-on { display: none; }
:root[data-theme="light"] #theme .icon-off { display: inline; }

.main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 10px;
}
.preview { position: relative; min-height: 0; display: flex; }
#stage {
  position: relative; flex: 1; min-width: 0; min-height: 0;
  border-radius: var(--radius); overflow: hidden;
  background: var(--stage);
  box-shadow: inset 0 0 0 1px var(--stage-line);
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.label {
  font-size: 10px;
  letter-spacing: 0.34em;
  color: var(--muted);
  text-transform: uppercase;
}
.side {
  min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: clamp(8px, 1vh, 18px);
  scrollbar-width: none;
}
.side::-webkit-scrollbar { display: none; }
.card { flex: none; background: var(--panel); border-radius: var(--radius); padding: clamp(14px, 1.6vh, 26px) clamp(14px, 1.5vh, 22px) clamp(13px, 1.5vh, 24px); }
.card > .label { display: block; margin-bottom: clamp(11px, 1.2vh, 20px); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: clamp(11px, 1.2vh, 20px); }
.card-head .label { margin: 0; }

/* text field */
.field {
  display: block; width: 100%; margin: 0;
  padding: 10px 12px; border: 0; border-radius: 8px; outline: none;
  background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 15px;
  transition: box-shadow 0.15s;
}
.field:focus { box-shadow: 0 0 0 1px var(--dim); }
.field::placeholder { color: var(--dim); }
textarea.field { resize: none; line-height: 1.35; max-height: 7.6em; overflow-y: auto; }
/* which letters grow: one chip per letter, a row per line; dimmed = stays ink */
.letters { display: flex; flex-wrap: wrap; gap: 3px; margin-top: clamp(10px, 1.1vh, 16px); }
.letters:empty { display: none; }
.letters .br { flex-basis: 100%; height: 0; }
.letters button {
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: 6px;
  background: var(--panel-2); color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.letters button:hover { color: var(--text); }
.letters button.on { background: var(--pill); color: var(--text); }
/* the faces the text can be set in — each key wears its own font */
.seg.fonts { margin-top: clamp(10px, 1.1vh, 16px); margin-bottom: 0; }
.seg.fonts button { text-transform: none; font-size: 13px; line-height: 1; }
.seg.fonts [data-val="geist"]  { font-family: Geist, sans-serif; font-weight: 600; }
.seg.fonts [data-val="serif"]  { font-family: "Instrument Serif", Georgia, serif; font-size: 16px; }
.seg.fonts [data-val="rubik"]  { font-family: "Rubik Mono One", Impact, sans-serif; font-size: 11px; }
.seg.fonts [data-val="script"] { font-family: Caveat, cursive; font-weight: 700; font-size: 17px; }
.note { margin-top: 8px; font-size: 11px; color: var(--muted); font-family: "Geist Mono", ui-monospace, monospace; }

/* sprite picker: one block per set, a grid of cells per block */
#tabs { margin-bottom: clamp(12px, 1.3vh, 18px); }
#tabs button { font-size: 11px; padding-left: 2px; padding-right: 2px; }
.set[hidden] { display: none; }
.set { margin-bottom: clamp(10px, 1.1vh, 16px); }
.set:last-child { margin-bottom: 0; }
.set-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; padding: 0 2px;
  font-size: 12px; font-weight: 500; text-transform: lowercase;
}
.set-head .set-name { color: var(--text); }
.set.live .set-head .set-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--dim); }
/* three-state checkbox button: all / some / none */
.ckb { display: inline-flex; padding: 4px; margin: -4px; border-radius: 6px; }
.ck {
  width: 16px; height: 16px; border-radius: 5px; flex: none;
  background: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.ck svg { display: block; width: 10px; height: 10px; stroke: var(--text); stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ck path { display: none; }
.ck.all .tick { display: inline; }
.ck.some .dash { display: inline; }
.ckb:hover .ck { background: var(--line); }
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 3px; }
.cell {
  display: flex; align-items: center; justify-content: center;
  height: 36px; border-radius: 6px;
  font-size: 20px; line-height: 1;
  background: var(--panel-2);
  transition: background 0.15s, opacity 0.15s, filter 0.15s, transform 0.1s;
}
.cell img { width: 26px; height: 28px; object-fit: contain; display: block; }
.cell canvas { max-width: 26px; max-height: 26px; width: auto; height: auto; display: block; }
.cell img.blend { mix-blend-mode: screen; }
:root[data-theme="light"] .cell img.blend { mix-blend-mode: multiply; }
.cell:not(.on) { background: transparent; opacity: 0.55; filter: grayscale(1); }
/* the box under the picker: the user's own emoji, for this visit */
.field.yours { margin-top: clamp(10px, 1.1vh, 16px); font-size: 15px; padding: 9px 11px; }
.field.yours[hidden] { display: none; }
.cell:hover { opacity: 1; filter: none; background: var(--panel-2); }
.cell:active { transform: scale(0.94); }

/* sliders */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; margin-bottom: clamp(10px, 1vh, 16px); padding: 3px; border-radius: 8px; background: var(--panel-2); }
.seg:last-child { margin-bottom: 0; }
.seg button { padding: clamp(6px, 0.75vh, 11px) 4px; border-radius: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; text-transform: lowercase; transition: background 0.15s, color 0.15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--pill); color: var(--text); }

.row { position: relative; margin-bottom: clamp(6px, 0.7vh, 12px); border-radius: 8px; background: var(--track); }
.row::before {
  content: ""; position: absolute; left: 3px; top: 3px; bottom: 3px;
  width: calc(81px + (100% - 134px) * var(--pf, 0.5) + 6px);
  border-radius: 6px; background: var(--pill);
}
.row:last-child { margin-bottom: 0; }
.row .head {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 12px; font-size: 12px; font-weight: 500; text-transform: lowercase;
}
.row .head output { color: var(--muted); font-weight: 400; font-family: "Geist Mono", ui-monospace, monospace; font-size: 11px; }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  position: relative; z-index: 1; display: block;
  width: 100%; height: clamp(36px, 3.7vh, 50px); margin: 0; padding: 0 48px 0 84px;
  border-radius: 8px; background: transparent; cursor: ew-resize; outline: none;
}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 2px; height: 20px; border-radius: 2px; background: var(--thumb); }
input[type=range]::-moz-range-thumb { width: 2px; height: 20px; border: 0; border-radius: 2px; background: var(--thumb); }
input[type=range]:hover::-webkit-slider-thumb { transform: scaleY(1.15); }

.go {
  display: block; width: 100%; padding: clamp(9px, 1vh, 13px);
  border-radius: 8px; background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 500; text-transform: lowercase;
  transition: opacity 0.15s;
}
.go:hover { opacity: 0.88; }
.go:active { transform: scale(0.99); }

/* credit line: same voice as the title; the heart turns into a banana when lit */
.foot {
  display: flex; align-items: center; justify-content: center; gap: 0.5em;
  color: var(--muted); font-size: 10px; letter-spacing: 0.5em; text-transform: uppercase;
  user-select: none; padding-left: 0.5em;
}
.foot a { color: inherit; text-decoration: none; transition: color 0.2s; }
.foot a:hover { color: var(--text); }
#heartBtn { display: inline-flex; align-items: center; padding: 0; margin: 0 0.1em 0 0; color: inherit; }
#heartBtn svg, #heartBtn .banana { display: block; transition: transform 0.2s; transform-origin: center; }
#heartBtn .banana {
  display: none; font-size: 17px; line-height: 1; margin: -6px 0; letter-spacing: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
#heartBtn.liked svg { display: none; }
#heartBtn.liked .banana { display: block; }
#heartBtn.pop .banana { animation: heartPop 0.35s ease; }
#heartBtn:hover .banana { animation: heartSway 0.7s ease-in-out infinite; }
#heartBtn.pop svg { animation: heartPop 0.35s ease; }
#heartBtn:hover svg { animation: heartSway 0.7s ease-in-out infinite; }
@keyframes heartSway {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-11deg) scale(1.12); }
  75% { transform: rotate(11deg) scale(1.12); }
}
@keyframes heartPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

@media (max-width: 900px) {
  html, body { height: 100%; overflow: hidden; }
  .app { display: block; height: 100%; padding: 0; max-width: none; }
  .top {
    position: fixed; top: 0; left: 0; right: 0; z-index: 5;
    height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0 16px;
    box-sizing: border-box; pointer-events: none;
  }
  .top .title, .top .right { pointer-events: auto; }
  /* the buttons sit in the same 56px band as the title, under the notch */
  .top .right { right: 10px; top: env(safe-area-inset-top); bottom: 0; transform: none; align-items: center; }
  .top .right button { background: color-mix(in srgb, var(--panel) 70%, transparent); }
  #side-toggle { display: none; } /* the pill below does this job on phones */
  .main { display: block; }
  .preview { position: fixed; inset: 0; }
  #stage { border-radius: 0; box-shadow: none; }

  /* the controls: a small pill at the bottom that grows into the sheet */
  .side {
    position: fixed; z-index: 7; box-sizing: border-box;
    left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
    width: 64px; height: 36px; max-height: 36px;
    transform: translateX(-50%);
    padding: 0; gap: 10px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14), inset 0 0 0 1px var(--line);
    overflow: hidden; cursor: pointer;
    overscroll-behavior: contain; touch-action: pan-y;
    transition: left 0.38s, width 0.38s, height 0.38s, max-height 0.38s, bottom 0.38s, border-radius 0.38s,
      padding 0.38s, transform 0.38s, background 0.3s, box-shadow 0.3s;
    transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .side::before { /* the grab handle: the whole pill when closed, a bar on top when open */
    content: ""; display: block; flex: 0 0 4px; width: 36px; height: 4px; margin: 16px auto 0;
    border-radius: 2px; background: var(--dim); transition: margin 0.38s;
  }
  .side .card { opacity: 0; transition: opacity 0.2s; }
  .app.sheet-open .side {
    left: 0; bottom: 0; width: 100%; height: min(72vh, 72dvh); max-height: min(72vh, 72dvh);
    transform: none; padding: 8px 10px calc(14px + env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0; background: var(--bg);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
    overflow-y: auto; cursor: default;
  }
  .app.sheet-open .side::before { margin: 4px auto 4px; }
  .app.sheet-open .side .card { opacity: 1; transition-delay: 0.22s; }
  .side.dragging { transition: none; }
  .app.no-side .side { display: flex; }
  .card { padding: 14px 14px 13px; }
  .cells { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
  .cell { height: 40px; font-size: 22px; }
  .cell img { width: 28px; height: 30px; }

  .foot { display: none; }
}
