:root {
  --system-blue: #007aff;
  --system-label: #1c1c1e;
  --system-secondary: #6e6e73;
  --system-tertiary: #8e8e93;
  --system-fill: #e9e9eb;
  --system-separator: rgba(60, 60, 67, 0.18);
  --press-fill: rgba(118, 118, 128, 0.12);
  --glass-fill:
    radial-gradient(120% 115% at 12% -18%, rgba(255, 255, 255, 0.86) 0%, rgba(255, 255, 255, 0.24) 47%, transparent 68%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0.16) 52%, rgba(255, 255, 255, 0.36) 100%);
  --glass-white-fill:
    radial-gradient(120% 115% at 12% -18%, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.48) 48%, transparent 68%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.5) 54%, rgba(255, 255, 255, 0.64) 100%);
  --glass-border: rgba(255, 255, 255, 0.86);
  --glass-filter: blur(28px) saturate(1.62) brightness(1.16);
  --glass-radius: 18px;
  --glass-shadow:
    0 10px 28px rgba(0, 0, 0, 0.06),
    0 2px 5px rgba(0, 0, 0, 0.025),
    inset 0 1.2px 0 rgba(255, 255, 255, 0.98),
    inset 0 -0.7px 0 rgba(60, 60, 67, 0.05),
    inset 1px 0 0 rgba(255, 255, 255, 0.42),
    inset -1px 0 0 rgba(255, 255, 255, 0.18);
  --ios-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ios-quick: cubic-bezier(0.25, 0.1, 0.25, 1);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  color: var(--system-label);
  background: #f2f2f7;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

html,
body,
.app,
button,
.emoji-grid,
.category-bar {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input {
  -webkit-user-select: text;
  user-select: text;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #f2f2f7;
}

body {
  display: grid;
  place-items: center;
  background: #f2f2f7;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  background: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    color 140ms var(--ios-quick),
    background-color 140ms var(--ios-quick),
    filter 140ms var(--ios-quick),
    opacity 140ms var(--ios-quick),
    transform 140ms var(--ios-ease);
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible {
  outline: 0;
}

input:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.36);
  outline-offset: 1px;
}

.icon-button:focus-visible,
.category-button:focus-visible,
.emoji-button:focus-visible,
.asset-button:focus-visible,
.command-row button:focus-visible,
.edit-tabs button:focus-visible {
  background: var(--press-fill);
}

svg {
  display: block;
}

.app {
  position: relative;
  width: min(100vw, 430px);
  height: 100dvh;
  min-height: 620px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f2f2f7;
}

.topbar {
  position: relative;
  z-index: 100;
  flex: 0 0 calc(64px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: transparent;
  pointer-events: none;
  transition: flex-basis 260ms var(--ios-ease);
}

.app.house-fullscreen .topbar {
  flex-basis: calc(100px + env(safe-area-inset-top, 0px));
}

.topbar-bubble,
.toolbar-capsule,
.save-button {
  border: 0.5px solid var(--glass-border);
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
}

.back-button {
  position: absolute;
  z-index: 3;
  left: 16px;
  top: calc(9px + env(safe-area-inset-top, 0px));
  width: 44px;
  height: 44px;
  pointer-events: auto;
}

.topbar-actions {
  position: absolute;
  z-index: 3;
  right: 16px;
  top: calc(8px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}

.toolbar-capsule {
  width: 88px;
  height: 46px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 23px;
  transform-origin: right center;
  transition:
    width 240ms var(--ios-ease),
    transform 150ms var(--ios-ease),
    filter 150ms var(--ios-quick);
}

.toolbar-capsule .icon-button {
  flex: 0 0 44px;
  width: 44px;
  height: 46px;
  overflow: hidden;
  border-radius: 50%;
  transition:
    flex-basis 240ms var(--ios-ease),
    width 240ms var(--ios-ease),
    opacity 150ms var(--ios-quick),
    transform 200ms var(--ios-ease);
}

.save-button {
  width: 46px;
  height: 46px;
  border-color: var(--glass-border);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 217, 28, 0.96), rgba(242, 197, 0, 0.82));
  color: #1c1c1e;
}

