:root {
  color-scheme: dark;
  --bg: #0b0d16;
  --bg-deep: #070910;
  --surface: #111522;
  --surface-soft: #171c2d;
  --surface-raised: #1c2235;
  --surface-hover: #232a40;
  --purple: #8b6bc9;
  --purple-bright: #a98be2;
  --purple-deep: #5a4088;
  --purple-wash: rgba(139, 107, 201, 0.15);
  --cyan: #68b7d5;
  --green: #61c49b;
  --amber: #e5b767;
  --red: #e16f7d;
  --text: #f4f1fa;
  --text-soft: #c5c0d1;
  --muted: #918b9f;
  --line: #292e40;
  --line-strong: #3a4055;
  --header-height: 76px;
  --nav-width: 228px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

a {
  color: inherit;
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 1.8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 18px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.app-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 22, 0.96);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  width: 128px;
  height: 52px;
  object-fit: contain;
  image-rendering: pixelated;
}

.brand-copy {
  display: grid;
  gap: 1px;
  padding-left: 15px;
  border-left: 1px solid var(--line-strong);
}

.brand-copy strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  line-height: 1.15;
}

.beta-tag {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 0 6px;
  border: 1px solid rgba(169, 139, 226, 0.55);
  border-radius: 3px;
  background: var(--purple-wash);
  color: var(--purple-bright);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
}

.header-status,
.view-actions,
.view-heading,
.view-actions,
.connection-banner,
.connection-actions,
.action-row,
.preview-heading,
.preview-actions,
.installer-lead,
.install-progress,
.install-result,
.dialog-actions {
  display: flex;
  align-items: center;
}

.header-status {
  gap: 16px;
}

.privacy-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font-size: 13px;
}

.privacy-label svg {
  color: var(--green);
}

.app-shell {
  min-height: 100vh;
  padding-top: var(--header-height);
}

.app-nav {
  position: fixed;
  inset: var(--header-height) auto 0 0;
  z-index: 20;
  width: var(--nav-width);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: var(--bg-deep);
}

.nav-spacer {
  flex: 1;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
  transition: color 140ms ease, background 140ms ease;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

.nav-item.is-active {
  background: var(--purple-wash);
  color: var(--purple-bright);
}

.nav-item.is-active svg {
  color: var(--purple-bright);
}

.nav-link {
  min-height: 40px;
  font-weight: 550;
}

.workspace {
  min-height: calc(100vh - var(--header-height));
  margin-left: var(--nav-width);
  padding: clamp(28px, 4vw, 52px);
}

.view {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.view[hidden],
[hidden] {
  display: none !important;
}

.view-heading {
  justify-content: space-between;
  gap: 30px;
  min-height: 92px;
  margin-bottom: 30px;
}

.view-heading > div:first-child {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--purple-bright);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 43px);
  line-height: 1.06;
}

.view-heading p:last-child {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 16px;
}

h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

h3 {
  margin: 0;
  font-size: 15px;
}

.button,
.icon-button,
.text-button,
.segmented button,
.tabs button {
  border: 0;
  color: var(--text);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover:not(:disabled),
.button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  outline: none;
}

.button.primary {
  background: var(--purple);
  color: #fff;
}

.button.primary:hover:not(:disabled),
.button.primary:focus-visible:not(:disabled) {
  background: var(--purple-bright);
}

.button.secondary {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.button.secondary:hover:not(:disabled),
.button.secondary:focus-visible:not(:disabled) {
  border-color: var(--purple-deep);
  background: var(--surface-hover);
}

.button.danger {
  background: var(--red);
  color: #fff;
}

.button.inline {
  min-height: 38px;
  border-color: var(--line-strong);
  background: var(--surface-raised);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
}

.icon-button:hover:not(:disabled),
.icon-button:focus-visible:not(:disabled) {
  border-color: var(--purple-deep);
  background: var(--surface-hover);
  outline: none;
}

.icon-button.compact {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  background: transparent;
  color: var(--purple-bright);
  font-size: 13px;
  font-weight: 650;
}

.text-button:hover,
.text-button:focus-visible {
  color: #c8b4ee;
  outline: none;
}

.connection-banner {
  gap: 16px;
  min-height: 84px;
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.connection-banner[data-state="connected"] {
  border-color: rgba(97, 196, 155, 0.42);
  background: rgba(97, 196, 155, 0.06);
}

.connection-banner[data-state="error"] {
  border-color: rgba(225, 111, 125, 0.45);
  background: rgba(225, 111, 125, 0.06);
}

.connection-banner[data-state="choice"] {
  border-color: rgba(229, 183, 103, 0.45);
  background: rgba(229, 183, 103, 0.06);
}

.connection-actions {
  gap: 9px;
}

.connection-icon,
.action-symbol,
.dialog-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  border-radius: 6px;
  background: var(--purple-wash);
  color: var(--purple-bright);
}

.connection-banner > div:nth-child(2) {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 3px;
}

.connection-banner strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-banner span:not(.status-pill) {
  color: var(--text-soft);
  font-size: 13px;
}

.status-pill,
.format-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  overflow: hidden;
}

