.editor-page {
  width: min(100% - 32px, 1440px);
  margin: 0 auto;
  padding: 28px 0 56px;
}

.panel-heading h1,
.preview-heading h2,
.download-section h3 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.source-state {
  margin: -5px 0 14px;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 12px;
}

.source-state.is-error {
  border: 1px solid rgba(255, 133, 139, 0.4);
  color: #ffc0c4;
  background: rgba(255, 133, 139, 0.06);
}

.mobile-workspace-tabs {
  position: sticky;
  z-index: 35;
  top: 80px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(7, 10, 15, 0.96);
  backdrop-filter: blur(12px);
}

.mobile-tab {
  color: var(--muted);
  background: transparent;
}

.mobile-tab.is-active {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

.editor-workspace {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}

.settings-panel,
.preview-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading,
.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h1,
.preview-heading h2 {
  margin-top: 3px;
  font-size: 20px;
}

.theme-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 20px;
  border: 0;
  border-bottom: 1px solid var(--border);
}

.theme-form legend {
  float: left;
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.theme-form legend + * {
  clear: both;
}

.field-help {
  margin: 4px 0 14px;
  color: var(--subtle);
  font-size: 12px;
}

.theme-picker-help {
  clear: both;
  margin: -6px 0 12px;
}

.theme-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 8px;
  min-height: var(--theme-option-placeholder-height, 60px);
  margin-top: 10px;
}

.theme-option {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 60px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  gap: 5px 8px;
  padding: 9px 44px 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface-2);
  font: inherit;
  text-align: left;
  touch-action: manipulation;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.theme-option[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent), transparent 38%);
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent), transparent 88%), color-mix(in srgb, var(--accent), transparent 96%));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent), transparent 88%);
}

.theme-option:focus-visible {
  outline-color: var(--focus);
}