.save-button:active {
  background: linear-gradient(145deg, rgba(255, 225, 62, 0.98), rgba(248, 207, 19, 0.9));
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  color: var(--system-blue);
}

.icon-button .system-symbol {
  width: 40px;
  height: 40px;
}

.topbar .system-symbol {
  width: 32px;
  height: 32px;
}

.toolbar-capsule .system-symbol {
  width: 37px;
  height: 37px;
}

.topbar .back-button .system-symbol {
  width: 32px;
  height: 32px;
}

.topbar .save-button .system-symbol {
  width: 33px;
  height: 33px;
}

.toolbar-capsule .icon-button:first-child .system-symbol {
  transform: translateX(1.5px);
}

.toolbar-capsule .icon-button:last-child .system-symbol {
  transform: translateX(-1.5px);
}

.topbar .icon-button {
  color: #3a3a3c;
}

.system-symbol {
  --symbol-image: none;
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--symbol-image) center / contain no-repeat;
  mask: var(--symbol-image) center / contain no-repeat;
  transition: opacity 120ms var(--ios-quick), color 120ms var(--ios-quick);
}

.symbol-undo { --symbol-image: url("symbols/undo.png?v=8"); }
.symbol-redo { --symbol-image: url("symbols/redo.png?v=8"); }
.symbol-trash { --symbol-image: url("symbols/trash.png"); }
.symbol-export { --symbol-image: url("symbols/export.png?v=7"); }
.symbol-close { --symbol-image: url("symbols/close.png"); }
.symbol-edit { --symbol-image: url("symbols/edit.png"); }
.symbol-transform { --symbol-image: url("symbols/transform.png"); }
.symbol-search { --symbol-image: url("symbols/search.png"); }
.symbol-eraser { --symbol-image: url("symbols/eraser.png"); }
.symbol-opacity { --symbol-image: url("symbols/opacity.png"); }
.symbol-rotate { --symbol-image: url("symbols/rotate.png"); }
.symbol-layers { --symbol-image: url("symbols/layers.png"); }
.symbol-rotate-left { --symbol-image: url("symbols/rotate-left.png"); }
.symbol-rotate-right { --symbol-image: url("symbols/rotate-right.png"); }
.symbol-flip-horizontal { --symbol-image: url("symbols/flip-horizontal.png"); }
.symbol-flip-vertical { --symbol-image: url("symbols/flip-vertical.png"); }
.symbol-layer-front { --symbol-image: url("symbols/layer-front.png"); }
.symbol-layer-forward { --symbol-image: url("symbols/layer-forward.png"); }
.symbol-layer-backward { --symbol-image: url("symbols/layer-backward.png"); }
.symbol-layer-back { --symbol-image: url("symbols/layer-back.png"); }
.symbol-copy { --symbol-image: url("symbols/copy.png"); }
.symbol-more { --symbol-image: url("symbols/more.png"); }
.symbol-back { --symbol-image: url("symbols/back.png?v=2"); }
.symbol-check { --symbol-image: url("symbols/check.png?v=1"); }
.topbar .back-button,
.topbar .save-button {
  border-radius: 50%;
}

.topbar .back-button {
  width: 44px;
  height: 44px;
}

.topbar .save-button {
  width: 44px;
  height: 44px;
  color: #fff;
  box-shadow:
    0 5px 15px rgba(0, 0, 0, 0.065),
    0 1px 2px rgba(0, 0, 0, 0.035),
    inset 0 1px 0 rgba(255, 255, 255, 0.68),
    inset 0 -0.5px 0 rgba(60, 60, 67, 0.06);
}

.topbar .icon-button:active,
.icon-button:active {
  background: transparent;
  color: inherit;
  filter: none;
  transform: none;
}

.topbar .icon-button:active .system-symbol,
.icon-button:active .system-symbol {
  opacity: 0.5;
}

