/* UI-only anchor-overlap candidate. No ad/CMP selectors or z-index escalation. */
.kt-consent-ui {
  color: #18202b;
  background: #fff;
  border: 1px solid #68788b;
  border-radius: .65rem;
  box-shadow: 0 .2rem 1rem #0002;
  box-sizing: border-box;
  --kt-consent-admin-clearance: 0px;
  --kt-consent-closed-top-space: max(6rem, calc(var(--kt-consent-admin-clearance) + 4rem), env(safe-area-inset-top));
  --kt-consent-top-space: max(4rem, calc(var(--kt-consent-admin-clearance) + .75rem), env(safe-area-inset-top));
  --kt-consent-lower-space: max(9rem, 25dvh, env(safe-area-inset-bottom));
  position: fixed;
  inset-inline-end: max(.75rem, env(safe-area-inset-right));
  inset-block-start: var(--kt-consent-top-space);
  inset-block-end: auto;
  z-index: 10000;
  width: min(34rem, calc(100vw - 1.5rem));
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--kt-consent-top-space) - var(--kt-consent-lower-space) - .75rem);
  overflow: hidden;
  padding: .75rem;
  font: 1rem/1.55 system-ui, -apple-system, sans-serif;
  text-align: start;
  overflow-wrap: anywhere;
  color-scheme: light;
}
/* The ordinary page keeps only one compact labeled control. Its lower closed
 * offset clears the observed SWELL mobile header; opening uses the independent
 * upper panel placement above, preserving its action-scroll budget. */
.kt-consent-ui[data-consent-open="false"] {
  inset-block-start: var(--kt-consent-closed-top-space);
  width: max-content;
  max-width: calc(100vw - 1.5rem);
  max-height: none;
  padding: .4rem;
  overflow: visible;
}
/* Keep role=status / aria-live in the accessibility tree without a visual box.
 * Do not use display:none, visibility:hidden or aria-hidden for this region. */
