html, body {
  height: 100%;
  margin: 0;
}

/* Base theme */
:root {
  --ch-gap: 12px;
  --ch-bg: #0f172a;
  --ch-card: rgba(17, 24, 39, 0.94);
  --ch-text: #e5e7eb;
  --ch-border-radius: 12px;
}

* { box-sizing: border-box; }

body .ch-container {
  position: relative;
  width: 100%;
  height: 100vh;
  padding: var(--ch-gap);
  background-color: var(--ch-bg);
  color: var(--ch-text);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica', 'Arial', sans-serif;
  overflow: hidden;
}

.ch-zone {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--ch-card);
  border-radius: var(--ch-border-radius);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
  transition: box-shadow 0.15s ease;
  overflow: hidden;
}

.ch-zone:focus-within,
.ch-zone:hover {
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.45);
}

.ch-zone-surface {
  display: flex;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.ch-zone[data-content-type="media"] .ch-zone-surface {
  padding: 0;
  background: #000;
}

.ch-zone-player {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.ch-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  will-change: opacity, filter, transform;
}

.ch-media-enter {
  animation: ch-media-appear 0.6s ease forwards;
}

@keyframes ch-media-appear {
  0% {
    opacity: 0;
    filter: blur(18px);
    transform: scale(1.04);
  }
  60% {
    opacity: 1;
    filter: blur(6px);
    transform: scale(1.01);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
}

.ch-zone[data-content-type="html"] .ch-zone-surface {
  padding: 18px;
  justify-content: center;
  align-items: center;
}

.ch-zone-html {
  width: 100%;
  height: 100%;
  overflow: auto;
  color: var(--ch-text);
  font-size: 1.15rem;
  line-height: 1.45;
}

.ch-zone-html::-webkit-scrollbar {
  width: 10px;
}

.ch-zone-html::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.ch-zone-placeholder {
  opacity: 0.6;
  font-size: 1rem;
}

@media (max-width: 1024px) {
  body .ch-container {
    padding: 10px;
  }
}

@media (max-width: 780px) {
  body .ch-container {
    height: auto;
    min-height: 100vh;
    padding: 8px;
  }
}

/* Layout editor overlays */
.ch-layout-editor-active .ch-zone {
  outline: 1px dashed rgba(148, 163, 184, 0.35);
}

.ch-layout-overlay {
  position: absolute;
  border: 2px dashed rgba(59, 130, 246, 0.85);
  background: rgba(59, 130, 246, 0.12);
  pointer-events: auto;
  z-index: 40;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
}

.ch-layout-overlay .ch-overlay-label {
  position: absolute;
  left: 0;
  bottom: 100%;
  transform: translateY(-6px);
  background: rgba(37, 99, 235, 0.94);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  pointer-events: none;
}

.ch-layout-overlay .ch-overlay-size {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.ch-layout-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #2563eb;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
}

.ch-layout-handle.nw { left: -10px; top: -10px; cursor: nwse-resize; }
.ch-layout-handle.se { right: -10px; bottom: -10px; cursor: nwse-resize; }

.ch-layout-overlay.dragging,
.ch-layout-overlay.resizing { cursor: move; }

.ch-layout-info {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 45;
}

.ch-layout-save {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 45;
  background: #2563eb;
  color: #fff;
  border: 0;
  padding: 9px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.ch-layout-save:hover { filter: brightness(1.08); }
.ch-layout-save:disabled { opacity: 0.6; cursor: progress; }

.ch-dragging { user-select: none; }
