* {
  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-bottom {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

#fullscreen-mode {
  display: none;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

#fullscreen-mode:active {
  background: rgba(255, 255, 255, 0.3);
}

/* Shutter button */
#fullscreen-shutter {
  width: 64px;
  height: 64px;
  padding: 0;
  background: transparent;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fullscreen-shutter:active {
  transform: scale(0.95);
}

.shutter-icon {
  width: 48px;
  height: 48px;
  background: #ea4335;
  border-radius: 50%;
  transition: border-radius 0.15s, width 0.15s, height 0.15s;
}

#fullscreen-shutter.recording .shutter-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
}

/* 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;
  transition: transform 0.1s, opacity 0.1s;
}

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

.layer-item.dragging {
  opacity: 0.5;
}

.layer-item.drag-over {
  border: 2px dashed #4a7;
  background: #3a4a3a;
}

.layer-drag-handle {
  color: #666;
  cursor: grab;
  font-size: 12px;
  letter-spacing: -2px;
  user-select: none;
}

.layer-drag-handle:active {
  cursor: grabbing;
}

.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 bar (horizontal scroll) */
.layer-effects {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  margin-top: -4px;
  margin-bottom: 8px;
  background: #2a2a2a;
  border-radius: 0 0 8px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.layer-effects::-webkit-scrollbar {
  height: 4px;
}

.layer-effects::-webkit-scrollbar-track {
  background: #222;
}

.layer-effects::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 2px;
}

.effect-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  background: #383838;
  border: none;
  border-radius: 4px;
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.effect-btn:active {
  background: #4a7;
  color: #fff;
}

.effect-btn-add {
  background: transparent;
  border: 1px dashed #555;
  color: #888;
  padding: 6px 14px;
}

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

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

/* 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;
}

.toolbar-spacer {
  flex: 1;
}

/* 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;
}

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

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

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

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

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

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

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-empty {
  text-align: center;
  color: #666;
  padding: 24px;
}

.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #333;
  border-radius: 8px;
}

.preset-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-name {
  font-size: 14px;
  color: #fff;
}

.preset-date {
  font-size: 11px;
  color: #666;
}

.preset-actions {
  display: flex;
  gap: 8px;
}

.preset-load {
  padding: 6px 12px;
  background: #4a7;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

.preset-load:active {
  background: #3a6;
}

.preset-delete {
  padding: 6px 10px;
  background: #555;
  border: none;
  border-radius: 4px;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
}

.preset-delete:active {
  background: #c44;
  color: #fff;
}