.topbar .back-button:active,
.topbar .save-button:active,
.toolbar-capsule:has(.icon-button:active) {
  filter: brightness(1.09);
  transform: scale(1.04);
}

.topbar .save-button:active {
  background: linear-gradient(145deg, rgba(255, 229, 74, 0.99), rgba(250, 207, 20, 0.94));
  color: #fff;
}

.topbar .save-button:active .system-symbol {
  opacity: 0.52;
}

.icon-button:disabled {
  color: #b5b5ba;
  opacity: 1;
}

.name-field {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: calc(62px + env(safe-area-inset-top, 0px));
  width: min(250px, calc(100vw - 96px));
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-4px);
  transition:
    opacity 180ms var(--ios-quick),
    transform 220ms var(--ios-ease);
  -webkit-tap-highlight-color: transparent;
}

.app.house-fullscreen .name-field {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.name-field:focus-within {
  z-index: 4;
  width: min(250px, calc(100vw - 96px));
  border: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.name-field input {
  width: 100%;
  height: 30px;
  padding: 3px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--system-secondary);
  caret-color: var(--system-blue);
  font-family: -apple-system, BlinkMacSystemFont, "Apple Color Emoji", sans-serif;
  font-size: 17px;
  font-weight: 400;
  line-height: 22px;
  letter-spacing: 0;
  text-align: center;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  outline: 0;
  box-shadow: none;
  text-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.name-field input:focus,
.name-field input:focus-visible,
.name-field input:active {
  outline: 0;
  background: transparent;
  box-shadow: none;
  filter: none;
}

.topbar-actions {
  transition: opacity 160ms var(--ios-quick), transform 200ms var(--ios-ease);
}

.workspace {
  position: relative;
  z-index: 1;
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: visible;
  padding: 0;
  background: #f2f2f7;
  transition: padding 280ms var(--ios-ease);
}

.app.house-fullscreen .workspace {
  place-items: center;
  padding: 0 0 calc(100px + env(safe-area-inset-top, 0px));
}

.canvas {
  position: relative;
  width: min(78%, 320px);
  height: auto;
  aspect-ratio: 984 / 1111;
  overflow: visible;
  background: transparent;
  transition:
    width 300ms var(--ios-ease),
    height 300ms var(--ios-ease),
    max-width 300ms var(--ios-ease);
}

.app.house-fullscreen .canvas {
  width: min(91%, 382px);
  height: auto;
}

.motion-ready .topbar,
.motion-ready .workspace,
.motion-ready .canvas,
.motion-ready .drawer,
.motion-ready .name-field,
.motion-ready .edit-drawer {
  transition: none;
}

.motion-ready .canvas,
.motion-ready .drawer,
.motion-ready .emoji-variant-popover,
.motion-ready .edit-drawer {
  will-change: transform, opacity;
}

.motion-ready .selection-menu {
  will-change: opacity;
}

.motion-ready .selection-menu,
.motion-ready .emoji-variant-popover,
.motion-ready .edit-panel {
  animation: none;
  transition: none;
}

.house {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.sticker-layer {
  position: absolute;
  inset: 0;
}

.sticker-node {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  will-change: transform, width, height;
}

.sticker-node:active {
  cursor: grabbing;
}

.sticker-visual,
.sticker-visual svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.selection-box {
  --selection-rotation: 0deg;
  position: absolute;
  z-index: 10000;
  left: 0;
  top: 0;
  border: 1.5px solid #0a84ff;
  transform-origin: center;
  pointer-events: none;
  touch-action: none;
}

.selection-box[hidden] {
  display: none;
}

.selection-actions {
  --toolbar-offset: 0px;
  --menu-offset: 0px;
  --menu-y-offset: 0px;
  position: absolute;
  z-index: 10001;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.selection-actions[hidden] {
  display: none;
}

.selection-box .transform-handle,
.selection-box .edge-handle,
.selection-actions {
  transition: opacity 100ms var(--ios-quick);
}

.selection-box.move-preview .transform-handle,
.selection-box.move-preview .edge-handle,
.selection-actions.move-preview {
  opacity: 0;
  pointer-events: none;
}

.selection-toolbar {
  position: absolute;
  z-index: 7;
  left: var(--toolbar-offset);
  top: -12px;
  width: 136px;
  height: 48px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 1px;
  overflow: hidden;
  border: 0.5px solid var(--glass-border);
  border-radius: 24px;
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
  transform: translate(-50%, -100%);
  transform-origin: center bottom;
  pointer-events: auto;
  transition: opacity 160ms var(--ios-quick), transform 220ms var(--ios-ease);
}

.selection-toolbar button {
  min-width: 0;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 23px;
  background: transparent;
  color: var(--system-secondary);
  pointer-events: auto;
}

.selection-toolbar button:active {
  background: transparent;
  color: inherit;
  filter: none;
  transform: none;
}

.selection-toolbar button:active .system-symbol,
.menu-layer-row button:active .system-symbol,
.menu-action-grid button:active .system-symbol {
  opacity: 0.5;
}

.selection-toolbar:has(button:active) {
  filter: brightness(1.08);
  transform: translate(-50%, -100%) scale(1.035);
}

.selection-actions.toolbar-below .selection-toolbar:has(button:active) {
  transform: translate(-50%, 0) scale(1.035);
}

.selection-toolbar .system-symbol {
  width: 36px;
  height: 36px;
}

.selection-toolbar .symbol-copy {
  width: 38px;
  height: 38px;
}

.selection-toolbar .symbol-trash {
  width: 35px;
  height: 35px;
}

.selection-toolbar .symbol-more {
  width: 38px;
  height: 38px;
}

.selection-toolbar .toolbar-delete {
  color: #ff3b30;
}

.selection-actions.toolbar-below .selection-toolbar {
  top: 12px;
  transform: translate(-50%, 0);
  transform-origin: center top;
}

.selection-actions.menu-open .selection-toolbar {
  opacity: 0;
  transform: translate(-50%, -92%) scale(0.96);
  pointer-events: none;
}

.selection-actions.toolbar-below.menu-open .selection-toolbar {
  transform: translate(-50%, 0) scale(0.96);
}

.selection-menu {
  position: absolute;
  z-index: 8;
  left: var(--menu-offset);
  top: calc(-12px + var(--menu-y-offset));
  width: min(204px, calc(100vw - 32px));
  overflow: hidden;
  border: 0.5px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-white-fill);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
  color: var(--system-label);
  transform: translate(-50%, -100%);
  transform-origin: center bottom;
  pointer-events: auto;
  transition: filter 140ms var(--ios-quick), transform 160ms var(--ios-ease);
}

.selection-menu[hidden] {
  display: none;
}

.selection-actions.toolbar-below .selection-menu {
  top: calc(12px + var(--menu-y-offset));
  transform: translate(-50%, 0);
  transform-origin: center top;
}

.menu-layer-row {
  position: relative;
  height: 70px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 9px 10px 11px;
}

.menu-layer-row[hidden] {
  display: none;
}

.menu-layer-row::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 0.5px;
  background: rgba(60, 60, 67, 0.16);
  pointer-events: none;
}

.menu-layer-row button,
.menu-action-grid button {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  padding: 0 14px;
  color: var(--system-label);
  font-size: 15px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: 0;
  text-align: left;
}

.menu-layer-row button {
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  text-align: center;
}

.menu-layer-row button:active,
.menu-action-grid button:active {
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(10px) brightness(1.08) saturate(1.1);
  backdrop-filter: blur(10px) brightness(1.08) saturate(1.1);
  box-shadow:
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.22),
    0 2px 8px rgba(0, 0, 0, 0.025);
  transform: none;
}

.selection-menu:has(button:active) {
  filter: brightness(1.07);
  transform: translate(-50%, -100%) scale(1.018);
}

.selection-actions.toolbar-below .selection-menu:has(button:active) {
  transform: translate(-50%, 0) scale(1.018);
}

.menu-layer-row button:disabled {
  opacity: 0.32;
  pointer-events: none;
}

.menu-layer-row .system-symbol {
  width: 30px;
  height: 30px;
}

.menu-action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.menu-action-grid button {
  position: relative;
  width: auto;
  height: 43px;
  margin: 0 8px;
  padding: 0 10px;
  border-radius: 999px;
}

.menu-action-grid .destructive {
  height: 48px;
  margin: 1px 8px 0;
}

.menu-action-grid .system-symbol {
  width: 30px;
  height: 30px;
}

.menu-layer-row button > span:last-child,
.menu-action-grid button > span:last-child {
  min-width: 0;
  white-space: nowrap;
}

.menu-action-grid .destructive {
  color: #ff3b30;
}

.menu-action-grid .destructive::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -1px;
  height: 0.5px;
  background: rgba(60, 60, 67, 0.16);
}