.theme-option__name {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.theme-option__palette {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  grid-column: 1;
  grid-row: 2;
}

.theme-option__swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.theme-option__check {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 20px;
  height: 20px;
  color: var(--accent);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 150ms ease;
}

.theme-option__label {
  position: absolute;
  top: 0;
  right: 12px;
  z-index: 1;
  display: block;
  max-width: calc(100% - 24px);
  padding: 4px 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  font-size: 10px;
  font-weight: 850;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateY(-50%);
  pointer-events: none;
}

.theme-option__check circle,
.theme-option__check path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.theme-option__check path {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-option[aria-pressed="true"] .theme-option__check {
  opacity: 1;
}

@media (hover: hover) {
  .theme-option:hover {
    border-color: var(--border-strong);
    background-color: var(--surface-3);
    transform: translateY(-1px);
  }

  .theme-option[aria-pressed="true"]:hover {
    border-color: var(--accent);
  }
}

@media (max-width: 430px) {
  .theme-option-grid {
    min-height: var(--theme-option-mobile-placeholder-height, 60px);
    grid-template-columns: minmax(0, 1fr);
  }
}

.toggle-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.toggle {
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.toggle:has(input:checked) {
  border-color: rgba(67, 217, 139, 0.34);
  color: var(--text);
  background: rgba(67, 217, 139, 0.045);
}

.toggle input {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  accent-color: var(--success);
}

.toggle span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.custom-buttons-editor {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.custom-buttons-editor h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.custom-buttons-editor__description {
  max-width: 52ch;
  margin: -3px 0 2px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}

.custom-button-list:empty {
  display: none;
}

.custom-button-list {
  display: grid;
  gap: 8px;
}

.custom-button-empty {
  margin: 2px 0 0;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.custom-button-empty[hidden] {
  display: none;
}

.custom-button-row {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.custom-button-swatch {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.035);
}

.custom-button-row__copy {
  min-width: 0;
}

.custom-button-row__copy strong,
.custom-button-row__copy small {
  display: block;
  min-width: 0;
}

.custom-button-row__copy strong {
  color: var(--text);
  font-size: 12px;
}

.custom-button-row__copy small {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--subtle);
  font: 600 10px/1.4 ui-monospace, Consolas, monospace;
}

.custom-button-row__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-button-delete {
  min-width: 44px;
  padding-inline: 8px;
}

.custom-button-delete svg {
  display: block;
  width: 18px;
  height: 18px;
}

.custom-button-add {
  width: fit-content;
  min-width: min(100%, 176px);
  min-height: 44px;
  margin-inline: auto;
  padding: 9px 13px;
}

.advanced-panel {
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 16, 0.2);
}

.advanced-panel summary {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-panel summary span,
.advanced-panel summary strong,
.advanced-panel summary small { display: block; }
.advanced-panel summary strong { font-size: 14px; }
.advanced-panel summary small { margin-top: 3px; color: var(--subtle); font-size: 11px; font-weight: 600; }
.advanced-panel summary svg { width: 20px; height: 20px; flex: 0 0 20px; color: var(--muted); transition: transform .16s ease; }
.advanced-panel[open] summary svg { transform: rotate(180deg); }
.advanced-panel summary:focus-visible { outline: 3px solid rgba(130,184,244,.45); outline-offset: -3px; }
.advanced-panel__body { display: grid; gap: 18px; padding: 0 20px 22px; }
.advanced-group { display: grid; gap: 12px; }
.advanced-group h3 { margin: 0; color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.advanced-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 9px; }
.behavior-field { display: flex; min-width: 0; min-height: 64px; align-items: center; justify-content: space-between; gap: 14px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); background: var(--surface-2); cursor: pointer; transition: border-color .16s ease,background-color .16s ease,color .16s ease; }
.behavior-field:has(input:checked) { border-color: rgba(67,217,139,.34); color: var(--text); background: rgba(67,217,139,.045); }
.behavior-field__copy { display: grid; min-width: 0; gap: 4px; }
.behavior-field__copy strong { color: var(--text); font-size: 12px; }
.behavior-field__copy small { color: var(--subtle); font-size: 11px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.behavior-field__dependency { color: #ffd477!important; }
.behavior-field input { width: 19px; height: 19px; flex: 0 0 19px; accent-color: var(--success); }
.behavior-field.is-dependent-disabled { border-style: dashed; color: var(--subtle); cursor: not-allowed; filter: saturate(.55); }
.behavior-field.is-dependent-disabled .behavior-field__copy strong { color: var(--muted); }
.behavior-field.is-dependent-disabled input { cursor: not-allowed; }
.advanced-field,
.color-field,
.range-field { min-width: 0; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); background: var(--surface-2); font-size: 12px; font-weight: 750; }
.advanced-field { display: grid; gap: 7px; padding: 11px; }
.advanced-field select { width: 100%; min-height: 42px; padding: 0 34px 0 10px; border: 1px solid #3a4658; border-radius: 8px; color: var(--text); background: #101620; font: inherit; }
.color-field { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 6px; padding: 9px; }
.color-control { display: flex; min-width: 0; flex: 0 0 auto; align-items: center; gap: 6px; }
.color-control input[type="color"] { width: 34px; min-width: 34px; height: 34px; flex: 0 0 34px; padding: 3px; overflow: hidden; border: 1px solid #3a4658; border-radius: 8px; background: #101620; cursor: pointer; }
.color-control input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-control input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-control input[type="color"]::-moz-color-swatch { border: 0; border-radius: 5px; }
.color-control output { min-width: 48px; flex: 0 0 48px; color: var(--subtle); font: 650 9px/1 ui-monospace,Consolas,monospace; text-align: right; }
.range-field { display: grid; gap: 10px; padding: 11px; }
.range-field > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.range-field output { color: var(--accent); font-size: 11px; }
.range-field input { width: 100%; min-height: 30px; accent-color: var(--accent); cursor: pointer; }
.advanced-field select:focus-visible,
.behavior-field input:focus-visible,
.color-control input:focus-visible,
.range-field input:focus-visible { outline: 3px solid rgba(130,184,244,.45); outline-offset: 2px; }

.download-section {
  padding: 20px;
}

.download-section h3 {
  margin-top: 4px;
  font-size: 19px;
}

.download-section > p {
  margin: 7px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.device-serial-field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.device-serial-field input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  background: #0c121a;
  font: 650 16px/1.3 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.device-serial-field small {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.device-serial-field input[aria-invalid="true"] {
  border-color: rgba(255, 133, 139, .78);
  background: rgba(255, 133, 139, .045);
}

.device-status {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 62px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-2);
}

.device-status__indicator {
  width: 12px;
  height: 12px;
  justify-self: center;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.device-status__copy { min-width: 0; }
.device-status strong,
.device-status small { display: block; overflow-wrap: anywhere; }
.device-status strong { color: var(--text); font-size: 14px; line-height: 1.35; }
.device-status small { margin-top: 4px; color: var(--subtle); font-size: 12px; line-height: 1.4; }
.device-status__cost {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  margin-left: 3px;
  padding: 2px 8px;
  border: 1px solid rgba(244, 189, 80, .38);
  border-radius: 999px;
  color: #ffe09b;
  background: rgba(244, 189, 80, .1);
  font-weight: 800;
  white-space: nowrap;
}
.device-status[data-state="checking"] .device-status__indicator { border-top-color: transparent; animation: device-status-spin .75s linear infinite; }
.device-status[data-state="available"] { border-color: rgba(244, 189, 80, .34); background: rgba(244, 189, 80, .055); }
.device-status[data-state="available"] .device-status__indicator { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 2px var(--surface-2); }
.device-status[data-state="activated"] { border-color: rgba(66, 217, 139, .3); background: rgba(66, 217, 139, .055); }
.device-status[data-state="activated"] .device-status__indicator { border-color: var(--success); background: var(--success); box-shadow: inset 0 0 0 2px var(--surface-2); }
.device-status[data-state="error"] { border-color: rgba(255, 133, 139, .3); background: rgba(255, 133, 139, .045); }
.device-status[data-state="error"] .device-status__indicator { color: #ff858b; }
@keyframes device-status-spin { to { transform: rotate(360deg); } }

.device-activate-button {
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  border: 1px solid #b98320;
  border-radius: var(--radius-sm);
  color: var(--accent-ink);
  background: linear-gradient(180deg, #ffc85a, #e8a92e);
  box-shadow: 0 10px 28px rgba(232, 169, 46, .14);
  font-weight: 850;
}

.device-activate-button[hidden] { display: none; }
.device-activate-button:hover:not(:disabled) { border-color: #d49b32; background: linear-gradient(180deg, #ffd271, #edb341); }
.device-activate-button:disabled { border-color: var(--border-strong); color: var(--subtle); background: var(--surface-2); box-shadow: none; opacity: .62; }
#downloadButton:disabled { border-color: var(--border); color: var(--subtle); background: #151b24; box-shadow: none; opacity: .58; }
.device-activate-button:focus-visible,
.device-serial-field input:focus-visible { outline: 3px solid rgba(130, 184, 244, .55); outline-offset: 2px; }
.device-activate-button:focus-visible { outline-color: rgba(244, 189, 80, .72); }

.header-tools,
.auth-user {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.auth-user[hidden] {
  display: none;
}

.auth-area {
  min-width: 0;
  flex: 0 0 auto;
}

.auth-login-button,
.auth-logout-button,
.auth-redeem-button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 800;
  touch-action: manipulation;
}

.auth-login-button:hover,
.auth-logout-button:hover,
.auth-redeem-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-user__capsule {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
}

.auth-user__avatar {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border: 1px solid rgba(130, 184, 244, 0.28);
  border-radius: 50%;
  color: #d7e8ff;
  background: rgba(130, 184, 244, 0.1);
  font-size: 12px;
  font-weight: 850;
}

.auth-user__name {
  min-width: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
}

.auth-credits {
  position: relative;
  display: inline-flex;
  min-height: 32px;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid rgba(244, 189, 80, 0.46);
  border-radius: 999px;
  color: #f5d58c;
  background: rgba(244, 189, 80, 0.1);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  font-family: inherit;
  line-height: inherit;
  touch-action: manipulation;
}

.auth-credits::after {
  position: absolute;
  inset: -6px -3px;
  content: "";
}

.auth-credits:hover {
  border-color: var(--accent);
  color: #ffe0a0;
  background: rgba(244, 189, 80, 0.15);
}

.auth-credits:disabled {
  cursor: default;
  opacity: 1;
}

.auth-credits svg {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  color: var(--accent);
}

.auth-credits strong {
  color: #ffd477;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.auth-logout-button {
  color: var(--muted);
  background: transparent;
}

.auth-redeem-button {
  min-height: 44px;
  padding: 8px 12px;
  border-color: rgba(244, 189, 80, 0.46);
  color: #f5d58c;
  background: rgba(244, 189, 80, 0.08);
  white-space: nowrap;
}

body.is-auth-open,
body.is-voucher-open,
body.is-account-modal-open {
  overflow: hidden;
}

body.is-activation-open { overflow: hidden; }

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(3, 6, 10, 0.82);
  backdrop-filter: blur(5px);
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal__panel {
  display: flex;
  width: min(430px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--muted);
  background: #111820;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.62);
}

.auth-modal__header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.auth-modal__header h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 21px;
}

.auth-modal__close {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  padding: 0;
  color: #c8d2df;
  background: #171f2a;
}

.auth-modal__close svg {
  width: 21px;
  height: 21px;
}

.auth-form {
  min-height: 0;
  overflow-y: auto;
}

.auth-modal__body {
  display: grid;
  gap: 12px;
  padding: 18px 20px 20px;
}

.auth-context {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid rgba(130, 184, 244, 0.28);
  border-radius: 10px;
  color: #c9daf3;
  background: rgba(105, 173, 255, 0.07);
  font-size: 13px;
  line-height: 1.45;
}

.auth-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.auth-field[hidden] {
  display: none;
}

.auth-field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #3a4658;
  border-radius: 10px;
  color: var(--text);
  background: #0c121a;
  font-size: 16px;
  font-weight: 500;
}

.auth-field small {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 600;
}

.auth-field input[aria-invalid="true"] {
  border-color: rgba(255, 133, 139, 0.78);
  background: rgba(255, 133, 139, 0.045);
}

.auth-field .auth-field-error {
  color: #ffc0c4;
  line-height: 1.4;
}

.auth-field-error:empty {
  display: none;
}

.auth-options {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 18px;
}

.auth-check {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-check[hidden] {
  display: none;
}

.auth-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.auth-error {
  margin: 0;
  color: #ffc0c4;
  font-size: 12px;
  line-height: 1.45;
}

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

.auth-switch {
  margin: 0;
  color: var(--subtle);
  font-size: 13px;
  text-align: center;
}

.auth-switch button {
  min-height: 44px;
  padding: 7px 4px;
  border: 0;
  color: #b9d2fa;
  background: transparent;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-form .primary-button {
  min-height: 48px;
}

.auth-modal button:focus-visible,
.auth-modal input:focus-visible,
.auth-modal a:focus-visible,
.auth-area button:focus-visible {
  outline: 3px solid rgba(130, 184, 244, 0.55);
  outline-offset: 2px;
}

.account-success-modal__panel,
.contact-admin-modal__panel {
  width: min(400px, calc(100vw - 24px));
}

.account-success-modal__header {
  justify-content: flex-start;
}

.account-success-modal__body,
.contact-admin-modal__body {
  display: grid;
  gap: 12px;
  padding: 22px 20px 20px;
}

.account-success-modal__body {
  justify-items: center;
  text-align: center;
}

.account-success-icon {
  width: 68px;
  height: 68px;
  color: var(--success);
}

.account-success-amount {
  margin-top: 2px;
  color: var(--text);
  font-size: clamp(28px, 9vw, 36px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.account-success-description,
.account-success-balance {
  margin: 0;
}

.account-success-description {
  color: #bcefd2;
  font-size: 14px;
  font-weight: 800;
}

.account-success-balance {
  color: var(--muted);
  font-size: 14px;
}

.account-success-balance strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.account-success-modal__body .primary-button {
  margin-top: 6px;
}

.contact-admin-balance {
  margin: 0;
}

.contact-admin-balance > div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.contact-admin-balance dt {
  color: var(--subtle);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-admin-balance dd {
  margin: 3px 0 0;
  color: #ffd477;
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.contact-admin-copy strong,
.contact-admin-copy p {
  display: block;
  margin: 0;
}

.contact-admin-copy strong {
  color: var(--text);
  font-size: 15px;
}

.contact-admin-copy p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.contact-admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.contact-admin-close {
  width: 100%;
  min-height: 44px;
}

.site-footer {
  width: min(100% - 32px, 1440px);
  margin: 0 auto;
  padding: 22px 0 28px;
  border-top: 1px solid var(--border);
  color: var(--subtle);
  font-size: 12px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer p + p {
  margin-top: 3px;
}

.site-footer a {
  color: #dcb75f;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.site-footer a:hover {
  color: var(--accent-hover);
}

#authVoucherInput,
#accountVoucherInput {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-weight: 800;
}

.activation-modal {
  position: fixed;
  inset: 0;
  z-index: 1150;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(3, 6, 10, .84);
  backdrop-filter: blur(5px);
}

.activation-modal[hidden] { display: none; }
.activation-modal__panel {
  width: min(430px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--muted);
  background: #111820;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .62);
}
.activation-modal__header,
.activation-modal__footer { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.activation-modal__header { justify-content: space-between; border-bottom: 1px solid var(--border); }
.activation-modal__header h2 { margin: 3px 0 0; color: var(--text); font-size: 21px; }
.activation-modal__close { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; padding: 0; color: #c8d2df; background: #171f2a; }
.activation-modal__close svg { width: 21px; height: 21px; }
.activation-modal__body { padding: 18px 20px; }
.activation-summary { display: grid; gap: 10px; margin: 0; }
.activation-summary > div { min-width: 0; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.activation-summary dt { color: var(--subtle); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.activation-summary dd { margin: 4px 0 0; color: var(--text); font-weight: 800; overflow-wrap: anywhere; }
#activationSerial { font: 650 13px/1.45 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.activation-modal__body > p { margin: 14px 0 0; font-size: 13px; line-height: 1.5; }
.activation-error { color: #ffc0c4; }
.activation-error:empty { display: none; }
.activation-modal__footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.activation-modal__footer button { min-width: 112px; min-height: 46px; }
.activation-modal button:focus-visible { outline: 3px solid rgba(130, 184, 244, .55); outline-offset: 2px; }

.installation-button {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 9px;
  border-color: rgba(244, 189, 80, 0.55);
  color: #ffd477;
  background: rgba(244, 189, 80, 0.055);
  font-weight: 850;
}

.installation-button:hover {
  border-color: var(--accent);
  background: rgba(244, 189, 80, 0.1);
}

.installation-button svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

body.is-installation-open {
  overflow: hidden;
}

body.is-custom-button-open {
  overflow: hidden;
}

.installation-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(3, 6, 10, 0.78);
  backdrop-filter: blur(5px);
}

.installation-modal[hidden] {
  display: none;
}

.installation-modal__panel {
  display: flex;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 24px);
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--muted);
  background: #111820;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
  font-size: 12px;
}

.installation-modal__header,
.installation-modal__footer {
  flex: 0 0 auto;
  padding: 14px 16px;
  background: #111820;
}

.installation-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.installation-modal__header h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 19px;
}

.installation-modal__close {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  padding: 0;
  color: #c8d2df;
  background: #171f2a;
}

.installation-modal__close svg {
  width: 21px;
  height: 21px;
}

.custom-button-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(3, 6, 10, 0.78);
  backdrop-filter: blur(5px);
}

.custom-button-modal[hidden] {
  display: none;
}

.custom-button-modal__panel {
  display: flex;
  width: min(500px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--muted);
  background: #111820;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
}

.custom-button-modal__header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.custom-button-modal__header h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
}

.custom-button-modal__close {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  padding: 0;
  color: #c8d2df;
  background: #171f2a;
}

.custom-button-modal__close svg {
  width: 21px;
  height: 21px;
}

.custom-button-form {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.custom-button-modal__body {
  display: grid;
  min-height: 0;
  gap: 16px;
  padding: 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.custom-button-field {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.custom-button-field > input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #3a4658;
  border-radius: 9px;
  color: var(--text);
  background: #0c121a;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
}

.custom-button-field > input[aria-invalid="true"] {
  border-color: #ff858b;
}

.custom-button-help,
.custom-button-error {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
}

.custom-button-help {
  color: var(--subtle);
}

.custom-button-error {
  min-height: 0;
  color: #ffc0c4;
}

.custom-button-error:empty {
  display: none;
}

.custom-button-color-field {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.custom-button-color-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-button-color-control input {
  width: 44px;
  height: 44px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid #3a4658;
  border-radius: 9px;
  background: #0c121a;
  cursor: pointer;
}

.custom-button-color-control input::-webkit-color-swatch-wrapper { padding: 0; }
.custom-button-color-control input::-webkit-color-swatch { border: 0; border-radius: 5px; }
.custom-button-color-control input::-moz-color-swatch { border: 0; border-radius: 5px; }
.custom-button-color-control output { min-width: 64px; color: var(--text); font: 700 12px/1 ui-monospace, Consolas, monospace; }

.custom-button-modal__footer {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.custom-button-modal__footer button {
  min-width: 112px;
}

.custom-button-add:focus-visible,
.custom-button-row button:focus-visible,
.custom-button-modal button:focus-visible,
.custom-button-modal input:focus-visible {
  outline: 3px solid rgba(130, 184, 244, 0.55);
  outline-offset: 2px;
}

.installation-modal__body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--border-strong) transparent;
}

.installation-modal__footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.installation-modal__footer button {
  min-width: 96px;
}

.installation-steps {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.installation-step {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 11px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.installation-step__number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(130, 184, 244, 0.34);
  border-radius: 50%;
  color: #b9d2fa;
  background: rgba(105, 173, 255, 0.07);
  font-weight: 850;
}

.installation-step__content {
  min-width: 0;
}

.installation-step h5 {
  margin: 3px 0 6px;
  color: var(--text);
  font-size: 14px;
}

.installation-step p {
  margin: 0;
  line-height: 1.55;
}

.installation-modal code {
  color: #ffd477;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.installation-field {
  display: grid;
  gap: 6px;
  margin-top: 13px;
}

.installation-field__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.installation-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 7px;
}

.installation-copy-row code {
  display: block;
  min-width: 0;
  padding: 10px;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: #e6edf6;
  background: #0b1017;
  line-height: 1.5;
  user-select: all;
}

.copy-button {
  min-width: 62px;
  min-height: 44px;
  align-self: start;
  padding: 8px 10px;
  border: 1px solid #405875;
  border-radius: var(--radius-sm);
  color: #c8dcf7;
  background: #152235;
  font-size: 11px;
  font-weight: 800;
  touch-action: manipulation;
}

.copy-button:hover:not(:disabled) {
  border-color: var(--focus);
  color: var(--text);
  background: #19283b;
}

.installation-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px !important;
}

.allowed-badge {
  padding: 3px 8px;
  border: 1px solid rgba(67, 217, 139, 0.35);
  border-radius: 999px;
  color: #78e7ab;
  background: rgba(67, 217, 139, 0.08);
  font-weight: 850;
}

.installation-notice {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid rgba(244, 189, 80, 0.26);
  border-radius: 10px;
  color: #d5c7a9;
  background: rgba(244, 189, 80, 0.045);
}

.installation-notice a {
  width: fit-content;
  color: #ffd477;
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.installation-complete {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 14px 16px;
  color: #bcefd2;
  background: rgba(67, 217, 139, 0.045);
  line-height: 1.5;
}

.installation-complete svg {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  color: var(--success);
}

@media (max-width: 420px) {
  .auth-modal {
    place-items: start center;
  }

  .auth-modal__panel {
    width: 100%;
  }

  .activation-modal { place-items: start center; }
  .activation-modal__panel { width: 100%; }
  .activation-modal__footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-inline: 16px; }
  .activation-modal__footer button { min-width: 0; }

  .installation-modal {
    place-items: start center;
    padding: 12px;
  }

  .installation-modal__panel {
    width: 100%;
    max-height: calc(100dvh - 24px);
  }

  .installation-step {
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 9px;
    padding: 13px 12px;
  }

  .installation-step__number {
    width: 26px;
    height: 26px;
  }

  .installation-copy-row {
    gap: 6px;
  }

  .custom-button-modal {
    place-items: start center;
  }

  .custom-button-modal__panel {
    width: 100%;
  }

  .custom-button-color-field {
    grid-template-columns: minmax(0, 1fr);
  }

  .custom-button-modal__footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-button-modal__footer button {
    min-width: 0;
  }
}

@media (max-width: 700px) {
  .site-header__inner {
    gap: 10px;
  }

  .header-tools {
    gap: 6px;
  }

  .auth-user__name {
    max-width: 92px;
  }
}

@media (max-width: 520px) {
  .brand__tagline {
    display: none;
  }

  .site-header__inner {
    gap: 8px;
  }

  .auth-login-button,
  .auth-logout-button,
  .auth-redeem-button {
    padding-inline: 10px;
  }

  .auth-user {
    gap: 6px;
  }

  .auth-user__capsule {
    gap: 6px;
    padding-inline: 5px;
  }

  .auth-user__name {
    max-width: 64px;
  }

  .auth-credits {
    padding-inline: 7px;
  }
}

@media (max-width: 430px) {
  .auth-redeem-button {
    max-width: 76px;
    padding-inline: 7px;
    font-size: 10px;
    white-space: normal;
    line-height: 1.15;
  }
}

@media (max-width: 430px) {
  .site-header__inner {
    align-items: flex-start;
    padding-block: 8px;
  }

  .header-tools {
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  .auth-user {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .brand__copy {
    display: none;
  }

  .brand__mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .auth-user__avatar {
    display: none;
  }

  .auth-user__name {
    max-width: 52px;
  }

  .auth-modal__header {
    padding-inline: 16px;
  }

  .auth-modal__body {
    padding-inline: 16px;
  }

  .account-success-modal__body,
  .contact-admin-modal__body {
    padding-inline: 16px;
  }
}

@media (max-width: 350px) {
  .auth-user__avatar {
    display: none;
  }

  .auth-user__name {
    max-width: 44px;
  }

  .auth-credits svg {
    display: none;
  }
}

.device-toolbar {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  width: min(100%, 372px);
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.device-toolbar button {
  flex: 1 0 54px;
  min-width: 54px;
  padding: 6px 7px;
  color: var(--muted);
  background: var(--surface-2);
  font: 11px ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.device-toolbar button:hover {
  color: var(--text);
}

.device-toolbar button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(244, 189, 80, 0.1);
}

.preview-stage {
  position: relative;
  display: grid;
  min-height: 560px;
  overflow: auto;
  place-items: start center;
  padding: 14px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.023) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.023) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.023) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.023) 75%),
    #090d12;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  scrollbar-color: var(--border-strong) transparent;
}

.preview-scale-shell {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #3b4658;
  border-radius: 6px;
  background: #080b10;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.46);
}

#portalPreview {
  display: block;
  width: 390px;
  height: 844px;
  border: 0;
  background: #080b10;
  transform-origin: top left;
}

.preview-note {
  margin: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  color: var(--subtle);
  font-size: 11px;
}

.editor-workspace[data-mobile-panel="editor"] .preview-panel,
.editor-workspace[data-mobile-panel="preview"] .settings-panel {
  display: none;
}

@media (min-width: 460px) {
  .toggle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .advanced-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .advanced-field--wide { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .mobile-workspace-tabs {
    display: none;
  }

  .editor-workspace {
    grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  }

  .editor-workspace[data-mobile-panel] .settings-panel,
  .editor-workspace[data-mobile-panel] .preview-panel {
    display: block;
  }

  .preview-panel {
    position: sticky;
    top: 92px;
  }

  .preview-stage {
    min-height: 620px;
    max-height: calc(100dvh - 250px);
    padding: 20px;
  }
}

@media (max-width: 700px) {
  .editor-page {
    width: min(100% - 24px, 1440px);
    padding-top: 20px;
  }

  .panel-heading,
  .preview-heading,
  .theme-form fieldset,
  .download-section,
  .advanced-panel summary,
  .advanced-panel__body {
    padding-right: 15px;
    padding-left: 15px;
  }

  .preview-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .device-toolbar {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .device-toolbar button {
    padding-inline: 3px;
    font-size: 10px;
  }

  .preview-stage {
    padding: 10px;
  }

  .installation-step {
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 9px;
    padding: 13px;
  }

  .installation-step__number {
    width: 26px;
    height: 26px;
  }

  .installation-copy-row {
    grid-template-columns: minmax(0, 1fr) 58px;
  }

  .custom-button-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .custom-button-row__actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-height: 720px) and (orientation: landscape) {
  .preview-panel {
    position: static;
  }

  .preview-stage {
    min-height: 520px;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .device-status[data-state="checking"] .device-status__indicator { animation: none; }
  .theme-option,
  .theme-option__check { transition: none; }
  .theme-option:hover { transform: none; }
}
