* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a1a;
  color: #fff;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* Preview area */
#preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

#canvas {
  width: 100%;
  height: 100%;
}

/* Fullscreen UI */
#fullscreen-ui {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#preview.fullscreen #fullscreen-ui {
  display: block;
}

#fullscreen-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

#fullscreen-close:active {
  background: rgba(0, 0, 0, 0.7);
}

#fullscreen-save {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 32px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 24px;
  color: #000;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
}

#fullscreen-save:active {
  background: rgba(255, 255, 255, 0.7);
}

/* Fullscreen mode */
#preview.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

/* Layer panel */
#layer-panel {
  background: #252525;
  padding: 12px;
  max-height: 35vh;
  overflow-y: auto;
}

#layer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #333;
  border-radius: 8px;
  cursor: pointer;
}

.layer-item.active {
  background: #444;
  border: 1px solid #666;
}

.layer-item .layer-name {
  flex: 1;
  font-size: 14px;
}

.layer-item .layer-blend {
  font-size: 12px;
  color: #888;
}

.layer-item .layer-toggle {
  width: 20px;
  height: 20px;
  border: none;
  background: #555;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
}

.layer-item .layer-delete {
  width: 20px;
  height: 20px;
  margin-left: 12px;
  border: none;
  background: #c44;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.layer-item .layer-delete:active {
  background: #a33;
}

#add-layer {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: #444;
  border: 1px dashed #666;
  border-radius: 8px;
  color: #aaa;
  font-size: 14px;
  cursor: pointer;
}

#add-layer:active {
  background: #555;
}

/* Layer effects list */
.layer-effects {
  background: #2a2a2a;
  border-radius: 0 0 8px 8px;
  padding: 8px 12px;
  margin-top: -4px;
  margin-bottom: 8px;
}

.effect-item-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  background: #383838;
  border-radius: 4px;
  margin-bottom: 4px;
}

.effect-item-row .effect-name {
  flex: 1;
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
}

.effect-item-row .effect-name:active {
  color: #4a7;
}

.effect-item-row .effect-remove {
  width: 18px;
  height: 18px;
  border: none;
  background: #555;
  border-radius: 3px;
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
  line-height: 1;
}

.effect-item-row .effect-remove:active {
  background: #c44;
  color: #fff;
}

.add-effect-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px dashed #555;
  border-radius: 4px;
  color: #888;
  font-size: 12px;
  cursor: pointer;
}

.add-effect-btn:active {
  background: #333;
}

/* Top toolbar */
#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #202020;
}

#toolbar button {
  padding: 6px 12px;
  background: #333;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

#toolbar button:active {
  background: #555;
}

#toolbar button.active {
  background: #4a7;
}

#input-status {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: #888;
}

/* Effect panel (modal) */
#effect-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: flex-end;
  z-index: 100;
}

#effect-panel.open {
  display: flex;
}

#effect-panel .panel-content {
  width: 100%;
  max-height: 70vh;
  background: #252525;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  overflow-y: auto;
}

#effect-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#effect-panel .panel-title {
  font-size: 16px;
  font-weight: 600;
}

#effect-panel .panel-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

#effect-panel .effect-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

#effect-panel .effect-item {
  padding: 12px 8px;
  background: #333;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

#effect-panel .effect-item:active {
  background: #4a7;
}

/* Param panel (modal) */
#param-panel {
  position: fixed;
  inset: 0;
  background: transparent;
  display: none;
  align-items: flex-end;
  z-index: 101;
  pointer-events: none;
}

#param-panel.open {
  display: flex;
}

#param-panel .panel-content {
  pointer-events: auto;
  width: 100%;
  max-height: 60vh;
  background: #252525;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  overflow-y: auto;
}

#param-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#param-panel .panel-title {
  font-size: 16px;
  font-weight: 600;
}

#param-panel .panel-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

.param-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.param-label {
  width: 80px;
  font-size: 12px;
  color: #aaa;
}

.param-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #444;
  border-radius: 2px;
  outline: none;
}

.param-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #4a7;
  border-radius: 50%;
  cursor: pointer;
}

.param-value {
  width: 45px;
  text-align: right;
  font-size: 12px;
  color: #888;
  font-family: monospace;
}

.param-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
}
