/* Header */
header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
  position: sticky;
  top: 0;
  backdrop-filter: blur(6px);
  z-index: 5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

header .left {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Cards grid */
.cards {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* Footer */
footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
}

/* Builder layout */
.builder {
  display: grid;
  grid-template-columns: 180px 1fr;
  min-height: calc(100vh - 70px);
  transition: grid-template-columns 0.3s ease;
}

.builder.ad-pane-collapsed {
  grid-template-columns: 40px 1fr;
}

aside {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--panel);
  padding: 8px;
  overflow: auto;
}

main {
  padding: 8px 16px;
  overflow: auto;
}

/* Sections & grids inside builder - Free-flowing, no boxed appearance */
.section {
  background: transparent;
  backdrop-filter: none;
  border: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: var(--space-4);
  margin-top: 0;
  transition: none;
}

/* Remove top margin from first section in builder */
#adPane > .section:first-child,
#builderView .section:first-child {
  margin-top: 0;
}
.section:hover {
  box-shadow: none;
  border-color: transparent;
}

.g2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
  justify-items: start;
}

/* Single column grid for sections declaring cols:1 */
.g1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Auto grid: two columns when width allows, stack on narrow screens */
.gauto {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 16px;
  align-items: start;
  justify-items: start;
}
@media (min-width: 720px) {
  .gauto { grid-template-columns: 1fr 1fr; }
}

/* Field wrapper ensures label above input and limits width */
.section .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 80%;
}

/* In multi-column grids, ensure field fills its column */
.g2 .field, .gauto .field { width: 100%; }

/* Responsive: on narrow screens let fields use full width */
@media (max-width: 720px) {
  .section .field { max-width: 100%; }
}

/* When in single column grid, let field take full width but respect max */
.g1 .field {
  max-width: 80%;
}

/* Labels above inputs; help icon alignment */
.section .field > label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Ensure inputs don't exceed container */
.section .field input[type="text"],
.section .field input[type="number"],
.section .field select,
.section .field textarea,
.section .field .range-row {
  width: 100%;
}

/* Checkbox chip should not stretch full width */
.section .field .chip {
  width: auto;
  align-self: flex-start;
}

/* Checkbox chip left aligned under label */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 90px; /* range grows, number is compact */
  gap: 8px;
  align-items: center;
}
.range-row input[type="range"]{ width: 100%; }
.range-row input[type="number"]{
  width: 100%;
  min-width: 0;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--input-bg);
}
@media (hover:hover){
  .range-row input[type="number"]:hover{ background: var(--input-bg-hover); }
}
@media (max-width: 560px){
  .range-row { grid-template-columns: 1fr; }
}