.transform-handle {
  position: absolute;
  z-index: 4;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  pointer-events: auto;
  touch-action: none;
}

.transform-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0a84ff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
  transition: transform 140ms var(--ios-ease);
}

.transform-handle:active::before {
  transform: translate(-50%, -50%) scale(0.82);
}

.handle-top-left {
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
}

.handle-top-right {
  right: 0;
  top: 0;
  transform: translate(50%, -50%);
}

.handle-bottom-left {
  left: 0;
  bottom: 0;
  transform: translate(-50%, 50%);
}

.handle-bottom-right {
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%);
}

.edge-handle {
  position: absolute;
  z-index: 3;
  width: 44px;
  height: 24px;
  padding: 0;
  background: transparent;
  pointer-events: auto;
  touch-action: none;
}

.edge-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 6px;
  transform: translate(-50%, -50%);
  border: 1.5px solid #0a84ff;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  opacity: 1;
  transition: opacity 140ms var(--ios-quick), transform 140ms var(--ios-ease);
}

.edge-handle:active::before {
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.88);
}

.edge-top {
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  cursor: ns-resize;
}

.edge-bottom {
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
  cursor: ns-resize;
}

.edge-left {
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  cursor: ew-resize;
}

.edge-right {
  right: 0;
  top: 50%;
  transform: translate(50%, -50%) rotate(90deg);
  cursor: ew-resize;
}

