.home-page {
  padding-top: 68px;
}

.home-page .topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  width: 100%;
}

.home-page .topbar .product-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(430px, 100%);
}

.home-page .topbar .product-nav-button {
  width: 100%;
  min-width: 0;
  padding-inline: 12px;
}

.home-page > main {
  height: calc(100dvh - 68px);
  grid-template-rows: minmax(0, 1fr) 90px;
}

.restore-source-panel .restore-editor-footer {
  min-height: 34px;
  padding-bottom: 0;
}

.restore-result-panel {
  padding-bottom: 34px;
}

.side-ad,
.bottom-ad {
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.side-ad iframe,
.bottom-ad iframe {
  display: block;
  flex: 0 0 auto;
  border: 0;
}

.side-ad {
  display: none;
  position: fixed;
  top: 82px;
  z-index: 10;
  width: 160px;
  height: 600px;
  overflow: visible;
}

.side-ad-left {
  left: 8px;
}

.side-ad-right {
  right: 8px;
}

.side-ad iframe {
  width: 160px;
  height: 600px;
}

.home-page .bottom-ad {
  position: fixed;
  right: auto;
  bottom: 10px;
  left: 50%;
  z-index: 20;
  display: flex;
  width: min(970px, calc(100% - 32px));
  height: 90px;
  margin: 0;
  transform: translateX(-50%);
  justify-content: center;
}

.bottom-ad iframe {
  width: 970px;
  height: 90px;
}

.affiliate-disclosure {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.home-page .site-footer {
  padding-bottom: 128px;
}

@media (min-width: 1180px) and (min-height: 700px) {
  .side-ad {
    display: block;
  }

  .home-page > main {
    width: min(1360px, calc(100% - 360px));
  }

  .content-shell,
  .site-footer-inner,
  .affiliate-disclosure {
    width: min(1120px, calc(100% - 360px));
  }
}

@media (max-height: 800px) {
  .home-page {
    padding-top: 58px;
  }

  .home-page > main {
    height: calc(100dvh - 58px);
    grid-template-rows: minmax(0, 1fr) 90px;
  }

  .side-ad {
    top: 68px;
  }

  .restore-source-panel .restore-editor-footer {
    min-height: 26px;
    padding-top: 5px;
  }

  .restore-result-panel {
    padding-bottom: 26px;
  }
}

@media (max-width: 760px) {
  .home-page {
    padding-top: 64px;
  }

  .home-page > main {
    height: calc(100dvh - 64px);
    grid-template-rows: minmax(0, 1fr) 90px;
  }

  .home-page .bottom-ad {
    bottom: 6px;
    width: calc(100% - 16px);
  }

  .affiliate-disclosure {
    width: calc(100% - 32px);
  }

  .restore-source-panel .restore-editor-footer {
    min-height: 22px;
    padding: 4px 1px 0;
  }

  .restore-result-panel {
    padding-bottom: 22px;
  }
}

/* Phone and narrow-tablet layout: keep each editor readable instead of
   squeezing the comparison into two narrow columns. */
@media (max-width: 899px) {
  .home-page {
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .home-page > main {
    display: block;
    width: calc(100% - 16px);
    height: auto;
    min-height: calc(100dvh - 64px);
    padding: 10px 0 108px;
    overflow: visible;
  }

  .home-page .workspace,
  .home-page .editor-card.unified-card,
  .home-page .live-grid {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .home-page .editor-card.unified-card {
    padding: 12px;
  }

  .home-page .live-grid {
    --mobile-editor-height: clamp(280px, 45dvh, 380px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    gap: 18px;
  }

  .home-page .live-grid > .comparison-panel {
    width: 100%;
    height: auto;
    min-width: 0;
  }

  .home-page .source-editor-stack,
  .home-page .restore-editor-stack {
    height: var(--mobile-editor-height) !important;
    min-height: var(--mobile-editor-height);
    flex: 0 0 var(--mobile-editor-height);
  }

  .home-page .source-editor-stack .compare-input,
  .home-page .source-editor-stack .highlight-backdrop,
  .home-page .result-panel > .compare-surface,
  .home-page .restore-editor-stack .restore-compare-input {
    width: 100%;
    height: var(--mobile-editor-height) !important;
    min-height: var(--mobile-editor-height) !important;
    max-height: var(--mobile-editor-height) !important;
    padding: 15px !important;
    font-size: 16px !important;
    line-height: 1.7 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .home-page .result-panel,
  .home-page .restore-result-panel {
    padding-bottom: 0;
  }

  .home-page .panel-head {
    min-height: 36px;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px 12px;
  }

  .home-page .panel-head label,
  .home-page .panel-head > span:first-child,
  .home-page .result-heading > span:first-child {
    font-size: 16px;
    line-height: 1.3;
    word-break: keep-all;
    overflow-wrap: normal;
  }

  .home-page .micro-actions,
  .home-page .result-actions {
    margin-left: auto;
    flex-wrap: nowrap;
  }

  .home-page .text-button,
  .home-page .protect-action,
  .home-page .compact-result-action {
    white-space: nowrap;
  }

  .home-page .source-panel .protect-action {
    order: 0;
  }

  .home-page .inline-results,
  .home-page .restore-summary {
    max-height: none;
    overflow: visible;
  }

  .home-page .inline-results .summary,
  .home-page .restore-summary .summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-page .inline-results .summary-item,
  .home-page .restore-summary .summary-item {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .home-page .source-panel .panel-head > label {
    flex: 1 1 100%;
  }

  .home-page .source-panel .micro-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