.kt-consent-ui[data-consent-open="false"] > .kt-consent-ui__status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.kt-consent-ui *, .kt-consent-ui *::before, .kt-consent-ui *::after { box-sizing: border-box; }
.kt-consent-ui [hidden] { display: none !important; }
.kt-consent-ui__panel {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  min-block-size: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: .25rem .25rem .75rem;
}
.kt-consent-ui__title { margin: 0 5rem .65rem 0; font-size: 1.2rem; line-height: 1.4; }
.kt-consent-ui__description, .kt-consent-ui__help, .kt-consent-ui__status { margin: .6rem 0; }
.kt-consent-ui__status, .kt-consent-ui__help, .kt-consent-ui__privacy { font-size: .875rem; }
.kt-consent-ui__status { flex: 0 0 auto; }
.kt-consent-ui__status:last-child { margin-block-end: 0; }
.kt-consent-ui__button {
  appearance: none;
  color: #153963;
  background: #fff;
  border: 2px solid #254d7b;
  border-radius: .35rem;
  min-height: 44px;
  padding: .55rem .8rem;
  font: inherit;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
}
.kt-consent-ui__button:hover { background: #eaf1fa; }
.kt-consent-ui__button:disabled { cursor: default; opacity: .6; }
.kt-consent-ui__button:focus-visible, .kt-consent-ui__privacy:focus-visible, .kt-consent-ui__title:focus-visible {
  outline: 3px solid #065fca;
  outline-offset: 3px;
}
.kt-consent-ui__close { position: absolute; inset-inline-end: 0; inset-block-start: 0; min-width: 4rem; }
.kt-consent-ui__bar { flex: 0 0 auto; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.kt-consent-ui__privacy { color: #174e8b; text-decoration: underline; text-underline-offset: .15em; }
.kt-consent-ui__choices { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-block: .85rem; }
/* Allow and Reject have identical visual weight, order-independent styles. */
.kt-consent-ui__choices > .kt-consent-ui__button { width: 100%; }
.kt-consent-ui__actions > .kt-consent-ui__button { display: block; margin-block: .7rem; }
.kt-consent-ui__withdrawal { border-block-start: 1px solid #8794a4; padding-block-start: .75rem; margin-block-start: .9rem; }
/* WordPress's existing toolbar is independent of the consent/CMP layer. */
body.admin-bar .kt-consent-ui,
#wpadminbar ~ .kt-consent-ui { --kt-consent-admin-clearance: 32px; }
@media (max-width: 782px) {
  body.admin-bar .kt-consent-ui,
  #wpadminbar ~ .kt-consent-ui { --kt-consent-admin-clearance: 46px; }
}
@media (max-width: 28rem) {
  .kt-consent-ui { padding: .65rem; font-size: .95rem; }
  .kt-consent-ui__choices { grid-template-columns: 1fr; }
}
/* Preserve a usable panel in short landscape viewports. The trigger stays
 * outside the scroll area, above the reserved lower band. */
@media (max-height: 30rem) {
  .kt-consent-ui {
    --kt-consent-top-space: max(3.5rem, calc(var(--kt-consent-admin-clearance) + .75rem), env(safe-area-inset-top));
    --kt-consent-lower-space: max(8rem, 25dvh, env(safe-area-inset-bottom));
    padding: .4rem;
  }
}
@media (forced-colors: active) {
  .kt-consent-ui { border: 1px solid CanvasText; box-shadow: none; }
  .kt-consent-ui__button { border: 2px solid ButtonText; }
}
@media print { .kt-consent-ui { display: none; } }

/* Coherent open-panel geometry: decorative space is viewport/pixel bounded,
 * never multiplied by the theme's text size. At a 16px root and normal desktop
 * height this matches the existing top/lower/panel spacing. Text still scales. */
.kt-consent-ui[data-consent-open="true"] {
  --kt-consent-top-space: max(calc(var(--kt-consent-admin-clearance) + 8px), clamp(8px, calc(100dvh - 360px), 64px), env(safe-area-inset-top));
  --kt-consent-lower-space: max(clamp(8px, calc(100dvh - 246px), max(156px, calc(25dvh + 12px))), env(safe-area-inset-bottom));
  --kt-consent-layout-padding: clamp(4px, calc(5dvh - 16px), 12px);
  max-height: calc(100dvh - var(--kt-consent-top-space) - var(--kt-consent-lower-space));
  padding: var(--kt-consent-layout-padding);
}
.kt-consent-ui[data-consent-open="true"] .kt-consent-ui__panel {
  min-height: 0;
  min-block-size: 0;
  padding: 4px 4px var(--kt-consent-layout-padding);
}
.kt-consent-ui[data-consent-open="true"] .kt-consent-ui__button {
  padding: 8px 12px;
}
/* Closed geometry changes only at short heights. Normal desktop placement is
 * untouched; this clamp prevents theme rem size putting the control offscreen. */
@media (max-height: 480px) {
  .kt-consent-ui[data-consent-open="false"] {
    --kt-consent-closed-top-space: min(110px, max(calc(var(--kt-consent-admin-clearance) + 8px), calc(100dvh - 160px)));
    padding: 4px;
    max-height: calc(100dvh - var(--kt-consent-closed-top-space) - 8px);
  }
  .kt-consent-ui[data-consent-open="false"] .kt-consent-ui__button {
    padding: 8px 12px;
  }
}
/* Drop only the redundant open trigger where enlarged, wrapped labels need its
 * space. Existing Close/Escape remain. The spacing formula does not switch back
 * to unsafe rem geometry above this breakpoint. At extreme heights, the lower
 * reserve must shrink; real anchor overlap there remains an explicit limit. */
@media (max-height: 456px) {
  .kt-consent-ui[data-consent-open="true"] .kt-consent-ui__bar {
    display: none;
  }
}