@media (prefers-reduced-transparency: reduce) {
  .topbar-bubble,
  .toolbar-capsule,
  .save-button,
  .selection-toolbar,
  .selection-menu,
  .emoji-variant-popover,
  .search,
  .toast {
    background: rgba(248, 248, 250, 0.96);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.drawer {
  position: relative;
  z-index: 90;
  flex: 0 0 clamp(254px, 31dvh, 282px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border: 0.5px solid rgba(255, 255, 255, 0.74);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: #f2f2f7;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.08);
  transition: flex-basis 300ms var(--ios-ease);
}

.drawer.collapsed {
  flex-basis: env(safe-area-inset-bottom, 0px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.drawer.collapsed .search-panel,
.drawer.collapsed .emoji-grid,
.drawer.collapsed .picker-toolbar {
  display: none;
}

.drawer.covered {
  pointer-events: none;
}

.drawer[hidden],
.edit-drawer[hidden],
.edit-panel[hidden] {
  display: none;
}

.picker-toolbar {
  flex: 0 0 48px;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0 4px 0 8px;
}

.category-bar {
  min-width: 0;
  height: 48px;
  flex: 1;
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar,
.emoji-grid::-webkit-scrollbar {
  display: none;
}

.category-button {
  position: relative;
  flex: 0 0 36px;
  width: 36px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
}

.category-emoji {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-family: "Apple Color Emoji";
  font-size: 24px;
  line-height: 1;
  filter: grayscale(1);
  opacity: 0.48;
  transform: scale(var(--category-scale, 1));
  transition: filter 160ms var(--ios-quick), opacity 160ms var(--ios-quick), transform 160ms var(--ios-ease);
}

.category-button.active {
  background: transparent;
}

.category-button.active .category-emoji {
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.18);
  filter: grayscale(1);
  opacity: 0.94;
  transform: scale(var(--category-scale, 1));
}

.search-toggle {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  color: var(--system-secondary);
}

.search-toggle .system-symbol {
  width: 28px;
  height: 28px;
}

.search-toggle:active {
  background: transparent;
  filter: brightness(1.08);
  transform: scale(1.04);
}

.search-toggle:active .system-symbol {
  opacity: 0.5;
}

.search-panel {
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  padding: 10px 12px 6px;
}

.search-panel[hidden] {
  display: none;
}

.drawer.search-open .picker-toolbar {
  display: none;
}

.search {
  min-width: 0;
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 0.5px solid var(--glass-border);
  border-radius: var(--glass-radius);
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
  color: var(--system-tertiary);
}

.search-cancel {
  min-width: 50px;
  min-height: 40px;
  margin-right: -8px;
  padding: 0 8px;
  color: var(--system-secondary);
  font-size: 16px;
}

.search .system-symbol {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

.search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--system-label);
  font-size: 16px;
  letter-spacing: 0;
}

.search input::placeholder {
  color: var(--system-tertiary);
}

.emoji-grid {
  --emoji-cell-width: calc((min(100vw, 430px) - 16px) / 7.3);
  min-height: 0;
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 6px 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  scroll-snap-type: x proximity;
  touch-action: pan-x;
  background: transparent;
  scrollbar-width: none;
}

.emoji-grid::after {
  content: "";
  flex: 0 0 var(--emoji-end-spacer, 0px);
}

.emoji-section {
  flex: 0 0 auto;
  height: 100%;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-auto-flow: column;
  grid-auto-columns: var(--emoji-cell-width);
  gap: 0;
}

.emoji-button,
.asset-button {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  line-height: 1;
}

.emoji-button {
  font-family: "Apple Color Emoji";
  font-size: 42px;
}

.emoji-variant-popover {
  position: absolute;
  z-index: 30000;
  max-width: calc(100% - 16px);
  height: 58px;
  display: flex;
  align-items: center;
  gap: 1px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 6px;
  border: 0.5px solid var(--glass-border);
  border-radius: 17px;
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
  scrollbar-width: none;
}

.emoji-variant-popover[hidden] {
  display: none;
}

.emoji-variant-popover::-webkit-scrollbar {
  display: none;
}

.emoji-variant-button {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 12px;
  font-family: "Apple Color Emoji";
  font-size: 36px;
  line-height: 1;
}

.emoji-variant-button:active {
  background: transparent;
  transform: scale(0.94);
}

.emoji-variant-button.asset-variant-button img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
  pointer-events: none;
}

.emoji-button:active,
.asset-button:active {
  background: transparent;
  transform: scale(0.94);
}

.asset-button img {
  display: block;
  width: 47px;
  height: 43px;
  object-fit: contain;
  pointer-events: none;
}

.empty-result {
  flex: 0 0 100%;
  display: grid;
  place-items: center;
  height: 88px;
  color: var(--system-tertiary);
  font-size: 14px;
}

.edit-drawer {
  position: absolute;
  z-index: 20000;
  left: 0;
  right: 0;
  bottom: 0;
  height: clamp(286px, 33dvh, 326px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border: 0.5px solid rgba(255, 255, 255, 0.9);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: var(--glass-white-fill);
  -webkit-backdrop-filter: blur(30px) saturate(1.52) brightness(1.16);
  backdrop-filter: blur(30px) saturate(1.52) brightness(1.16);
  color: var(--system-label);
  box-shadow:
    0 -10px 30px rgba(0, 0, 0, 0.065),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
  opacity: 0;
  visibility: hidden;
  transform: translateY(22px);
  pointer-events: none;
  transition:
    transform 240ms var(--ios-ease),
    opacity 180ms var(--ios-quick),
    visibility 0s linear 240ms;
}

.edit-drawer::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 6px;
  width: 36px;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: #d1d1d6;
}

.edit-drawer.presented {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition-delay: 0s;
}

.edit-header {
  flex: 0 0 54px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding: 8px 10px 0;
  border-bottom: 0.5px solid rgba(60, 60, 67, 0.13);
}

.edit-title {
  align-self: center;
  margin: 7px 0 0;
  color: var(--system-label);
  font-size: 18px;
  font-weight: 600;
  line-height: 22px;
  letter-spacing: 0;
}

.cancel-button,
.done-button {
  min-width: 54px;
  height: 46px;
  padding: 0 6px;
  color: var(--system-blue);
  font-size: 18px;
}

.cancel-button {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  text-align: left;
}

.done-button {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  font-weight: 600;
  text-align: right;
}

.edit-title {
  grid-column: 2;
  grid-row: 1;
}

.edit-panels {
  min-height: 0;
  flex: 1;
  padding: 16px 18px 10px;
}

.edit-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.slider-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  color: var(--system-label);
  font-size: 16px;
}

.slider-row input[type="range"] {
  width: 100%;
  height: 32px;
  margin: 0;
  accent-color: var(--system-blue);
}

.slider-row output {
  color: var(--system-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.mode-control {
  width: min(220px, 70%);
  height: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 auto 14px;
  padding: 2px;
  border-radius: 9px;
  background: rgba(118, 118, 128, 0.1);
}

.mode-control button {
  min-width: 0;
  border-radius: 7px;
  color: var(--system-label);
  font-size: 15px;
}

.mode-control button.active {
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.command-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  margin-top: 10px;
}

.command-row button {
  min-width: 0;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 2px;
  border-radius: 9px;
  color: var(--system-label);
}

.command-row button:active {
  background: rgba(255, 255, 255, 0.18);
  filter: brightness(1.06);
  transform: scale(1.025);
}

.command-row button:active .system-symbol,
.edit-tabs button:active .system-symbol {
  opacity: 0.5;
}

.command-row .system-symbol {
  width: 38px;
  height: 38px;
}

.command-row button > span:not(.system-symbol) {
  max-width: 100%;
  overflow: hidden;
  color: var(--system-secondary);
  font-size: 12px;
  line-height: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-tabs {
  flex: 0 0 68px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 0.5px solid rgba(60, 60, 67, 0.13);
  background: rgba(255, 255, 255, 0.46);
  -webkit-backdrop-filter: blur(18px) brightness(1.08);
  backdrop-filter: blur(18px) brightness(1.08);
}

.edit-tabs button {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  color: var(--system-tertiary);
  font-size: 12px;
}

.edit-tabs button.active {
  color: var(--system-blue);
}

.edit-tabs button:active {
  background: rgba(255, 255, 255, 0.16);
  filter: brightness(1.06);
  transform: scale(1.025);
}

.edit-tabs .system-symbol {
  width: 38px;
  height: 38px;
}

.toast {
  position: fixed;
  z-index: 100000;
  left: 50%;
  top: max(16px, env(safe-area-inset-top, 0px));
  transform: translate(-50%, -8px);
  padding: 8px 13px;
  border: 0.5px solid var(--glass-border);
  border-radius: var(--glass-radius);
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
  color: var(--system-label);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms var(--ios-ease), opacity 140ms var(--ios-quick);
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast.name-warning {
  top: calc(100px + env(safe-area-inset-top, 0px));
  border-radius: 20px;
  background: var(--glass-white-fill);
}

@media (hover: hover) {
  .name-field:focus-within input:hover {
    background: transparent;
  }
}

@media (min-width: 480px) {
  .app {
    box-shadow: 0 0 36px rgba(0, 0, 0, 0.08);
  }
}

@media (max-height: 700px) {
  .app {
    min-height: 0;
  }

  .drawer {
    flex-basis: 228px;
  }

  .canvas {
    width: min(70%, 286px);
  }

  .app.house-fullscreen .canvas {
    width: min(88%, 350px);
  }

  .edit-drawer {
    height: 238px;
  }

  .edit-panels {
    padding-top: 10px;
  }

  .edit-tabs {
    flex-basis: 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
