* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at top, #f1f5ff 0%, #e4ecff 40%, #f7faff 100%);
  color: #1f2933;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.challenge-layout {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(400px, 2fr) minmax(200px, 1fr);
  gap: 16px;
  width: 100%;
  padding: 40px 32px;
  flex: 1;
  align-content: stretch;
}

#instructions,
#editor-area,
#preview-area {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  box-shadow: 0 15px 45px -20px rgba(15, 23, 42, 0.3);
  padding: 24px;
  backdrop-filter: blur(12px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

#editor-area {
  gap: 16px;
}
.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.editor-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.editor-meta h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1f2933;
}
.editor-tabs {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.editor-tab {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.editor-tab.is-active {
  background: #246bff;
  color: #f8fafc;
  box-shadow: 0 6px 16px -8px rgba(36, 107, 255, 0.7);
}
.editor-tab:focus-visible {
  outline: 2px solid #246bff;
  outline-offset: 2px;
}
.editor-tip {
  font-size: 0.85rem;
  color: #64748b;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 999px;
  padding: 4px 12px;
}
.editor-panels {
  flex: 1;
  min-height: 0;
  position: relative;
}
.editor-panel {
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  display: none;
}
.editor-panel.is-active {
  display: block;
}
#editor-container,
#html-viewer {
  height: 100%;
}
#html-viewer {
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}
#instructions h2 {
  margin-top: 0;
  font-size: 1.6rem;
  color: #1a56db;
}
#instructions p {
  margin-bottom: 0;
  line-height: 1.5;
  color: #475569;
}
#instructions ul {
  margin: 16px 0 0;
  padding-left: 18px;
  color: #475569;
  line-height: 1.5;
}
#editor-container {
  flex: 1;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}

iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  background: #f8fafc;
  flex: 1;
  min-height: 0;
}

#preview-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -6px;
  width: 12px;
  cursor: col-resize;
  background: linear-gradient(180deg, rgba(94, 96, 206, 0.08), rgba(36, 107, 255, 0.18));
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#preview-area:hover #preview-resizer,
body.resizing #preview-resizer {
  opacity: 1;
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

body.resizing iframe {
  pointer-events: none;
}

.challenge-footer {
  width: 100%;
  padding: 0 32px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#check-btn {
  padding: 12px 28px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #246bff, #5e60ce);
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 12px 30px -12px rgba(36, 107, 255, 0.7);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#check-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px -16px rgba(36, 107, 255, 0.8);
}

#check-btn:active {
  transform: translateY(1px);
  box-shadow: 0 8px 20px -14px rgba(36, 107, 255, 0.9);
}

#feedback-msg {
  flex: 1;
  font-size: 0.95rem;
  color: #334155;
}

@media (max-width: 1024px) {
  .challenge-layout {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(280px, auto);
    padding: 32px 20px;
  }

  .challenge-footer {
    flex-direction: column;
    align-items: stretch;
    padding: 0 20px 32px;
  }

  #check-btn {
    width: 100%;
  }
}