.aqr-editor,
.aqr-editor * {
  box-sizing: border-box;
}

.aqr-editor {
  --aqr-bg: var(--bg, #f7f8fc);
  --aqr-surface: var(--surface, #ffffff);
  --aqr-soft: var(--soft, #eef1ff);
  --aqr-text: var(--text, #11182d);
  --aqr-muted: var(--muted, #647089);
  --aqr-line: var(--line, #dde3ef);
  --aqr-primary: var(--primary, #5b5cf0);
  --aqr-primary-2: var(--primary2, #7763ee);
  --aqr-green: var(--green, #11a977);
  --aqr-danger: var(--danger, #c4384d);
  --aqr-shadow: var(--shadow, 0 22px 70px rgba(31, 39, 83, 0.11));
  width: 100%;
  max-width: 1180px;
  margin: 30px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 410px);
  align-items: start;
  gap: 24px;
  color: var(--aqr-text);
  background: transparent;
  font: 16px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.aqr-controls,
.aqr-preview {
  min-width: 0;
  background: var(--aqr-surface);
  border: 1px solid var(--aqr-line);
  border-radius: 22px;
  box-shadow: 0 15px 50px rgba(35, 43, 88, 0.07);
  overflow: hidden;
}

.aqr-controls {
  padding: 25px;
}

.aqr-heading h2,
.aqr-preview-header h2 {
  margin: 0;
  color: var(--aqr-text);
  font-family: inherit;
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.aqr-step {
  display: block;
  margin-bottom: 4px;
  color: var(--aqr-primary);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.35;
  letter-spacing: 0.1em;
}

.aqr-url-field {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: #38445d;
  font-size: 0.91rem;
  font-weight: 750;
}

.aqr-url-field input {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  color: var(--aqr-text);
  background: var(--aqr-surface);
  border: 1px solid #d9dfeb;
  border-radius: 11px;
  font: inherit;
  outline: 0;
}

.aqr-url-field input::placeholder {
  color: #8c97aa;
}

.aqr-url-field input:focus {
  border-color: #9294f8;
  box-shadow: 0 0 0 4px rgba(91, 92, 240, 0.1);
}

.aqr-divider {
  margin: 27px 0;
  border: 0;
  border-top: 1px solid var(--aqr-line);
}

.aqr-styles {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.aqr-styles legend {
  margin-bottom: 10px;
  color: #38445d;
  font-size: 0.91rem;
  font-weight: 750;
}

.aqr-pack-tabs {
  margin-bottom: 10px;
  padding-bottom: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aqr-pack-tabs button {
  min-height: 38px;
  padding: 8px 13px;
  color: #55627a;
  background: var(--aqr-surface);
  border: 1px solid var(--aqr-line);
  border-radius: 10px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: 0.2s;
}

.aqr-pack-tabs button:hover {
  color: #4547bd;
  border-color: #cacaFF;
}

.aqr-pack-tabs button.is-active {
  color: #4547bd;
  background: #eeeeff;
  border-color: #cacaFF;
}

.aqr-style-grid {
  max-height: 430px;
  padding: 2px 7px 2px 2px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  scrollbar-color: #c8cede transparent;
  scrollbar-width: thin;
}

.aqr-style-grid button {
  min-height: 66px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--aqr-text);
  text-align: left;
  background: var(--aqr-surface);
  border: 1px solid var(--aqr-line);
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
}

.aqr-style-grid button[hidden] {
  display: none !important;
}

.aqr-style-grid button:hover {
  border-color: #cacaFF;
  transform: translateY(-1px);
}

.aqr-style-grid button.is-selected {
  color: #4547bd;
  background: #eeeeff;
  border-color: #b9baff;
  box-shadow: 0 0 0 2px rgba(91, 92, 240, 0.08);
}

.aqr-style-icon {
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  display: grid;
  place-items: center;
  color: var(--aqr-primary);
  background: var(--aqr-soft);
  border-radius: 11px;
  font-size: 23px;
  line-height: 1;
}

.is-selected .aqr-style-icon {
  color: #ffffff;
  background: linear-gradient(135deg, var(--aqr-primary), var(--aqr-primary-2));
  box-shadow: 0 8px 18px rgba(91, 92, 240, 0.2);
}

.aqr-style-grid button[data-aqr-style="glasses"] .aqr-style-icon {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.08em;
}

.aqr-style-grid button > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.aqr-style-grid strong {
  font-size: 0.82rem;
  font-weight: 800;
}

.aqr-style-grid small {
  overflow: hidden;
  color: var(--aqr-muted);
  font-size: 0.69rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.aqr-module-note {
  margin: 12px 2px 0;
  color: var(--aqr-muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.aqr-custom-request {
  margin: 14px 0 0;
  padding: 13px 15px;
  color: #55627a;
  background: #eeeeff;
  border: 1px solid #d7d8ff;
  border-radius: 11px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.55;
}

.aqr-custom-request a {
  color: var(--aqr-primary) !important;
  font-weight: 850;
  text-decoration: none;
}

.aqr-custom-request a:hover {
  text-decoration: underline;
}

.aqr-color-grid {
  margin-top: 17px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: var(--aqr-bg);
  border: 1px solid var(--aqr-line);
  border-radius: 14px;
}

.aqr-color-grid label {
  display: grid;
  grid-template-columns: 1fr 52px;
  align-items: center;
  gap: 10px;
  color: #38445d;
  font-size: 0.82rem;
  font-weight: 750;
}

.aqr-color-grid input[type="color"] {
  width: 52px;
  height: 46px;
  padding: 4px;
  background: var(--aqr-surface);
  border: 1px solid var(--aqr-line);
  border-radius: 11px;
  cursor: pointer;
}

.aqr-logo-uploader {
  margin-top: 17px;
}

.aqr-logo-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.aqr-logo-picker {
  min-height: 78px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--aqr-text);
  background: #fafaff;
  border: 1px dashed #bfc1fa;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s;
}

.aqr-logo-picker:hover {
  background: #f4f4ff;
  border-color: var(--aqr-primary);
}

.aqr-logo-input:focus-visible + .aqr-logo-picker {
  outline: 3px solid rgba(91, 92, 240, 0.25);
  outline-offset: 2px;
}

.aqr-logo-picker-icon {
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--aqr-primary), var(--aqr-primary-2));
  border-radius: 12px;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(91, 92, 240, 0.2);
}

.aqr-logo-picker > span:last-child,
.aqr-logo-selected > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.aqr-logo-picker strong,
.aqr-logo-selected strong {
  font-size: 0.88rem;
  font-weight: 800;
}

.aqr-logo-picker small,
.aqr-logo-selected small {
  overflow: hidden;
  color: var(--aqr-muted);
  font-size: 0.74rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.aqr-logo-selected {
  margin-top: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: #e9faf4;
  border: 1px solid #b9e8d8;
  border-radius: 12px;
}

.aqr-logo-selected[hidden] {
  display: none !important;
}

.aqr-logo-selected img {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid #d2e9e1;
  border-radius: 10px;
}

.aqr-logo-selected > span {
  flex: 1;
}

.aqr-logo-selected button {
  min-height: 36px;
  padding: 0 11px;
  color: #9c2e41;
  background: #ffffff;
  border: 1px solid #f0c2ca;
  border-radius: 9px;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}

.aqr-logo-tip,
.aqr-logo-error {
  margin: 9px 2px 0;
  color: var(--aqr-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.aqr-logo-error {
  color: var(--aqr-danger);
  font-weight: 750;
}

.aqr-logo-error:empty {
  display: none;
}

.aqr-frames {
  margin: 17px 0 0;
  padding: 0;
  border: 0;
}

.aqr-frames legend {
  margin-bottom: 10px;
  color: #38445d;
  font-size: 0.91rem;
  font-weight: 750;
}

.aqr-frame-grid {
  max-height: 430px;
  padding: 2px 7px 2px 2px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  scrollbar-color: #c8cede transparent;
  scrollbar-width: thin;
}

.aqr-frame-grid button {
  min-height: 120px;
  padding: 9px 8px 10px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  color: var(--aqr-text);
  text-align: center;
  background: var(--aqr-surface);
  border: 1px solid var(--aqr-line);
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
}

.aqr-frame-grid button:hover {
  border-color: #cacaFF;
  transform: translateY(-1px);
}

.aqr-frame-grid button.is-selected {
  color: #4547bd;
  background: #eeeeff;
  border-color: #b9baff;
  box-shadow: 0 0 0 2px rgba(91, 92, 240, 0.08);
}

.aqr-frame-icon {
  width: 68px;
  height: 72px;
  display: grid;
  place-items: center;
  color: var(--aqr-primary);
  background: transparent;
  border-radius: 10px;
  font-size: 21px;
  line-height: 1;
}

.aqr-frame-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.aqr-frame-grid button.is-selected .aqr-frame-icon {
  filter: drop-shadow(0 6px 10px rgba(91, 92, 240, 0.18));
}

.aqr-frame-grid button > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
  justify-items: center;
}

.aqr-frame-grid strong {
  font-size: 0.82rem;
  font-weight: 800;
}

.aqr-frame-grid small {
  overflow: hidden;
  color: var(--aqr-muted);
  font-size: 0.69rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.aqr-frame-text {
  margin-top: 14px;
  display: grid;
  gap: 7px;
  color: #38445d;
  font-size: 0.82rem;
  font-weight: 750;
}

.aqr-frame-text input {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  color: var(--aqr-text);
  background: var(--aqr-surface);
  border: 1px solid #d9dfeb;
  border-radius: 11px;
  font: inherit;
  outline: 0;
}

.aqr-frame-text input:focus {
  border-color: #9294f8;
  box-shadow: 0 0 0 4px rgba(91, 92, 240, 0.1);
}

.aqr-frame-text input:disabled {
  color: #9aa4b6;
  background: #f2f4f8;
  cursor: not-allowed;
}

.aqr-frame-text small {
  color: var(--aqr-muted);
  font-size: 0.73rem;
  font-weight: 500;
  line-height: 1.45;
}

.aqr-preview {
  position: sticky;
  top: 98px;
  display: flex;
  flex-direction: column;
  color: var(--aqr-text);
}

.admin-bar .aqr-preview {
  top: 130px;
}

.aqr-preview-header {
  padding: 23px 25px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  border-bottom: 1px solid var(--aqr-line);
}

.aqr-status {
  align-self: flex-start;
  padding: 5px 9px;
  color: #087f58;
  background: #e4f8f0;
  border: 1px solid #b9e8d8;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
}

.aqr-status.is-warning {
  color: #9c2e41;
  background: #fff0f2;
  border-color: #f0c2ca;
}

.aqr-stage {
  min-height: 410px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 15px;
  padding: 27px;
  background: linear-gradient(145deg, #f3f4ff, #eafff7);
}

.aqr-code {
  width: min(310px, 100%);
  aspect-ratio: 1;
  padding: 10px;
  background: var(--aqr-surface);
  border-radius: 17px;
  box-shadow: 0 16px 35px rgba(32, 42, 93, 0.13);
}

.aqr-code svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 11px;
}

.aqr-stage > p {
  max-width: 320px;
  margin: 0;
  color: var(--aqr-muted);
  font-size: 0.73rem;
  line-height: 1.55;
  text-align: center;
}

.aqr-stage .aqr-error {
  color: var(--aqr-danger);
  font-weight: 750;
}

.aqr-error:empty {
  display: none;
}

.aqr-downloads {
  padding: 18px 23px 23px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  background: var(--aqr-surface);
}

.aqr-downloads button {
  min-width: 0;
  min-height: 47px;
  padding: 0 18px;
  color: var(--aqr-text);
  background: var(--aqr-surface);
  border: 1px solid var(--aqr-line);
  border-radius: 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.aqr-downloads button:hover {
  transform: translateY(-2px);
}

.aqr-downloads button:first-child {
  color: #ffffff;
  background: linear-gradient(135deg, var(--aqr-primary), var(--aqr-primary-2));
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(91, 92, 240, 0.26);
}

.aqr-downloads button:focus-visible,
.aqr-style-grid button:focus-visible,
.aqr-frame-grid button:focus-visible,
.aqr-pack-tabs button:focus-visible,
.aqr-logo-selected button:focus-visible,
.aqr-custom-request a:focus-visible {
  outline: 3px solid rgba(91, 92, 240, 0.25);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .aqr-editor {
    grid-template-columns: 1fr;
  }

  .aqr-preview {
    position: static;
  }

  .aqr-style-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .aqr-editor {
    gap: 18px;
  }

  .aqr-controls {
    padding: 22px;
  }

  .aqr-preview-header {
    padding: 21px 22px;
  }

  .aqr-style-grid,
  .aqr-color-grid {
    grid-template-columns: 1fr;
  }

  .aqr-frame-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .aqr-style-grid {
    max-height: 390px;
  }

  .aqr-frame-grid {
    max-height: 390px;
  }

  .aqr-stage {
    min-height: 380px;
    padding: 22px;
  }

  .aqr-code {
    width: min(280px, 100%);
  }

  .aqr-downloads {
    grid-template-columns: 1fr;
  }
}