.metric {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 17px 18px;
  border-right: 1px solid var(--line);
}

.metric-button {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.metric-button:disabled {
  cursor: default;
  opacity: 1;
}

.metric-button.is-selectable {
  background: var(--purple-wash);
}

.metric-button.is-selectable:hover,
.metric-button.is-selectable:focus-visible {
  background: rgba(139, 107, 201, 0.24);
  outline: 2px solid var(--purple);
  outline-offset: -2px;
}

.metric-value {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-value svg {
  width: 15px;
  height: 15px;
  color: var(--purple-bright);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-card {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.setup-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.setup-heading > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.setup-heading h2 {
  margin: 2px 0 3px;
  font-size: 18px;
}

.setup-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.setup-symbol {
  width: 44px;
  height: 44px;
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 6px;
  background: var(--purple-wash);
  color: var(--purple-bright);
}

.setup-symbol svg {
  width: 21px;
  height: 21px;
}

.setup-state {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.setup-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.personalisation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 24px;
  align-items: start;
  padding-top: 20px;
}

.settings-groups {
  min-width: 0;
  border-top: 1px solid var(--line);
}

.settings-group {
  border-bottom: 1px solid var(--line);
}

.settings-group summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-soft);
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 750;
}

.settings-group summary::-webkit-details-marker {
  display: none;
}

.settings-group summary > span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.settings-group summary > span svg {
  color: var(--purple-bright);
}

.settings-group summary > svg {
  color: var(--muted);
  transition: transform 140ms ease;
}

.settings-group[open] summary > svg {
  transform: rotate(180deg);
}

.settings-group .setup-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 2px 0 20px;
}

.launcher-preview-panel {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-deep);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.preview-toolbar > div:first-child {
  min-width: 0;
  display: grid;
}

.preview-scenes {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.preview-scenes button {
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.preview-scenes button.is-active {
  background: var(--surface-raised);
  color: var(--text);
}

.screen-preview-stage {
  min-height: 382px;
  display: grid;
  place-items: center;
  padding: 28px 0 24px;
}

.gba-screen-frame {
  width: min(100%, 494px);
  padding: 6px;
  border: 1px solid #3c3a48;
  border-radius: 6px;
  background: #08090c;
  box-shadow:
    0 28px 62px rgba(0, 0, 0, 0.5),
    0 0 54px rgba(139, 79, 225, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.gba-screen-frame canvas {
  width: 100%;
  aspect-ratio: 3 / 2;
  display: block;
  background: #fff;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.launcher-preview-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 20px;
  padding-top: 20px;
}

.setup-field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
}

.setup-field > span:first-child,
.setup-field legend {
  padding: 0;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.setup-field small {
  color: var(--muted);
  font-size: 11px;
}

.setup-segmented {
  min-height: 40px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--bg-deep);
}

.setup-segmented button {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.setup-segmented button.is-active {
  background: var(--surface-raised);
  color: var(--text);
}

.setup-segmented button:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}

.setup-segmented svg {
  width: 14px;
  height: 14px;
}

.colour-select {
  position: relative;
  display: block;
}

.colour-select > i {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 12px;
  width: 15px;
  height: 15px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 3px;
  background: #52738c;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
  transform: translateY(-50%);
  pointer-events: none;
}

.colour-select select {
  padding-left: 38px;
}

.setup-toggle {
  min-height: 40px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 0 2px;
  cursor: pointer;
}

.toggle-copy {
  display: grid;
  gap: 3px;
}

.toggle-copy strong {
  color: var(--text-soft);
  font-size: 12px;
}

.setup-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  width: 42px;
  height: 24px;
  display: block;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-deep);
  transition: background 120ms ease, border-color 120ms ease;
}

.toggle-track i {
  width: 16px;
  height: 16px;
  display: block;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 120ms ease, background 120ms ease;
}

.setup-toggle input:checked + .toggle-track {
  border-color: var(--purple);
  background: var(--purple-wash);
}

.setup-toggle input:checked + .toggle-track i {
  background: var(--purple-bright);
  transform: translateX(18px);
}

.setup-toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.installer-card {
  margin-top: 28px;
  padding: 24px;
  border: 1px solid rgba(139, 107, 201, 0.42);
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(139, 107, 201, 0.13), rgba(17, 21, 34, 0.82) 58%);
}

.installer-lead {
  gap: 18px;
}

.installer-symbol {
  width: 52px;
  height: 52px;
  display: grid;
  flex: 0 0 52px;
  place-items: center;
  border: 1px solid rgba(169, 139, 226, 0.38);
  border-radius: 7px;
  background: var(--purple-wash);
  color: var(--purple-bright);
}

.installer-symbol svg {
  width: 25px;
  height: 25px;
}

.installer-lead > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.installer-lead h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.installer-lead p {
  max-width: 700px;
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.installer-action {
  display: grid;
  flex: 0 0 auto;
  justify-items: end;
  gap: 8px;
}

.installer-action > span {
  color: var(--muted);
  font-size: 12px;
}

.installer-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.installer-action > small {
  max-width: 360px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: right;
}

.install-progress {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.install-progress > div:last-child {
  display: grid;
  gap: 2px;
}

.install-progress span {
  color: var(--muted);
  font-size: 12px;
}

.install-result {
  align-items: flex-start;
  gap: 12px;
  margin-top: 22px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.install-result[data-state="success"] {
  border-color: rgba(97, 196, 155, 0.42);
}

.install-result[data-state="success"] > svg {
  color: var(--green);
}

.install-result[data-state="error"] {
  border-color: rgba(225, 111, 125, 0.48);
}

.install-result[data-state="error"] > svg {
  color: var(--red);
}

.install-result > div {
  display: grid;
  gap: 3px;
}

.install-result p {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.installer-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.installer-note svg {
  color: var(--green);
}

.section-block,
.form-section {
  margin-top: 34px;
}

.section-title {
  margin-bottom: 14px;
}

.section-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.action-list {
  border-top: 1px solid var(--line);
}

.action-row {
  gap: 16px;
  min-height: 82px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.action-copy {
  min-width: 0;
  flex: 1;
}

.action-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.artwork-workflow-tabs {
  margin-bottom: 8px;
}

.artwork-workflow-tabs button {
  min-width: 126px;
}

.artwork-workflow-panel[hidden] {
  display: none;
}

.workflow-intro {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.workflow-symbol {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(167, 128, 224, 0.42);
  border-radius: 6px;
  background: var(--purple-wash);
  color: var(--purple-bright);
}

.workflow-symbol svg {
  width: 20px;
  height: 20px;
}

.workflow-intro h2 {
  margin: 0;
  font-size: 18px;
}

.workflow-intro p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.artwork-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(460px, 1.22fr);
  gap: 34px;
  align-items: start;
}

.controls-column,
.preview-column {
  min-width: 0;
}

.segmented,
.tabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-deep);
}

.segmented button,
.tabs button {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented button.is-active,
.tabs button.is-active {
  background: var(--surface-raised);
  color: var(--text);
}

.segmented button:focus-visible,
.tabs button:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}

.control-panel {
  margin-top: 18px;
}

.drop-zone {
  min-height: 118px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragging {
  border-color: var(--purple);
  background: var(--purple-wash);
  outline: none;
}

.drop-zone svg {
  width: 25px;
  height: 25px;
  margin-bottom: 3px;
  color: var(--purple-bright);
}

.drop-zone span {
  color: var(--muted);
  font-size: 12px;
}

.form-section {
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.form-section.workflow-first-section {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.form-section h2 {
  margin-bottom: 16px;
  font-size: 15px;
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading-row > div {
  min-width: 0;
}

.section-heading-row h2,
.section-heading-row h3 {
  margin: 0;
}

.section-heading-row h3 {
  color: var(--text);
  font-size: 13px;
}

.section-heading-row .field-note {
  margin-top: 5px;
  line-height: 1.5;
}

.section-heading-row.compact {
  align-items: center;
  margin-bottom: 14px;
}

.beta-label {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid rgba(167, 128, 224, 0.44);
  border-radius: 4px;
  background: var(--purple-wash);
  color: var(--purple-bright);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field-row {
  display: flex;
  gap: 14px;
}

.field-row.split > * {
  flex: 1;
}

.field,
.range-field {
  display: grid;
  gap: 7px;
  margin-bottom: 15px;
}

.field.grow {
  flex: 1.4;
}

.pack-output-fields {
  display: grid;
  grid-template-columns: 1fr;
}

.field > span:first-child,
.range-field > span:first-child {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.field small,
.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.artwork-size-note {
  margin: -5px 0 17px;
  line-height: 1.5;
}

.artwork-size-note strong {
  color: var(--text-soft);
}

.checkbox-field {
  margin: 16px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.checkbox-field input {
  margin: 3px 0 0;
  accent-color: var(--purple);
}

.checkbox-field span {
  display: grid;
  gap: 3px;
}

.checkbox-field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.scan-status {
  margin-top: 10px;
}

.library-source-panel {
  margin: 2px 0 15px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(10, 12, 20, 0.34);
}

.library-source-panel > .field:last-child,
.library-source-panel > .field-row:last-child > .field {
  margin-bottom: 0;
}

.region-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.region-fieldset legend,
.region-priority > div:first-child > strong {
  padding: 0;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.region-fieldset > .field-note,
.region-priority > div:first-child > .field-note {
  margin: 5px 0 11px;
  line-height: 1.45;
}

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

.region-checkbox {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.region-checkbox:has(input:checked) {
  border-color: rgba(167, 128, 224, 0.58);
  background: var(--purple-wash);
}

.region-checkbox input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--purple);
}

.region-priority {
  display: grid;
  grid-template-columns: minmax(130px, 0.75fr) minmax(220px, 1.25fr);
  gap: 18px;
  align-items: start;
  padding-top: 16px;
}

.region-priority-list {
  display: grid;
  gap: 6px;
}

.region-priority-row {
  min-height: 36px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 30px 30px;
  gap: 5px;
  align-items: center;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.region-priority-row > strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-rank {
  color: var(--purple-bright);
  font-size: 11px;
  font-weight: 800;
}

.region-priority-row .icon-button {
  width: 28px;
  height: 28px;
  border-radius: 4px;
}

.region-priority-row .icon-button svg {
  width: 15px;
  height: 15px;
}

.artwork-folder-picker {
  display: flex;
  align-items: center;
  gap: 13px;
}

.artwork-folder-picker .field-note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-position {
  margin-top: 18px;
}

.library-preview-stage {
  min-height: 270px;
  display: grid;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 15px;
  padding: 22px;
  border: 1px solid #222738;
  border-radius: 6px;
  background: #090b13;
}

.library-preview-item {
  display: grid;
  justify-items: center;
  gap: 9px;
}

.library-preview-item > span {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.library-preview-item > small {
  color: var(--muted);
  font-size: 11px;
}

.library-preview-stage canvas {
  display: block;
  width: auto;
  height: 180px;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  background: #05060a;
  image-rendering: pixelated;
}

#library-square-preview {
  height: 180px;
}

.library-preview-caption {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.compact-checkbox {
  margin-bottom: 16px;
}

#art-manual-position-controls,
#library-manual-position-controls {
  display: grid;
  gap: 13px;
}

.fit-background-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.8fr);
  gap: 12px;
  margin: 0 0 17px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(10, 12, 20, 0.34);
}

.fit-background-options[hidden] {
  display: none;
}

.fit-background-options .field {
  min-width: 0;
  margin: 0;
}

.fit-blend-field {
  grid-column: 1 / -1;
  margin: 0;
}

.position-reset-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.color-picker-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-row input[type="color"] {
  width: 48px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}

.color-picker-row output {
  color: var(--text-soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
}

.library-actions .button {
  flex: 1 1 160px;
  min-width: 0;
}

.pack-preview-column {
  display: flex;
  flex-direction: column;
}

.pack-preview-column .library-position {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.pack-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 20px;
  padding: 13px 14px;
  border-left: 3px solid var(--purple);
  background: rgba(124, 87, 176, 0.1);
}

.pack-note svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin-top: 1px;
  color: var(--purple-bright);
}

.pack-note p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
}

input[type="text"],
input[type="search"],
input[type="url"],
select {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

input::placeholder {
  color: #6f697b;
}

input:focus,
select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-wash);
}

select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 17px,
    calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.input-with-button {
  display: flex;
  gap: 7px;
}

.input-with-button input {
  flex: 1;
}

.range-field {
  margin-bottom: 14px;
}

.range-field > span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.range-field output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 550;
}

input[type="range"] {
  width: 100%;
  height: 20px;
  margin: 0;
  accent-color: var(--purple);
}

.search-results {
  max-height: 260px;
  margin-top: 12px;
  overflow: auto;
  border-top: 1px solid var(--line);
  scrollbar-color: var(--line-strong) var(--surface);
}

.search-result {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text-soft);
  text-align: left;
}

.search-result:hover,
.search-result:focus-visible {
  color: var(--text);
  outline: none;
}

.search-result small {
  color: var(--muted);
}

.preview-column {
  position: sticky;
  top: calc(var(--header-height) + 28px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-heading {
  justify-content: space-between;
  gap: 20px;
}

.preview-heading > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.preview-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-preview-column .preview-heading strong {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.preview-stage {
  min-height: 410px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 5vw, 58px);
  margin: 20px 0;
  padding: 26px;
  border: 1px solid #222738;
  border-radius: 6px;
  background-color: #090b13;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.025) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.025) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.preview-item {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.preview-item > span {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.preview-item small {
  color: var(--muted);
  font-size: 11px;
}

.preview-item canvas {
  display: block;
  width: auto;
  height: 240px;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  background: #05060a;
  image-rendering: pixelated;
}

#wide-preview {
  aspect-ratio: 3 / 2;
}

#square-preview {
  aspect-ratio: 1;
}

.preview-actions {
  flex-wrap: wrap;
  gap: 10px;
}

.preview-column > .field-note {
  margin-top: 12px;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.style-library {
  margin-bottom: 34px;
}

.style-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.style-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(112px, auto) auto;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.style-card > img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center 26%;
  border-bottom: 1px solid var(--line);
}

.style-card > div {
  padding: 16px 16px 12px;
}

.style-card h3 {
  margin: 2px 0 6px;
  font-size: 16px;
}

.style-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.style-card > .button {
  margin: 0 16px 16px;
}

.installed-styles-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 12px;
}

.installed-styles-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.empty-state svg {
  width: 32px;
  height: 32px;
  color: var(--purple-bright);
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.style-list {
  border-top: 1px solid var(--line);
}

.style-row {
  min-height: 66px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}

.style-row > div:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.style-row strong,
.style-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.style-row small {
  color: var(--muted);
}

.progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  flex: 0 0 100%;
  border-radius: 3px;
  background: var(--surface-raised);
  overflow: hidden;
}

.progress-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--purple-bright);
  transition: width 220ms ease;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  width: min(380px, calc(100vw - 40px));
  display: grid;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  color: var(--text-soft);
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 160ms ease-out;
}

.toast[data-type="success"] svg { color: var(--green); }
.toast[data-type="error"] svg { color: var(--red); }
.toast[data-type="info"] svg { color: var(--purple-bright); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.confirm-dialog,
.cartridge-dialog {
  width: min(440px, calc(100vw - 34px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop,
.cartridge-dialog::backdrop {
  background: rgba(3, 4, 8, 0.78);
  backdrop-filter: blur(3px);
}

.confirm-dialog form,
.cartridge-dialog form {
  padding: 24px;
}

.confirm-dialog h2,
.cartridge-dialog h2 {
  margin-top: 16px;
}

.confirm-dialog p,
.cartridge-dialog p {
  margin: 9px 0 22px;
  color: var(--text-soft);
}

.cartridge-dialog {
  width: min(540px, calc(100vw - 34px));
}

.cartridge-options {
  display: grid;
  gap: 9px;
  margin-bottom: 20px;
}

.cartridge-options > button {
  min-height: 68px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 13px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.cartridge-options > button:hover,
.cartridge-options > button:focus-visible {
  border-color: var(--purple);
  background: var(--purple-wash);
  outline: none;
}

.cartridge-options > button > svg:first-child {
  color: var(--purple-bright);
}

.cartridge-options > button > svg:last-child {
  color: var(--muted);
}

.cartridge-options span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.cartridge-options small {
  color: var(--muted);
  font-size: 12px;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 10px;
}

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

  .launcher-preview-panel {
    position: static;
    grid-row: 1;
  }
}

@media (max-width: 1080px) {
  :root {
    --nav-width: 82px;
  }

  .app-nav {
    align-items: center;
    padding-inline: 10px;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .nav-item span {
    display: none;
  }

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

  .metric:nth-child(3) {
    border-right: 0;
  }

  .metric:nth-child(n+4) {
    border-top: 1px solid var(--line);
  }

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

  .personalisation-layout {
    grid-template-columns: 1fr;
  }

  .launcher-preview-panel {
    position: static;
    grid-row: 1;
  }

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

  .artwork-layout {
    grid-template-columns: 1fr;
  }

  .preview-column {
    position: static;
  }

  .preview-stage {
    min-height: 350px;
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: 68px;
    --nav-width: 0px;
  }

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

  .region-priority {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .app-header {
    padding: 0 14px;
  }

  .brand {
    gap: 10px;
  }

  .brand img {
    width: 104px;
    height: 44px;
  }

  .brand-copy {
    display: none;
  }

  .privacy-label {
    display: none;
  }

  .header-status .button {
    width: 42px;
    padding: 0;
  }

  .header-status .button span {
    display: none;
  }

  .app-nav {
    inset: auto 0 0;
    width: 100%;
    height: 66px;
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-right: 0;
    overflow-x: auto;
  }

  .nav-spacer,
  .nav-link {
    display: none;
  }

  .nav-item {
    width: 54px;
    min-width: 54px;
    min-height: 48px;
  }

  .workspace {
    margin-left: 0;
    padding: 24px 16px 92px;
  }

  .view-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .view-heading > .button,
  .view-heading > .view-actions,
  .view-actions .button {
    width: 100%;
  }

  .connection-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .connection-banner > div:nth-child(2) {
    flex-basis: calc(100% - 60px);
  }

  .connection-actions {
    width: calc(100% - 60px);
    justify-content: space-between;
    margin-left: 60px;
  }

  .connection-actions .status-pill {
    margin-left: 0;
  }

  .status-pill {
    margin-left: 60px;
  }

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

  .metric,
  .metric:nth-child(3) {
    border-right: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }

  .metric:nth-child(1),
  .metric:nth-child(2) {
    border-top: 0;
  }

  .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric:last-child {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .setup-card {
    padding: 18px;
  }

  .setup-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .setup-heading > div:nth-child(2) {
    flex-basis: calc(100% - 58px);
  }

  .setup-actions {
    width: 100%;
    justify-content: space-between;
    padding-left: 58px;
  }

  .setup-grid,
  .settings-group .setup-grid {
    grid-template-columns: 1fr;
  }

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

  .preview-scenes {
    width: 100%;
  }

  .preview-scenes button {
    flex: 1;
  }

  .screen-preview-stage {
    min-height: 0;
    padding-block: 22px 18px;
  }

  .style-card-grid {
    grid-template-columns: 1fr;
  }

  .style-card {
    grid-template-rows: auto auto auto;
  }

  .style-card > img {
    height: auto;
  }

  .installed-styles-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .action-row > .button,
  .action-row > .icon-button {
    grid-column: 2;
    width: 100%;
  }

  .installer-card {
    padding: 18px;
  }

  .installer-lead {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .installer-lead > div:nth-child(2) {
    flex-basis: calc(100% - 70px);
  }

  .installer-action {
    width: 100%;
    justify-items: stretch;
    padding-left: 70px;
  }

  .installer-action > span {
    text-align: right;
  }

  .installer-action-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .installer-action-buttons .button {
    width: 100%;
  }

  .installer-action > small {
    max-width: none;
    text-align: left;
  }

  .installer-note {
    align-items: flex-start;
  }

  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .fit-background-options {
    grid-template-columns: 1fr;
  }

  .artwork-workflow-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .artwork-workflow-tabs button {
    min-width: 0;
    padding-inline: 8px;
  }

  .workflow-intro {
    align-items: flex-start;
  }

  .section-heading-row {
    gap: 10px;
  }

  .artwork-folder-picker,
  .library-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .artwork-folder-picker .button,
  .library-actions .button {
    width: 100%;
  }

  .artwork-folder-picker .field-note {
    white-space: normal;
  }

  .library-preview-stage {
    min-height: 0;
    gap: 16px;
    padding: 18px;
  }

  .library-preview-stage canvas {
    width: auto;
    height: auto;
    max-width: 100%;
  }

  #library-wide-preview {
    width: min(360px, 100%);
  }

  #library-square-preview {
    width: min(280px, 100%);
    height: auto;
  }

  .preview-column {
    padding: 16px;
  }

  .preview-stage {
    min-height: auto;
    flex-direction: column;
    gap: 28px;
  }

  .preview-item canvas {
    height: auto;
    max-height: none;
  }

  #wide-preview {
    width: min(360px, 100%);
  }

  #square-preview {
    width: min(240px, 100%);
  }

  .preview-actions .button {
    width: 100%;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
