.autovasp-page {
  --tool-width: 1320px;
  padding: clamp(36px, 5vw, 66px) clamp(20px, 5vw, 64px) clamp(48px, 6vw, 76px);
}

.tool-hero,
.template-section,
.config-layout {
  width: min(100%, var(--tool-width));
  margin-inline: auto;
}

.tool-hero {
  display: flex;
  gap: 28px;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.tool-kicker,
.section-index {
  margin: 0 0 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-hero h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(2.1rem, 5vw, 4.3rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.04;
}

.tool-hero p:last-child {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.template-section {
  padding: 32px 0 38px;
  border-bottom: 1px solid var(--line);
}

.section-heading,
.group-header,
.preview-header {
  display: flex;
  gap: 22px;
  align-items: flex-end;
  justify-content: space-between;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2,
.group-header h2,
.preview-header h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 1.3rem;
  font-weight: 800;
}

.section-heading > p,
.group-header > p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.template-card {
  min-width: 0;
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.template-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.template-card.is-active {
  border-color: #202124;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px #202124;
}

.template-card strong,
.template-card small {
  display: block;
}

.template-card strong {
  color: var(--text-strong);
  font-size: 0.93rem;
  line-height: 1.4;
}

.template-card small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.48;
}

.config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 0.72fr);
  gap: 28px;
  align-items: start;
  padding-top: 38px;
}

.parameter-groups {
  display: grid;
  min-width: 0;
  gap: 26px;
}

.parameter-group {
  min-width: 0;
}

.group-header {
  margin-bottom: 12px;
}

.parameter-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.parameter-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(220px, 1.1fr);
  gap: 18px;
  align-items: center;
  min-height: 74px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.parameter-card:last-child {
  border-bottom: 0;
}

.parameter-card:hover {
  background: var(--surface-soft);
}

.parameter-card.is-textarea {
  align-items: start;
}

.parameter-meta {
  display: flex;
  min-width: 0;
  gap: 9px;
  align-items: center;
}

.parameter-name {
  min-width: 0;
}

.parameter-name strong,
.parameter-name code {
  display: block;
}

.parameter-name strong {
  color: var(--text-strong);
  font-size: 0.92rem;
  line-height: 1.38;
}

.parameter-name code {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.help-wrap {
  position: relative;
  flex: 0 0 auto;
}

.help-button {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.help-button:hover,
.help-button[aria-expanded="true"] {
  border-color: var(--line-strong);
  color: var(--text-strong);
  background: var(--accent-soft);
}

.help-popover {
  position: absolute;
  z-index: 30;
  top: 31px;
  left: 0;
  width: min(360px, calc(100vw - 48px));
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 18px 48px rgba(24, 24, 24, 0.14);
  font-size: 0.82rem;
  line-height: 1.62;
}

.help-popover[hidden] {
  display: none;
}

.help-popover dl {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0;
}

.help-popover dt {
  color: var(--text-strong);
  font-weight: 800;
}

.help-popover dd {
  margin: 0;
  color: var(--muted);
}

.parameter-control,
.array-control {
  min-width: 0;
}

.parameter-control input[type="text"],
.parameter-control input[type="number"],
.parameter-control select,
.parameter-control textarea,
.array-control input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.parameter-control textarea {
  min-height: 142px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
}

.parameter-control input:focus,
.parameter-control select:focus,
.parameter-control textarea:focus,
.array-control input:focus {
  border-color: #333;
  outline: 2px solid rgba(32, 33, 36, 0.12);
  outline-offset: 1px;
}

.array-control {
  display: grid;
  grid-template-columns: repeat(var(--array-columns, 3), minmax(0, 1fr));
  gap: 8px;
}

.array-control.is-fluid {
  display: block;
}

.control-note,
.validation-message {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

.validation-message {
  color: var(--danger);
}

.switch-control {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #e8e8e5;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.switch-control input:checked + .switch-track {
  border-color: #111;
  background: #111;
}

.switch-control input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 2px solid #252525;
  outline-offset: 4px;
}

.switch-value {
  min-width: 62px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.script-preview {
  position: sticky;
  top: 18px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.parameter-count {
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--accent-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 10px;
}

.tool-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tool-button:hover {
  border-color: #1d1d1d;
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.tool-button-primary {
  border-color: #111;
  color: #fff;
  background: #111;
}

.tool-button-primary:hover {
  color: #fff;
  background: #2b2b2b;
}

.tool-button-quiet {
  margin-left: auto;
  color: var(--muted);
}

.preview-status {
  min-height: 1.4em;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.script-code {
  max-height: calc(100vh - 230px);
  min-height: 560px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #24313f;
  background: #f7f8fa;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.62;
  white-space: pre;
  overflow: auto;
}

.script-code code {
  font: inherit;
}

@media (max-width: 1180px) {
  .template-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .config-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.78fr);
  }

  .parameter-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .switch-control {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .config-layout {
    grid-template-columns: 1fr;
  }

  .script-preview {
    position: static;
  }

  .script-code {
    max-height: 680px;
    min-height: 420px;
  }
}

@media (max-width: 760px) {
  .autovasp-page {
    padding: 30px 18px 44px;
  }

  .tool-hero,
  .section-heading,
  .group-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .tool-hero {
    gap: 20px;
  }

  .section-heading > p,
  .group-header > p {
    text-align: left;
  }

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

  .parameter-card {
    padding: 14px;
  }

  .help-popover {
    position: fixed;
    top: auto;
    right: 16px;
    bottom: 16px;
    left: 16px;
    width: auto;
    max-height: 58vh;
    overflow: auto;
  }
}

@media (max-width: 480px) {
  .template-list {
    grid-template-columns: 1fr;
  }

  .template-card {
    min-height: 0;
  }

  .array-control {
    grid-template-columns: 1fr;
  }

  .preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tool-button-quiet {
    grid-column: 1 / -1;
    margin-left: 0;
  }

  .script-code {
    margin-inline: -8px;
    font-size: 0.7rem;
  }
}
